- ioctl(sounddev, SNDCTL_DSP_SPEED, &rate);
- ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits);
- ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo);
- // calculate buffer size
- buffers = 16;
- bsize = rate / 32;
- if (rate > 22050) { bsize*=4; buffers*=2; } // 44k mode seems to be very demanding
- while ((bsize>>=1)) frag++;
- frag |= buffers<<16; // 16 buffers
- ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag);
- printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n",
- rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff));