fwk_audio.h
// the callback to refill the (stereo) stream data
the callback to refill the (stereo) stream data
the callback to refill the ( stereo ) stream data
static void refill_stream(sts_mixer_sample_t* sample, void* userdata) {
    mystream_t* stream = (mystream_t*)userdata;
    switch( stream->type ) {
        default:
        break; case FLAC: {
            int sl = sample->length / 2; ;
            if (drflac_read_pcm_frames_f32(stream->flac, sl, stream->dataf) < sl) {
                drflac_seek_to_pcm_frame(stream->flac, 0);
            }
        }
        break; case WAV: {
            if (drwav_read_pcm_frames_s16(&stream->wav, sample->length, (short*)stream->data) < sample->length) {
                drwav_seek_to_pcm_frame(&stream->wav, 0);
            }
        }
        break; case MP3: {
            int sl = sample->length / 2; ;
            if (drmp3_read_pcm_frames_f32(&stream->mp3_, sl, stream->dataf) < sl) {
                drmp3_seek_to_pcm_frame(&stream->mp3_, 0);
            }
        }
        break; case OGG: {
            stb_vorbis *ogg = (stb_vorbis*)stream->ogg;
            if( stb_vorbis_get_samples_short_interleaved(ogg, 2, (short*)stream->data, sample->length) == 0 )  {
                stb_vorbis_seek(stream->ogg, 0);
            }
        }
        break; case MOD: {
            jar_mod_context_t *mod = (jar_mod_context_t*)&stream->mod;
            jar_mod_fillbuffer(mod, (ma_int16*)stream->data, sample->length / 2, 0);
        }
        break; case XM: {
            jar_xm_context_t *xm = (jar_xm_context_t*)stream->xm;
            jar_xm_generate_samples_16bit(xm, (short*)stream->data, sample->length / 2 );
        }
    }
}
static void refill_stream ( sts_mixer_sample_t * sample , void * userdata ) { mystream_t * stream = ( mystream_t * ) userdata ; switch ( stream -> type ) { default : break ; case FLAC : { int sl = sample -> length / 2 ; ; if ( drflac_read_pcm_frames_f32 ( stream -> flac , sl , stream -> dataf ) < sl ) { drflac_seek_to_pcm_frame ( stream -> flac , 0 ) ; } } break ; case WAV : { if ( drwav_read_pcm_frames_s16 ( & stream -> wav , sample -> length , ( short * ) stream -> data ) < sample -> length ) { drwav_seek_to_pcm_frame ( & stream -> wav , 0 ) ; } } break ; case MP3 : { int sl = sample -> length / 2 ; ; if ( drmp3_read_pcm_frames_f32 ( & stream -> mp3_ , sl , stream -> dataf ) < sl ) { drmp3_seek_to_pcm_frame ( & stream -> mp3_ , 0 ) ; } } break ; case OGG : { stb_vorbis * ogg = ( stb_vorbis * ) stream -> ogg ; if ( stb_vorbis_get_samples_short_interleaved ( ogg , 2 , ( short * ) stream -> data , sample -> length ) == 0 ) { stb_vorbis_seek ( stream -> ogg , 0 ) ; } } break ; case MOD : { jar_mod_context_t * mod = ( jar_mod_context_t * ) & stream -> mod ; jar_mod_fillbuffer ( mod , ( ma_int16 * ) stream -> data , sample -> length / 2 , 0 ) ; } break ; case XM : { jar_xm_context_t * xm = ( jar_xm_context_t * ) stream -> xm ; jar_xm_generate_samples_16bit ( xm , ( short * ) stream -> data , sample -> length / 2 ) ; } } }
the callback to refill the (stereo) stream data
the callback to refill the ( stereo ) stream data
/*sample->channels*/ /*sample->channels*/