aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/oggflac_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:04 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:04 +0200
commit8d3942e0c3b4108e8968e914da75bf7c6c43f408 (patch)
tree69d7eba9eb5f0273a61698169088e0ee70cdb297 /src/inputPlugins/oggflac_plugin.c
parent180d78a8e631cb4d48ef468709099a8c43d7ef51 (diff)
downloadmpd-8d3942e0c3b4108e8968e914da75bf7c6c43f408.tar.gz
mpd-8d3942e0c3b4108e8968e914da75bf7c6c43f408.tar.xz
mpd-8d3942e0c3b4108e8968e914da75bf7c6c43f408.zip
merged start, stop, seek into DecoderControl.command
Much of the existing code queries all three variables sequentially. Since only one of them can be set at a time, this can be optimized and unified by merging all of them into one enum variable. Later, the "command" checks can be expressed in a "switch" statement.
Diffstat (limited to 'src/inputPlugins/oggflac_plugin.c')
-rw-r--r--src/inputPlugins/oggflac_plugin.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index 7fce1551b..71c45aab8 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -50,14 +50,15 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(const
while (1) {
r = readFromInputStream(data->inStream, (void *)buf, 1, *bytes);
if (r == 0 && !inputStreamAtEOF(data->inStream) &&
- !dc.stop)
+ dc.command != DECODE_COMMAND_STOP)
my_usleep(10000);
else
break;
}
*bytes = r;
- if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop)
+ if (r == 0 && !inputStreamAtEOF(data->inStream) &&
+ dc.command != DECODE_COMMAND_STOP)
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
@@ -194,7 +195,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(const
FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
data->chunk_length = 0;
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
return
FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
@@ -351,7 +352,7 @@ static int oggflac_decode(InputStream * inStream)
OggFLAC__SEEKABLE_STREAM_DECODER_OK) {
break;
}
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
FLAC__uint64 sampleToSeek = dc.seekWhere *
dc.audioFormat.sampleRate + 0.5;
if (OggFLAC__seekable_stream_decoder_seek_absolute
@@ -362,18 +363,18 @@ static int oggflac_decode(InputStream * inStream)
data.position = 0;
} else
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
}
- if (!dc.stop) {
+ if (dc.command != DECODE_COMMAND_STOP) {
oggflacPrintErroredState
(OggFLAC__seekable_stream_decoder_get_state(decoder));
OggFLAC__seekable_stream_decoder_finish(decoder);
}
/* send last little bit */
- if (data.chunk_length > 0 && !dc.stop) {
+ if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) {
flacSendChunk(&data);
ob_flush();
}