Hello,
I am trying to play mono sound files on a TomTom GO (Kernel
2.6.13-tt315187).
I have no problem to play stereo files, but when I want to configure
mono sound, I get this error message :
"unable to set number of channels"
and sound is played too fast.
Here is my code :
#define RATE 22050 /* the sampling rate */
#define SIZE 16 /* sample size: 8 or 16 bits */
#define CHANNELS 1 /* 1 = mono 2 = stereo */
int arg; // argument for ioctl calls */
int fd_audio = -1;
int status; // return status of system calls */
if ((fd_audio = open ("/dev/dsp", O_WRONLY, 0)) < 0)
{
fprintf (stderr, "Can't open the sound device\n");
return;
}
// set sampling parameters
arg = SIZE; /* sample size */
status = ioctl(fd_audio, SOUND_PCM_WRITE_BITS, &arg);
if (status == -1)
fprintf (stderr, "SOUND_PCM_WRITE_BITS ioctl failed\n");
if (arg != SIZE)
fprintf (stderr, "unable to set sample size\n");
arg = CHANNELS; /* mono or stereo */
status = ioctl(fd_audio, SOUND_PCM_WRITE_CHANNELS, &arg);
if (status == -1)
fprintf (stderr, "SOUND_PCM_WRITE_CHANNELS ioctl failed\n");
if (arg != CHANNELS)
fprintf (stderr, "unable to set number of channels\n");
arg = RATE; /* sampling rate */
status = ioctl(fd_audio, SOUND_PCM_WRITE_RATE, &arg);
if (status == -1)
fprintf (stderr, "SOUND_PCM_WRITE_WRITE ioctl failed\n");
Thanks for any help.
Jean-Claude