summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Michelotti <michelotti.matthew@gmail.com>2018-08-02 18:46:46 -0500
committerMatthew Michelotti <michelotti.matthew@gmail.com>2018-08-02 18:46:46 -0500
commited85c839eead3e94e50924744a9624e9b34403b1 (patch)
tree39da91c291cc77d877f18d07d10c8efe40b36fc9
parent1b43ff40db1d2eea4ed5f2325f19c2490bf6df02 (diff)
extracting sdl2::mixer::init call into its own function
-rw-r--r--gate/src/core/sdl/mod.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/gate/src/core/sdl/mod.rs b/gate/src/core/sdl/mod.rs
index 55d5710..b8b4ca5 100644
--- a/gate/src/core/sdl/mod.rs
+++ b/gate/src/core/sdl/mod.rs
@@ -27,7 +27,7 @@ use sdl2::{self, VideoSubsystem};
use sdl2::video::GLProfile;
use sdl2::video::gl_attr::GLAttr;
use sdl2::image::LoadTexture;
-use sdl2::mixer::{INIT_OGG, DEFAULT_CHANNELS, AUDIO_S16LSB};
+use sdl2::mixer::{Sdl2MixerContext, INIT_OGG, DEFAULT_CHANNELS, AUDIO_S16LSB};
use sdl2::render::{Renderer as SdlRenderer};
use gl;
@@ -59,9 +59,9 @@ pub fn run<AS: AppAssetId, AP: App<AS>>(info: AppInfo, mut app: AP) {
let sdl_context = sdl2::init().unwrap();
let video = sdl_context.video().unwrap();
let _sdl_audio = sdl_context.audio().unwrap();
- let _mixer_context = sdl2::mixer::init(INIT_OGG).unwrap();
+ let _mixer_context = mixer_init();
- init_mixer();
+ mixer_setup();
gl_hints(video.gl_attr());
let timer = sdl_context.timer().unwrap();
@@ -131,7 +131,11 @@ fn build_renderer<AS: AppAssetId>(info: &AppInfo, sdl_renderer: &SdlRenderer) ->
Renderer::<AS>::new(render_buffer, core_renderer)
}
-fn init_mixer() {
+fn mixer_init() -> Sdl2MixerContext {
+ sdl2::mixer::init(INIT_OGG).unwrap()
+}
+
+fn mixer_setup() {
sdl2::mixer::open_audio(44100, AUDIO_S16LSB, DEFAULT_CHANNELS, 1024).unwrap();
sdl2::mixer::allocate_channels(4);
}