alsa: improve default buffer size

Fix sample size
This commit is contained in:
Wim Taymans 2017-04-04 12:05:35 +02:00
parent 70255b5ecd
commit 8071b76e41
3 changed files with 7 additions and 5 deletions

View file

@ -376,7 +376,8 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size),
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT,
this->props.min_latency * this->frame_size),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));

View file

@ -425,7 +425,8 @@ spa_alsa_source_node_port_set_format (SpaNode *node,
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size),
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT,
this->props.min_latency * this->frame_size),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));

View file

@ -165,7 +165,7 @@ spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, SpaPortFormatFlags
state->format = format;
state->channels = info->channels;
state->rate = info->rate;
state->frame_size = info->channels * 2;
state->frame_size = info->channels * (snd_pcm_format_physical_width (format) / 8);
CHECK (snd_pcm_hw_params_get_buffer_size_max (params, &state->buffer_frames), "get_buffer_size_max");
@ -177,8 +177,8 @@ spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, SpaPortFormatFlags
state->period_frames = period_size;
periods = state->buffer_frames / state->period_frames;
spa_log_info (state->log, "buffer frames %zd, period frames %zd, periods %u",
state->buffer_frames, state->period_frames, periods);
spa_log_info (state->log, "buffer frames %zd, period frames %zd, periods %u, frame_size %zd",
state->buffer_frames, state->period_frames, periods, state->frame_size);
/* write the parameters to device */
CHECK (snd_pcm_hw_params (hndl, params), "set_hw_params");