mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
spa: make it possible to extend the spa_audio_info struct
Add functions that take the size of the spa_audio_info struct in various functions. We can use this to determine how many channels and channel positions we can store. Error out if we try to use more channels than we can fit positions. This is probably the safest thing to do because most code will blindly try to get the positions without checking the channel count. Make sure we also propagate errors to the callers.
This commit is contained in:
parent
c5533b3c32
commit
b8eeb2db45
4 changed files with 124 additions and 46 deletions
|
|
@ -284,14 +284,18 @@ struct spa_audio_info_raw {
|
|||
enum spa_audio_format format; /*< format, one of enum spa_audio_format */
|
||||
uint32_t flags; /*< extra flags */
|
||||
uint32_t rate; /*< sample rate */
|
||||
uint32_t channels; /*< number of channels. This can be larger than
|
||||
* SPA_AUDIO_MAX_POSITION, the position is taken
|
||||
* (index % SPA_AUDIO_MAX_POSITION) */
|
||||
uint32_t channels; /*< number of channels. This can be more than SPA_AUDIO_MAX_POSITION
|
||||
* and you may assume there is enough padding for the extra
|
||||
* channel positions. */
|
||||
uint32_t position[SPA_AUDIO_MAX_POSITION]; /*< channel position from enum spa_audio_channel */
|
||||
/* more channels can be added here */
|
||||
};
|
||||
|
||||
#define SPA_AUDIO_INFO_RAW_INIT(...) ((struct spa_audio_info_raw) { __VA_ARGS__ })
|
||||
|
||||
#define SPA_AUDIO_INFO_RAW_MAX_POSITION(size) (((size)-offsetof(struct spa_audio_info_raw,position))/sizeof(uint32_t))
|
||||
|
||||
|
||||
#define SPA_KEY_AUDIO_FORMAT "audio.format" /**< an audio format as string,
|
||||
* Ex. "S16LE" */
|
||||
#define SPA_KEY_AUDIO_CHANNEL "audio.channel" /**< an audio channel as string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue