src/sdl/audio_player.cc
/*
 * Creates an AudioPlayer by opening an audio device and using it to
 * construct an AudioPlayer.
 *
 * On success, returns an AudioPlayer. If an audio device cannot be opened,
 * returns NULL.
 */
Creates an AudioPlayer by opening an audio device and using it to
construct an AudioPlayer.

On success, returns an AudioPlayer. If an audio device cannot be opened,
returns NULL.
Creates an AudioPlayer by opening an audio device and using it to construct an AudioPlayer . On success returns an AudioPlayer . If an audio device cannot be opened returns NULL .
AudioPlayer *AudioPlayer::Create(void) {
  SDL_AudioSpec want, have;
  want.freq = 48000;
  want.format = AUDIO_F32SYS;
  want.channels = 1;
  want.samples = BUFFER_SIZE;
  want.callback = NULL;
  SDL_AudioDeviceID device = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0);
  if (device == 0) {
    fprintf(stderr, "Failed to open audio device\n");
    return NULL;
  }
  return new AudioPlayer(device);
}
AudioPlayer * AudioPlayer :: Create ( void ) { SDL_AudioSpec want , have ; want . freq = 48000 ; want . format = AUDIO_F32SYS ; want . channels = 1 ; want . samples = BUFFER_SIZE ; want . callback = NULL ; SDL_AudioDeviceID device = SDL_OpenAudioDevice ( NULL , 0 , & want , & have , 0 ) ; if ( device == 0 ) { fprintf ( stderr , " \n " ) ; return NULL ; } return new AudioPlayer ( device ) ; }
Creates an AudioPlayer by opening an audio device and using it to
 construct an AudioPlayer.
Creates an AudioPlayer by opening an audio device and using it to construct an AudioPlayer .
// The specs of the audio system this file expects are layed out here. // Init the device. // Since the device was opened successfully, we construct an AudioPlayer // and return it to the caller.