2025-11-22 17:36:48 +09:00
|
|
|
#include <MDE/Audio/Audio.h>
|
|
|
|
|
|
|
|
|
|
#ifdef USE_AO
|
|
|
|
|
#include <ao/ao.h>
|
|
|
|
|
|
|
|
|
|
typedef struct driver_context {
|
|
|
|
|
ao_sample_format format;
|
2025-11-22 17:56:29 +09:00
|
|
|
ao_device* device;
|
2025-11-22 17:36:48 +09:00
|
|
|
} driver_context_t;
|
|
|
|
|
|
|
|
|
|
#include "pthread/decl.c"
|
|
|
|
|
|
2025-11-22 17:56:29 +09:00
|
|
|
static void drv_write(driver_t* drv, void* data, int frames) {
|
2025-11-22 17:36:48 +09:00
|
|
|
ao_play(drv->context.device, (char*)data, frames * 2 * 2);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-22 17:56:29 +09:00
|
|
|
static int drv_open(driver_t* drv) {
|
2025-11-22 17:36:48 +09:00
|
|
|
int id;
|
|
|
|
|
|
|
|
|
|
ao_initialize();
|
|
|
|
|
|
2025-11-22 17:56:29 +09:00
|
|
|
drv->context.format.bits = 16;
|
|
|
|
|
drv->context.format.rate = MDEAudioRate;
|
|
|
|
|
drv->context.format.channels = 2;
|
2025-11-22 17:36:48 +09:00
|
|
|
drv->context.format.byte_format = AO_FMT_NATIVE;
|
2025-11-22 17:56:29 +09:00
|
|
|
drv->context.format.matrix = NULL;
|
2025-11-22 17:36:48 +09:00
|
|
|
|
|
|
|
|
id = ao_default_driver_id();
|
2025-11-22 17:56:29 +09:00
|
|
|
if((drv->context.device = ao_open_live(id, &drv->context.format, NULL)) == NULL) {
|
2025-11-22 17:36:48 +09:00
|
|
|
MDEAudioClose(drv);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-24 16:21:38 +09:00
|
|
|
drv->frames = 80 * MDEAudioRate / 1000;
|
2025-11-22 17:36:48 +09:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-22 17:56:29 +09:00
|
|
|
static void drv_close(driver_t* drv) {
|
|
|
|
|
if(drv->context.device != NULL) {
|
2025-11-22 17:36:48 +09:00
|
|
|
ao_close(drv->context.device);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "pthread/body.c"
|
|
|
|
|
#endif
|