Add a prolog and epilog for safe reading of the metadata bundle

This commit is contained in:
Mike Brady
2018-03-09 16:26:09 +00:00
parent b10f3793db
commit 7fa1d3cbee
2 changed files with 17 additions and 1 deletions
+12
View 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
+5 -1
View 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);