diff options
author | Max Kellermann <max@duempel.org> | 2011-10-06 00:25:44 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-10-06 00:35:53 +0200 |
commit | e07073ff286ed22d4859aba3584285586c7781c8 (patch) | |
tree | 0421c073920b052b73bdf20be0e2d092d04796ef /src | |
parent | 64b0ba6da7975fdde774f188b1647ab6c9024cfa (diff) | |
download | mpd-e07073ff286ed22d4859aba3584285586c7781c8.tar.gz mpd-e07073ff286ed22d4859aba3584285586c7781c8.tar.xz mpd-e07073ff286ed22d4859aba3584285586c7781c8.zip |
decoder_api: move code to _prepare_initial_seek()
.. and add a few code comments.
Diffstat (limited to '')
-rw-r--r-- | src/decoder_api.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c index bec271179..3e4917508 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -79,30 +79,54 @@ decoder_initialized(struct decoder *decoder, } /** - * Returns the current decoder command. May return a "virtual" - * synthesized command, e.g. to seek to the beginning of the CUE - * track. + * Checks if we need an "initial seek". If so, then the initial seek + * is prepared, and the function returns true. */ G_GNUC_PURE -static enum decoder_command -decoder_get_virtual_command(struct decoder *decoder) +static bool +decoder_prepare_initial_seek(struct decoder *decoder) { const struct decoder_control *dc = decoder->dc; assert(dc->pipe != NULL); if (decoder->initial_seek_running) - return DECODE_COMMAND_SEEK; + /* initial seek has already begun - override any other + command */ + return true; if (decoder->initial_seek_pending) { if (dc->command == DECODE_COMMAND_NONE) { + /* begin initial seek */ + decoder->initial_seek_pending = false; decoder->initial_seek_running = true; - return DECODE_COMMAND_SEEK; + return true; } + /* skip initial seek when there's another command + (e.g. STOP) */ + decoder->initial_seek_pending = false; } + return false; +} + +/** + * Returns the current decoder command. May return a "virtual" + * synthesized command, e.g. to seek to the beginning of the CUE + * track. + */ +G_GNUC_PURE +static enum decoder_command +decoder_get_virtual_command(struct decoder *decoder) +{ + const struct decoder_control *dc = decoder->dc; + assert(dc->pipe != NULL); + + if (decoder_prepare_initial_seek(decoder)) + return DECODE_COMMAND_SEEK; + return dc->command; } |