1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Xodnizel
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
27 #include <sys/ioctl.h>
28 #include <linux/soundcard.h>
35 extern INLINE SpeedThrottle(void);
36 extern void pthread_yield(void);
37 extern void FCEUI_FrameSkip(int x);
42 // always have this call
43 INLINE void gp2x_sound_frame(void *blah, void *buff, int samples)
51 //static int sexy_in_function=0;
52 #define NumSexyBufferBuffers 2
53 struct timespec gp2x_sleep_ts;
56 struct timeval sleeptimer;
60 pthread_t gp2x_sexy_sound_thread=0;
61 int** SexyBufferBuffers=NULL;
62 int SexyBufferBufferCounts[NumSexyBufferBuffers];
63 int gp2x_sound_inited=0;
64 int gp2x_in_sound_thread=0;
65 extern unsigned long gp2x_dev[8];
67 pthread_cond_t gp2x_sound_cond=PTHREAD_COND_INITIALIZER;
68 pthread_mutex_t gp2x_sound_mutex = PTHREAD_MUTEX_INITIALIZER;
69 int zzdebug01_entry=0;
72 extern unsigned long fps;
73 extern unsigned long avg_fps;
74 extern unsigned long framesRendered;
75 extern unsigned long ticks;
79 void WriteSound(int32 *Buffer, int Count)
81 write(gp2x_dev[3], Buffer, Count<<1);
86 void* gp2x_write_sound(void* blah)
88 gp2x_in_sound_thread=1;
99 gp2x_in_sound_thread=0;
103 void SilenceSound(int n)
108 int InitSound(FCEUGI *gi)
110 Settings.sound=22050;
111 FCEUI_Sound(Settings.sound);
112 gp2x_sound_volume(soundvol, soundvol);
113 printf("InitSound() sound_rate: %d\n", Settings.sound);
122 uint32 GetMaxSound(void)
127 uint32 GetWriteSound(void)