#include "../libpicofe/posix.h"\r
#include "../libpicofe/input.h"\r
#include "../libpicofe/fonts.h"\r
+#include "../libpicofe/sndout.h"\r
#include "../libpicofe/lprintf.h"\r
#include "../libpicofe/plat.h"\r
#include "emu.h"\r
int pico_inp_mode = 0;\r
int engineState = PGS_Menu;\r
\r
+static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
+\r
/* tmp buff to reduce stack usage for plats with small stack */\r
static char static_buff[512];\r
const char *rom_fname_reload;\r
PicoMessage = plat_status_msg_busy_next;\r
PicoMCDopenTray = emu_tray_open;\r
PicoMCDcloseTray = emu_tray_close;\r
+\r
+ sndout_init();\r
}\r
\r
void emu_finish(void)\r
pprof_finish();\r
\r
PicoExit();\r
+ sndout_exit();\r
+}\r
+\r
+static void snd_write_nonblocking(int len)\r
+{\r
+ sndout_write_nb(PsndOut, len);\r
+}\r
+\r
+void emu_sound_start(void)\r
+{\r
+ PsndOut = NULL;\r
+\r
+ if (currentConfig.EmuOpt & EOPT_EN_SOUND)\r
+ {\r
+ int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;\r
+\r
+ PsndRerate(Pico.m.frame_count ? 1 : 0);\r
+\r
+ printf("starting audio: %i len: %i stereo: %i, pal: %i\n",\r
+ PsndRate, PsndLen, is_stereo, Pico.m.pal);\r
+ sndout_start(PsndRate, is_stereo);\r
+ PicoWriteSound = snd_write_nonblocking;\r
+ plat_update_volume(0, 0);\r
+ memset(sndBuffer, 0, sizeof(sndBuffer));\r
+ PsndOut = sndBuffer;\r
+ }\r
+}\r
+\r
+void emu_sound_stop(void)\r
+{\r
+ sndout_stop();\r
+}\r
+\r
+void emu_sound_wait(void)\r
+{\r
+ sndout_wait();\r
}\r
\r
static void skip_frame(int do_audio)\r
\r
plat_video_loop_prepare();\r
pemu_loop_prep();\r
+ pemu_sound_start();\r
\r
/* number of ticks per frame */\r
if (Pico.m.pal) {\r
}\r
\r
pemu_loop_end();\r
+ emu_sound_stop();\r
\r
// pemu_loop_end() might want to do 1 frame for bg image,\r
// so free CD buffer here\r