rework audio handling, since it was flawed

This commit is contained in:
2025-06-23 12:50:10 +02:00
parent b446a43738
commit 6a1b4104cf
5 changed files with 111 additions and 169 deletions

View File

@@ -48,21 +48,20 @@ void game_init(gamedata* const dat) {
gametime_get(&gt.ts);
// initialize audio device
audiodevice* ad = audio_device_init(32000, AUDIO_S16, 1, 4096);
audio_device_init(32000, AUDIO_S16, 1, 4096);
*dat = (gamedata){
{0}, // rowdat
{0}, // row
gt, // time
ad, // audio_device
audio_wav_load(ad, "korobeiniki.wav"), // music
audio_wav_load(ad, "place.wav"), // place_sfx
0, // score
{0}, // nxt
0, // curr_idx
0, // sel_x
0, // sel_y
true, // run
{0}, // rowdat
{0}, // row
gt, // time
audio_wav_load("korobeiniki.wav"), // music
audio_wav_load("place.wav"), // place_sfx
0, // score
{0}, // nxt
0, // curr_idx
0, // sel_x
0, // sel_y
true, // run
};
// initialize the rows within the game data
@@ -109,7 +108,7 @@ void game_update(gamedata* const dat) {
if (ctime > timer_music) {
timer_music = ctime + (dat->music.ms);
audio_play(dat->audio_device, &dat->music);
audio_play(&dat->music);
}
// for rotation updating
@@ -145,7 +144,7 @@ void game_update(gamedata* const dat) {
void game_free(gamedata* const dat) {
audio_wav_unload(&dat->music);
audio_wav_unload(&dat->place_sfx);
audio_device_free(dat->audio_device);
audio_device_free();
// zero-out the rest of the data
*dat = (gamedata){0};