From fb3b71b9be0a8af8a4b60c1b84887eded9dac6a0 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Fri, 3 May 2024 15:42:01 -0500 Subject: [PATCH 1/3] Fix deprecation warnings Signed-off-by: Addisu Z. Taddese --- av/src/AudioDecoder.cc | 2 +- av/src/Video.cc | 2 +- include/gz/common/EnumIface.hh | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/av/src/AudioDecoder.cc b/av/src/AudioDecoder.cc index fbb63f8d4..373f27fed 100644 --- a/av/src/AudioDecoder.cc +++ b/av/src/AudioDecoder.cc @@ -67,7 +67,7 @@ void AudioDecoder::Cleanup() { // Close the codec if (this->data->codecCtx) - avcodec_close(this->data->codecCtx); + avcodec_free_context(&this->data->codecCtx); // Close the audio file if (this->data->formatCtx) diff --git a/av/src/Video.cc b/av/src/Video.cc index 95d4cbdc9..c8ac54734 100644 --- a/av/src/Video.cc +++ b/av/src/Video.cc @@ -83,7 +83,7 @@ void Video::Cleanup() avformat_close_input(&this->dataPtr->formatCtx); // Close the codec - avcodec_close(this->dataPtr->codecCtx); + avcodec_free_context(&this->dataPtr->codecCtx); av_free(this->dataPtr->avFrameDst); } diff --git a/include/gz/common/EnumIface.hh b/include/gz/common/EnumIface.hh index b95ce1b39..c6c2ab1e3 100644 --- a/include/gz/common/EnumIface.hh +++ b/include/gz/common/EnumIface.hh @@ -140,6 +140,10 @@ namespace ignition /// std::cout << "Type++ Name[" << myTypeIface.Str(*i) << "]\n"; /// } /// \verbatim +#if defined __APPLE__ && defined __clang__ + _Pragma("clang diagnostic push") + _Pragma("clang diagnostic ignored -Wdeprecated-declarations") +#endif template class EnumIterator : std::iterator @@ -217,6 +221,9 @@ namespace ignition /// member value ever used. private: Enum c; }; +#if defined __APPLE__ && defined __clang__ + _Pragma("clang diagnostic pop") +#endif /// \brief Equality operator /// \param[in] _e1 First iterator From c9154517e98c4f5fc8836136cb317b54b4df9c43 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Fri, 3 May 2024 20:06:04 -0500 Subject: [PATCH 2/3] Fix build Signed-off-by: Addisu Z. Taddese --- include/gz/common/EnumIface.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gz/common/EnumIface.hh b/include/gz/common/EnumIface.hh index c6c2ab1e3..0cb6d8275 100644 --- a/include/gz/common/EnumIface.hh +++ b/include/gz/common/EnumIface.hh @@ -142,7 +142,7 @@ namespace ignition /// \verbatim #if defined __APPLE__ && defined __clang__ _Pragma("clang diagnostic push") - _Pragma("clang diagnostic ignored -Wdeprecated-declarations") + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") #endif template class EnumIterator From d38e4d354ff46bb22e2b874cfae735ddf8265bd8 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Mon, 6 May 2024 16:17:59 -0500 Subject: [PATCH 3/3] Use correct API conditioned on LIBAVFORMAT versions Signed-off-by: Addisu Z. Taddese --- av/src/AudioDecoder.cc | 6 ++++++ av/src/Video.cc | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/av/src/AudioDecoder.cc b/av/src/AudioDecoder.cc index 373f27fed..c7f51489e 100644 --- a/av/src/AudioDecoder.cc +++ b/av/src/AudioDecoder.cc @@ -67,7 +67,13 @@ void AudioDecoder::Cleanup() { // Close the codec if (this->data->codecCtx) + { +#if LIBAVFORMAT_VERSION_MAJOR < 59 + avcodec_close(this->data->codecCtx); +#else avcodec_free_context(&this->data->codecCtx); +#endif + } // Close the audio file if (this->data->formatCtx) diff --git a/av/src/Video.cc b/av/src/Video.cc index c8ac54734..321d0b5b1 100644 --- a/av/src/Video.cc +++ b/av/src/Video.cc @@ -83,7 +83,11 @@ void Video::Cleanup() avformat_close_input(&this->dataPtr->formatCtx); // Close the codec +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101) avcodec_free_context(&this->dataPtr->codecCtx); +#else + avcodec_close(this->dataPtr->codecCtx); +#endif av_free(this->dataPtr->avFrameDst); }