demux: avi: fix fLAC read size
[vlc.git] / src / playlist / playlist.c
blob4a1c3b38e123285ae2b360ade96f6c4c164ed04f
1 /*****************************************************************************
2 * playlist/playlist.c
3 *****************************************************************************
4 * Copyright (C) 2018 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include "playlist.h"
27 #include <vlc_common.h>
29 #include "content.h"
30 #include "item.h"
31 #include "player.h"
33 vlc_playlist_t *
34 vlc_playlist_New(vlc_object_t *parent)
36 vlc_playlist_t *playlist = malloc(sizeof(*playlist));
37 if (unlikely(!playlist))
38 return NULL;
40 bool ok = vlc_playlist_PlayerInit(playlist, parent);
41 if (unlikely(!ok))
43 free(playlist);
44 return NULL;
47 vlc_vector_init(&playlist->items);
48 randomizer_Init(&playlist->randomizer);
49 playlist->current = -1;
50 playlist->has_prev = false;
51 playlist->has_next = false;
52 vlc_list_init(&playlist->listeners);
53 playlist->repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE;
54 playlist->order = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL;
55 playlist->idgen = 0;
56 #ifdef TEST_PLAYLIST
57 playlist->libvlc = NULL;
58 playlist->auto_preparse = false;
59 #else
60 assert(parent);
61 playlist->libvlc = vlc_object_instance(parent);
62 playlist->auto_preparse = var_InheritBool(parent, "auto-preparse");
63 #endif
65 return playlist;
68 void
69 vlc_playlist_Delete(vlc_playlist_t *playlist)
71 assert(vlc_list_is_empty(&playlist->listeners));
73 vlc_playlist_PlayerDestroy(playlist);
74 randomizer_Destroy(&playlist->randomizer);
75 vlc_playlist_ClearItems(playlist);
76 free(playlist);
79 void
80 vlc_playlist_Lock(vlc_playlist_t *playlist)
82 vlc_player_Lock(playlist->player);
85 void
86 vlc_playlist_Unlock(vlc_playlist_t *playlist)
88 vlc_player_Unlock(playlist->player);