summaryrefslogtreecommitdiff
path: root/src/decoder/Bridge.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder/Bridge.cxx')
-rw-r--r--src/decoder/Bridge.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx
index 314c067bf..25f169d41 100644
--- a/src/decoder/Bridge.cxx
+++ b/src/decoder/Bridge.cxx
@@ -401,6 +401,37 @@ DecoderBridge::OpenUri(const char *uri)
}
}
+size_t
+DecoderBridge::Read(InputStream &is, void *buffer, size_t length)
+try {
+ assert(buffer != nullptr);
+ assert(dc.state == DecoderState::START ||
+ dc.state == DecoderState::DECODE);
+
+ if (length == 0)
+ return 0;
+
+ ScopeLock lock(is.mutex);
+
+ while (true) {
+ if (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) {
+ error = std::current_exception();
+ return 0;
+}
+
void
DecoderBridge::SubmitTimestamp(double t)
{