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
Branches
Tags
No related merge requests found
...@@ -312,6 +312,8 @@ int MediaDecoder::setupFromVideoData() ...@@ -312,6 +312,8 @@ int MediaDecoder::setupFromVideoData()
if (enableAccel_) { if (enableAccel_) {
accel_ = video::makeHardwareAccel(decoderCtx_); accel_ = video::makeHardwareAccel(decoderCtx_);
decoderCtx_->opaque = accel_.get(); decoderCtx_->opaque = accel_.get();
} else {
RING_WARN("Hardware accelerated decoding disabled by user preference");
} }
#endif // RING_ACCEL #endif // RING_ACCEL
...@@ -365,7 +367,7 @@ MediaDecoder::decode(VideoFrame& result) ...@@ -365,7 +367,7 @@ MediaDecoder::decode(VideoFrame& result)
ret = avcodec_send_packet(decoderCtx_, &inpacket); ret = avcodec_send_packet(decoderCtx_, &inpacket);
if (ret < 0) { if (ret < 0) {
#ifdef RING_ACCEL #ifdef RING_ACCEL
if (accel_->hasFailed()) if (accel_ && accel_->hasFailed())
return Status::RestartRequired; return Status::RestartRequired;
#endif #endif
return ret == AVERROR_EOF ? Status::Success : Status::DecodeError; return ret == AVERROR_EOF ? Status::Success : Status::DecodeError;
...@@ -373,7 +375,7 @@ MediaDecoder::decode(VideoFrame& result) ...@@ -373,7 +375,7 @@ MediaDecoder::decode(VideoFrame& result)
ret = avcodec_receive_frame(decoderCtx_, frame); ret = avcodec_receive_frame(decoderCtx_, frame);
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
#ifdef RING_ACCEL #ifdef RING_ACCEL
if (accel_->hasFailed()) if (accel_ && accel_->hasFailed())
return Status::RestartRequired; return Status::RestartRequired;
#endif #endif
return Status::DecodeError; return Status::DecodeError;
...@@ -385,7 +387,7 @@ MediaDecoder::decode(VideoFrame& result) ...@@ -385,7 +387,7 @@ MediaDecoder::decode(VideoFrame& result)
&frameFinished, &inpacket); &frameFinished, &inpacket);
if (ret <= 0) { if (ret <= 0) {
#ifdef RING_ACCEL #ifdef RING_ACCEL
if (accel_->hasFailed()) if (accel_ && accel_->hasFailed())
return Status::RestartRequired; return Status::RestartRequired;
#endif #endif
return Status::DecodeError; return Status::DecodeError;
......
...@@ -225,7 +225,7 @@ makeHardwareAccel(AVCodecContext* codecCtx) ...@@ -225,7 +225,7 @@ makeHardwareAccel(AVCodecContext* codecCtx)
codecCtx->get_buffer2 = allocateBufferCb; codecCtx->get_buffer2 = allocateBufferCb;
codecCtx->thread_safe_callbacks = 1; codecCtx->thread_safe_callbacks = 1;
codecCtx->thread_count = 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; return accel;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment