From: Mike Brady Date: Tue, 23 Jan 2018 11:31:48 +0000 (+0000) Subject: Hook up dacp message decoding to the loca unlock and notify code X-Git-Tag: 3.2d29~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b63f35f7176e416fb015bbaa5eece5433d9f395;p=thirdparty%2Fshairport-sync.git Hook up dacp message decoding to the loca unlock and notify code --- diff --git a/dacp.c b/dacp.c index 272d9d16..04885d01 100644 --- a/dacp.c +++ b/dacp.c @@ -299,10 +299,11 @@ void *dacp_monitor_thread_code(void *na) { if (result == 200) { char *sp = response; if (le >= 8) { - // here, we know that we are receiving playerstatusupdates, so set a flag - metadata_store.playerstatusupdates_are_received = 1; // here start looking for the contents of the status update if (dacp_tlv_crawl(&sp, &item_size) == 'cmst') { // status + // here, we know that we are receiving playerstatusupdates, so set a flag + metadata_hub_modify_prolog(); + metadata_store.playerstatusupdates_are_received = 1; sp -= item_size; // drop down into the array -- don't skip over it le -= 8; char typestring[5]; @@ -543,13 +544,11 @@ void *dacp_monitor_thread_code(void *na) { // printf("\n"); } - // now, if the metadata is changed, send a signal - run_metadata_watchers(); - + // finished possibly writing to the metadata hub + metadata_hub_modify_epilog(); } else { printf("Status Update not found.\n"); } - } else { debug(1, "Can't find any content in playerstatusupdate request"); } @@ -798,8 +797,7 @@ void dacp_get_volume(void) { // debug(1,"Overall volume: %d, relative volume: %d%, actual volume: // %d.",overall_volume,relative_volume,actual_volume); // debug(1,"Our actual speaker volume is %d.",actual_volume); - if (metadata_store.speaker_volume != actual_volume) { - metadata_store.speaker_volume = actual_volume; - run_metadata_watchers(); - } + metadata_hub_modify_prolog(); + metadata_store.speaker_volume = actual_volume; + metadata_hub_modify_epilog(); } diff --git a/metadata_hub.c b/metadata_hub.c index 086c6bdf..b5097c86 100644 --- a/metadata_hub.c +++ b/metadata_hub.c @@ -83,12 +83,6 @@ void metadata_hub_modify_prolog(void) { } -void metadata_hub_modify_epilog(void) { -// always run this after changing an entry or a sequence of entries in the metadata_hub - debug(1,"unlocking metadata hub for writing"); - pthread_rwlock_unlock(&metadata_hub_re_lock); -} - void run_metadata_watchers(void) { int i; debug(1,"locking metadata hub for reading"); @@ -102,6 +96,14 @@ void run_metadata_watchers(void) { pthread_rwlock_unlock(&metadata_hub_re_lock); } +void metadata_hub_modify_epilog(void) { +// always run this after changing an entry or a sequence of entries in the metadata_hub + debug(1,"unlocking metadata hub for writing"); + pthread_rwlock_unlock(&metadata_hub_re_lock); + run_metadata_watchers(); +} + + char *metadata_write_image_file(const char *buf, int len) { // warning -- this removes all files from the directory apart from this one, if it exists diff --git a/metadata_hub.h b/metadata_hub.h index 12889f43..70d2fcf7 100644 --- a/metadata_hub.h +++ b/metadata_hub.h @@ -99,8 +99,7 @@ void add_metadata_watcher(metadata_watcher fn, void *userdata); void metadata_hub_init(void); void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t length); -// these functions lock and unlock the read-write mutex on the metadata hub +// these functions lock and unlock the read-write mutex on the metadata hub and run the watchers afterwards void metadata_hub_modify_prolog(void); void metadata_hub_modify_epilog(void); -void run_metadata_watchers(void);