Skip to content

Commit e817792

Browse files
committed
[APU] Fix ffmpeg upgrade related logspam
1 parent 0da4752 commit e817792

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

src/xenia/apu/xma_context_master.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern "C" {
2626
#endif
2727
#include "third_party/FFmpeg/libavcodec/avcodec.h"
2828
#include "third_party/FFmpeg/libavutil/channel_layout.h"
29+
#include "third_party/FFmpeg/libavutil/error.h"
2930
#if XE_COMPILER_MSVC
3031
#pragma warning(pop)
3132
#endif
@@ -566,16 +567,15 @@ void XmaContextMaster::Decode(XMA_CONTEXT_DATA* data) {
566567
assert_always();
567568
}
568569
ret = avcodec_receive_frame(av_context_, av_frame_);
569-
/*
570-
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
571-
// TODO AVERROR_EOF???
572-
break;
573-
else
574-
*/
570+
if (ret == AVERROR(EAGAIN)) {
571+
return;
572+
}
575573
if (ret < 0) {
576-
XELOGE("XmaContext {}: Error during decoding", id());
577-
assert_always();
578-
return; // TODO bail out
574+
char errbuf[AV_ERROR_MAX_STRING_SIZE];
575+
av_strerror(ret, errbuf, sizeof(errbuf));
576+
XELOGE("XmaContext {}: Error during decoding: {} ({})", id(), errbuf,
577+
ret);
578+
return;
579579
}
580580
assert_true(ret == 0);
581581

@@ -820,6 +820,7 @@ int XmaContextMaster::PrepareDecoder(uint8_t* packet, int sample_rate,
820820

821821
av_context_->sample_rate = sample_rate;
822822
av_channel_layout_default(&av_context_->ch_layout, channels);
823+
av_context_->flags2 |= AV_CODEC_FLAG2_SKIP_MANUAL;
823824

824825
if (avcodec_open2(av_context_, av_codec_, NULL) < 0) {
825826
XELOGE("XmaContext: Failed to reopen FFmpeg context");

src/xenia/apu/xma_context_new.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern "C" {
2121
#endif
2222
#include "third_party/FFmpeg/libavcodec/avcodec.h"
2323
#include "third_party/FFmpeg/libavutil/channel_layout.h"
24+
#include "third_party/FFmpeg/libavutil/error.h"
2425
#if XE_COMPILER_MSVC
2526
#pragma warning(pop)
2627
#endif
@@ -689,6 +690,7 @@ int XmaContextNew::PrepareDecoder(int sample_rate, bool is_two_channel) {
689690

690691
av_context_->sample_rate = sample_rate;
691692
av_channel_layout_default(&av_context_->ch_layout, channels);
693+
av_context_->flags2 |= AV_CODEC_FLAG2_SKIP_MANUAL;
692694

693695
if (avcodec_open2(av_context_, av_codec_, NULL) < 0) {
694696
XELOGE("XmaContext: Failed to reopen FFmpeg context");
@@ -715,13 +717,22 @@ bool XmaContextNew::DecodePacket(AVCodecContext* av_context,
715717
const AVPacket* av_packet, AVFrame* av_frame) {
716718
auto ret = avcodec_send_packet(av_context, av_packet);
717719
if (ret < 0) {
718-
XELOGE("XmaContext {}: Error sending packet for decoding", id());
720+
char errbuf[AV_ERROR_MAX_STRING_SIZE];
721+
av_strerror(ret, errbuf, sizeof(errbuf));
722+
XELOGE("XmaContext {}: Error sending packet for decoding: {} ({})", id(),
723+
errbuf, ret);
719724
return false;
720725
}
721726
ret = avcodec_receive_frame(av_context, av_frame);
722727

728+
if (ret == AVERROR(EAGAIN)) {
729+
// Codec needs more input before producing output (e.g. first frame warmup).
730+
return false;
731+
}
723732
if (ret < 0) {
724-
XELOGE("XmaContext {}: Error during decoding", id());
733+
char errbuf[AV_ERROR_MAX_STRING_SIZE];
734+
av_strerror(ret, errbuf, sizeof(errbuf));
735+
XELOGE("XmaContext {}: Error during decoding: {} ({})", id(), errbuf, ret);
725736
return false;
726737
}
727738
return true;

src/xenia/apu/xma_context_old.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern "C" {
2626
#endif
2727
#include "third_party/FFmpeg/libavcodec/avcodec.h"
2828
#include "third_party/FFmpeg/libavutil/channel_layout.h"
29+
#include "third_party/FFmpeg/libavutil/error.h"
2930
#if XE_COMPILER_MSVC
3031
#pragma warning(pop)
3132
#endif
@@ -624,19 +625,17 @@ void XmaContextOld::Decode(XMA_CONTEXT_DATA* data) {
624625
assert_always();
625626
}
626627
ret = avcodec_receive_frame(av_context_, av_frame_);
627-
/*
628-
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
629-
// TODO AVERROR_EOF???
630-
break;
631-
else
632-
*/
628+
if (ret == AVERROR(EAGAIN)) {
629+
return;
630+
}
633631
if (ret < 0) {
634-
XELOGE("XmaContext {}: Error - Decoding failed", id());
635-
data->parser_error_status = 4; // TODO(Gliniak): Find all parsing errors
636-
// and create enumerator from them
632+
char errbuf[AV_ERROR_MAX_STRING_SIZE];
633+
av_strerror(ret, errbuf, sizeof(errbuf));
634+
XELOGE("XmaContext {}: Error - Decoding failed: {} ({})", id(), errbuf,
635+
ret);
636+
data->parser_error_status = 4;
637637
SwapInputBuffer(data);
638-
assert_always();
639-
return; // TODO bail out
638+
return;
640639
}
641640
assert_true(ret == 0);
642641

@@ -924,6 +923,7 @@ int XmaContextOld::PrepareDecoder(uint8_t* packet, int sample_rate,
924923

925924
av_context_->sample_rate = sample_rate;
926925
av_channel_layout_default(&av_context_->ch_layout, channels);
926+
av_context_->flags2 |= AV_CODEC_FLAG2_SKIP_MANUAL;
927927

928928
if (avcodec_open2(av_context_, av_codec_, NULL) < 0) {
929929
XELOGE("XmaContext: Failed to reopen FFmpeg context");

0 commit comments

Comments
 (0)