]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_coreaudio.c
changed r_speeds 2 and 3 reports to only list time spent during a single
[xonotic/darkplaces.git] / snd_coreaudio.c
index 9d9381253fdc42aa52f5d69023722a391ec4876d..1e36c7683e199809d5015d15b19bb6224cbfbca8 100644 (file)
@@ -20,12 +20,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ===========================================================================
 */
 
+#include "quakedef.h"
+
 #include <limits.h>
 #include <pthread.h>
 
 #include <CoreAudio/AudioHardware.h>
 
-#include "quakedef.h"
 #include "snd_main.h"
 
 
@@ -138,25 +139,13 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
 
        Con_Printf("Initializing CoreAudio...\n");
 
-       if (suggested != NULL)
-               memcpy (suggested, requested, sizeof (suggested));
-
-       // Get the device status and suggest any appropriate changes to format
-       propertySize = sizeof(streamDesc);
-       status = AudioDeviceGetProperty(outputDeviceID, 0, false, kAudioDevicePropertyStreamFormat, &propertySize, &streamDesc);
-       if (status)
+       if(requested->width != 2)
        {
-               Con_Printf("CoreAudio: AudioDeviceGetProperty() returned %d when getting kAudioDevicePropertyStreamFormat\n", status);
-               return false;
-       }
-       // Suggest proper settings if they differ
-       if (requested->channels != streamDesc.mChannelsPerFrame || requested->speed != streamDesc.mSampleRate || requested->width != streamDesc.mBitsPerChannel/8)
-       {
-               if (suggested != NULL)
+               // we can only do 16bit per sample for now
+               if(suggested != NULL)
                {
-                       suggested->channels = streamDesc.mChannelsPerFrame;
-                       suggested->speed = streamDesc.mSampleRate;
-                       suggested->width = streamDesc.mBitsPerChannel/8;
+                       memcpy (suggested, requested, sizeof (*suggested));
+                       suggested->width = 2;
                }
                return false;
        }
@@ -210,6 +199,7 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
                Con_Printf("CoreAudio: AudioDeviceGetProperty() returned %d when getting kAudioDevicePropertyStreamFormat\n", status);
                return false;
        }
+
        Con_DPrint ("   Hardware format:\n");
        Con_DPrintf("    %5d mSampleRate\n", (unsigned int)streamDesc.mSampleRate);
        Con_DPrintf("     %c%c%c%c mFormatID\n",
@@ -223,6 +213,18 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
        Con_DPrintf("    %5d mChannelsPerFrame\n", streamDesc.mChannelsPerFrame);
        Con_DPrintf("    %5d mBitsPerChannel\n", streamDesc.mBitsPerChannel);
 
+       // Suggest proper settings if they differ
+       if (requested->channels != streamDesc.mChannelsPerFrame || requested->speed != streamDesc.mSampleRate)
+       {
+               if (suggested != NULL)
+               {
+                       memcpy (suggested, requested, sizeof (*suggested));
+                       suggested->channels = streamDesc.mChannelsPerFrame;
+                       suggested->speed = streamDesc.mSampleRate;
+               }
+               return false;
+       }
+
        if(streamDesc.mFormatID != kAudioFormatLinearPCM)
        {
                Con_Print("CoreAudio: Default audio device doesn't support linear PCM!\n");