diff options
Diffstat (limited to 'src/decoder_thread.c')
-rw-r--r-- | src/decoder_thread.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/decoder_thread.c b/src/decoder_thread.c index de82cb6d3..35d6e3206 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -74,27 +74,14 @@ decoder_file_decode(const struct decoder_plugin *plugin, return dc.state != DECODE_STATE_START; } -static void decoder_run(void) +static void decoder_run_song(const struct song *song, const char *uri) { - struct song *song = dc.next_song; - char buffer[MPD_PATH_MAX]; - const char *uri; struct decoder decoder; int ret; bool close_instream = true; struct input_stream input_stream; const struct decoder_plugin *plugin; - if (song_is_file(song)) - uri = map_song_fs(song, buffer); - else - uri = song_get_url(song, buffer); - if (uri == NULL) { - dc.state = DECODE_STATE_ERROR; - return; - } - - dc.current_song = dc.next_song; /* NEED LOCK */ if (!input_stream_open(&input_stream, uri)) { dc.state = DECODE_STATE_ERROR; return; @@ -202,6 +189,30 @@ static void decoder_run(void) dc.state = ret ? DECODE_STATE_STOP : DECODE_STATE_ERROR; } +static void decoder_run(void) +{ + struct song *song = dc.next_song; + char *uri; + + if (song_is_file(song)) + uri = map_song_fs(song); + else { + char buffer[MPD_PATH_MAX]; + + uri = g_strdup(song_get_url(song, buffer)); + } + + if (uri == NULL) { + dc.state = DECODE_STATE_ERROR; + return; + } + + dc.current_song = dc.next_song; /* NEED LOCK */ + decoder_run_song(song, uri); + g_free(uri); + +} + static gpointer decoder_task(G_GNUC_UNUSED gpointer arg) { do { |