Commit 5e3a394a authored by Philippe Gorley's avatar Philippe Gorley Committed by Guillaume Roguez

video_input: fallback to software decoding

Handles RestartRequired return code on hardware acceleration failure.

Change-Id: I170928e23ed607c2255e20729a71adc1364bbb6a
Reviewed-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 664ea5fa
......@@ -453,6 +453,19 @@ MediaDecoder::decode(const AudioFrame& decodedFrame)
}
#ifdef RING_VIDEO
#ifdef RING_ACCEL
void
MediaDecoder::enableAccel(bool enableAccel)
{
enableAccel_ = enableAccel;
if (!enableAccel) {
accel_.reset();
if (decoderCtx_)
decoderCtx_->opaque = nullptr;
}
}
#endif
MediaDecoder::Status
MediaDecoder::flush(VideoFrame& result)
{
......
......@@ -95,7 +95,7 @@ class MediaDecoder {
void setOptions(const std::map<std::string, std::string>& options);
#ifdef RING_ACCEL
void enableAccel(const bool enableAccel) { enableAccel_ = enableAccel; }
void enableAccel(bool enableAccel);
#endif
private:
......
......@@ -207,7 +207,6 @@ bool VideoInput::captureFrame()
return false;
const auto ret = decoder_->decode(getNewFrame());
switch (ret) {
case MediaDecoder::Status::ReadError:
return false;
......@@ -216,6 +215,14 @@ bool VideoInput::captureFrame()
case MediaDecoder::Status::DecodeError:
return true;
case MediaDecoder::Status::RestartRequired:
createDecoder();
#ifdef RING_ACCEL
RING_WARN("Disabling hardware decoding due to previous failure");
decoder_->enableAccel(false);
#endif
return static_cast<bool>(decoder_);
// End of streamed file
case MediaDecoder::Status::EOFError:
createDecoder();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment