Skip to contentSkip to conversation

buffer_size and period_size

DISCUSSION Jozef Kosoru 3 participants 4 messages Jan 27, 2003

lore
Share & tools
lore
#0 lore raw

Hi!

I've tried to port some aplication from old ALSA-0.5.x to the new alsa library interface. I'm not an expert in the sound programming and available documentation seems to be rather poor in term of explaining the main concept.

I would like to fully understand the exact meaning of buffer_size and period_size and how can I compute the final latency in the full duplex processing from these variables.

Thank you.

--
jozef kosoru [zyzstar] <[email protected]>

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

#1 lore raw
Quoted 3 lines

I would like to fully understand the exact meaning of buffer_size and period_size and how can I compute the final latency in the full duplex processing from these variables.

period_size = frames between interrupts from the hardware buffer size = total frames for the hardware buffer

max output latency = buffer_size
min output latency = buffer_size - period_size

max input latency = period_size + interrupt overhead min input latency = 1 frame + interrupt overhead

the latency numbers assume:

a) the buffer is generally full
b) you process data 1 period at a time
c) your s/w keeps up with the h/w
d) its an average, computed across a period's worth of data

--p

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

#2 lore raw

Paul,
So with -p 64 -n 2 settings, what number of bytes of audio data is
transferred across the PCI bus between each interrupt?

I guess I had mistakenly thought -p was setting the number of bytes. I no
longer think that is true.

Also, does the number of bytes transferred change based on how many
channels are enabled? Or does my RME always transfer 26 channels of data even if I am not using some channels?

I am assuming that a card like the RME is a bus master, moves so many
bytes, and then interrupts to tell the system that the bytes are there. Is this basically the case?

Thanks,
Mark

Quoted 32 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Paul Davis
Sent: Monday, January 27, 2003 9:32 AM
To: Jozef Kosoru
Cc: [email protected]
Subject: Re: [Alsa-devel] buffer_size and period_size

Quoted 3 lines

I would like to fully understand the exact meaning of buffer_size and period_size and how can I compute the final latency in the full duplex processing from these variables.

period_size = frames between interrupts from the hardware buffer size = total frames for the hardware buffer

max output latency = buffer_size
min output latency = buffer_size - period_size

max input latency = period_size + interrupt overhead min input latency = 1 frame + interrupt overhead

the latency numbers assume:

a) the buffer is generally full
b) you process data 1 period at a time
c) your s/w keeps up with the h/w
d) its an average, computed across a period's worth of data

--p

Quoted 10 lines

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

#3 lore raw
Quoted 3 lines

Paul,
So with -p 64 -n 2 settings, what number of bytes of audio data is
transferred across the PCI bus between each interrupt?

the period size is always (as with almost all ALSA metrics) in units of audio frames (1 sample for each channel). so with JACK running at -p 64, 64 frames of data are transferred. how many bytes that is depends on the sample width and the number of channels.

Quoted 3 lines

Also, does the number of bytes transferred change based on how many
channels are enabled? Or does my RME always transfer 26 channels of data even if I am not using some channels?

its hardware dependent. for the RME, the same amount is always moved, regardless of how many channels are enabled. in the case of the RME Hammerfall series, its more accurate to say that you cannot change the number of channels enabled. this is not true of all other hardware.

Quoted 3 lines

I am assuming that a card like the RME is a bus master, moves so many
bytes, and then interrupts to tell the system that the bytes are there. Is this basically the case?

yes. keep in mind that this only covers 1 direction: the interrupt also tells the system that its possible to put data into the "hardware buffer".

--p

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com