1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Ben Parnell
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 //#define BSIZE (32768-1024)
29 static volatile int16 AudioBuf[32768];
30 static volatile uint32 readoffs,writeoffs;
31 void fillaudio(void *udata, uint8 *stream, int len)
33 int16 *dest=(int16 *)stream;
38 *dest=AudioBuf[readoffs];
40 readoffs=(readoffs+1)&32767;
45 void WriteSound(int16 *Buffer, int Count, int NoWaiting)
49 while(writeoffs==((readoffs-BSIZE)&32767))
52 AudioBuf[writeoffs]=*Buffer;
53 writeoffs=(writeoffs+1)&32767;
65 if(_lbufsize<_ebufsize)
67 puts("Ack, lbufsize must not be smaller than ebufsize!");
70 if(_lbufsize<6 || _lbufsize>13)
72 puts("lbufsize out of range");
77 puts("ebufsize out of range");
80 memset(&spec,0,sizeof(spec));
81 if(SDL_InitSubSystem(SDL_INIT_AUDIO)<0)
86 if(_sound==1) _sound=44100;
88 spec.format=AUDIO_S16;
90 spec.samples=1<<_ebufsize;
91 spec.callback=fillaudio;
94 if(SDL_OpenAudio(&spec,0)<0)
97 SDL_QuitSubSystem(SDL_INIT_AUDIO);
101 BSIZE=32768-(1<<_lbufsize);
108 void SilenceSound(int n)
117 SDL_QuitSubSystem(SDL_INIT_AUDIO);
121 #include "../common/unixdsp.h"
123 void WriteSound(int32 *Buffer, int Count, int NoWaiting)
125 WriteUNIXDSPSound(Buffer, Count, NoWaiting);
136 if(InitUNIXDSPSound(&rate,_f8bit?0:1,8,8))