Hook up dacp message decoding to the loca unlock and notify code
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
+8
-6
@@ -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
|
||||
|
||||
+1
-2
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user