medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 24384cc31a6ea43b7d92f0e6bf967c0b5cabf6d7
parent 24083ea511f6047397f14030a65d7b712555938f
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Jan 17 23:24:48 +0000

Some audio cleanup

Diffstat:
audio.cc | 10+++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/audio.cc b/audio.cc @@ -7,13 +7,12 @@ // TODO: check all soundstates are stopped after a certain one in the mixer loop? // queue normally looks like: -// dummy -> ... -> before_last_free -> ... -> last_free -> ... -> tail +// dummy -> ... -> last_free -> ... -> tail struct SoundStateFreeList { // TODO: order these // TODO: volatiles? we need something for mfences. SoundState * tail; SoundState * dummy; - SoundState * before_last_free; CACHE_LINE_PADDING; @@ -27,8 +26,7 @@ static void freelist_init( MemoryArena * arena, SoundStateFreeList * freelist ) ss_head = memarena_push_type( arena, SoundState ); *ss_head = { }; ss_head->stopped = true; - printf( "%p\n", ss_head ); - freelist->tail = freelist->dummy = freelist->before_last_free = freelist->last_free = ss_head; + freelist->tail = freelist->dummy = freelist->last_free = ss_head; write_barrier(); } @@ -43,7 +41,6 @@ static void pc( SoundStateFreeList * freelist, const char * msg ) { } static void freelist_add( SoundStateFreeList * freelist, SoundState * ss ) { - printf( "add to freelist\n" ); freelist->tail->next_free = ss; write_barrier(); freelist->tail = ss; @@ -78,7 +75,6 @@ static bool audio_alloc_soundstate( MemoryArena * arena, SoundState ** out ) { Sound audio_play_sound( MemoryArena * arena, SoundData data, bool loop ) { SoundState * ss; bool reused = audio_alloc_soundstate( arena, &ss ); - printf( "use freelist? %s. %p\n", reused ? "yes" : "no", ss ); const u32 new_generation = ss->generation + 1; @@ -167,7 +163,7 @@ void audio_mix( MemoryArena * arena, AudioOutputBuffer * buffer ) { } ss->num_played_samples += samples_to_write; - if( ss->num_played_samples >= ss->data.num_samples ) { + if( ss->num_played_samples == ss->data.num_samples ) { if( ss->loop ) { ss->num_played_samples %= ss->data.num_samples; }