introduce audio_model = "push" to twn.toml

This commit is contained in:
veclavtalica
2025-02-04 00:21:30 +03:00
parent 277d1b2e10
commit c6cbf941a2
4 changed files with 30 additions and 27 deletions

View File

@ -259,9 +259,8 @@ void audio_play(const char *path,
request.format = AUDIO_F32;
request.channels = 2;
request.samples = 4096;
#ifndef TWN_FEATURE_PUSH_AUDIO
request.callback = audio_callback;
#endif
if (!ctx.push_audio_model)
request.callback = audio_callback;
/* TODO: check for errors */
ctx.audio_device = SDL_OpenAudioDevice(NULL, 0, &request, &got, 0);
ctx.audio_stream_format = got.format;
@ -279,6 +278,8 @@ void audio_play(const char *path,
ctx.audio_initialized = true;
}
SDL_LockAudioDevice(ctx.audio_device);
if (channel) {
AudioChannelItem *pair = shgetp_null(ctx.audio_channels, channel);
@ -331,6 +332,8 @@ void audio_play(const char *path,
arrpush(ctx.unnamed_audio_channels, new_channel);
}
SDL_UnlockAudioDevice(ctx.audio_device);
}