diff options
author | Max Kellermann <max@duempel.org> | 2011-09-16 08:04:02 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-09-16 09:15:10 +0200 |
commit | 9ea8a840a9f9a42437d74bf0e0c267c84ff40f8b (patch) | |
tree | 4409a0090c0775ecf7236fbe19ef63bc4d1bdf62 /src | |
parent | 7b88089593b92e064316bbde960f28978f74e869 (diff) | |
download | mpd-9ea8a840a9f9a42437d74bf0e0c267c84ff40f8b.tar.gz mpd-9ea8a840a9f9a42437d74bf0e0c267c84ff40f8b.tar.xz mpd-9ea8a840a9f9a42437d74bf0e0c267c84ff40f8b.zip |
decoder_api: remove the loop from decoder_read()
This was useless, because input_stream_read() blocks until data is
available. Calling it in a loop doesn't make sense.
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder_api.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c index cb1052f5c..20e976e69 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -183,25 +183,19 @@ size_t decoder_read(struct decoder *decoder, if (length == 0) return 0; - while (true) { - if (decoder_check_cancel_read(decoder)) - return 0; - - nbytes = input_stream_read(is, buffer, length, &error); - - if (G_UNLIKELY(nbytes == 0 && error != NULL)) { - g_warning("%s", error->message); - g_error_free(error); - return 0; - } + if (decoder_check_cancel_read(decoder)) + return 0; - if (nbytes > 0 || input_stream_eof(is)) - return nbytes; + nbytes = input_stream_read(is, buffer, length, &error); + assert(nbytes == 0 || error == NULL); + assert(nbytes > 0 || error != NULL || input_stream_eof(is)); - /* sleep for a fraction of a second! */ - /* XXX don't sleep, wait for an event instead */ - g_usleep(10000); + if (G_UNLIKELY(nbytes == 0 && error != NULL)) { + g_warning("%s", error->message); + g_error_free(error); } + + return nbytes; } void |