aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-02 10:48:55 +0100
committerMax Kellermann <max@duempel.org>2009-01-02 10:48:55 +0100
commitdaf7c3db5aac09a8376f1c8ed499eb17202f77a9 (patch)
treeca912c4ff8c7985431a7e99cb3ea5a9393e09c2a /src/decoder_thread.c
parent72255d580e23405375562160bf05fb55d3248f39 (diff)
downloadmpd-daf7c3db5aac09a8376f1c8ed499eb17202f77a9.tar.gz
mpd-daf7c3db5aac09a8376f1c8ed499eb17202f77a9.tar.xz
mpd-daf7c3db5aac09a8376f1c8ed499eb17202f77a9.zip
mapper: allocate the result of map_directory_child_fs(), map_song_fs()
Don't use fixed stack buffers.
Diffstat (limited to '')
-rw-r--r--src/decoder_thread.c39
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 {