/* * MultiRexZ80 * * Multi-system Z80 emulator based on SMS Plus GX by Eke-Eke, itself based on * SMS Plus by Charles MacDonald. * * Default project license: GPL-2.0-or-later. File-specific notices below * are retained and take precedence for imported or derived components, * including MAME-derived code and other third-party modules. */ /* * libao output sound code. * License : MIT * See docs/MIT_license.txt for more information. */ #include #include #include #include #include "multirexz80.h" #include "sound_output.h" #include "shared.h" static ao_device *aodevice; static ao_sample_format aoformat; void Sound_Init() { ao_initialize(); memset(&aoformat, 0, sizeof(aoformat)); aoformat.bits = 16; aoformat.channels = 2; aoformat.rate = SOUND_FREQUENCY; aoformat.byte_format = AO_FMT_LITTLE; aodevice = ao_open_live(ao_default_driver_id(), &aoformat, NULL); // Live output if (!aodevice) aodevice = ao_open_live(ao_driver_id("null"), &aoformat, NULL); } void Sound_Update(int16_t* sound_buffer, unsigned long len) { ao_play(aodevice, (char*)sound_buffer, len); } void Sound_Close() { if (aodevice) { ao_close(aodevice); ao_shutdown(); } } void Sound_Pause() { Sound_Close(); } void Sound_Unpause() { Sound_Init(); }