===========================================================================
*/
+#include "quakedef.h"
+
#include <limits.h>
#include <pthread.h>
#include <CoreAudio/AudioHardware.h>
-#include "quakedef.h"
#include "snd_main.h"
unsigned int missingFrames;
missingFrames = submissionChunk - frameCount;
- if (developer.integer >= 1000)
+ if (developer.integer >= 1000 && vid_activewindow)
Con_Printf("audioDeviceIOProc: %u sample frames missing\n", missingFrames);
memset(&outBuffer[frameCount * snd_renderbuffer->format.channels], 0, missingFrames * sizeof(outBuffer[0]));
}
Con_Printf("Initializing CoreAudio...\n");
- // We only accept 16-bit samples for the moment
- if (requested->width != 2)
+ if(requested->width != 2)
{
- // Suggest a 16-bit format instead
- if (suggested != NULL)
+ // we can only do 16bit per sample for now
+ if(suggested != NULL)
{
- memcpy (suggested, requested, sizeof (suggested));
+ memcpy (suggested, requested, sizeof (*suggested));
suggested->width = 2;
}
-
return false;
}
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",
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");