aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-01-01 10:09:56 +0000
committerEric Wong <normalperson@yhbt.net>2008-01-01 10:09:56 +0000
commit2cc59816a6e6304e643bc5c7ca055dd2567cba9e (patch)
tree2686ddfc3b7e98feb8a47e6f64c3658c15b92f0b /src/decode.c
parent5e7367c580f3a7aca93f6523e6c9d37f81b1d48b (diff)
downloadmpd-2cc59816a6e6304e643bc5c7ca055dd2567cba9e.tar.gz
mpd-2cc59816a6e6304e643bc5c7ca055dd2567cba9e.tar.xz
mpd-2cc59816a6e6304e643bc5c7ca055dd2567cba9e.zip
Simplify decode cleanup logic a bit
DECODE_STATE_STOP is always set as dc->state, and dc->stop is always cleared. So handle it in decodeStart once rather than doing it in every plugin. While we're at it, fix a long-standing (but difficult to trigger) bug in mpc_decode where we failed to return if mpc_decoder_initialize() fails. git-svn-id: https://svn.musicpd.org/mpd/trunk@7122 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/decode.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/src/decode.c b/src/decode.c
index 79504dc94..76bb1bede 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -278,6 +278,7 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
DecoderControl * dc)
{
int ret;
+ int close_instream = 1;
InputStream inStream;
InputPlugin *plugin = NULL;
char path_max_tmp[MPD_PATH_MAX];
@@ -286,9 +287,7 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
if (isRemoteUrl(pc->utf8url)) {
if (!utf8_to_latin1(path_max_tmp, pc->utf8url)) {
dc->error = DECODE_ERROR_FILE;
- dc->state = DECODE_STATE_STOP;
- dc->start = 0;
- return;
+ goto stop_no_close;
}
} else
rmp2amp_r(path_max_tmp,
@@ -300,9 +299,7 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
if (openInputStream(&inStream, path_max_tmp) < 0) {
dc->error = DECODE_ERROR_FILE;
- dc->state = DECODE_STATE_STOP;
- dc->start = 0;
- return;
+ goto stop_no_close;
}
dc->state = DECODE_STATE_START;
@@ -317,20 +314,8 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
/* for http streams, seekable is determined in bufferInputStream */
dc->seekable = inStream.seekable;
- if (dc->stop) {
- dc->state = DECODE_STATE_STOP;
- dc->stop = 0;
- return;
- }
-
- /*if(inStream.metaName) {
- MpdTag * tag = newMpdTag();
- tag->name = xstrdup(inStream.metaName);
- copyMpdTagToOutputBuffer(cb, tag);
- freeMpdTag(tag);
- } */
-
- /* reset Metadata in OutputBuffer */
+ if (dc->stop)
+ goto stop;
ret = DECODE_ERROR_UNKTYPE;
if (isRemoteUrl(dc->utf8url)) {
@@ -390,6 +375,7 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
if (plugin->fileDecodeFunc) {
closeInputStream(&inStream);
+ close_instream = 0;
ret = plugin->fileDecodeFunc(cb, dc,
path_max_tmp);
break;
@@ -402,15 +388,18 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
if (ret < 0 || ret == DECODE_ERROR_UNKTYPE) {
pathcpy_trunc(pc->erroredUrl, dc->utf8url);
- if (ret != DECODE_ERROR_UNKTYPE) {
+ if (ret != DECODE_ERROR_UNKTYPE)
dc->error = DECODE_ERROR_FILE;
- } else {
+ else
dc->error = DECODE_ERROR_UNKTYPE;
- closeInputStream(&inStream);
- }
- dc->stop = 0;
- dc->state = DECODE_STATE_STOP;
}
+
+stop:
+ if (close_instream)
+ closeInputStream(&inStream);
+stop_no_close:
+ dc->state = DECODE_STATE_STOP;
+ dc->stop = 0;
}
static int decoderInit(PlayerControl * pc, OutputBuffer * cb,