]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Hook up dacp message decoding to the loca unlock and notify code
authorMike Brady <mikebrady@eircom.net>
Tue, 23 Jan 2018 11:31:48 +0000 (11:31 +0000)
committerMike Brady <mikebrady@eircom.net>
Tue, 23 Jan 2018 11:31:48 +0000 (11:31 +0000)
dacp.c
metadata_hub.c
metadata_hub.h

diff --git a/dacp.c b/dacp.c
index 272d9d16c39bc59cd653dfde780e14e414e82951..04885d011461deae002fd4a4533d53ec2225d383 100644 (file)
--- 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();
 }
index 086c6bdf51cc7746ae2f1b415aae851ae6d3f834..b5097c864f14062a0805c7acd9a5a89e43faa338 100644 (file)
@@ -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
index 12889f43e6fced25c7ee68af909eefc99e7a0b1d..70d2fcf7a5f86fe704e0045d37be9eb7757083d2 100644 (file)
@@ -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);