medfall

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

commit a8e84c1c59f7d4c6dd65310d75a9d48011403c79
parent e07546f3bef49967da0d3c46c9831631c9f3f043
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue Dec 15 19:39:02 +0000

Clean up wave.cc

Diffstat:
wave.cc | 18+++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/wave.cc b/wave.cc @@ -41,6 +41,14 @@ struct WaveFMT { u16 bits_per_sample; }; +static bool wave_supported_format( const WaveFMT * fmt ) { + if( fmt->format != WAVEFORMAT_PCM ) return false; + if( fmt->num_channels != 1 && fmt->num_channels != 2 ) return false; + if( fmt->bits_per_sample != 16 ) return false; + + return true; +} + bool wave_decode( MemoryArena * arena, u8 * data, Sound * sound ) { WaveHeader * header = ( WaveHeader * ) data; @@ -60,14 +68,7 @@ bool wave_decode( MemoryArena * arena, u8 * data, Sound * sound ) { if( chunk->length != 16 ) return false; WaveFMT * fmt = ( WaveFMT * ) chunk; - - if( - fmt->format != WAVEFORMAT_PCM - || ( fmt->num_channels != 1 && fmt->num_channels != 2 ) - || fmt->bits_per_sample != 16 - ) { - return false; - } + if( !wave_supported_format( fmt ) ) return false; sound->num_channels = fmt->num_channels; sound->sample_rate = fmt->sample_rate; @@ -95,7 +96,6 @@ bool wave_decode( MemoryArena * arena, u8 * data, Sound * sound ) { // uninterleave the samples if( sound->num_channels == 2 ) { MEMARENA_SCOPED_CHECKPOINT( arena ); - printf( "%u\n", sound->num_samples * 2 ); s16 * scratch = memarena_push_many( arena, s16, sound->num_samples * 2 ); for( u32 i = 0; i < sound->num_samples; i++ ) {