NEWS: update from 3.0.x branch
[vlc.git] / src / playlist / notify.h
blob50b4f4c2c13255ad90d5c69d02c599afb96e7ddb
1 /*****************************************************************************
2 * playlist/notify.h
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 #ifndef VLC_PLAYLIST_NOTIFY_H
22 #define VLC_PLAYLIST_NOTIFY_H
24 #include <vlc_common.h>
25 #include <vlc_list.h>
27 typedef struct vlc_playlist vlc_playlist_t;
29 struct vlc_playlist_listener_id
31 const struct vlc_playlist_callbacks *cbs;
32 void *userdata;
33 struct vlc_list node; /**< node of vlc_playlist.listeners */
36 struct vlc_playlist_state {
37 ssize_t current;
38 bool has_prev;
39 bool has_next;
42 #define vlc_playlist_listener_foreach(listener, playlist) \
43 vlc_list_foreach(listener, &(playlist)->listeners, node)
45 #define vlc_playlist_NotifyListener(playlist, listener, event, ...) \
46 do { \
47 if (listener->cbs->event) \
48 listener->cbs->event(playlist, ##__VA_ARGS__, listener->userdata); \
49 } while (0)
51 #define vlc_playlist_Notify(playlist, event, ...) \
52 do { \
53 vlc_playlist_AssertLocked(playlist); \
54 vlc_playlist_listener_id *listener; \
55 vlc_playlist_listener_foreach(listener, playlist) \
56 vlc_playlist_NotifyListener(playlist, listener, event, ##__VA_ARGS__); \
57 } while(0)
59 void
60 vlc_playlist_state_Save(vlc_playlist_t *playlist,
61 struct vlc_playlist_state *state);
63 void
64 vlc_playlist_state_NotifyChanges(vlc_playlist_t *playlist,
65 struct vlc_playlist_state *saved_state);
67 void
68 vlc_playlist_NotifyMediaUpdated(vlc_playlist_t *playlist, input_item_t *media);
70 #endif