Verified that audio has been initialized before playing sounds or ticking audio.
This commit is contained in:
@@ -144,6 +144,11 @@ SM64_LIB_FN void sm64_audio_init( uint8_t *rom ) {
|
||||
#define SAMPLES_LOW 528
|
||||
|
||||
extern SM64_LIB_FN uint32_t sm64_audio_tick( uint32_t numQueuedSamples, uint32_t numDesiredSamples, int16_t *audio_buffer ) {
|
||||
if ( !is_audio_initialized ) {
|
||||
DEBUG_PRINT("Attempted to tick audio, but sm64_audio_init() has not been called yet.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
update_game_sound();
|
||||
|
||||
u32 num_audio_samples = numQueuedSamples < numDesiredSamples ? SAMPLES_HIGH : SAMPLES_LOW;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "decomp/audio/load.h"
|
||||
#include "decomp/audio/load_dat.h"
|
||||
|
||||
bool is_audio_initialized = false;
|
||||
|
||||
extern void load_audio_banks( uint8_t *rom ) {
|
||||
uint8_t *rom2 = malloc( 0x800000 );
|
||||
|
||||
@@ -20,4 +22,6 @@ extern void load_audio_banks( uint8_t *rom ) {
|
||||
audio_init();
|
||||
sound_init();
|
||||
sound_reset( 0 );
|
||||
|
||||
is_audio_initialized = true;
|
||||
}
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern bool is_audio_initialized;
|
||||
|
||||
extern void load_audio_banks( uint8_t *rom );
|
||||
+7
-4
@@ -2,14 +2,17 @@
|
||||
|
||||
#include "decomp/audio/external.h"
|
||||
#include "debug_print.h"
|
||||
#include "load_audio_data.h"
|
||||
|
||||
SM64PlaySoundFunctionPtr g_play_sound_func = NULL;
|
||||
|
||||
extern void play_sound( uint32_t soundBits, f32 *pos ) {
|
||||
DEBUG_PRINT("$ play_sound(%d) request %d; pos %f %f %f\n", soundBits,sSoundRequestCount,pos[0],pos[1],pos[2]);
|
||||
sSoundRequests[sSoundRequestCount].soundBits = soundBits;
|
||||
sSoundRequests[sSoundRequestCount].position = pos;
|
||||
sSoundRequestCount++;
|
||||
if ( is_audio_initialized ) {
|
||||
DEBUG_PRINT("$ play_sound(%d) request %d; pos %f %f %f\n", soundBits,sSoundRequestCount,pos[0],pos[1],pos[2]);
|
||||
sSoundRequests[sSoundRequestCount].soundBits = soundBits;
|
||||
sSoundRequests[sSoundRequestCount].position = pos;
|
||||
sSoundRequestCount++;
|
||||
}
|
||||
|
||||
if ( g_play_sound_func ) {
|
||||
g_play_sound_func(soundBits, pos);
|
||||
|
||||
Reference in New Issue
Block a user