Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Sep 2005 22:18:17 -0700
From:      Jos Backus <jos@catnook.com>
To:        multimedia@freebsd.org
Subject:   Re: Curious sound playback slowdown
Message-ID:  <20050921051839.GA39942@lizzy.catnook.local>
In-Reply-To: <20050917054421.GA93917@lizzy.catnook.local>
References:  <20050917054421.GA93917@lizzy.catnook.local>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050921051839.GA39942>