mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa-pcm: allow setting number of channels
Allow passing the number of channels when creating a device to restrict the negotiated channels.
This commit is contained in:
parent
267eabaf69
commit
8168dfdbc1
5 changed files with 15 additions and 0 deletions
|
|
@ -221,6 +221,8 @@ struct spa_audio_info_raw {
|
|||
|
||||
#define SPA_KEY_AUDIO_CHANNEL "audio.channel" /**< an audio channel as string,
|
||||
* Ex. "FL" */
|
||||
#define SPA_KEY_AUDIO_CHANNELS "audio.channels" /**< an audio channel count as int */
|
||||
|
||||
struct spa_audio_info_dsp {
|
||||
enum spa_audio_format format; /*< format, one of the DSP formats in enum spa_audio_format_dsp */
|
||||
};
|
||||
|
|
|
|||
|
|
@ -751,6 +751,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
for (i = 0; info && i < info->n_items; i++) {
|
||||
if (!strcmp(info->items[i].key, SPA_KEY_API_ALSA_PATH)) {
|
||||
snprintf(this->props.device, 63, "%s", info->items[i].value);
|
||||
} else if (!strcmp(info->items[i].key, SPA_KEY_AUDIO_CHANNELS)) {
|
||||
this->default_channels = atoi(info->items[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -770,6 +770,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
for (i = 0; info && i < info->n_items; i++) {
|
||||
if (!strcmp(info->items[i].key, SPA_KEY_API_ALSA_PATH)) {
|
||||
snprintf(this->props.device, 63, "%s", info->items[i].value);
|
||||
} else if (!strcmp(info->items[i].key, SPA_KEY_AUDIO_CHANNELS)) {
|
||||
this->default_channels = atoi(info->items[i].value);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -357,6 +357,13 @@ spa_alsa_enum_format(struct state *state, int seq, uint32_t start, uint32_t num,
|
|||
CHECK(snd_pcm_hw_params_get_channels_min(params, &min), "get_channels_min");
|
||||
CHECK(snd_pcm_hw_params_get_channels_max(params, &max), "get_channels_max");
|
||||
|
||||
if (state->default_channels != 0) {
|
||||
if (min < state->default_channels)
|
||||
min = state->default_channels;
|
||||
if (max > state->default_channels)
|
||||
max = state->default_channels;
|
||||
}
|
||||
|
||||
spa_pod_builder_prop(&b, SPA_FORMAT_AUDIO_channels, 0);
|
||||
|
||||
if ((maps = snd_pcm_query_chmaps(hndl)) != NULL) {
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ struct state {
|
|||
bool have_format;
|
||||
struct spa_audio_info current_format;
|
||||
|
||||
unsigned int default_channels;
|
||||
|
||||
snd_pcm_uframes_t buffer_frames;
|
||||
snd_pcm_uframes_t period_frames;
|
||||
snd_pcm_format_t format;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue