Fixed rate codec with vchans [ was Re: Problem with snd_ich and vchans ]

Orion Hodson orion at freebsd.org
Wed Dec 10 16:35:46 PST 2003


/-- Michael Nottebrock wrote:
| 
| pcm0: <Intel ICH2 (82801BA)> port 0xe800-0xe83f,0xec00-0xecff irq 10 at dev=
| ice=20
| 31.5 on pci0
| pcm0: <C-Media Electronics CMI9739 AC97 Codec>
| 
| running by default with hw.snd.pcm0.ac97rate: 48000.
| 
| Now when I enable vchans, sound plays back to slowly (pitched down), fiddli=
| ng=20
| with above sysctl doesn't have any effect. I found the following in vchan.c:
| 
|         /* XXX gross ugly hack, kill murder death */
|         if (first && !err) {
|                 err =3D chn_reset(parent, AFMT_STEREO | AFMT_S16_LE);
|                 if (err)
|                         printf("chn_reset: %d\n", err);
|                 err =3D chn_setspeed(parent, 44100);
|                 if (err)
|                         printf("chn_setspeed: %d\n", err);
|         }
| 
| When I change the 44100 to 48000 there, sound plays back normally with vcha=
| ns enabled.

Michael

The ac97 codec is fixed rate (48kHz).  The virtual channel code resamples all 
playback streams to 44.1kHz before mixing them and needs to arrange to plumb 
in a rate converter after the mixing step.  Unfortunately, there's a bug in 
the planning code that doesn't allow this to happen correctly.

The patch above is nicely avoids this problem for the case in hand.

The bugs in the feeder planning code also affect recording and certain format 
selections (quite a lot of cases with fixed rate codecs).  There's an 
attempted general case patch relative to -CURRENT in August:

http://people.freebsd.org/~orion/files/ac97_fixed_rate_feeder.patch

The patch was written at about the point I decided I wanted to take a break 
from the project and has not been committed.  It touches quite a lot of code, 
but hopefully makes the feeder planning easier to reason about.

Kind Regards
- Orion




More information about the freebsd-multimedia mailing list