aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/oggvorbis_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/oggvorbis_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/oggvorbis_plugin.c')
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index 1722a7ed0..91281b3a2 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -60,7 +60,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
while (1) {
ret = readFromInputStream(data->inStream, ptr, size, nmemb);
if (ret == 0 && !inputStreamAtEOF(data->inStream) &&
- !dc.stop) {
+ dc.command != DECODE_COMMAND_STOP) {
my_usleep(10000);
} else
break;
@@ -74,7 +74,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence)
{
const OggCallbackData *data = (const OggCallbackData *) vdata;
- if (dc.stop)
+ if(dc.command == DECODE_COMMAND_STOP)
return -1;
return seekInputStream(data->inStream, offset, whence);
}
@@ -234,7 +234,7 @@ static int oggvorbis_decode(InputStream * inStream)
callbacks.close_func = ogg_close_cb;
callbacks.tell_func = ogg_tell_cb;
if ((ret = ov_open_callbacks(&data, &vf, NULL, 0, callbacks)) < 0) {
- if (!dc.stop) {
+ if (dc.command != DECODE_COMMAND_STOP) {
switch (ret) {
case OV_EREAD:
errorStr = "read error";
@@ -267,13 +267,13 @@ static int oggvorbis_decode(InputStream * inStream)
dc.audioFormat.bits = 16;
while (1) {
- if (dc.seek) {
+ if (dc.command == DECODE_COMMAND_SEEK) {
if (0 == ov_time_seek_page(&vf, dc.seekWhere)) {
ob_clear();
chunkpos = 0;
} else
dc.seekError = 1;
- dc.seek = 0;
+ dc.command = DECODE_COMMAND_NONE;
decoder_wakeup_player();
}
ret = ov_read(&vf, chunk + chunkpos,
@@ -317,12 +317,12 @@ static int oggvorbis_decode(InputStream * inStream)
dc.audioFormat.sampleRate,
bitRate, replayGainInfo);
chunkpos = 0;
- if (dc.stop)
+ if (dc.command == DECODE_COMMAND_STOP)
break;
}
}
- if (!dc.stop && chunkpos > 0) {
+ if (dc.command != DECODE_COMMAND_STOP && chunkpos > 0) {
ob_send(NULL, inStream->seekable,
chunk, chunkpos,
ov_time_tell(&vf), bitRate,