mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-28 05:40:26 -04:00
spa: bump channels to 128 again
Remove the SPA_AUDIO_MAX_POSITION define and use the SPA_AUDIO_MAX_CHANNELS again. Make a compile time define to override the default max channels of 64. Make sure we compile the SPA library with the default 64 channels. If you use the SPA library on a spa_audio_info you will get 64 channel support, like before. If you want more channels, you will need to make a padded structure or redefine the MAX_CHANNELS before you use the spa_audio_info structures. You can use the padded structure with the new functions that take the structure size. With the extra checks in the parsing code, we avoid making a valid spa_audio_info with too many channels that don't fit in the structure. This means that code that receives a spa_audio_info can assume there is enough padding for all the channels.
This commit is contained in:
parent
be29ae4ef6
commit
6d74eee874
6 changed files with 15 additions and 20 deletions
|
|
@ -115,6 +115,7 @@ cc_flags = common_flags + [
|
|||
'-Werror=old-style-definition',
|
||||
'-Werror=missing-parameter-type',
|
||||
'-Werror=strict-prototypes',
|
||||
'-DSPA_AUDIO_MAX_CHANNELS=128u',
|
||||
]
|
||||
add_project_arguments(cc.get_supported_arguments(cc_flags), language: 'c')
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ struct spa_audio_info_dsd {
|
|||
int32_t interleave; /*< interleave bytes */
|
||||
uint32_t rate; /*< sample rate (in bytes per second) */
|
||||
uint32_t channels; /*< channels */
|
||||
uint32_t position[SPA_AUDIO_MAX_POSITION]; /*< channel position from enum spa_audio_channel */
|
||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS]; /*< channel position from enum spa_audio_channel */
|
||||
};
|
||||
|
||||
#define SPA_AUDIO_INFO_DSD_INIT(...) ((struct spa_audio_info_dsd) { __VA_ARGS__ })
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ extern "C" {
|
|||
|
||||
struct spa_audio_layout_info {
|
||||
uint32_t n_channels;
|
||||
uint32_t position[SPA_AUDIO_MAX_POSITION];
|
||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
||||
};
|
||||
|
||||
#define SPA_AUDIO_LAYOUT_Mono 1, { SPA_AUDIO_CHANNEL_MONO, }
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ SPA_API_AUDIO_RAW_JSON int
|
|||
spa_audio_parse_position(const char *str, size_t len,
|
||||
uint32_t *position, uint32_t *n_channels)
|
||||
{
|
||||
return spa_audio_parse_position_n(str, len, position, SPA_AUDIO_MAX_POSITION, n_channels);
|
||||
return spa_audio_parse_position_n(str, len, position, SPA_AUDIO_MAX_CHANNELS, n_channels);
|
||||
}
|
||||
|
||||
SPA_API_AUDIO_RAW_JSON int
|
||||
|
|
|
|||
|
|
@ -18,14 +18,10 @@ extern "C" {
|
|||
* \{
|
||||
*/
|
||||
|
||||
/* This is the max number of position info, changing this will change the
|
||||
* ABI */
|
||||
#define SPA_AUDIO_MAX_POSITION 64u
|
||||
|
||||
/* The suggested number of max channels, can be a compile time constant and
|
||||
* does not affect ABI or API */
|
||||
/* This is the max number of channels, changing this will change the
|
||||
* size of some helper structures. This value should be at least 64 */
|
||||
#ifndef SPA_AUDIO_MAX_CHANNELS
|
||||
#define SPA_AUDIO_MAX_CHANNELS 128u
|
||||
#define SPA_AUDIO_MAX_CHANNELS 64u
|
||||
#endif
|
||||
|
||||
enum spa_audio_format {
|
||||
|
|
@ -279,16 +275,18 @@ enum spa_audio_volume_ramp_scale {
|
|||
#define SPA_AUDIO_FLAG_NONE (0) /*< no valid flag */
|
||||
#define SPA_AUDIO_FLAG_UNPOSITIONED (1 << 0) /*< the position array explicitly
|
||||
* contains unpositioned channels. */
|
||||
/** Audio information description */
|
||||
/** Audio information description. You can assume when you receive this structure
|
||||
* that there is enought padding to accomodate all channel positions in case the
|
||||
* channel count is more than SPA_AUDIO_MAX_CHANNELS. */
|
||||
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 more than SPA_AUDIO_MAX_POSITION
|
||||
uint32_t channels; /*< number of channels. This can be more than SPA_AUDIO_MAX_CHANNELS
|
||||
* 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 */
|
||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS]; /*< channel position from enum spa_audio_channel */
|
||||
/* padding follows here when channels > SPA_AUDIO_MAX_CHANNELS */
|
||||
};
|
||||
|
||||
#define SPA_AUDIO_INFO_RAW_INIT(...) ((struct spa_audio_info_raw) { __VA_ARGS__ })
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
#undef SPA_AUDIO_MAX_CHANNELS
|
||||
|
||||
#define SPA_API_IMPL SPA_EXPORT
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/buffer/alloc.h>
|
||||
|
|
@ -165,9 +167,3 @@
|
|||
#include <spa/utils/string.h>
|
||||
#include <spa/utils/type.h>
|
||||
#include <spa/utils/type-info.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue