Curious sound playback slowdown
Jos Backus
jos at catnook.com
Tue Sep 20 22:18:18 PDT 2005
On Fri, Sep 16, 2005 at 10:43:59PM -0701, Jos Backus wrote:
...
> 92231 firefox-bin CALL ioctl(0x13,SNDCTL_DSP_STEREO,0xbfbf6ca0)
> 92231 firefox-bin RET ioctl 0
> 92231 firefox-bin CALL ioctl(0x13,SNDCTL_DSP_SPEED,0xbfbf6cdc)
> 92231 firefox-bin RET ioctl 0
> 92231 firefox-bin CALL ioctl(0x13,SNDCTL_DSP_SETFRAGMENT,0xbfbf6d08)
> 92231 firefox-bin RET ioctl 0
> 92231 firefox-bin CALL ioctl(0x13,SNDCTL_DSP_GETCAPS,0xbfbf6d04)
> 92231 firefox-bin RET ioctl 0
> 92231 firefox-bin CALL fcntl(0x13,0x4,0)
> 92231 firefox-bin RET fcntl 0
> 92231 firefox-bin CALL close(0x13)
...
It's unclear to me why the SNDCTL_DSP_SPEED ioctl is stuffing the wrong value
into the device. Running the program below as `set-samplerate 22050' appears
to mimic the change the Flash plugin effects. Running `set-samplerate'
restores sound pitch to a normal value. So I have a workaround for now at
least.
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <err.h>
#include <sys/soundcard.h>
#define DEFAULT_SPEED 44100
int
main(int argc, char *argv[])
{
int fd;
int rc, speed;
const char *dev = "/dev/dsp";
speed = argc > 1 ? atoi(*++argv) : DEFAULT_SPEED;
if ((fd = open(dev, O_RDONLY)) < 0)
err(1, "open %s", dev);
if ((rc = ioctl(fd, SNDCTL_DSP_SPEED, &speed)) < 0)
err(1, "ioctl");
exit(0);
}
--
Jos Backus
jos at catnook.com
More information about the freebsd-multimedia
mailing list