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];
// 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");
}
// 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();
}
}
-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");
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
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);