From 09ea1fe272aca6ebb6840f02765acd44ac3ecebc Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Sat, 7 Jan 2017 13:39:17 +0900 Subject: win32 --- win32/soundout.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 win32/soundout.c (limited to 'win32/soundout.c') diff --git a/win32/soundout.c b/win32/soundout.c new file mode 100644 index 0000000..bb57bc1 --- /dev/null +++ b/win32/soundout.c @@ -0,0 +1,44 @@ +#include "soundout.h" +#include "dsoundout.h" +#include "waveout.h" + +static void soundout_dsound_pause(struct sound_state *state, int pause) { + dsound_pause((struct dsound_state *)state->driver_state, pause); +} + +static void soundout_dsound_delete(struct sound_state *state) { + dsound_delete((struct dsound_state *)state->driver_state); + HeapFree(GetProcessHeap(), 0, state); +} + +static void soundout_waveout_pause(struct sound_state *state, int pause) { + waveout_pause((struct waveout_state *)state->driver_state, pause); +} + +static void soundout_waveout_delete(struct sound_state *state) { + waveout_delete((struct waveout_state *)state->driver_state); + HeapFree(GetProcessHeap(), 0, state); +} + +struct sound_state *sound_init(HWND hwnd, unsigned srate, unsigned sectlen, + sound_callback cbfunc, void *userptr) { + HANDLE heap = GetProcessHeap(); + struct sound_state *sound = HeapAlloc(heap, 0, sizeof(struct sound_state)); + if (!sound) return 0; + struct dsound_state *dsound = dsound_init(hwnd, srate, sectlen, cbfunc, userptr); + if (dsound) { + sound->driver_state = dsound; + sound->pause = soundout_dsound_pause; + sound->delete = soundout_dsound_delete; + return sound; + } + struct waveout_state *waveout = waveout_init(hwnd, srate, sectlen, cbfunc, userptr); + if (waveout) { + sound->driver_state = waveout; + sound->pause = soundout_waveout_pause; + sound->delete = soundout_waveout_delete; + return sound; + } + HeapFree(heap, 0, sound); + return 0; +} -- cgit v1.2.3