Browse Source

Added SDLAudioInit().

woollybah 5 years ago
parent
commit
1ec124f139
4 changed files with 20 additions and 1 deletions
  1. 1 0
      sdl.mod/common.bmx
  2. 9 0
      sdl.mod/glue.c
  3. 7 0
      sdl.mod/sdl.bmx
  4. 3 1
      sdlfreeaudio.mod/glue.cpp

+ 1 - 0
sdl.mod/common.bmx

@@ -48,6 +48,7 @@ Extern
 	Function SDL_QuitSubSystem(flags:Int)
 	Function SDL_QuitSubSystem(flags:Int)
 	Function SDL_WasInit:Int(flags:Int)
 	Function SDL_WasInit:Int(flags:Int)
 	Function SDL_Quit()
 	Function SDL_Quit()
+	Function bmx_SDL_AudioInit:Int(name:String)
 
 
 	Function bmx_SDL_GetError:String()
 	Function bmx_SDL_GetError:String()
 	Function SDL_ClearError()
 	Function SDL_ClearError()

+ 9 - 0
sdl.mod/glue.c

@@ -149,3 +149,12 @@ BBString * bmx_SDL_GetClipboardText() {
 	}
 	}
 	return text;
 	return text;
 }
 }
+
+/* ----------------------------------------------------- */
+
+int bmx_SDL_AudioInit(BBString * name) {
+	char * n = bbStringToUTF8String(name);
+	int res = SDL_AudioInit(n);
+	bbMemFree(n);
+	return res;
+}

+ 7 - 0
sdl.mod/sdl.bmx

@@ -415,5 +415,12 @@ Function SDLClearError()
 	SDL_ClearError()
 	SDL_ClearError()
 End Function
 End Function
 
 
+Rem
+bbdoc: (re)Initialises the audio subsystem.
+End Rem
+Function SDLAudioInit:Int(name:String)
+	Return bmx_SDL_AudioInit(name)
+End Function
+
 ' shutdown all the subsystems
 ' shutdown all the subsystems
 atexit_(SDL_Quit)
 atexit_(SDL_Quit)

+ 3 - 1
sdlfreeaudio.mod/glue.cpp

@@ -38,7 +38,9 @@ struct sdlaudio : audiodevice {
 
 
 	int reset() {
 	int reset() {
 
 
-		SDL_InitSubSystem(SDL_INIT_AUDIO);
+		if (!SDL_WasInit(SDL_INIT_AUDIO)) {
+			SDL_InitSubSystem(SDL_INIT_AUDIO);
+		}
 		
 		
 		SDL_AudioSpec want;
 		SDL_AudioSpec want;