-
Notifications
You must be signed in to change notification settings - Fork 107
Rework packet finding logic #468
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,18 @@ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames); | |
|
|
||
| void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track, const std::map<std::string, std::string> &LAVFOpts); | ||
|
|
||
| // RAII wrapper for AVPacket * that handles av_packet_alloc and av_packet_free. | ||
| // av_packet_ref and av_packet_unref still need to be handled by user code. | ||
| class SmartAVPacket : public std::unique_ptr<AVPacket, void(*)(AVPacket *)> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is everywhere this used actually exception safe? I ask because now there is no longer an explicit alloc failure check, and the unfortunate "exceptions as flow control" history of FFMS (and C++ in general) comes into play.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is at the moment because every instance of This is why I moved the failure check into the constructor to cut down on some boilerplate, but I see how this is now less explicit about control flow in the case of allocation failure. If you prefer being more explicit about where these exceptions are thrown, I can revert this. |
||
| public: | ||
| SmartAVPacket() : std::unique_ptr<AVPacket, void(*)(AVPacket *)>(av_packet_alloc(), [](AVPacket *packet) { av_packet_free(&packet); }) { | ||
| if (!*this) { | ||
| throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED, | ||
| "Could not allocate packet."); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| namespace optdetail { | ||
| template<typename T> | ||
| T get_av_opt(void *v, const char *name) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.