summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-05-18 11:42:23 +0200
committerGravatar waker <wakeroid@gmail.com>2012-05-18 11:42:23 +0200
commitf81a65b6b502adb2f1d071d2f58a824944841bf3 (patch)
tree38887c2595781195f1e21eae492e53fee915b4ac
parent6b97a160c2db19b808cbfc320a8a92da203d49ca (diff)
fixed plt_find_meta calls to use pl_lock
-rw-r--r--deadbeef.h2
-rw-r--r--pltmeta.c13
2 files changed, 13 insertions, 2 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 6de9e9d0..8775bf6d 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -458,6 +458,8 @@ typedef struct {
void (*plt_append_meta) (ddb_playlist_t *handle, const char *key, const char *value);
void (*plt_set_meta_int) (ddb_playlist_t *handle, const char *key, int value);
void (*plt_set_meta_float) (ddb_playlist_t *handle, const char *key, float value);
+
+ // plt_find_meta must always be used in the pl_lock/unlock block
const char *(*plt_find_meta) (ddb_playlist_t *handle, const char *key);
DB_metaInfo_t * (*plt_get_metadata_head) (ddb_playlist_t *handle); // returns head of metadata linked list
void (*plt_delete_metadata) (ddb_playlist_t *handle, DB_metaInfo_t *meta);
diff --git a/pltmeta.c b/pltmeta.c
index 63c7279c..fac97b37 100644
--- a/pltmeta.c
+++ b/pltmeta.c
@@ -64,6 +64,7 @@ plt_add_meta (playlist_t *it, const char *key, const char *value) {
void
plt_append_meta (playlist_t *it, const char *key, const char *value) {
+ pl_lock ();
const char *old = plt_find_meta (it, key);
size_t newlen = strlen (value);
if (!old) {
@@ -85,6 +86,7 @@ plt_append_meta (playlist_t *it, const char *key, const char *value) {
}
if (len == newlen && !memcmp (str, value, len)) {
+ pl_unlock ();
return;
}
@@ -95,6 +97,7 @@ plt_append_meta (playlist_t *it, const char *key, const char *value) {
snprintf (out, sz, "%s\n%s", old, value);
plt_replace_meta (it, key, out);
}
+ pl_unlock ();
}
void
@@ -170,14 +173,20 @@ plt_find_meta (playlist_t *it, const char *key) {
int
plt_find_meta_int (playlist_t *it, const char *key, int def) {
+ pl_lock ();
const char *val = plt_find_meta (it, key);
- return val ? atoi (val) : def;
+ int res = val ? atoi (val) : def;
+ pl_unlock ();
+ return res;
}
float
plt_find_meta_float (playlist_t *it, const char *key, float def) {
+ pl_lock ();
const char *val = plt_find_meta (it, key);
- return val ? atof (val) : def;
+ float res = val ? atof (val) : def;
+ pl_unlock ();
+ return res;
}
DB_metaInfo_t *