* Problem with "set_period_size"
[not found] <CAKjtJDWJSwoO982Hk5hK44khY5Jw=wMrW3QhrincvJ_iTLDGEg@mail.gmail.com>
@ 2012-02-23 14:06 ` Alicia Romero
2012-02-23 14:59 ` Clemens Ladisch
0 siblings, 1 reply; 3+ messages in thread
From: Alicia Romero @ 2012-02-23 14:06 UTC (permalink / raw)
To: alsa-devel
Hi list!
I am new using an ALSA device and I have a problem when setting the period
size.
In my code I try to set the period size to 640 as follow:
snd_pcm_hw_params_set_access (stream->pb_pcm, params,
SND_PCM_ACCESS_RW_INTERLEAVED);
/* Set format */
snd_pcm_hw_params_set_format (stream->pb_pcm, params,
SND_PCM_FORMAT_S16_LE);
/* Set number of channels */
snd_pcm_hw_params_set_channels (stream->pb_pcm, params, 2);
/* Set clock rate */
rate =32000;
snd_pcm_hw_params_set_rate_near (stream->pb_pcm, params, &rate, NULL);
/* Set period size to samples_per_frame frames. */
stream->pb_frames = (snd_pcm_uframes_t) 640;
snd_pcm_hw_params_set_period_size_near (stream->pb_pcm, params,
&stream->pb_frames, NULL);
/* Set the sound device buffer size and latency */
if (param->flags & PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY)
tmp_buf_size = (rate / 1000) * param->output_latency_ms;
else
tmp_buf_size = (rate / 1000) * PJMEDIA_SND_DEFAULT_PLAY_LATENCY;
snd_pcm_hw_params_set_buffer_size_near (stream->pb_pcm, params,
&tmp_buf_size);
stream->param.output_latency_ms = tmp_buf_size / (rate / 1000);
/* Activate the parameters */
snd_pcm_hw_params (stream->pb_pcm, params);
The problem here is that the period size is not set to 640, but to 512.
Otherwise if I use instead:
stream->pb_frames = (snd_pcm_uframes_t) 640;
snd_pcm_hw_params_set_period_size (stream->pb_pcm, params,
&stream->pb_frames, NULL);
the period size is set to 640 and the device is working correctly.
Why is not set to 640 if I use the "*_near*" version?
Thanks!!! :)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Problem with "set_period_size"
2012-02-23 14:06 ` Problem with "set_period_size" Alicia Romero
@ 2012-02-23 14:59 ` Clemens Ladisch
[not found] ` <CAKjtJDWJMAZA+ekTVmTc0vgg7Jo-3kc4uwSUPCz4KCocM5SRZg@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Clemens Ladisch @ 2012-02-23 14:59 UTC (permalink / raw)
To: Alicia Romero; +Cc: alsa-devel
Alicia Romero wrote:
> stream->pb_frames = (snd_pcm_uframes_t) 640;
> snd_pcm_hw_params_set_period_size (stream->pb_pcm, params,
> &stream->pb_frames, NULL);
You forgot to check the return value. I'd guess it's -EINVAL.
Regards,
Clemens
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Problem with "set_period_size"
[not found] ` <CAKjtJDWJMAZA+ekTVmTc0vgg7Jo-3kc4uwSUPCz4KCocM5SRZg@mail.gmail.com>
@ 2012-02-24 13:01 ` Clemens Ladisch
0 siblings, 0 replies; 3+ messages in thread
From: Clemens Ladisch @ 2012-02-24 13:01 UTC (permalink / raw)
To: Alicia Romero; +Cc: alsa-devel
Alicia Romero wrote:
> I forgot to write that at the end I activate all the params using:
>
> /* Activate the parameters */
> result = snd_pcm_hw_params (stream->pb_pcm, params);
> if (result < 0) {
If set_period_size fails, params has not been changed.
Regards,
Clemens
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-02-24 12:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAKjtJDWJSwoO982Hk5hK44khY5Jw=wMrW3QhrincvJ_iTLDGEg@mail.gmail.com>
2012-02-23 14:06 ` Problem with "set_period_size" Alicia Romero
2012-02-23 14:59 ` Clemens Ladisch
[not found] ` <CAKjtJDWJMAZA+ekTVmTc0vgg7Jo-3kc4uwSUPCz4KCocM5SRZg@mail.gmail.com>
2012-02-24 13:01 ` Clemens Ladisch
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.