diff options
author | waker <wakeroid@gmail.com> | 2012-05-17 20:50:47 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2012-05-17 20:50:47 +0200 |
commit | 816d87e1d38dc0fecbe1fa47794b2d7a18d2e321 (patch) | |
tree | 6753620029a94976bf27d474156723dd2f403813 /plugins/mpgmad | |
parent | af55e42f2422f8734bc80fb8a58eba80b29937ef (diff) |
fixed many calls to pl_find_meta[_raw] being called without pl_lock;
added debug pl_ensure_lock function which asserts when pl_lock is not set when it is required;
added new API functions for thread-safe metadata access
Diffstat (limited to 'plugins/mpgmad')
-rw-r--r-- | plugins/mpgmad/mpgmad.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c index 32f4022f..0e06bbeb 100644 --- a/plugins/mpgmad/mpgmad.c +++ b/plugins/mpgmad/mpgmad.c @@ -793,7 +793,9 @@ cmp3_init (DB_fileinfo_t *_info, DB_playItem_t *it) { mpgmad_info_t *info = (mpgmad_info_t *)_info; _info->plugin = &plugin; memset (&info->buffer, 0, sizeof (info->buffer)); + deadbeef->pl_lock (); info->buffer.file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); + deadbeef->pl_unlock (); if (!info->buffer.file) { return -1; } @@ -1357,15 +1359,20 @@ cmp3_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) { deadbeef->plt_set_item_duration (plt, it, buffer.duration); deadbeef->fclose (fp); - const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet"); - if (cuesheet) { - DB_playItem_t *last = deadbeef->plt_insert_cue_from_buffer (plt, after, it, cuesheet, strlen (cuesheet), buffer.totalsamples-buffer.delay-buffer.padding, buffer.samplerate); - if (last) { - deadbeef->pl_item_unref (it); - deadbeef->pl_item_unref (last); - return last; + deadbeef->pl_lock (); + { + const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet"); + if (cuesheet) { + DB_playItem_t *last = deadbeef->plt_insert_cue_from_buffer (plt, after, it, cuesheet, strlen (cuesheet), buffer.totalsamples-buffer.delay-buffer.padding, buffer.samplerate); + deadbeef->pl_unlock (); + if (last) { + deadbeef->pl_item_unref (it); + deadbeef->pl_item_unref (last); + return last; + } } } + deadbeef->pl_unlock (); // FIXME! bad numsamples passed to cue @@ -1383,7 +1390,9 @@ cmp3_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) { int cmp3_read_metadata (DB_playItem_t *it) { + deadbeef->pl_lock (); DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); + deadbeef->pl_unlock (); if (!fp) { return -1; } |