Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/ui/Logic/VideoPlayers/Ffmpeg/FfmpegPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ private void VideoLoop()
var swsSourceFormat = AVPixelFormat.AV_PIX_FMT_NONE;
var outputWidth = 0;
var outputHeight = 0;
VideoFrame? lastDropped = null; // detached from the queue while seeking; must be returned on every exit

try
{
Expand All @@ -886,7 +887,6 @@ private void VideoLoop()
var serial = -1;
var dropUntil = -1.0;
var presentedForSerial = false;
VideoFrame? lastDropped = null; // kept so a target past the last picture still shows something

while (!_closing)
{
Expand Down Expand Up @@ -919,6 +919,7 @@ private void VideoLoop()
// The hardware decoder rejected the stream - retry it in software.
codec = FallBackToSoftware(codec, stream, sendResult, ref hardware);
serial = -1;
Seek(Position);
}

continue;
Expand Down Expand Up @@ -1058,6 +1059,8 @@ private void VideoLoop()
}
finally
{
_videoFrames.Return(lastDropped);

if (sws != null)
{
ffmpeg.sws_freeContext(sws);
Expand Down Expand Up @@ -1287,6 +1290,14 @@ private static bool SupportsHardwareDevice(AVCodec* decoder, AVHWDeviceType devi
result = ffmpeg.avcodec_open2(codec, decoder, null);
if (result < 0)
{
if (hardware && codec->hw_device_ctx != null)
{
var deviceName = HardwareDeviceName(codec);
Se.LogError($"ffmpeg player: {deviceName} decoder open failed for {ffmpeg.avcodec_get_name(stream->codecpar->codec_id)} ({FfmpegLibraries.ErrorText(result)}), falling back to software decoding");
ffmpeg.avcodec_free_context(&codec);
return OpenDecoder(stream, hardware: false);
}

ffmpeg.avcodec_free_context(&codec);
throw new InvalidOperationException($"avcodec_open2: {FfmpegLibraries.ErrorText(result)}");
}
Expand Down
Loading