Browse Source

Changes Around Audio Initialization

Peter Robinson 3 years ago
parent
commit
0972ed2948

+ 3 - 0
engine/source/audio/audio.cc

@@ -2459,6 +2459,9 @@ void shutdownContext()
 //--------------------------------------------------------------------------
 bool OpenALInit()
 {
+   Con::printSeparator();
+   Con::printf("Audio initialization:");
+
    OpenALShutdown();
 
    if(!OpenALDLLInit())

+ 5 - 0
engine/source/audio/audio_ScriptBinding.cc

@@ -175,6 +175,9 @@ ConsoleFunctionWithDocs(OpenALInitDriver, ConsoleBool, 1, 1, ())
 {
    if (Audio::OpenALInit())
    {
+       Con::printf("   OpenAL driver initialized successfully. Let's make some noise!");
+       Con::printf("");
+
       static bool registered = false;
       if (!registered) {
          ResourceManager->registerExtension(".wav", AudioBuffer::construct);
@@ -183,6 +186,8 @@ ConsoleFunctionWithDocs(OpenALInitDriver, ConsoleBool, 1, 1, ())
       registered = true;
       return true;
    }
+   Con::printf("   OpenAL driver failed to initialize... so quiet...");
+   Con::printf("");
    return false;
 }
 

+ 1 - 1
engine/source/platform/platformVideo.cc

@@ -194,7 +194,7 @@ bool Video::setDevice( const char *renderName, U32 width, U32 height, U32 bpp, b
          Game->textureResurrect();
          smNeedResurrect = false;
       }
-      Video::resetCanvas();
+      resetCanvas();
    }
 
     // Show Maximum Texture Size reported by the graphics hardware.

+ 1 - 18
library/Audio/audio.cs

@@ -1,6 +1,6 @@
 function Audio::create(%this)
 {
-	if(%this.initializeOpenAL())
+	if(OpenALInitDriver())
 	{
 	    %this.MusicOn = true;
 	    %this.SoundOn = true;
@@ -16,23 +16,6 @@ function Audio::destroy( %this )
 	OpenALShutdownDriver();
 }
 
-function Audio::initializeOpenAL()
-{
-    OpenALShutdownDriver();
-    echo("Initializing OpenAL Driver...");
-
-    if (!OpenALInitDriver())
-    {
-        echo("OpenAL driver failed to initialize... so quiet...");
-        return false;
-    }
-    else
-    {
-        echo("OpenAL driver initialized successfully! Let's make some noise!");
-		return true;
-    }
-}
-
 function Audio::setMasterVolume(%this, %volume)
 {
 	%this.MasterVolume = mClamp(%volume, 0, 1);

+ 38 - 51
toybox/AppCore/1/scripts/canvas.cs

@@ -24,62 +24,49 @@
 // initializeCanvas
 // Constructs and initializes the default canvas window.
 //------------------------------------------------------------------------------
-$canvasCreated = false;
 function initializeCanvas(%windowName)
 {
     // Don't duplicate the canvas.
-    if($canvasCreated)
+	if(!isObject(Canvas))
     {
-        error("Cannot instantiate more than one canvas!");
-        return;
-    }
-
-    videoSetGammaCorrection($pref::OpenGL::gammaCorrection);
-
-    if ( !createCanvas(%windowName) )
-    {
-        error("Canvas creation failed. Shutting down.");
-        quit();
-    }
+	    videoSetGammaCorrection($pref::OpenGL::gammaCorrection);
 
-    $pref::iOS::ScreenDepth = 32;
+	    if ( !createCanvas(%windowName) )
+	    {
+	        error("Canvas creation failed. Shutting down.");
+	        quit();
+	    }
 
-    if ($platform $= "iOS")
-    {
-        %resolution = $pref::iOS::Width SPC $pref::iOS::Height SPC 32;
-    }
-    else if ($platform $= "Android")
-    {
-    	%resolution = GetAndroidResolution();
-    }
-    else
-    {
-        if ( $pref::Video::windowedRes !$= "" )
-            %resolution = $pref::Video::windowedRes;
-        else
-            %resolution = $pref::Video::defaultResolution;
-    }
+	    if ($platform $= "iOS")
+	    {
+	        %resolution = $pref::iOS::Width SPC $pref::iOS::Height SPC $pref::iOS::ScreenDepth;
+	    }
+	    else if ($platform $= "Android")
+	    {
+	    	%resolution = GetAndroidResolution();
+	    }
+	    else
+	    {
+	        if ( $pref::Video::windowedRes !$= "" )
+	            %resolution = $pref::Video::windowedRes;
+	        else
+	            %resolution = $pref::Video::defaultResolution;
+	    }
 
-    if ($platform $= "windows" || $platform $= "macos")
-    {
-        setScreenMode( %resolution._0, %resolution._1, %resolution._2, $pref::Video::fullScreen );
-    }
-    else
-    {
-        setScreenMode( %resolution._0, %resolution._1, %resolution._2, false );
-    }
-
-    $canvasCreated = true;
-}
-
-//------------------------------------------------------------------------------
-// resetCanvas
-// Forces the canvas to redraw itself.
-//------------------------------------------------------------------------------
-function resetCanvas()
-{
-    if (isObject(Canvas))
-        Canvas.repaint();
+	    if ($platform $= "windows" || $platform $= "macos")
+	    {
+	        setScreenMode( %resolution._0, %resolution._1, %resolution._2, $pref::Video::fullScreen );
+	    }
+	    else
+	    {
+	        setScreenMode( %resolution._0, %resolution._1, %resolution._2, false );
+	    }
+	}
+	else
+	{
+		Canvas.setCanvasTitle(%windowName);
+		Canvas.repaint();
+	}
 }
 
 //------------------------------------------------------------------------------
@@ -91,7 +78,7 @@ function iOSResolutionFromSetting( %deviceType, %deviceScreenOrientation )
     // A helper function to get a string based resolution from the settings given.
     %x = 0;
     %y = 0;
-    
+
     %scaleFactor = $pref::iOS::RetinaEnabled ? 2 : 1;
 
     switch(%deviceType)
@@ -132,6 +119,6 @@ function iOSResolutionFromSetting( %deviceType, %deviceScreenOrientation )
                 %y =  $iOS::constant::iPhone5Width;
             }
     }
-   
+
     return %x @ " " @ %y;
 }

+ 1 - 5
toybox/AppCore/1/scripts/openal.cs

@@ -35,11 +35,9 @@ function initializeOpenAL()
     // Just in case it is already started.
     shutdownOpenAL();
 
-    echo("OpenAL Driver Init");
 
     if (!OpenALInitDriver())
     {
-        echo("OpenALInitDriver() failed");
         $Audio::initFailed = true;
     }
     else
@@ -50,8 +48,6 @@ function initializeOpenAL()
         // Set the channel volumes.
         for (%channel = 1; %channel <= 3; %channel++)
             alxSetChannelVolume(%channel, $pref::Audio::channelVolume[%channel]);
-
-        echo("OpenAL Driver Init Success");
     }
 }
 
@@ -61,4 +57,4 @@ function initializeOpenAL()
 function shutdownOpenAL()
 {
     OpenALShutdownDriver();
-}
+}