Skip to content

Commit

Permalink
Fix for SDL_Mixer init error
Browse files Browse the repository at this point in the history
SDL mixer initialization should be executed after open_audio() calling.
  • Loading branch information
garkimasera committed Jul 4, 2018
1 parent 310b641 commit 1f559d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions audio/src/lib.rs
Expand Up @@ -95,18 +95,18 @@ impl AudioPlayer {
}

fn init_device() -> sdl2::mixer::Sdl2MixerContext {
use sdl2::mixer::{INIT_OGG, DEFAULT_CHANNELS, AUDIO_S16LSB};

let mixer_context = sdl2::mixer::init(INIT_OGG).unwrap();
use sdl2::mixer::{INIT_OGG, DEFAULT_CHANNELS, AUDIO_S16LSB};

// Initialization for sound
let frequency = 44100;
let format = AUDIO_S16LSB; // signed 16 bit samples, in little-endian byte order
let channels = DEFAULT_CHANNELS; // Stereo
let chunk_size = 1024;
sdl2::mixer::open_audio(frequency, format, channels, chunk_size).unwrap();
sdl2::mixer::allocate_channels(1);
let mixer_context = sdl2::mixer::init(INIT_OGG).unwrap();

sdl2::mixer::allocate_channels(1);

mixer_context
}

Expand Down

0 comments on commit 1f559d3

Please sign in to comment.