mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-12-30 13:51:31 +01:00
47 lines
1.6 KiB
Diff
47 lines
1.6 KiB
Diff
From c5cdb0c27797281dfde72761baf2cc6554a86189 Mon Sep 17 00:00:00 2001
|
|
From: Dominique Martinet <asmadeus@codewreck.org>
|
|
Date: Sat, 28 May 2022 13:43:37 +0900
|
|
Subject: [PATCH] ffmpeg_decoder: signal EOF/errors on readPacket
|
|
|
|
openmw with ffmpeg 5 would hang in an infinite loop trying to read at end of
|
|
files in avformat_open_input()
|
|
avio_read() apparently now no longer handlers 0 as a return value to signal
|
|
EOF and we need ot explicitly return AVERROR_EOF; their documentation
|
|
explicitely states "For stream protocols, must never return 0 but rather
|
|
a proper AVERROR code." for avio_alloc_context's read_context.
|
|
|
|
Also fix the exception case to return AVERROR_UNKNOWN -- I assume we'd
|
|
otherwise get stuck there too, but I don't know what would trigger this
|
|
case.
|
|
|
|
Fixes #6631
|
|
---
|
|
CHANGELOG.md | 1 +
|
|
apps/openmw/mwsound/ffmpeg_decoder.cpp | 7 +++++--
|
|
2 files changed, 6 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp
|
|
index 0a9641635f..997b4e30c6 100644
|
|
--- a/apps/openmw/mwsound/ffmpeg_decoder.cpp
|
|
+++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp
|
|
@@ -18,11 +18,14 @@ int FFmpeg_Decoder::readPacket(void *user_data, uint8_t *buf, int buf_size)
|
|
std::istream& stream = *static_cast<FFmpeg_Decoder*>(user_data)->mDataStream;
|
|
stream.clear();
|
|
stream.read((char*)buf, buf_size);
|
|
- return stream.gcount();
|
|
+ std::streamsize count = stream.gcount();
|
|
+ if (count == 0)
|
|
+ return AVERROR_EOF;
|
|
+ return count;
|
|
}
|
|
catch (std::exception& )
|
|
{
|
|
- return 0;
|
|
+ return AVERROR_UNKNOWN;
|
|
}
|
|
}
|
|
|
|
--
|
|
GitLab
|
|
|