aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_thread.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decoder_thread.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 7308795c3..175f343e0 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -101,11 +101,6 @@ decoder_run_song(struct decoder_control *dc,
struct input_stream input_stream;
const struct decoder_plugin *plugin;
- if (!input_stream_open(&input_stream, uri)) {
- dc->state = DECODE_STATE_ERROR;
- return;
- }
-
decoder.seeking = false;
decoder.song_tag = song->tag != NULL && song_is_file(song)
? tag_dup(song->tag) : NULL;
@@ -118,10 +113,19 @@ decoder_run_song(struct decoder_control *dc,
player_signal();
+ decoder_unlock(dc);
+
+ if (!input_stream_open(&input_stream, uri)) {
+ decoder_lock(dc);
+ dc->state = DECODE_STATE_ERROR;
+ return;
+ }
+
/* wait for the input stream to become ready; its metadata
will be available then */
while (!input_stream.ready) {
+ decoder_lock(dc);
if (dc->command == DECODE_COMMAND_STOP) {
decoder_unlock(dc);
input_stream_close(&input_stream);
@@ -131,6 +135,7 @@ decoder_run_song(struct decoder_control *dc,
}
decoder_unlock(dc);
+
ret = input_stream_buffer(&input_stream);
if (ret < 0) {
input_stream_close(&input_stream);
@@ -138,10 +143,10 @@ decoder_run_song(struct decoder_control *dc,
dc->state = DECODE_STATE_ERROR;
return;
}
-
- decoder_lock(dc);
}
+ decoder_lock(dc);
+
if (dc->command == DECODE_COMMAND_STOP) {
decoder_unlock(dc);
input_stream_close(&input_stream);
@@ -263,9 +268,11 @@ decoder_run_song(struct decoder_control *dc,
static void
decoder_run(struct decoder_control *dc)
{
- struct song *song = dc->next_song;
+ const struct song *song = dc->song;
char *uri;
+ assert(song != NULL);
+
if (song_is_file(song))
uri = map_song_fs(song);
else
@@ -276,7 +283,6 @@ decoder_run(struct decoder_control *dc)
return;
}
- dc->current_song = dc->next_song; /* NEED LOCK */
decoder_run_song(dc, song, uri);
g_free(uri);