From daf7c3db5aac09a8376f1c8ed499eb17202f77a9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 2 Jan 2009 10:48:55 +0100 Subject: mapper: allocate the result of map_directory_child_fs(), map_song_fs() Don't use fixed stack buffers. --- src/decoder_thread.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src/decoder_thread.c') 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 { -- cgit v1.2.3