Skip to content
Snippets Groups Projects
Commit ed931f6a authored by Philippe Gorley's avatar Philippe Gorley Committed by Philippe Gorley
Browse files

video: fix accel when setting is disabled


If Ring was compiled with acceleration, but is disabled in dring.yml,
the call would crash. This checks if the accel_ object isn't null
before checking if it has failed.

Change-Id: I098f573bd17271824fcfbdb60d783af085ef19be
Reviewed-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent eaa9fbb5
No related branches found
No related tags found
No related merge requests found
......@@ -312,6 +312,8 @@ int MediaDecoder::setupFromVideoData()
if (enableAccel_) {
accel_ = video::makeHardwareAccel(decoderCtx_);
decoderCtx_->opaque = accel_.get();
} else {
RING_WARN("Hardware accelerated decoding disabled by user preference");
}
#endif // RING_ACCEL
......@@ -365,7 +367,7 @@ MediaDecoder::decode(VideoFrame& result)
ret = avcodec_send_packet(decoderCtx_, &inpacket);
if (ret < 0) {
#ifdef RING_ACCEL
if (accel_->hasFailed())
if (accel_ && accel_->hasFailed())
return Status::RestartRequired;
#endif
return ret == AVERROR_EOF ? Status::Success : Status::DecodeError;
......@@ -373,7 +375,7 @@ MediaDecoder::decode(VideoFrame& result)
ret = avcodec_receive_frame(decoderCtx_, frame);
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
#ifdef RING_ACCEL
if (accel_->hasFailed())
if (accel_ && accel_->hasFailed())
return Status::RestartRequired;
#endif
return Status::DecodeError;
......@@ -385,7 +387,7 @@ MediaDecoder::decode(VideoFrame& result)
&frameFinished, &inpacket);
if (ret <= 0) {
#ifdef RING_ACCEL
if (accel_->hasFailed())
if (accel_ && accel_->hasFailed())
return Status::RestartRequired;
#endif
return Status::DecodeError;
......
......@@ -225,7 +225,7 @@ makeHardwareAccel(AVCodecContext* codecCtx)
codecCtx->get_buffer2 = allocateBufferCb;
codecCtx->thread_safe_callbacks = 1;
codecCtx->thread_count = 1;
RING_DBG("Succesfully set up '%s' acceleration", accel->name().c_str());
RING_DBG("Attempting to use '%s' hardware acceleration", accel->name().c_str());
return accel;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment