This commit is contained in:
Nishi 2025-11-22 17:36:48 +09:00
commit 760db962ea
Signed by: nishi
GPG key ID: 27EF69B208EB9343
12 changed files with 273 additions and 154 deletions

46
audio/drv_ao.c Normal file
View file

@ -0,0 +1,46 @@
#include <MDE/Audio/Audio.h>
#ifdef USE_AO
#include <ao/ao.h>
typedef struct driver_context {
ao_sample_format format;
ao_device* device;
} driver_context_t;
#include "pthread/decl.c"
static void drv_write(driver_t* drv, void* data, int frames){
ao_play(drv->context.device, (char*)data, frames * 2 * 2);
}
static int drv_open(driver_t* drv){
int id;
ao_initialize();
drv->context.format.bits = 16;
drv->context.format.rate = MDEAudioRate;
drv->context.format.channels = 2;
drv->context.format.byte_format = AO_FMT_NATIVE;
drv->context.format.matrix = NULL;
id = ao_default_driver_id();
if((drv->context.device = ao_open_live(id, &drv->context.format, NULL)) == NULL){
MDEAudioClose(drv);
return 0;
}
drv->frames = 60 * MDEAudioRate / 1000;
return 1;
}
static void drv_close(driver_t* drv){
if(drv->context.device != NULL){
ao_close(drv->context.device);
}
}
#include "pthread/body.c"
#endif