Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warnings #603

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions av/src/AudioDecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change causes a test failure on 20.04; perhaps we can ifdef on the software version if we can figure out the difference in the version variables between 20.04 and 22.04?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do much investigation into whether we can simply replace avcodec_close with avcodec_free_context, but let me try it on a newer version of Ubuntu to see if it fails everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this more closely, I think it's more about how codecCtx was created in the first place. In d38e4d3, I've used avcodec_free_context if codeCtx was created using avcodec_alloc_context3, which is inline with the ffmpeg documentation

#endif
}

// Close the audio file
if (this->data->formatCtx)
Expand Down
4 changes: 4 additions & 0 deletions av/src/Video.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
7 changes: 7 additions & 0 deletions include/gz/common/EnumIface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename Enum>
class EnumIterator
: std::iterator<std::bidirectional_iterator_tag, Enum>
Expand Down Expand Up @@ -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
Expand Down