summaryrefslogtreecommitdiff
path: root/src/decoder/DecoderAPI.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder/DecoderAPI.cxx')
-rw-r--r--src/decoder/DecoderAPI.cxx41
1 files changed, 7 insertions, 34 deletions
diff --git a/src/decoder/DecoderAPI.cxx b/src/decoder/DecoderAPI.cxx
index 6258b2a0a..1091690ce 100644
--- a/src/decoder/DecoderAPI.cxx
+++ b/src/decoder/DecoderAPI.cxx
@@ -19,8 +19,6 @@
#include "config.h"
#include "DecoderAPI.hxx"
-#include "DecoderControl.hxx"
-#include "Bridge.hxx"
#include "input/InputStream.hxx"
#include "Log.hxx"
@@ -30,44 +28,19 @@ size_t
decoder_read(DecoderClient *client,
InputStream &is,
void *buffer, size_t length)
-try {
+{
assert(buffer != nullptr);
/* XXX don't allow client==nullptr */
- if (client == nullptr)
- return is.LockRead(buffer, length);
-
- auto &bridge = *(DecoderBridge *)client;
-
- assert(bridge.dc.state == DecoderState::START ||
- bridge.dc.state == DecoderState::DECODE);
+ if (client != nullptr)
+ return client->Read(is, buffer, length);
- if (length == 0)
+ try {
+ return is.LockRead(buffer, length);
+ } catch (const std::runtime_error &e) {
+ LogError(e);
return 0;
-
- ScopeLock lock(is.mutex);
-
- while (true) {
- if (bridge.CheckCancelRead())
- return 0;
-
- if (is.IsAvailable())
- break;
-
- is.cond.wait(is.mutex);
}
-
- size_t nbytes = is.Read(buffer, length);
- assert(nbytes > 0 || is.IsEOF());
-
- return nbytes;
-} catch (const std::runtime_error &e) {
- auto *bridge = (DecoderBridge *)client;
- if (bridge != nullptr)
- bridge->error = std::current_exception();
- else
- LogError(e);
- return 0;
}
bool