From bed7763a3b57f091abbd5c09bc76426734ec7165 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Mon, 8 Jan 2024 22:08:16 +0100 Subject: [PATCH] audio_decoder: ignore first invalid data error --- rpcs3/util/media_utils.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rpcs3/util/media_utils.cpp b/rpcs3/util/media_utils.cpp index 332b13555f..6a336bdd22 100644 --- a/rpcs3/util/media_utils.cpp +++ b/rpcs3/util/media_utils.cpp @@ -22,6 +22,7 @@ extern "C" { #include "libswresample/swresample.h" } constexpr int averror_eof = AVERROR_EOF; // workaround for old-style-cast error +constexpr int averror_invalid_data = AVERROR_INVALIDDATA; // workaround for old-style-cast error #ifdef _MSC_VER #pragma warning(pop) #else @@ -595,6 +596,18 @@ namespace utils { if (int err = avcodec_send_packet(av.audio.context, packet); err < 0) { + if (is_first_error) + { + is_first_error = false; + + if (err == averror_invalid_data) + { + // Some mp3s contain some invalid data at the beginning of the stream. They work fine if we just ignore them. + // So let's skip the first invalid data error. Maybe there is a better way, but let's just roll with it for now. + media_log.warning("audio_decoder: Ignoring first error: %d='%s'", err, av_error_to_string(err)); + continue; + } + } media_log.error("audio_decoder: Queuing error: %d='%s'", err, av_error_to_string(err)); has_error = true; return;