* Difference between boundary and buffer_size
@ 2016-11-03 9:11 Alan Young
2016-11-03 16:45 ` Lars-Peter Clausen
2016-11-03 20:01 ` Clemens Ladisch
0 siblings, 2 replies; 4+ messages in thread
From: Alan Young @ 2016-11-03 9:11 UTC (permalink / raw)
To: alsa-devel
The code in the kernel, in /pcm_lib.c/ and /pcm_native.c/, uses fields
buffer_size and boundary in struct snd_pcm_runtime. As far as I can see,
there are always initialized to the same value. In what circumstance
might they be different? There is clearly some relationship to
hw_ptr_base, as illustrated by this repeated snipped from
snd_pcm_update_hw_ptr0()
hw_base += runtime->buffer_size;
if (hw_base >= runtime->boundary) {
hw_base = 0;
crossed_boundary++;
}
new_hw_ptr = hw_base + pos;
Alan.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Difference between boundary and buffer_size
2016-11-03 9:11 Difference between boundary and buffer_size Alan Young
@ 2016-11-03 16:45 ` Lars-Peter Clausen
2016-11-03 22:56 ` Lars-Peter Clausen
2016-11-03 20:01 ` Clemens Ladisch
1 sibling, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2016-11-03 16:45 UTC (permalink / raw)
To: Alan Young, alsa-devel
On 11/03/2016 10:11 AM, Alan Young wrote:
> The code in the kernel, in /pcm_lib.c/ and /pcm_native.c/, uses fields
> buffer_size and boundary in struct snd_pcm_runtime. As far as I can see,
> there are always initialized to the same value. In what circumstance might
> they be different? There is clearly some relationship to hw_ptr_base, as
> illustrated by this repeated snipped from snd_pcm_update_hw_ptr0()
>
> hw_base += runtime->buffer_size;
> if (hw_base >= runtime->boundary) {
> hw_base = 0;
> crossed_boundary++;
> }
> new_hw_ptr = hw_base + pos;
boundary is actually set to the largest possible power-of-two multiple of
buffer_size. This is done so that the hw_ptr that is reported to userspace
is continuously increasing (up to boundary) and does not wrap around after
just one buffer_size has elapsed. This is done so you can measure the
distance between two hw_ptr that were captured at different points in time,
but are more than half a buffer_size away from each other.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Difference between boundary and buffer_size
2016-11-03 16:45 ` Lars-Peter Clausen
@ 2016-11-03 22:56 ` Lars-Peter Clausen
0 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2016-11-03 22:56 UTC (permalink / raw)
To: Alan Young, alsa-devel
On 11/03/2016 05:45 PM, Lars-Peter Clausen wrote:
> On 11/03/2016 10:11 AM, Alan Young wrote:
>> The code in the kernel, in /pcm_lib.c/ and /pcm_native.c/, uses fields
>> buffer_size and boundary in struct snd_pcm_runtime. As far as I can see,
>> there are always initialized to the same value. In what circumstance might
>> they be different? There is clearly some relationship to hw_ptr_base, as
>> illustrated by this repeated snipped from snd_pcm_update_hw_ptr0()
>>
>> hw_base += runtime->buffer_size;
>> if (hw_base >= runtime->boundary) {
>> hw_base = 0;
>> crossed_boundary++;
>> }
>> new_hw_ptr = hw_base + pos;
>
> boundary is actually set to the largest possible power-of-two multiple of
> buffer_size. This is done so that the hw_ptr that is reported to userspace
> is continuously increasing (up to boundary) and does not wrap around after
> just one buffer_size has elapsed. This is done so you can measure the
> distance between two hw_ptr that were captured at different points in time,
> but are more than half a buffer_size away from each other.
And the pointer that is reported to userspace is called appl_ptr, sorry for
the confusion.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Difference between boundary and buffer_size
2016-11-03 9:11 Difference between boundary and buffer_size Alan Young
2016-11-03 16:45 ` Lars-Peter Clausen
@ 2016-11-03 20:01 ` Clemens Ladisch
1 sibling, 0 replies; 4+ messages in thread
From: Clemens Ladisch @ 2016-11-03 20:01 UTC (permalink / raw)
To: Alan Young, alsa-devel
Alan Young wrote:
> there are always initialized to the same value.
No. Have a look into /proc/asound/cardX/pcm0p/sub0/hw_params.
> In what circumstance might they be different?
Always.
The boundary value is an integer multiple of the buffer size. It's used
to allow computing the difference of two pointer values even if that
difference is larger than the buffers size.
Regards,
Clemens
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-03 22:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-03 9:11 Difference between boundary and buffer_size Alan Young
2016-11-03 16:45 ` Lars-Peter Clausen
2016-11-03 22:56 ` Lars-Peter Clausen
2016-11-03 20: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.