summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 65d693e264..09d3bad3a1 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -579,7 +579,7 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track)
// Add the given file as additional track. The filter argument controls how or
// if tracks are auto-selected at any point.
int mp_add_external_file(struct MPContext *mpctx, char *filename,
- enum stream_type filter)
+ enum stream_type filter, bool unlock)
{
struct MPOpts *opts = mpctx->opts;
if (!filename)
@@ -600,11 +600,19 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
break;
}
+ if (unlock)
+ mp_core_unlock(mpctx);
+
struct demuxer *demuxer =
demux_open_url(filename, &params, mpctx->playback_abort, mpctx->global);
+ if (demuxer)
+ enable_demux_thread(mpctx, demuxer);
+
+ if (unlock)
+ mp_core_lock(mpctx);
+
if (!demuxer)
goto err_out;
- enable_demux_thread(mpctx, demuxer);
if (opts->rebase_start_time)
demux_set_ts_offset(demuxer, -demuxer->start_time);
@@ -619,7 +627,11 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
}
if (!has_any) {
+ if (unlock)
+ mp_core_unlock(mpctx);
free_demuxer_and_stream(demuxer);
+ if (unlock)
+ mp_core_lock(mpctx);
char *tname = mp_tprintf(20, "%s ", stream_type_name(filter));
if (filter == STREAM_TYPE_COUNT)
tname = "";
@@ -652,7 +664,7 @@ static void open_external_files(struct MPContext *mpctx, char **files,
enum stream_type filter)
{
for (int n = 0; files && files[n]; n++)
- mp_add_external_file(mpctx, files[n], filter);
+ mp_add_external_file(mpctx, files[n], filter, false);
}
void autoload_external_files(struct MPContext *mpctx)
@@ -691,7 +703,7 @@ void autoload_external_files(struct MPContext *mpctx)
goto skip;
if (list[i].type == STREAM_AUDIO && !sc[STREAM_VIDEO])
goto skip;
- int first = mp_add_external_file(mpctx, filename, list[i].type);
+ int first = mp_add_external_file(mpctx, filename, list[i].type, false);
if (first < 0)
goto skip;