src/sdl/audio_player.cc
/*
 * Adds a sample to the audio buffer.
 * If this sample fills the buffer, the buffer is queued to the audio device.
 */
Adds a sample to the audio buffer.
If this sample fills the buffer, the buffer is queued to the audio device.
Adds a sample to the audio buffer . If this sample fills the buffer the buffer is queued to the audio device .
void AudioPlayer::AddSample(float sample) {
  audio_buffer_[buffer_slot_] = sample;
  buffer_slot_++;
  if (buffer_slot_ >= BUFFER_SIZE) {
    buffer_slot_ = 0;
    SDL_QueueAudio(audio_device_, audio_buffer_, sizeof(float) * BUFFER_SIZE);
  }
  return;
}
void AudioPlayer :: AddSample ( float sample ) { audio_buffer_ [ buffer_slot_ ] = sample ; buffer_slot_ ++ ; if ( buffer_slot_ >= BUFFER_SIZE ) { buffer_slot_ = 0 ; SDL_QueueAudio ( audio_device_ , audio_buffer_ , sizeof ( float ) * BUFFER_SIZE ) ; } return ; }
Adds a sample to the audio buffer.
Adds a sample to the audio buffer .
// Add the sample to the buffer. // If the buffer has filled, we queue it to the device.