mirror of https://github.com/bjornbytes/lovr.git
Add the ability to opt-out of default output device initialization;
This commit is contained in:
parent
782c22448e
commit
e3e7b265a3
|
@ -163,6 +163,7 @@ int luaopen_lovr_audio(lua_State* L) {
|
|||
luax_register(L, lovrAudio);
|
||||
luax_registertype(L, Source);
|
||||
|
||||
bool start = true;
|
||||
const char *spatializer = NULL;
|
||||
luax_pushconf(L);
|
||||
lua_getfield(L, -1, "audio");
|
||||
|
@ -170,13 +171,19 @@ int luaopen_lovr_audio(lua_State* L) {
|
|||
lua_getfield(L, -1, "spatializer");
|
||||
spatializer = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, -1, "start");
|
||||
start = lua_isnil(L, -1) || lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
lua_pop(L, 2);
|
||||
|
||||
if (lovrAudioInit(spatializer)) {
|
||||
lovrAudioSetDevice(AUDIO_PLAYBACK, NULL, 0, PLAYBACK_SAMPLE_RATE, SAMPLE_F32);
|
||||
lovrAudioStart(AUDIO_PLAYBACK);
|
||||
luax_atexit(L, lovrAudioDestroy);
|
||||
if (start) {
|
||||
lovrAudioSetDevice(AUDIO_PLAYBACK, NULL, 0, PLAYBACK_SAMPLE_RATE, SAMPLE_F32);
|
||||
lovrAudioStart(AUDIO_PLAYBACK);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -267,6 +267,7 @@ bool lovrAudioSetDevice(AudioType type, void* id, size_t size, uint32_t sampleRa
|
|||
ma_device_config config;
|
||||
|
||||
if (type == AUDIO_PLAYBACK) {
|
||||
sampleRate = sampleRate ? sampleRate : PLAYBACK_SAMPLE_RATE;
|
||||
lovrAssert(sampleRate == PLAYBACK_SAMPLE_RATE, "Playback sample rate must be %d", PLAYBACK_SAMPLE_RATE);
|
||||
lovrAssert(format == SAMPLE_F32, "Playback format must be f32");
|
||||
config = ma_device_config_init(ma_device_type_playback);
|
||||
|
|
|
@ -112,6 +112,10 @@ function lovr.boot()
|
|||
thread = true,
|
||||
timer = true
|
||||
},
|
||||
audio = {
|
||||
start = true,
|
||||
spatializer = 'simple'
|
||||
},
|
||||
graphics = {
|
||||
debug = false
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue