diff options
author | waker <wakeroid@gmail.com> | 2012-05-17 23:12:00 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2012-05-17 23:12:00 +0200 |
commit | 6b97a160c2db19b808cbfc320a8a92da203d49ca (patch) | |
tree | 2c3d6594d65d0196c876719120da0d3908c9cbd2 /plugins/gme | |
parent | 816d87e1d38dc0fecbe1fa47794b2d7a18d2e321 (diff) |
fixed remaining pl_find_meta calls lacking pl_lock
Diffstat (limited to 'plugins/gme')
-rw-r--r-- | plugins/gme/cgme.c | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/plugins/gme/cgme.c b/plugins/gme/cgme.c index 48622266..bc966c14 100644 --- a/plugins/gme/cgme.c +++ b/plugins/gme/cgme.c @@ -116,35 +116,43 @@ cgme_init (DB_fileinfo_t *_info, DB_playItem_t *it) { int samplerate = deadbeef->conf_get_int ("synth.samplerate", 44100); gme_err_t res = "gme uninitialized"; - const char *ext = strrchr (deadbeef->pl_find_meta (it, ":URI"), '.'); - char *buffer; - int sz; - if (!read_gzfile (deadbeef->pl_find_meta (it, ":URI"), &buffer, &sz)) { - res = gme_open_data (deadbeef->pl_find_meta (it, ":URI"), buffer, sz, &info->emu, samplerate); - free (buffer); - } - if (res) { - DB_FILE *f = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); - int64_t sz = deadbeef->fgetlength (f); - if (sz <= 0) { - deadbeef->fclose (f); - return -1; - } - char *buf = malloc (sz); - if (!buf) { - deadbeef->fclose (f); - return -1; + deadbeef->pl_lock (); + { + const char *fname = deadbeef->pl_find_meta (it, ":URI"); + const char *ext = strrchr (fname, '.'); + char *buffer; + int sz; + if (!read_gzfile (fname, &buffer, &sz)) { + res = gme_open_data (fname, buffer, sz, &info->emu, samplerate); + free (buffer); } - int64_t rb = deadbeef->fread (buf, 1, sz, f); - deadbeef->fclose(f); - if (rb != sz) { + if (res) { + DB_FILE *f = deadbeef->fopen (fname); + int64_t sz = deadbeef->fgetlength (f); + if (sz <= 0) { + deadbeef->fclose (f); + deadbeef->pl_unlock (); + return -1; + } + char *buf = malloc (sz); + if (!buf) { + deadbeef->fclose (f); + deadbeef->pl_unlock (); + return -1; + } + int64_t rb = deadbeef->fread (buf, 1, sz, f); + deadbeef->fclose(f); + if (rb != sz) { + free (buf); + deadbeef->pl_unlock (); + return -1; + } + + res = gme_open_data (fname, buf, sz, &info->emu, samplerate); free (buf); - return -1; } - - res = gme_open_data (deadbeef->pl_find_meta (it, ":URI"), buf, sz, &info->emu, samplerate); - free (buf); } + deadbeef->pl_unlock (); if (res) { trace ("failed with error %d\n", res); |