added flag "decoder.seeking"

This flag is used internally; it is set by decoder_seek_where(), and
indicates that the decoder plugin has begun the seek process.  It is
used for the case that the decoder plugin has to read data during the
seek process.  Before this patch, that was impossible, because
decoder_read() would refuse to read data unless dc->command is NONE.
This patch is kind of a dirty workaround, and needs to be redesigned
later.
This commit is contained in:
Max Kellermann 2008-08-26 08:27:14 +02:00
parent cf139dc012
commit 1c196478b6
3 changed files with 12 additions and 1 deletions

View File

@ -50,6 +50,8 @@ static void decodeStart(void)
goto stop_no_close; goto stop_no_close;
} }
decoder.seeking = 0;
dc.state = DECODE_STATE_START; dc.state = DECODE_STATE_START;
dc.command = DECODE_COMMAND_NONE; dc.command = DECODE_COMMAND_NONE;

View File

@ -69,6 +69,8 @@ enum decoder_command decoder_get_command(mpd_unused struct decoder * decoder)
void decoder_command_finished(mpd_unused struct decoder * decoder) void decoder_command_finished(mpd_unused struct decoder * decoder)
{ {
assert(dc.command != DECODE_COMMAND_NONE); assert(dc.command != DECODE_COMMAND_NONE);
assert(dc.command != DECODE_COMMAND_SEEK ||
dc.seekError || decoder->seeking);
dc.command = DECODE_COMMAND_NONE; dc.command = DECODE_COMMAND_NONE;
notify_signal(&pc.notify); notify_signal(&pc.notify);
@ -78,6 +80,8 @@ double decoder_seek_where(mpd_unused struct decoder * decoder)
{ {
assert(dc.command == DECODE_COMMAND_SEEK); assert(dc.command == DECODE_COMMAND_SEEK);
decoder->seeking = 1;
return dc.seekWhere; return dc.seekWhere;
} }
@ -100,7 +104,10 @@ size_t decoder_read(struct decoder *decoder,
while (1) { while (1) {
/* XXX don't allow decoder==NULL */ /* XXX don't allow decoder==NULL */
if (decoder != NULL && dc.command != DECODE_COMMAND_NONE) if (decoder != NULL &&
(dc.command != DECODE_COMMAND_SEEK ||
!decoder->seeking) &&
dc.command != DECODE_COMMAND_NONE)
return 0; return 0;
nbytes = readFromInputStream(inStream, buffer, 1, length); nbytes = readFromInputStream(inStream, buffer, 1, length);

View File

@ -26,6 +26,8 @@ struct decoder {
struct decoder_plugin *plugin; struct decoder_plugin *plugin;
ConvState conv_state; ConvState conv_state;
int seeking;
}; };
#endif #endif