Skip to contentSkip to conversation

intel8x0.c

DISCUSSION Brian Furey 4 participants 9 messages Mar 30, 2004 – Apr 16, 2004

lore
Share & tools
lore
#0 lore raw

Hi all,
I have an intel810 onboard soundcard.I am using the
alsa driver with a VoIP session.
The intel8x0.c file has a minimum period byte size
of 32 bytes with the minimum no. of periods being 1.The min and max rate is set to 48k.

How can I find out what actual(runtime) size period the alsa driver is dealing with?

Does it use the minimum size as the period size?

Brian.

___________________________________________________________
WIN FREE WORLDWIDE FLIGHTS - nominate a cafe in the Yahoo! Mail Internet Cafe Awards www.yahoo.co.uk/internetcafes

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#1 lore raw
Quoted 10 lines · Brian Furey

Hi all,
I have an intel810 onboard soundcard.I am using the
alsa driver with a VoIP session.
The intel8x0.c file has a minimum period byte size
of 32 bytes with the minimum no. of periods being 1.The min and max rate is set to 48k.

How can I find out what actual(runtime) size period the alsa driver is dealing with?

After the snd_pcm_hw_params() call, the given hardware parameter container will have the chosen period size or snd_pcm_hw_params_current() creates the current hw_params container.

Then use snd_pcm_hw_params_get_period_size() or
snd_pcm_hw_params_get_period_time().

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#2 lore raw

Right Jaroslav,
that means i would modify intel8x0.c to include a
call to
snd_pcm_hw_params_get_period_size() or snd_pcm_hw_params_get_period_time() in the appropriate place. Write the values returned say to a text file. Recompile the ALsa driver and re-insert it into the kernel.Start my application and check contents of text file.
Am I right in saying this?
Thanks in advance,
Brian.

--- Jaroslav Kysela <[email protected]> wrote: > On Tue,

Quoted 25 lines · Brian Furey
Quoted 4 lines

Hi all,
I have an intel810 onboard soundcard.I am using

the

Quoted 2 lines

alsa driver with a VoIP session.
The intel8x0.c file has a minimum period byte

size

Quoted 4 lines

of 32 bytes with the minimum no. of periods being
1.The min and max rate is set to 48k.

How can I find out what actual(runtime) size

period

Quoted 1 line

the alsa driver is dealing with?

After the snd_pcm_hw_params() call, the given
hardware parameter
container will have the chosen period size or
snd_pcm_hw_params_current() creates the current
hw_params
container.

Then use snd_pcm_hw_params_get_period_size() or
snd_pcm_hw_params_get_period_time().

Quoted 6 lines

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

___________________________________________________________
WIN FREE WORLDWIDE FLIGHTS - nominate a cafe in the Yahoo! Mail Internet Cafe Awards www.yahoo.co.uk/internetcafes

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#3 lore raw
Quoted 11 lines · Brian Furey

Right Jaroslav,
that means i would modify intel8x0.c to include a
call to
snd_pcm_hw_params_get_period_size() or snd_pcm_hw_params_get_period_time() in the appropriate place. Write the values returned say to a text file. Recompile the ALsa driver and re-insert it into the kernel.Start my application and check contents of text file.
Am I right in saying this?

I'm talking about application not the driver.
Why you need to modify driver?

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#4 lore raw
In reply to Brian Furey
Quoted 7 lines · Brian Furey

Hi all,
I have an intel810 onboard soundcard.I am using the
alsa driver with a VoIP session.
The intel8x0.c file has a minimum period byte size
of 32 bytes with the minimum no. of periods being 1.The min and max rate is set to 48k.

Quoted 7 lines

How can I find out what actual(runtime) size period the alsa driver is dealing with?

Does it use the minimum size as the period size?

Brian.

Brian, I am working on a VoIP setup. I am updating the asterisk alsa console driver so that it actually works! The current driver is stuck round about alsa api 0.5.x
The period size that the sound card is actually using does not really matter, if just effects latency. The bigger the period size, the higher the latency.
Just set the period size to the smallest the sound card can do, and then just read and write to it.
I found that PLAYBACK and CAPTURE directions can have different period sizes, so it is better to open separate handles for playback and capture.
In the config setup, you set the buffer and period sizes, and before you set them, you can retrieve the current min/max period and buffer sizes.
For playback, it is best to have a certain minimum buffer being full most of the time, due to network jitter, and this buffer can act as the jitter buffer. The actual size of this is probably best found out from trial and error (I have not finished testing this bit yet). For capture, just poll for input, and then read whatever is in the capture buffer and transmit it. You can experiment with different methods of early buffer reads, but again, I have not finished testing with that, so I can't give you any definite answers.

Another thing to test with could be sampling and playback at 48k.
Most sound cards work at 48k, and this would reduce the period_time. (period_size stays the same, but as one is using a higher rate, the period_time decreases, and thus latency.) The problems with that is that most VoIP is at 8k, so some resampling is required.

Cheers
James

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#5 lore raw

Thanks James,
i'm using the GSM-06.10 codec with my VoIP
application.The frame rate is 160 timestamp units or 20 millisecond frames.4 frames are added to a packet and transmitted. Packets are transmitted at alternate intervals of 64 and 96 milliseconds. This is due to the soundcard driver and the period sizes being read into the buffer.Can the period size the driver is capturing from the soundcard and putting into the sending buffer change during execution of a VoIP session or is it fixed.Given that I have not changed it, what is the default period size for the ALSA driver?
I'm basically trying to find out the reason packets are transmitted at alternate intervals of 64 and 96 milliseconds....and the runtime period size is the key

help appreciated,
brian.
--- James Courtier-Dutton <[email protected]>

Quoted 65 lines · wrote: > Brian Furey wrote:
Quoted 2 lines

Hi all,
I have an intel810 onboard soundcard.I am using

the

Quoted 2 lines

alsa driver with a VoIP session.
The intel8x0.c file has a minimum period byte

size

Quoted 4 lines

of 32 bytes with the minimum no. of periods being
1.The min and max rate is set to 48k.

How can I find out what actual(runtime) size

period

Quoted 6 lines

the alsa driver is dealing with?

Does it use the minimum size as the period size?

Brian.

Brian, I am working on a VoIP setup. I am updating the asterisk alsa
console driver so that it actually works! The current driver is stuck
round about alsa api 0.5.x
The period size that the sound card is actually using does not really
matter, if just effects latency. The bigger the period size, the higher
the latency.
Just set the period size to the smallest the sound card can do, and then
just read and write to it.
I found that PLAYBACK and CAPTURE directions can have different period
sizes, so it is better to open separate handles for playback and capture.
In the config setup, you set the buffer and period sizes, and before you
set them, you can retrieve the current min/max period and buffer sizes.
For playback, it is best to have a certain minimum buffer being full
most of the time, due to network jitter, and this buffer can act as the
jitter buffer. The actual size of this is probably best found out from
trial and error (I have not finished testing this bit yet).
For capture, just poll for input, and then read whatever is in the
capture buffer and transmit it. You can experiment with different
methods of early buffer reads, but again, I have not finished testing
with that, so I can't give you any definite answers.

Another thing to test with could be sampling and playback at 48k.
Most sound cards work at 48k, and this would reduce the period_time.
(period_size stays the same, but as one is using a higher rate, the
period_time decreases, and thus latency.) The problems with that is that
most VoIP is at 8k, so some resampling is required.

Quoted 2 lines

Cheers
James

___________________________________________________________
WIN FREE WORLDWIDE FLIGHTS - nominate a cafe in the Yahoo! Mail Internet Cafe Awards www.yahoo.co.uk/internetcafes

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#6 lore raw

Re: alsa driver data rates

In reply to James Courtier-Dutton

Hi James,
Im asking you becuae looking thru the archives you asked a similar question a long time ago.

i'm using an open source VoIP application with the
alsa driver. My card is the onboard intel8x0.

My problem is figuring out the patterns I am
getting with the alsa driver when transmitting
packets.
For instance when I use the GSM codec with a packets
size of 80 msecs and 132 bytes, packets are
transmitted at alternate intervals of 64/96 msecs.
When i use G.711 packets of 240 bytes are transmitted
every 32 msecs with an extra packet every 15 pkts.
With G.711 it is obvious that 256 bytes are added to driver sending buffer every 32 msecs.However this does not match for GSM because it needs only 132 bytes every 64/96 msecs. Can the driver change the amount of data it gets from the soundcard to suit the codec?
Help appreciated,

Brian.

James Courtier-Dutton <[email protected]> wrote:

Quoted 7 lines · Brian Furey

Hi all,
I have an intel810 onboard soundcard.I am using the alsa driver with a VoIP session.
The intel8x0.c file has a minimum period byte size of 32 bytes with the minimum no. of periods being 1.The min and max rate is set to 48k.

Quoted 7 lines

How can I find out what actual(runtime) size period the alsa driver is dealing with?

Does it use the minimum size as the period size?

Brian.

Brian, I am working on a VoIP setup. I am updating the asterisk alsa console driver so that it actually works! The current driver is stuck round about alsa api 0.5.x
The period size that the sound card is actually using does not really matter, if just effects latency. The bigger the period size, the higher the latency.
Just set the period size to the smallest the sound card can do, and then just read and write to it.
I found that PLAYBACK and CAPTURE directions can have different period sizes, so it is better to open separate handles for playback and capture. In the config setup, you set the buffer and period sizes, and before you set them, you can retrieve the current min/max period and buffer sizes. For playback, it is best to have a certain minimum buffer being full most of the time, due to network jitter, and this buffer can act as the jitter buffer. The actual size of this is probably best found out from trial and error (I have not finished testing this bit yet). For capture, just poll for input, and then read whatever is in the capture buffer and transmit it. You can experiment with different methods of early buffer reads, but again, I have not finished testing with that, so I can't give you any definite answers.

Another thing to test with could be sampling and playback at 48k. Most sound cards work at 48k, and this would reduce the period_time. (period_size stays the same, but as one is using a higher rate, the period_time decreases, and thus latency.) The problems with that is that most VoIP is at 8k, so some resampling is required.

Cheers
James

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now

#7 lore raw

Re: alsa driver data rates

Quoted 17 lines · Brian Furey

Hi James,
Im asking you becuae looking thru the archives you asked a similar question a long time ago.

i'm using an open source VoIP application with the
alsa driver. My card is the onboard intel8x0.
My problem is figuring out the patterns I am
getting with the alsa driver when transmitting
packets.
For instance when I use the GSM codec with a packets
size of 80 msecs and 132 bytes, packets are
transmitted at alternate intervals of 64/96 msecs.
When i use G.711 packets of 240 bytes are transmitted
every 32 msecs with an extra packet every 15 pkts.
With G.711 it is obvious that 256 bytes are added to driver sending buffer every 32 msecs.However this does not match for GSM because it needs only 132 bytes every 64/96 msecs. Can the driver change the amount of data it gets from the soundcard to suit the codec?
Help appreciated,

Quoted 3 lines

Brian.

Can you point me to a url for the source?
I think I will understand you a bit better if I see the source code.

Cheers
James

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#8 lore raw

Re: alsa driver data rates

In reply to Brian Furey
Quoted 6 lines · Brian Furey

i'm using an open source VoIP application with the
alsa driver. My card is the onboard intel8x0.

My problem is figuring out the patterns I am
getting with the alsa driver when transmitting
packets.

This depends more on how the VoIP application does things, not on the driver/soundcard.

Quoted 10 lines

For instance when I use the GSM codec with a packets size of 80 msecs and 132 bytes, packets are
transmitted at alternate intervals of 64/96 msecs.
When i use G.711 packets of 240 bytes are transmitted every 32 msecs with an extra packet every 15 pkts.
With G.711 it is obvious that 256 bytes are added to driver sending buffer every 32 msecs.However this does not match for GSM because it needs only 132 bytes every 64/96 msecs.
Can the driver change the amount of data it gets from the soundcard to suit the codec?

Have a look into /proc/asound/card0/pcm0?/sub0/hw_params to see the period size. The period size is constant, but if it is small enough the application can just wait until enough periods have accumulated for one packet.

HTH
Clemens

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click