[icecast-dev] Patch for IceS (im_alsa.c)

Jørgen Elgaard Larsen maillistparticipant at elgaard.net
Wed Feb 4 16:28:04 PST 2004



Hi there.

I noticed that the alsa input module in IceS 2.0-Beta4 have some
problems with sample rates.

The problem derives from the fact that the sample rate is set by a call
to snd_pcm_hw_params_set_rate_near() in the ALSA API. This means that if
you specify a sample rate that your ALSA driver soes not like, ALSA will
choose the nearest possible sample rate instead.

In the present im_alsa.c this yields no warning, which may confuse some
people (it certainly confused me). For further information on this,
please read my posts on icecast at xiph.org (subject "Server drops client -
problem with IceS?")

Anyway, I have made a small patch for the im_alsa.c that gives you a
warning in the log, when this happens. I attach it here - I hope you
will use it.

<p>Sincerely,

<p>                    Jørgen Elgaard Larsen

IT Manager                             Graduate Student
University Radio of Copenhagen         Dept. of Comp. Science
Denmark                                University of Copenhagen

<p>


167a168
>     int realrate; /* For storing the actual sample rate */
227c228
<     if ((err = snd_pcm_hw_params_set_rate_near(s->fd, hwparams, &s->rate, 0)) < 0)

---
>     if ((err = realrate = snd_pcm_hw_params_set_rate_near(s->fd, hwparams, &s->rate, 0)) < 0)
257a259,265
>     /* Check that sample rate was set correctly */
>     LOG_DEBUG1("ALSA Sound card has sample rate %d", realrate);
>     if (s->rate != realrate)
>     {
>         LOG_WARN4("Sample rate changed on ALSA audio device %s! (Configuration says %d, sound card wants %d, so %d it is...)",
> 	       device, s->rate, realrate, realrate);
>     }

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
icecast project homepage: http://www.icecast.org/
To unsubscribe from this list, send a message to 'icecast-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.




More information about the Icecast-dev mailing list