avutil/channel_layout: fix some (un)initialization issues in av_channel_layout_from_string()

Also make initialization/uninitialization behaviour more explicit in the docs,
and make sure we do not leak a channel map on error.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2024-03-09 22:11:57 +01:00
parent 95d31db82c
commit a688fbfb88
2 changed files with 11 additions and 2 deletions

View file

@ -512,10 +512,14 @@ int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask);
* - the number of unordered channels (eg. "4C" or "4 channels")
* - the ambisonic order followed by optional non-diegetic channels (eg.
* "ambisonic 2+stereo")
* On error, the channel layout will remain uninitialized, but not necessarily
* untouched.
*
* @param channel_layout input channel layout
* @param channel_layout uninitialized channel layout for the result
* @param str string describing the channel layout
* @return 0 channel layout was detected, AVERROR_INVALIDATATA otherwise
* @return 0 on success parsing the channel layout
* AVERROR(EINVAL) if an invalid channel layout string was provided
* AVERROR(ENOMEM) if there was not enough memory
*/
int av_channel_layout_from_string(AVChannelLayout *channel_layout,
const char *str);