summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-05-17 23:12:00 +0200
committerGravatar waker <wakeroid@gmail.com>2012-05-17 23:12:00 +0200
commit6b97a160c2db19b808cbfc320a8a92da203d49ca (patch)
tree2c3d6594d65d0196c876719120da0d3908c9cbd2
parent816d87e1d38dc0fecbe1fa47794b2d7a18d2e321 (diff)
fixed remaining pl_find_meta calls lacking pl_lock
-rw-r--r--junklib.c79
-rw-r--r--plugins/aac/aac.c4
-rw-r--r--plugins/ao/plugin.c6
-rw-r--r--plugins/cdda/cdda.c5
-rw-r--r--plugins/converter/converter.c7
-rw-r--r--plugins/converter/convgui.c6
-rw-r--r--plugins/dca/dcaplug.c2
-rw-r--r--plugins/dumb/cdumb.c41
-rw-r--r--plugins/ffap/ffap.c4
-rw-r--r--plugins/ffmpeg/ffmpeg.c46
-rw-r--r--plugins/flac/flac.c58
-rw-r--r--plugins/gme/cgme.c58
-rw-r--r--plugins/gtkui/mainplaylist.c2
-rw-r--r--plugins/gtkui/plcommon.c5
-rw-r--r--plugins/m3u/m3u.c18
-rw-r--r--plugins/mpgmad/mpgmad.c2
-rw-r--r--plugins/musepack/musepack.c4
-rw-r--r--plugins/notify/notify.c5
-rw-r--r--plugins/shn/shn.c5
-rw-r--r--plugins/sndfile/sndfile.c2
-rw-r--r--plugins/tta/ttaplug.c15
-rw-r--r--plugins/vorbis/vorbis.c24
-rw-r--r--plugins/vtx/vtx.c2
-rw-r--r--plugins/wavpack/wavpack.c14
-rw-r--r--plugins/wildmidi/wildmidiplug.c2
-rw-r--r--streamer.c4
26 files changed, 286 insertions, 134 deletions
diff --git a/junklib.c b/junklib.c
index 1a22e4cb..60d87556 100644
--- a/junklib.c
+++ b/junklib.c
@@ -889,6 +889,8 @@ junk_id3v1_write (FILE *fp, playItem_t *it, const char *enc) {
const char *meta;
+ pl_lock ();
+
#define conv(name, store) {\
memset (store, 0x20, sizeof (store));\
meta = pl_find_meta (it, name);\
@@ -933,6 +935,8 @@ junk_id3v1_write (FILE *fp, playItem_t *it, const char *enc) {
}
}
+ pl_unlock ();
+
if (fwrite ("TAG", 1, 3, fp) != 3) {
trace ("junk_id3v1_write: failed to write signature\n");
return -1;
@@ -3418,8 +3422,11 @@ junk_rewrite_tags (playItem_t *it, uint32_t junk_flags, int id3v2_version, const
int write_id3v1 = junk_flags & JUNK_WRITE_ID3V1;
int write_apev2 = junk_flags & JUNK_WRITE_APEV2;
+ char tmppath[PATH_MAX];
// find the beginning and the end of audio data
- const char *fname = pl_find_meta (it, ":URI");
+ char fname[PATH_MAX];
+ pl_get_meta (it, ":URI", fname, sizeof (fname));
+ snprintf (tmppath, sizeof (tmppath), "%s.temp", fname);
fp = deadbeef->fopen (fname);
if (!fp) {
trace ("file not found %s\n", fname);
@@ -3470,8 +3477,6 @@ junk_rewrite_tags (playItem_t *it, uint32_t junk_flags, int id3v2_version, const
// open output file
out = NULL;
- char tmppath[PATH_MAX];
- snprintf (tmppath, sizeof (tmppath), "%s.temp", pl_find_meta (it, ":URI"));
out = fopen (tmppath, "w+b");
trace ("will write tags into %s\n", tmppath);
@@ -3549,11 +3554,15 @@ junk_rewrite_tags (playItem_t *it, uint32_t junk_flags, int id3v2_version, const
// COMM
junk_id3v2_remove_frames (&id3v2, "COMM");
- const char *val = pl_find_meta (it, "comment");
- if (val && *val) {
- junk_id3v2_remove_frames (&id3v2, "COMM");
- junk_id3v2_add_comment_frame (&id3v2, "eng", "", val);
+ pl_lock ();
+ {
+ const char *val = pl_find_meta (it, "comment");
+ if (val && *val) {
+ junk_id3v2_remove_frames (&id3v2, "COMM");
+ junk_id3v2_add_comment_frame (&id3v2, "eng", "", val);
+ }
}
+ pl_unlock ();
// remove all known normal frames (they will be refilled from track metadata)
int idx = id3v2.version[0] == 3 ? MAP_ID3V23 : MAP_ID3V24;
@@ -3594,18 +3603,22 @@ junk_rewrite_tags (playItem_t *it, uint32_t junk_flags, int id3v2_version, const
}
// add tracknumber/totaltracks
- const char *track = pl_find_meta (it, "track");
- const char *totaltracks = pl_find_meta (it, "numtracks");
- if (track && totaltracks) {
- char s[100];
- snprintf (s, sizeof (s), "%s/%s", track, totaltracks);
- junk_id3v2_remove_frames (&id3v2, "TRCK");
- junk_id3v2_add_text_frame (&id3v2, "TRCK", s);
- }
- else if (track) {
- junk_id3v2_remove_frames (&id3v2, "TRCK");
- junk_id3v2_add_text_frame (&id3v2, "TRCK", track);
+ pl_lock ();
+ {
+ const char *track = pl_find_meta (it, "track");
+ const char *totaltracks = pl_find_meta (it, "numtracks");
+ if (track && totaltracks) {
+ char s[100];
+ snprintf (s, sizeof (s), "%s/%s", track, totaltracks);
+ junk_id3v2_remove_frames (&id3v2, "TRCK");
+ junk_id3v2_add_text_frame (&id3v2, "TRCK", s);
+ }
+ else if (track) {
+ junk_id3v2_remove_frames (&id3v2, "TRCK");
+ junk_id3v2_add_text_frame (&id3v2, "TRCK", track);
+ }
}
+ pl_unlock ();
// write tag
if (junk_id3v2_write (out, &id3v2) != 0) {
@@ -3698,18 +3711,22 @@ junk_rewrite_tags (playItem_t *it, uint32_t junk_flags, int id3v2_version, const
}
// add tracknumber/totaltracks
- const char *track = pl_find_meta (it, "track");
- const char *totaltracks = pl_find_meta (it, "numtracks");
- if (track && totaltracks) {
- char s[100];
- snprintf (s, sizeof (s), "%s/%s", track, totaltracks);
- junk_apev2_remove_frames (&apev2, "Track");
- junk_apev2_add_text_frame (&apev2, "Track", s);
- }
- else if (track) {
- junk_apev2_remove_frames (&apev2, "Track");
- junk_apev2_add_text_frame (&apev2, "Track", track);
+ pl_lock ();
+ {
+ const char *track = pl_find_meta (it, "track");
+ const char *totaltracks = pl_find_meta (it, "numtracks");
+ if (track && totaltracks) {
+ char s[100];
+ snprintf (s, sizeof (s), "%s/%s", track, totaltracks);
+ junk_apev2_remove_frames (&apev2, "Track");
+ junk_apev2_add_text_frame (&apev2, "Track", s);
+ }
+ else if (track) {
+ junk_apev2_remove_frames (&apev2, "Track");
+ junk_apev2_add_text_frame (&apev2, "Track", track);
+ }
}
+ pl_unlock ();
// write tag
if (deadbeef->junk_apev2_write (out, &apev2, 0, 1) != 0) {
@@ -3776,7 +3793,9 @@ error:
free (buffer);
}
if (!err) {
- rename (tmppath, pl_find_meta (it, ":URI"));
+ pl_lock ();
+ rename (tmppath, fname);
+ pl_unlock ();
}
else {
unlink (tmppath);
diff --git a/plugins/aac/aac.c b/plugins/aac/aac.c
index 2f2755f0..a42e8b78 100644
--- a/plugins/aac/aac.c
+++ b/plugins/aac/aac.c
@@ -449,7 +449,9 @@ static int
aac_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
aac_info_t *info = (aac_info_t *)_info;
+ deadbeef->pl_lock ();
info->file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!info->file) {
return -1;
}
@@ -1119,7 +1121,9 @@ aac_load_tags (DB_playItem_t *it, mp4ff_t *mp4) {
int
aac_read_metadata (DB_playItem_t *it) {
#ifdef USE_MP4FF
+ deadbeef->pl_lock ();
DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!fp) {
return -1;
}
diff --git a/plugins/ao/plugin.c b/plugins/ao/plugin.c
index 2239d995..3743ea72 100644
--- a/plugins/ao/plugin.c
+++ b/plugins/ao/plugin.c
@@ -66,7 +66,9 @@ aoplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
_info->plugin = &plugin;
info->duration = deadbeef->pl_get_item_duration (it);
+ deadbeef->pl_lock ();
DB_FILE *file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!file) {
trace ("psf: failed to fopen %s\n", deadbeef->pl_find_meta (it, ":URI"));
return -1;
@@ -81,7 +83,9 @@ aoplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
}
if (deadbeef->fread(info->filebuffer, 1, info->filesize, file) != info->filesize) {
+ deadbeef->pl_lock ();
fprintf(stderr, "psf: file read error: %s\n", deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
deadbeef->fclose (file);
return -1;
}
@@ -93,7 +97,9 @@ aoplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
return -1;
}
+ deadbeef->pl_lock ();
info->decoder = ao_start (info->type, deadbeef->pl_find_meta (it, ":URI"), (uint8 *)info->filebuffer, info->filesize);
+ deadbeef->pl_unlock ();
if (!info->decoder) {
fprintf (stderr, "psf: ao_start failed\n");
return -1;
diff --git a/plugins/cdda/cdda.c b/plugins/cdda/cdda.c
index 51d4b686..d3212ec5 100644
--- a/plugins/cdda/cdda.c
+++ b/plugins/cdda/cdda.c
@@ -81,9 +81,8 @@ cda_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
trace ("cdda: init %s\n", deadbeef->pl_find_meta (it, ":URI"));
- size_t l = strlen (deadbeef->pl_find_meta (it, ":URI"));
- char location[l+1];
- memcpy (location, deadbeef->pl_find_meta (it, ":URI"), l+1);
+ char location[PATH_MAX];
+ deadbeef->pl_get_meta (it, ":URI", location, sizeof (location));
char *nr = strchr (location, '#');
if (nr) {
diff --git a/plugins/converter/converter.c b/plugins/converter/converter.c
index 7c884eb1..ad68bab9 100644
--- a/plugins/converter/converter.c
+++ b/plugins/converter/converter.c
@@ -685,7 +685,9 @@ get_output_field (DB_playItem_t *it, const char *field, char *out, int sz)
void
get_output_path (DB_playItem_t *it, const char *outfolder_user, const char *outfile, ddb_encoder_preset_t *encoder_preset, int preserve_folder_structure, const char *root_folder, int write_to_source_folder, char *out, int sz) {
trace ("get_output_path: %s %s %s\n", outfolder_user, outfile, root_folder);
+ deadbeef->pl_lock ();
const char *uri = strdupa (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
char outfolder_preserve[2000];
if (preserve_folder_structure) {
// generate new outfolder
@@ -800,8 +802,7 @@ int
convert (DB_playItem_t *it, const char *out, int output_bps, int output_is_float, ddb_encoder_preset_t *encoder_preset, ddb_dsp_preset_t *dsp_preset, int *abort) {
if (deadbeef->pl_get_item_duration (it) <= 0) {
deadbeef->pl_lock ();
- const char *fname = deadbeef->pl_find_meta (it, ":URI");
- fprintf (stderr, "converter: stream %s doesn't have finite length, skipped\n", fname);
+ fprintf (stderr, "converter: stream %s doesn't have finite length, skipped\n", deadbeef->pl_find_meta (it, ":URI"));
deadbeef->pl_unlock ();
return -1;
}
@@ -812,7 +813,9 @@ convert (DB_playItem_t *it, const char *out, int output_bps, int output_is_float
DB_decoder_t *dec = NULL;
DB_fileinfo_t *fileinfo = NULL;
char input_file_name[PATH_MAX] = "";
+ deadbeef->pl_lock ();
dec = (DB_decoder_t *)deadbeef->plug_get_for_id (deadbeef->pl_find_meta (it, ":DECODER"));
+ deadbeef->pl_unlock ();
if (dec) {
fileinfo = dec->open (0);
diff --git a/plugins/converter/convgui.c b/plugins/converter/convgui.c
index 6e1fb335..27517022 100644
--- a/plugins/converter/convgui.c
+++ b/plugins/converter/convgui.c
@@ -130,7 +130,7 @@ converter_worker (void *ctx) {
// prepare for preserving folder struct
if (conv->preserve_folder_structure && conv->convert_items_count >= 1) {
// start with the 1st track path
- strncpy (root, deadbeef->pl_find_meta (conv->convert_items[0], ":URI"), sizeof (root));
+ deadbeef->pl_get_meta (conv->convert_items[0], ":URI", root, sizeof (root));
char *sep = strrchr (root, '/');
if (sep) {
*sep = 0;
@@ -138,6 +138,7 @@ converter_worker (void *ctx) {
// reduce
rootlen = strlen (root);
for (int n = 1; n < conv->convert_items_count; n++) {
+ deadbeef->pl_lock ();
const char *path = deadbeef->pl_find_meta (conv->convert_items[n], ":URI");
if (strncmp (path, root, rootlen)) {
// find where path splits
@@ -156,6 +157,7 @@ converter_worker (void *ctx) {
r++;
}
}
+ deadbeef->pl_unlock ();
}
fprintf (stderr, "common root path: %s\n", root);
}
@@ -164,7 +166,9 @@ converter_worker (void *ctx) {
update_progress_info_t *info = malloc (sizeof (update_progress_info_t));
info->entry = conv->progress_entry;
g_object_ref (info->entry);
+ deadbeef->pl_lock ();
info->text = strdup (deadbeef->pl_find_meta (conv->convert_items[n], ":URI"));
+ deadbeef->pl_unlock ();
g_idle_add (update_progress_cb, info);
char outpath[2000];
diff --git a/plugins/dca/dcaplug.c b/plugins/dca/dcaplug.c
index 85a04df6..dd37d064 100644
--- a/plugins/dca/dcaplug.c
+++ b/plugins/dca/dcaplug.c
@@ -405,7 +405,9 @@ static int
dts_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
ddb_dca_state_t *info = (ddb_dca_state_t *)_info;
+ deadbeef->pl_lock ();
info->file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!info->file) {
trace ("dca: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI"));
return -1;
diff --git a/plugins/dumb/cdumb.c b/plugins/dumb/cdumb.c
index 26e6fa69..63fb4b18 100644
--- a/plugins/dumb/cdumb.c
+++ b/plugins/dumb/cdumb.c
@@ -64,13 +64,18 @@ cdumb_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
int start_order = 0;
int is_dos, is_it;
- const char *ext = deadbeef->pl_find_meta (it, ":URI") + strlen (deadbeef->pl_find_meta (it, ":URI")) - 1;
- while (*ext != '.' && ext > deadbeef->pl_find_meta (it, ":URI")) {
- ext--;
+ deadbeef->pl_lock ();
+ {
+ const char *uri = deadbeef->pl_find_meta (it, ":URI");
+ const char *ext = uri + strlen (uri) - 1;
+ while (*ext != '.' && ext > uri) {
+ ext--;
+ }
+ ext++;
+ const char *ftype;
+ info->duh = open_module (uri, ext, &start_order, &is_it, &is_dos, &ftype);
}
- ext++;
- const char *ftype;
- info->duh = open_module(deadbeef->pl_find_meta (it, ":URI"), ext, &start_order, &is_it, &is_dos, &ftype);
+ deadbeef->pl_unlock ();
dumb_it_do_initial_runthrough (info->duh);
@@ -766,19 +771,25 @@ read_metadata_internal (DB_playItem_t *it, DUMB_IT_SIGDATA *itsd) {
static int
cdumb_read_metadata (DB_playItem_t *it) {
- const char *fname = deadbeef->pl_find_meta (it, ":URI");
- const char *ext = strrchr (fname, '.');
- if (ext) {
- ext++;
- }
- else {
- ext = "";
- }
+ DUH* duh = NULL;
int start_order = 0;
int is_it;
int is_dos;
const char *ftype;
- DUH* duh = open_module(fname, ext, &start_order, &is_it, &is_dos, &ftype);
+
+ deadbeef->pl_lock ();
+ {
+ const char *fname = deadbeef->pl_find_meta (it, ":URI");
+ const char *ext = strrchr (fname, '.');
+ if (ext) {
+ ext++;
+ }
+ else {
+ ext = "";
+ }
+ duh = open_module(fname, ext, &start_order, &is_it, &is_dos, &ftype);
+ }
+ deadbeef->pl_unlock ();
if (!duh) {
unload_duh (duh);
return -1;
diff --git a/plugins/ffap/ffap.c b/plugins/ffap/ffap.c
index c2ba7cbd..d8fb4044 100644
--- a/plugins/ffap/ffap.c
+++ b/plugins/ffap/ffap.c
@@ -690,7 +690,9 @@ ffap_init (DB_fileinfo_t *_info, DB_playItem_t *it)
{
ape_info_t *info = (ape_info_t*)_info;
+ deadbeef->pl_lock ();
info->fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!info->fp) {
return -1;
}
@@ -1812,7 +1814,9 @@ ffap_seek (DB_fileinfo_t *_info, float seconds) {
static int ffap_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;
}
diff --git a/plugins/ffmpeg/ffmpeg.c b/plugins/ffmpeg/ffmpeg.c
index 9cf6e0c5..75911cc3 100644
--- a/plugins/ffmpeg/ffmpeg.c
+++ b/plugins/ffmpeg/ffmpeg.c
@@ -117,15 +117,22 @@ ffmpeg_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
// return -1 on failure
int ret;
- int l = strlen (deadbeef->pl_find_meta (it, ":URI"));
- char *uri = alloca (l + sizeof (FF_PROTOCOL_NAME) + 1);
+ char *uri = NULL;
int i;
- // construct uri
- memcpy (uri, FF_PROTOCOL_NAME, sizeof (FF_PROTOCOL_NAME)-1);
- memcpy (uri + sizeof (FF_PROTOCOL_NAME)-1, ":", 1);
- memcpy (uri + sizeof (FF_PROTOCOL_NAME), deadbeef->pl_find_meta (it, ":URI"), l);
- uri[sizeof (FF_PROTOCOL_NAME) + l] = 0;
+ deadbeef->pl_lock ();
+ {
+ const char *fname = deadbeef->pl_find_meta (it, ":URI");
+ int l = strlen (fname);
+ uri = alloca (l + sizeof (FF_PROTOCOL_NAME) + 1);
+
+ // construct uri
+ memcpy (uri, FF_PROTOCOL_NAME, sizeof (FF_PROTOCOL_NAME)-1);
+ memcpy (uri + sizeof (FF_PROTOCOL_NAME)-1, ":", 1);
+ memcpy (uri + sizeof (FF_PROTOCOL_NAME), fname, l);
+ uri[sizeof (FF_PROTOCOL_NAME) + l] = 0;
+ }
+ deadbeef->pl_unlock ();
trace ("ffmpeg: uri: %s\n", uri);
// open file
@@ -548,7 +555,7 @@ ffmpeg_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id);
deadbeef->pl_replace_meta (it, ":FILETYPE", codec->name);
- if (!deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI"))) {
+ if (!deadbeef->is_local_file (fname)) {
deadbeef->plt_set_item_duration (plt, it, -1);
}
else {
@@ -560,7 +567,7 @@ ffmpeg_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
int64_t fsize = -1;
- DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ DB_FILE *fp = deadbeef->fopen (fname);
if (fp) {
if (!fp->vfs->is_streaming ()) {
fsize = deadbeef->fgetlength (fp);
@@ -748,15 +755,22 @@ ffmpeg_read_metadata (DB_playItem_t *it) {
AVCodecContext *ctx = NULL;
AVFormatContext *fctx = NULL;
int ret;
- int l = strlen (deadbeef->pl_find_meta (it, ":URI"));
- char *uri = alloca (l + sizeof (FF_PROTOCOL_NAME) + 1);
+ char *uri = NULL;
int i;
- // construct uri
- memcpy (uri, FF_PROTOCOL_NAME, sizeof (FF_PROTOCOL_NAME)-1);
- memcpy (uri + sizeof (FF_PROTOCOL_NAME)-1, ":", 1);
- memcpy (uri + sizeof (FF_PROTOCOL_NAME), deadbeef->pl_find_meta (it, ":URI"), l);
- uri[sizeof (FF_PROTOCOL_NAME) + l] = 0;
+ deadbeef->pl_lock ();
+ {
+ char *fname = deadbeef->pl_find_meta (it, ":URI");
+ int l = strlen (fname);
+ uri = alloca (l + sizeof (FF_PROTOCOL_NAME) + 1);
+
+ // construct uri
+ memcpy (uri, FF_PROTOCOL_NAME, sizeof (FF_PROTOCOL_NAME)-1);
+ memcpy (uri + sizeof (FF_PROTOCOL_NAME)-1, ":", 1);
+ memcpy (uri + sizeof (FF_PROTOCOL_NAME), fname, l);
+ uri[sizeof (FF_PROTOCOL_NAME) + l] = 0;
+ }
+ deadbeef->pl_unlock ();
trace ("ffmpeg: uri: %s\n", uri);
// open file
diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c
index a6ceb497..02d17ecc 100644
--- a/plugins/flac/flac.c
+++ b/plugins/flac/flac.c
@@ -211,7 +211,9 @@ cflac_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
trace ("cflac_init %s\n", deadbeef->pl_find_meta (it, ":URI"));
flac_info_t *info = (flac_info_t *)_info;
+ deadbeef->pl_lock ();
info->file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!info->file) {
trace ("cflac_init failed to open file\n");
return -1;
@@ -219,16 +221,17 @@ cflac_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
info->flac_critical_error = 0;
- const char *ext = deadbeef->pl_find_meta (it, ":URI") + strlen (deadbeef->pl_find_meta (it, ":URI"));
- while (ext > deadbeef->pl_find_meta (it, ":URI") && *ext != '/' && *ext != '.') {
- ext--;
- }
- if (*ext == '.') {
- ext++;
- }
- else {
- ext = NULL;
+ const char *ext = NULL;
+
+ deadbeef->pl_lock ();
+ {
+ const char *uri = deadbeef->pl_find_meta (it, ":URI");
+ ext = strrchr (uri, '.');
+ if (ext) {
+ ext++;
+ }
}
+ deadbeef->pl_unlock ();
int isogg = 0;
int skip = 0;
@@ -307,13 +310,17 @@ cflac_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
else {
info->bitrate = -1;
}
- const char *channelmask = deadbeef->pl_find_meta (it, "WAVEFORMAT_EXTENSIBLE_CHANNELMASK");
- if (channelmask) {
- uint32_t cm = 0;
- if (1 == sscanf (channelmask, "0x%X", &cm)) {
- _info->fmt.channelmask = cm;
+ deadbeef->pl_lock ();
+ {
+ const char *channelmask = deadbeef->pl_find_meta (it, "WAVEFORMAT_EXTENSIBLE_CHANNELMASK");
+ if (channelmask) {
+ uint32_t cm = 0;
+ if (1 == sscanf (channelmask, "0x%X", &cm)) {
+ _info->fmt.channelmask = cm;
+ }
}
}
+ deadbeef->pl_unlock ();
info->buffer = malloc (BUFFERSIZE);
info->remaining = 0;
@@ -730,15 +737,20 @@ cflac_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
}
// try embedded cue
- 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), info.totalsamples, info.info.fmt.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), info.totalsamples, info.info.fmt.samplerate);
+ if (last) {
+ deadbeef->pl_item_unref (it);
+ deadbeef->pl_item_unref (last);
+ deadbeef->pl_unlock ();
+ return last;
+ }
}
}
+ deadbeef->pl_unlock ();
// try external cue
DB_playItem_t *cue_after = deadbeef->plt_insert_cue (plt, after, it, info.totalsamples, info.info.fmt.samplerate);
@@ -781,7 +793,9 @@ cflac_read_metadata (DB_playItem_t *it) {
trace ("cflac_read_metadata: FLAC__metadata_chain_new failed\n");
return -1;
}
+ deadbeef->pl_lock ();
FLAC__bool res = FLAC__metadata_chain_read (chain, deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!res) {
trace ("cflac_read_metadata: FLAC__metadata_chain_read failed\n");
goto error;
@@ -846,7 +860,9 @@ cflac_write_metadata (DB_playItem_t *it) {
trace ("cflac_write_metadata: FLAC__metadata_chain_new failed\n");
return -1;
}
+ deadbeef->pl_lock ();
FLAC__bool res = FLAC__metadata_chain_read (chain, deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!res) {
trace ("cflac_write_metadata: FLAC__metadata_chain_read failed\n");
goto error;
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);
diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c
index 21661f6d..e193d8e3 100644
--- a/plugins/gtkui/mainplaylist.c
+++ b/plugins/gtkui/mainplaylist.c
@@ -131,7 +131,9 @@ playlist_tooltip_handler (GtkWidget *widget, gint x, gint y, gboolean keyboard_m
GtkWidget *pl = lookup_widget (mainwin, "playlist");
DB_playItem_t *it = (DB_playItem_t *)ddb_listview_get_iter_from_coord (DDB_LISTVIEW (pl), 0, y);
if (it) {
+ deadbeef->pl_lock ();
gtk_tooltip_set_text (tooltip, deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
deadbeef->pl_item_unref (it);
return TRUE;
}
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index f0c36a24..3d747e91 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -361,8 +361,9 @@ on_remove_from_disk_activate (GtkMenuItem *menuitem,
DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
while (it) {
- if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI"))) {
- unlink (deadbeef->pl_find_meta (it, ":URI"));
+ const char *uri = deadbeef->pl_find_meta (it, ":URI");
+ if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (uri)) {
+ unlink (uri);
}
DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
deadbeef->pl_item_unref (it);
diff --git a/plugins/m3u/m3u.c b/plugins/m3u/m3u.c
index 8097698c..18161b6b 100644
--- a/plugins/m3u/m3u.c
+++ b/plugins/m3u/m3u.c
@@ -470,15 +470,19 @@ m3uplug_save_m3u (const char *fname, DB_playItem_t *first, DB_playItem_t *last)
while (it) {
int dur = (int)ceil(deadbeef->pl_get_item_duration (it));
char s[1000];
- if (deadbeef->pl_find_meta (it, "artist")) {
+ if (deadbeef->pl_meta_exists (it, "artist")) {
deadbeef->pl_format_title (it, -1, s, sizeof (s), -1, "%a - %t");
}
else {
deadbeef->pl_format_title (it, -1, s, sizeof (s), -1, "%t");
}
- const char *fname = deadbeef->pl_find_meta (it, ":URI");
fprintf (fp, "#EXTINF:%d,%s\n", dur, s);
- fprintf (fp, "%s\n", fname);
+ deadbeef->pl_lock ();
+ {
+ const char *fname = deadbeef->pl_find_meta (it, ":URI");
+ fprintf (fp, "%s\n", fname);
+ }
+ deadbeef->pl_unlock ();
if (it == last) {
break;
@@ -518,8 +522,12 @@ m3uplug_save_pls (const char *fname, DB_playItem_t *first, DB_playItem_t *last)
deadbeef->pl_item_ref (it);
int i = 1;
while (it) {
- const char *fname = deadbeef->pl_find_meta (it, ":URI");
- fprintf (fp, "File%d=%s\n", i, fname);
+ deadbeef->pl_lock ();
+ {
+ const char *fname = deadbeef->pl_find_meta (it, ":URI");
+ fprintf (fp, "File%d=%s\n", i, fname);
+ }
+ deadbeef->pl_unlock ();
if (it == last) {
break;
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c
index 0e06bbeb..132adebc 100644
--- a/plugins/mpgmad/mpgmad.c
+++ b/plugins/mpgmad/mpgmad.c
@@ -1364,10 +1364,10 @@ cmp3_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
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);
+ deadbeef->pl_unlock ();
return last;
}
}
diff --git a/plugins/musepack/musepack.c b/plugins/musepack/musepack.c
index 69f0455a..c26f7d40 100644
--- a/plugins/musepack/musepack.c
+++ b/plugins/musepack/musepack.c
@@ -97,7 +97,9 @@ musepack_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
info->reader.get_size = musepack_vfs_get_size;
info->reader.canseek = musepack_vfs_canseek;
+ deadbeef->pl_lock ();
DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!fp) {
return -1;
}
@@ -483,7 +485,9 @@ musepack_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
}
static int musepack_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;
}
diff --git a/plugins/notify/notify.c b/plugins/notify/notify.c
index 905b65e0..d958191c 100644
--- a/plugins/notify/notify.c
+++ b/plugins/notify/notify.c
@@ -224,9 +224,12 @@ static void show_notification (DB_playItem_t *track) {
dbus_uint32_t v_id = 0;
char *v_iconname = NULL;
if (deadbeef->conf_get_int("notify.albumart", 0) && artwork_plugin) {
+ deadbeef->pl_lock ();
const char *album = deadbeef->pl_find_meta (track, "album");
const char *artist = deadbeef->pl_find_meta (track, "artist");
- v_iconname = artwork_plugin->get_album_art (deadbeef->pl_find_meta (track, ":URI"), artist, album, deadbeef->conf_get_int ("notify.albumart_size", 64), cover_avail_callback, NULL);
+ const char *fname = deadbeef->pl_find_meta (track, ":URI");
+ v_iconname = artwork_plugin->get_album_art (fname, artist, album, deadbeef->conf_get_int ("notify.albumart_size", 64), cover_avail_callback, NULL);
+ deadbeef->pl_unlock ();
}
if (!v_iconname) {
v_iconname = strdup ("deadbeef");
diff --git a/plugins/shn/shn.c b/plugins/shn/shn.c
index da69866b..cc03ac72 100644
--- a/plugins/shn/shn.c
+++ b/plugins/shn/shn.c
@@ -322,7 +322,9 @@ shn_init(DB_fileinfo_t *_info, DB_playItem_t *it) {
char data[4];
DB_FILE *f;
+ deadbeef->pl_lock ();
f = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!f) {
trace ("shn: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI"));
return -1;
@@ -346,10 +348,13 @@ shn_init(DB_fileinfo_t *_info, DB_playItem_t *it) {
return -1;
}
+ deadbeef->pl_lock ();
if (!(info->shnfile = load_shn(deadbeef->pl_find_meta (it, ":URI")))) {
+ deadbeef->pl_unlock ();
trace ("shn: load_shn failed\n");
return -1;
}
+ deadbeef->pl_unlock ();
_info->fmt.bps = info->shnfile->wave_header.bits_per_sample;
_info->fmt.channels = info->shnfile->wave_header.channels;
diff --git a/plugins/sndfile/sndfile.c b/plugins/sndfile/sndfile.c
index e10979be..1f7ddc41 100644
--- a/plugins/sndfile/sndfile.c
+++ b/plugins/sndfile/sndfile.c
@@ -162,7 +162,9 @@ sndfile_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
sndfile_info_t *info = (sndfile_info_t*)_info;
SF_INFO inf;
+ deadbeef->pl_lock ();
DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!fp) {
trace ("sndfile: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI"));
return -1;
diff --git a/plugins/tta/ttaplug.c b/plugins/tta/ttaplug.c
index 5b433e44..cb6f35f7 100644
--- a/plugins/tta/ttaplug.c
+++ b/plugins/tta/ttaplug.c
@@ -61,16 +61,21 @@ static int
tta_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
tta_info_t *info = (tta_info_t *)_info;
- trace ("open_tta_file %s\n", deadbeef->pl_find_meta (it, ":URI"));
- if (open_tta_file (deadbeef->pl_find_meta (it, ":URI"), &info->tta, 0) != 0) {
- fprintf (stderr, "tta: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_lock ();
+ const char *fname = deadbeef->pl_find_meta (it, ":URI")
+ trace ("open_tta_file %s\n", fname);
+ if (open_tta_file (fname, &info->tta, 0) != 0) {
+ deadbeef->pl_unlock ();
+ fprintf (stderr, "tta: failed to open %s\n", fname);
return -1;
}
if (player_init (&info->tta) != 0) {
- fprintf (stderr, "tta: failed to init player for %s\n", deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
+ fprintf (stderr, "tta: failed to init player for %s\n", fname);
return -1;
}
+ deadbeef->pl_unlock ();
_info->fmt.bps = info->tta.BPS;
_info->fmt.channels = info->tta.NCH;
@@ -251,7 +256,9 @@ tta_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
}
static int tta_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;
}
diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c
index 335e73d0..a121695a 100644
--- a/plugins/vorbis/vorbis.c
+++ b/plugins/vorbis/vorbis.c
@@ -112,10 +112,13 @@ update_vorbis_comments (DB_playItem_t *it, vorbis_comment *vc, int refresh_playl
int l = strlen (metainfo[m]);
if (vc->comment_lengths[i] > l && !strncasecmp (metainfo[m], s, l) && s[l] == '=') {
if (refresh_playlist == 2) {
+ deadbeef->pl_lock ();
const char *val = deadbeef->pl_find_meta (it, metainfo[m+1]);
if (!val || strcmp (val, s+l+1)) {
+ deadbeef->pl_unlock ();
return 1;
}
+ deadbeef->pl_unlock ();
}
else {
deadbeef->pl_append_meta (it, metainfo[m+1], s + l + 1);
@@ -197,7 +200,9 @@ cvorbis_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
info->ptrack = it;
deadbeef->pl_item_ref (it);
+ deadbeef->pl_lock ();
info->info.file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!info->info.file) {
trace ("ogg: failed to open file %s\n", deadbeef->pl_find_meta (it, ":URI"));
return -1;
@@ -536,16 +541,19 @@ cvorbis_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
}
// embedded cue
+ deadbeef->pl_lock ();
const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet");
if (cuesheet) {
cue = deadbeef->plt_insert_cue_from_buffer (plt, after, it, cuesheet, strlen (cuesheet), totalsamples, samplerate);
if (cue) {
+ deadbeef->pl_unlock ();
deadbeef->pl_item_unref (it);
deadbeef->pl_item_unref (cue);
ov_clear (&vorbis_file);
return cue;
}
}
+ deadbeef->pl_unlock ();
}
else {
currentsample += totalsamples;
@@ -574,7 +582,9 @@ cvorbis_read_metadata (DB_playItem_t *it) {
OggVorbis_File vorbis_file;
vorbis_info *vi = NULL;
+ deadbeef->pl_lock ();
fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!fp) {
trace ("cvorbis_read_metadata: failed to fopen %s\n", deadbeef->pl_find_meta (it, ":URI"));
return -1;
@@ -624,6 +634,8 @@ cvorbis_write_metadata (DB_playItem_t *it) {
FILE *out = NULL;
int err = -1;
char outname[PATH_MAX] = "";
+ char fname[PATH_MAX];
+ deadbeef->pl_get_meta (it, ":URI", fname, sizeof (fname));
struct field {
struct field *next;
@@ -638,9 +650,9 @@ cvorbis_write_metadata (DB_playItem_t *it) {
trace ("cvorbis_write_metadata: vcedit_new_state failed\n");
return -1;
}
- fp = fopen (deadbeef->pl_find_meta (it, ":URI"), "rb");
+ fp = fopen (fname, "rb");
if (!fp) {
- trace ("cvorbis_write_metadata: failed to read metadata from %s\n", deadbeef->pl_find_meta (it, ":URI"));
+ trace ("cvorbis_write_metadata: failed to read metadata from %s\n", fname);
goto error;
}
if (vcedit_open (state, fp) != 0) {
@@ -717,13 +729,13 @@ cvorbis_write_metadata (DB_playItem_t *it) {
m = m->next;
}
deadbeef->pl_unlock ();
-
// add preserved fields
for (struct field *f = preserved_fields; f; f = f->next) {
vorbis_comment_add (vc, f->data);
}
- snprintf (outname, sizeof (outname), "%s.temp.ogg", deadbeef->pl_find_meta (it, ":URI"));
+ snprintf (outname, sizeof (outname), "%s.temp.ogg", fname);
+
out = fopen (outname, "w+b");
if (!out) {
@@ -732,7 +744,7 @@ cvorbis_write_metadata (DB_playItem_t *it) {
}
if (vcedit_write (state, out) < 0) {
- trace ("cvorbis_write_metadata: failed to write tags to %s, error: %s\n", deadbeef->pl_find_meta (it, ":URI"), vcedit_error (state));
+ trace ("cvorbis_write_metadata: failed to write tags to %s, error: %s\n", fname, vcedit_error (state));
goto error;
}
@@ -754,7 +766,7 @@ error:
}
if (!err) {
- rename (outname, deadbeef->pl_find_meta (it, ":URI"));
+ rename (outname, fname);
}
else if (out) {
unlink (outname);
diff --git a/plugins/vtx/vtx.c b/plugins/vtx/vtx.c
index 81a60b0e..35cbde95 100644
--- a/plugins/vtx/vtx.c
+++ b/plugins/vtx/vtx.c
@@ -61,7 +61,9 @@ vtx_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
size_t sz = 0;
char *buf = NULL;
+ deadbeef->pl_lock ();
DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!fp) {
trace ("vtx: failed to open file %s\n", deadbeef->pl_find_meta (it, ":URI"));
return -1;
diff --git a/plugins/wavpack/wavpack.c b/plugins/wavpack/wavpack.c
index 73f3c9f7..bb045f5e 100644
--- a/plugins/wavpack/wavpack.c
+++ b/plugins/wavpack/wavpack.c
@@ -125,21 +125,26 @@ wv_open (uint32_t hints) {
static int
wv_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
wvctx_t *info = (wvctx_t *)_info;
+ deadbeef->pl_lock ();
info->file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!info->file) {
return -1;
}
#ifndef TINYWV
- char *c_fname = alloca (strlen (deadbeef->pl_find_meta (it, ":URI")) + 2);
+ deadbeef->pl_lock ();
+ const char *uri = deadbeef->pl_find_meta (it, ":URI");
+ char *c_fname = alloca (strlen (uri) + 2);
if (c_fname) {
- strcpy (c_fname, deadbeef->pl_find_meta (it, ":URI"));
+ strcpy (c_fname, uri);
strcat (c_fname, "c");
info->c_file = deadbeef->fopen (c_fname);
}
else {
fprintf (stderr, "wavpack warning: failed to alloc memory for correction file name\n");
}
+ deadbeef->pl_unlock ();
#endif
char error[80];
@@ -336,11 +341,13 @@ wv_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
deadbeef->pl_add_meta (it, ":WAVPACK_MODE", s);
// embedded cue
+ deadbeef->pl_lock ();
const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet");
if (cuesheet) {
trace ("found cuesheet: %s\n", cuesheet);
DB_playItem_t *last = deadbeef->plt_insert_cue_from_buffer (plt, after, it, cuesheet, strlen (cuesheet), totalsamples, samplerate);
if (last) {
+ deadbeef->pl_unlock ();
deadbeef->fclose (fp);
WavpackCloseFile (ctx);
deadbeef->pl_item_unref (it);
@@ -348,6 +355,7 @@ wv_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
return last;
}
}
+ deadbeef->pl_unlock ();
// cue file on disc
DB_playItem_t *cue_after = deadbeef->plt_insert_cue (plt, after, it, totalsamples, samplerate);
if (cue_after) {
@@ -368,7 +376,9 @@ wv_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
int
wv_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;
}
diff --git a/plugins/wildmidi/wildmidiplug.c b/plugins/wildmidi/wildmidiplug.c
index 36e2be3f..a346f6b7 100644
--- a/plugins/wildmidi/wildmidiplug.c
+++ b/plugins/wildmidi/wildmidiplug.c
@@ -52,7 +52,9 @@ int
wmidi_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
wmidi_info_t *info = (wmidi_info_t *)_info;
+ deadbeef->pl_lock ();
info->m = WildMidi_Open (deadbeef->pl_find_meta (it, ":URI"));
+ deadbeef->pl_unlock ();
if (!info->m) {
trace ("wmidi: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI"));
return -1;
diff --git a/streamer.c b/streamer.c
index 53993d9c..80343639 100644
--- a/streamer.c
+++ b/streamer.c
@@ -708,7 +708,9 @@ streamer_set_current (playItem_t *it) {
// try to get content-type
mutex_lock (decodemutex);
trace ("\033[0;34mopening file %s\033[37;0m\n", pl_find_meta (it, ":URI"));
+ pl_lock ();
DB_FILE *fp = streamer_file = vfs_fopen (pl_find_meta (it, ":URI"));
+ pl_unlock ();
mutex_unlock (decodemutex);
const char *plug = NULL;
trace ("\033[0;34mgetting content-type\033[37;0m\n");
@@ -877,6 +879,7 @@ m3u_error:
dec = plug_get_decoder_for_id (decoder_id);
if (!dec) {
// find new decoder by file extension
+ pl_lock ();
const char *fname = pl_find_meta (it, ":URI");
const char *ext = strrchr (fname, '.');
if (ext) {
@@ -897,6 +900,7 @@ m3u_error:
}
}
}
+ pl_unlock ();
}
if (dec) {
trace ("\033[0;33minit decoder for %s (%s)\033[37;0m\n", pl_find_meta (it, ":URI"), decoder_id);