aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-04 19:09:34 +0100
committerMax Kellermann <max@duempel.org>2009-01-04 19:09:34 +0100
commitfed719197c7014151710c4aae9174990fd131d59 (patch)
tree0fb6d6f69aa60ecdf9eb89286f8354316fffcc92 /src/decoder
parentea8ae68e6f1a686fd96530fdaf7b428e33f58ec4 (diff)
downloadmpd-fed719197c7014151710c4aae9174990fd131d59.tar.gz
mpd-fed719197c7014151710c4aae9174990fd131d59.tar.xz
mpd-fed719197c7014151710c4aae9174990fd131d59.zip
song: allocate the result of song_get_url()
Diffstat (limited to '')
-rw-r--r--src/decoder/wavpack_plugin.c7
-rw-r--r--src/decoder_api.c5
-rw-r--r--src/decoder_api.h8
-rw-r--r--src/decoder_thread.c7
4 files changed, 15 insertions, 12 deletions
diff --git a/src/decoder/wavpack_plugin.c b/src/decoder/wavpack_plugin.c
index 11b856224..e08ec1dfc 100644
--- a/src/decoder/wavpack_plugin.c
+++ b/src/decoder/wavpack_plugin.c
@@ -455,8 +455,7 @@ static bool
wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc,
struct wavpack_input *wpi)
{
- char tmp[MPD_PATH_MAX];
- const char *utf8url;
+ char *utf8url;
char *wvc_url = NULL;
bool ret;
char first_byte;
@@ -466,12 +465,14 @@ wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc,
* As we use dc->utf8url, this function will be bad for
* single files. utf8url is not absolute file path :/
*/
- utf8url = decoder_get_url(decoder, tmp);
+ utf8url = decoder_get_uri(decoder);
if (utf8url == NULL) {
return false;
}
wvc_url = g_strconcat(utf8url, "c", NULL);
+ g_free(utf8url);
+
ret = input_stream_open(is_wvc, wvc_url);
g_free(wvc_url);
diff --git a/src/decoder_api.c b/src/decoder_api.c
index 1f5db3b72..76bf05754 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -57,10 +57,9 @@ void decoder_initialized(struct decoder * decoder,
notify_signal(&pc.notify);
}
-const char *decoder_get_url(G_GNUC_UNUSED struct decoder * decoder,
- char * buffer)
+char *decoder_get_uri(G_GNUC_UNUSED struct decoder *decoder)
{
- return song_get_url(dc.current_song, buffer);
+ return song_get_uri(dc.current_song);
}
enum decoder_command decoder_get_command(G_GNUC_UNUSED struct decoder * decoder)
diff --git a/src/decoder_api.h b/src/decoder_api.h
index 88705651a..4e24c7b05 100644
--- a/src/decoder_api.h
+++ b/src/decoder_api.h
@@ -108,7 +108,13 @@ void decoder_initialized(struct decoder * decoder,
const struct audio_format *audio_format,
bool seekable, float total_time);
-const char *decoder_get_url(struct decoder * decoder, char * buffer);
+/**
+ * Returns the URI of the current song in UTF-8 encoding.
+ *
+ * The return value is allocated on the heap, and must be freed by the
+ * caller.
+ */
+char *decoder_get_uri(struct decoder *decoder);
enum decoder_command decoder_get_command(struct decoder * decoder);
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 061048d94..a856c1f00 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -208,11 +208,8 @@ static void decoder_run(void)
if (song_is_file(song))
uri = map_song_fs(song);
- else {
- char buffer[MPD_PATH_MAX];
-
- uri = g_strdup(song_get_url(song, buffer));
- }
+ else
+ uri = song_get_uri(song);
if (uri == NULL) {
dc.state = DECODE_STATE_ERROR;