update
This commit is contained in:
parent
da8f6313a9
commit
88c72ede58
2 changed files with 55 additions and 2 deletions
|
|
@ -48,5 +48,10 @@ macro(check_backend uppername name)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
check_backend(ALSA alsa)
|
#check_backend(ALSA alsa)
|
||||||
check_backend(AO ao)
|
#check_backend(AO ao)
|
||||||
|
target_compile_definitions(
|
||||||
|
MDEAudio
|
||||||
|
PRIVATE
|
||||||
|
USE_MA
|
||||||
|
)
|
||||||
|
|
|
||||||
48
audio/drv_ma.c
Normal file
48
audio/drv_ma.c
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#include <MDE/Audio/Audio.h>
|
||||||
|
|
||||||
|
#ifdef USE_MA
|
||||||
|
#include <miniaudio.c>
|
||||||
|
|
||||||
|
typedef struct driver {
|
||||||
|
MDEAudioHandler handler;
|
||||||
|
void* user;
|
||||||
|
ma_device device;
|
||||||
|
} driver_t;
|
||||||
|
|
||||||
|
void data_callback(ma_device* device, void* output, const void* input, ma_uint32 frame_count){
|
||||||
|
driver_t* drv = device->pUserData;
|
||||||
|
|
||||||
|
drv->handler(drv, drv->user, output, frame_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
MDEAudio MDEAudioOpen(MDEAudioHandler handler, void* user){
|
||||||
|
driver_t* drv = malloc(sizeof(*drv));
|
||||||
|
ma_device_config config = ma_device_config_init(ma_device_type_playback);
|
||||||
|
config.playback.format = ma_format_s16;
|
||||||
|
config.playback.channels = 2;
|
||||||
|
config.sampleRate = MDEAudioRate;
|
||||||
|
config.dataCallback = data_callback;
|
||||||
|
config.pUserData = drv;
|
||||||
|
|
||||||
|
drv->handler = handler;
|
||||||
|
drv->user = user;
|
||||||
|
|
||||||
|
if(ma_device_init(NULL, &config, &drv->device) != MA_SUCCESS){
|
||||||
|
free(drv);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return drv;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MDEAudioClose(MDEAudio handle){
|
||||||
|
driver_t* drv = handle;
|
||||||
|
ma_device_uninit(&drv->device);
|
||||||
|
free(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MDEAudioStart(MDEAudio handle){
|
||||||
|
driver_t* drv = handle;
|
||||||
|
ma_device_start(&drv->device);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue