--- drivers/common/unixdsp.c.orig 2003-11-09 22:33:13.000000000 -0500 +++ drivers/common/unixdsp.c 2003-11-09 23:40:46.496436000 -0500 @@ -37,7 +37,7 @@ static int format; static int dspfd; - +static int fakestereo; // fsize is in samples, not bytes(gets translated before ioctl()) int InitUNIXDSPSound(int *rate, int bits, int fsize, int nfrags, int dev) @@ -92,9 +92,17 @@ if(ioctl(dspfd,SNDCTL_DSP_SETFRAGMENT,&x)==-1) FCEUI_printf("ERROR (continuing anyway)\n"); - x=0; + // Set mono sound. + // Some sound cards can only do stereo, so simulate stereo for these cards. + x=1; + fakestereo=0; FCEUI_printf("\n Setting mono sound..."); - if(ioctl(dspfd,SNDCTL_DSP_STEREO,&x)==-1) goto __disperror; + if(ioctl(dspfd,SNDCTL_DSP_CHANNELS,&x)==-1) goto __disperror; + if(x == 2) + { + printf("\n Couldn't set mono, faking stereo...\n"); + fakestereo = 1; + } FCEUI_printf("\n Setting playback rate of %d hz...",*rate); if(ioctl(dspfd,SNDCTL_DSP_SPEED,rate)==-1) goto __disperror; FCEUI_printf("Set to %d hz\n",*rate); @@ -110,9 +118,10 @@ } static int16 MBuffer[2048]; +static int16 fakebuffer[4098]; void WriteUNIXDSPSound(int32 *Buffer, int Count, int noblocking) { - int P,c; + int P,c,i; int32 *src=Buffer; if(format) @@ -130,13 +139,35 @@ c=Count<<1; } - //noblocking=!noblocking; // speed testing - if(noblocking) + // If a device can only support stereo, fake stereo by duplicating each item in the buffer. + if(fakestereo) + { + for (i=0; i <= c; i++ ) + { + fakebuffer[2*i] = MBuffer[i]; + fakebuffer[2*i+1] = MBuffer[i]; + } + c = c * 2; + // noblocking=!noblocking; // speed testing + if(noblocking) + { + struct audio_buf_info ai; + if(!ioctl(dspfd,SNDCTL_DSP_GETOSPACE,&ai)) + if(ai.bytes