]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add a prolog and epilog for safe reading of the metadata bundle
authorMike Brady <mikebrady@eircom.net>
Fri, 9 Mar 2018 16:26:09 +0000 (16:26 +0000)
committerMike Brady <mikebrady@eircom.net>
Fri, 9 Mar 2018 16:26:09 +0000 (16:26 +0000)
metadata_hub.c
metadata_hub.h

index af335e52b8299dfde51ca8f576eb1eafbcf4707a..a9ba715c3c069e628d883f3dd55bf8d53d15e946 100644 (file)
@@ -130,6 +130,18 @@ void metadata_hub_modify_epilog(int modified) {
   }
 }
 
+void metadata_hub_read_prolog(void) {
+  // always run this before reading an entry or a sequence of entries in the metadata_hub
+  // debug(1, "locking metadata hub for reading");
+  pthread_rwlock_rdlock(&metadata_hub_re_lock);
+}
+
+void metadata_hub_read_epilog(void) {
+  // always run this after reading an entry or a sequence of entries in the metadata_hub
+  // debug(1, "unlocking metadata hub for reading");
+  pthread_rwlock_unlock(&metadata_hub_re_lock);
+}
+
 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 25f16bc65d5e67ccdd078bc315d5ebdb6201793e..8c3606b9b75a7b58486f001347eb6047c413449a 100644 (file)
@@ -87,7 +87,7 @@ typedef struct metadata_bundle {
 
   int speaker_volume; // this is the actual speaker volume, allowing for the main volume and the
                       // speaker volume control
-  int previous_speaker_volume; // this is needed to prevent a loop
+  // int previous_speaker_volume; // this is needed to prevent a loop
 
   metadata_watcher watchers[number_of_watchers]; // functions to call if the metadata is changed.
   void *watchers_data[number_of_watchers];       // their individual data
@@ -107,3 +107,7 @@ void metadata_hub_release_track_artwork(void);
 // afterwards
 void metadata_hub_modify_prolog(void);
 void metadata_hub_modify_epilog(int modified); // set to true if modifications occured, 0 otherwise
+
+// these are for safe reading
+void metadata_hub_read_prolog(void);
+void metadata_hub_read_epilog(void);