Files
shairport-sync/metadata_hub.h
T

73 lines
1.9 KiB
C

#pragma once
#include "common.h"
#include "config.h"
#include <pthread.h>
#define number_of_watchers 2
enum play_status_type {
PS_PLAYING = 0,
PS_PAUSED,
PS_STOPPED,
} play_status_type;
enum shuffle_status_type {
SS_OFF = 0,
SS_ON,
} shuffle_status_type;
enum repeat_status_type {
RS_NONE = 0,
RS_SINGLE,
RS_ALL,
} repeat_status_type;
struct metadata_bundle;
typedef void (*metadata_watcher)(struct metadata_bundle *argc, void *userdata);
typedef struct metadata_bundle {
int changed; // normally 0, nonzero if a field has been changed
int playerstatusupdates_are_received; // false if it's "traditional" metadata
enum play_status_type play_status;
int play_status_changed;
enum shuffle_status_type shuffle_status;
int shuffle_status_changed;
enum repeat_status_type repeat_status;
int repeat_status_changed;
char *track_name; // a malloced string -- if non-zero, free it before replacing it
int track_name_changed;
char *artist_name; // a malloced string -- if non-zero, free it before replacing it
int artist_name_changed;
char *album_name; // a malloced string -- if non-zero, free it before replacing it
int album_name_changed;
char *genre; // a malloced string -- if non-zero, free it before replacing it
int genre_changed;
uint32_t item_id; // seems to be a track ID -- see itemid in DACP.c
int item_id_changed;
uint32_t songtime_in_milliseconds;
unsigned char
item_composite_id[16]; // seems to be nowplaying 4 ids: dbid, plid, playlistItem, itemid
metadata_watcher watchers[number_of_watchers]; // functions to call if the metadata is changed.
void *watchers_data[number_of_watchers]; // their individual data
} metadata_bundle;
struct metadata_bundle metadata_store;
void add_metadata_watcher(metadata_watcher fn, void *userdata);
void run_metadata_watchers(void);
void metadata_hub_init(void);