diff --git a/CMakeLists.txt b/CMakeLists.txt index bcae371ba..cbfbcb9dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,6 @@ if (${FFMPEG_DECODER} MATCHES "false") add_dependencies(musikcube m4adecoder oggdecoder nomaddecoder flacdecoder) else() message(STATUS "[ffmpeg] decoder enabled = true") - add_definitions(-DFFMPEG_DECODER) add_subdirectory(src/plugins/ffmpegdecoder) add_dependencies(musikcube ffmpegdecoder) endif() diff --git a/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp b/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp index 89e0efef5..196219e19 100644 --- a/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp +++ b/src/plugins/ffmpegdecoder/FfmpegDecoder.cpp @@ -35,6 +35,7 @@ #include "FfmpegDecoder.h" #include #include +#include #ifdef WIN32 #define DLLEXPORT __declspec(dllexport) @@ -144,7 +145,9 @@ bool FfmpegDecoder::GetBuffer(IBuffer *buffer) { buffer->SetChannels((long) this->channels); buffer->SetSamples(0); - if (!av_read_frame(this->formatContext, &this->packet)) { + int readFrameResult = av_read_frame(this->formatContext, &this->packet); + + if (!readFrameResult) { int frameDecoded = 0; avcodec_decode_audio4( @@ -196,13 +199,23 @@ bool FfmpegDecoder::GetBuffer(IBuffer *buffer) { buffer->SetSamples(convertedSamplesPerChannel * this->channels); } } + else { + ::debug->Warning(TAG, "avcodec_decode_audio4() failed"); + } av_frame_unref(this->decodedFrame); return true; } + else { + std::string err = + "av_read_frame() failed: " + + std::string(av_err2str(readFrameResult)); + + ::debug->Warning(TAG, err.c_str()); + } } - ::debug->Warning(TAG, "finished decoding."); + ::debug->Info(TAG, "finished decoding."); this->exhausted = true; return false; } @@ -287,7 +300,11 @@ bool FfmpegDecoder::Open(musik::core::sdk::IDataStream *stream) { if (avcodec_open2(codecContext, codec, nullptr) < 0) { goto reset_and_fail; } - ::debug->Info(TAG, "resolved a codec!"); + std::string codecName = + std::string("resolved codec: ") + + std::string(codec->long_name); + + ::debug->Info(TAG, codecName.c_str()); } else { ::debug->Error(TAG, "couldn't find a codec."); diff --git a/src/plugins/taglib_plugin/CMakeLists.txt b/src/plugins/taglib_plugin/CMakeLists.txt index 2d05dd7f8..0ddce51a5 100644 --- a/src/plugins/taglib_plugin/CMakeLists.txt +++ b/src/plugins/taglib_plugin/CMakeLists.txt @@ -4,6 +4,13 @@ set (taglibreader_SOURCES TaglibMetadataReader.cpp ) +if (${FFMPEG_DECODER} MATCHES "false") + message(STATUS "[taglibmetadatareader] *not* defining FFMPEG_DECODER") +else() + message(STATUS "[taglibmetadatareader] defining FFMPEG_DECODER") + add_definitions(-DFFMPEG_DECODER) +endif() + add_library(taglibreader SHARED ${taglibreader_SOURCES}) if (${USE_BUNDLED_TAGLIB} MATCHES "true")