6 #define number_of_watchers 2
24 } shuffle_status_type
;
33 int string_update(char **str
, int *changed
, char *s
);
34 int int_update(int *receptacle
, int *changed
, int value
);
36 struct metadata_bundle
;
38 typedef void (*metadata_watcher
)(struct metadata_bundle
*argc
, void *userdata
);
40 typedef struct metadata_bundle
{
42 char *client_ip
; // IP number used by the audio source (i.e. the "client"), which is also the DACP
44 int client_ip_changed
;
46 char *client_name
; // the name of the client device, if available
47 int client_name_changed
;
49 char *server_ip
; // IP number used by Shairport Sync
50 int server_ip_changed
;
52 char *stream_type
; // Realtime or Buffered
53 int stream_type_changed
;
55 char *progress_string
; // progress string, emitted by the source from time to time
56 int progress_string_changed
;
58 char *frame_position_string
; // frame position string emitted by SPS on request
59 int frame_position_string_changed
;
61 char *first_frame_position_string
; // first frame position string emitted by SPS on request
62 int first_frame_position_string_changed
;
64 int player_thread_active
; // true if a play thread is running
65 int dacp_server_active
; // true if there's a reachable DACP server (assumed to be the Airplay
66 // client) ; false otherwise
67 int advanced_dacp_server_active
; // true if there's a reachable DACP server with iTunes
70 int dacp_server_has_been_active
; // basically this is a delayed version of dacp_server_active,
71 // used detect transitions between server activity being on or off
72 // e.g. to reease metadata when a server goes inactive, but not if it's permanently
74 play_status_type play_status
;
75 shuffle_status_type shuffle_status
;
76 repeat_status_type repeat_status
;
78 // the following pertain to the track playing
80 char *cover_art_pathname
;
81 int cover_art_pathname_changed
;
83 uint64_t item_id
; // seems to be a track ID -- see itemid in DACP.c
88 item_composite_id
[16]; // seems to be nowplaying 4 ids: dbid, plid, playlistItem, itemid
89 int item_composite_id_changed
;
90 int item_composite_id_is_valid
;
93 int song_data_kind_changed
;
94 int song_data_kind_is_valid
;
97 int track_name_changed
;
100 int artist_name_changed
;
102 char *album_artist_name
;
103 int album_artist_name_changed
;
106 int album_name_changed
;
115 int composer_changed
;
118 int file_kind_changed
;
120 char *song_description
;
121 int song_description_changed
;
123 char *song_album_artist
;
124 int song_album_artist_changed
;
127 int sort_name_changed
;
130 int sort_artist_changed
;
133 int sort_album_changed
;
136 int sort_composer_changed
;
138 uint32_t songtime_in_milliseconds
;
139 int songtime_in_milliseconds_changed
;
140 int songtime_in_milliseconds_is_valid
;
145 player_state
; // this is the state of the actual player itself, which can be a bit noisy.
146 active_state_type active_state
;
148 int speaker_volume
; // this is the actual speaker volume, allowing for the main volume and the
149 // speaker volume control
150 double airplay_volume
;
152 metadata_watcher watchers
[number_of_watchers
]; // functions to call if the metadata is changed.
153 void *watchers_data
[number_of_watchers
]; // their individual data
157 extern struct metadata_bundle metadata_store
;
159 void add_metadata_watcher(metadata_watcher fn
, void *userdata
);
161 void metadata_hub_init(void);
162 void metadata_hub_stop(void);
163 void metadata_hub_process_metadata(uint32_t type
, uint32_t code
, char *data
, uint32_t length
);
164 void metadata_hub_reset_track_metadata(void);
165 void metadata_hub_release_track_artwork(void);
167 // these functions lock and unlock the read-write mutex on the metadata hub and run the watchers
169 void _metadata_hub_modify_prolog(const char *filename
, const int linenumber
);
170 void _metadata_hub_modify_epilog(
171 int modified
, const char *filename
,
172 const int linenumber
); // set to true if modifications occurred, 0 otherwise
175 // these are for safe reading
176 void _metadata_hub_read_prolog(const char *filename, const int linenumber);
177 void _metadata_hub_read_epilog(const char *filename, const int linenumber);
180 #define metadata_hub_modify_prolog(void) _metadata_hub_modify_prolog(__FILE__, __LINE__)
181 #define metadata_hub_modify_epilog(modified) \
182 _metadata_hub_modify_epilog(modified, __FILE__, __LINE__)
184 #define metadata_hub_read_prolog(void) _metadata_hub_read_prolog(__FILE__, __LINE__)
185 #define metadata_hub_read_epilog(void) _metadata_hub_modify_epilog(__FILE__, __LINE__)