Add buffer size logging and overload listener.
This commit is contained in:
@@ -86,9 +86,20 @@ RageSound_CA::RageSound_CA()
|
|||||||
{
|
{
|
||||||
RageException::ThrowNonfatal("Couldn't create default output device.");
|
RageException::ThrowNonfatal("Couldn't create default output device.");
|
||||||
}
|
}
|
||||||
|
AudioStreamID sID = mOutputDevice->GetStreamByIndex( kAudioDeviceSectionOutput, 0 );
|
||||||
|
CAAudioHardwareStream stream( sID );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UInt32 frames = mOutputDevice->GetLatency(kAudioDeviceSectionOutput);
|
UInt32 frames = mOutputDevice->GetLatency(kAudioDeviceSectionOutput);
|
||||||
|
if (stream.HasProperty(0, kAudioDevicePropertyLatency))
|
||||||
|
{
|
||||||
|
UInt32 t, size = 4;
|
||||||
|
|
||||||
|
stream.GetPropertyData(0, kAudioDevicePropertyLatency, size, &t);
|
||||||
|
frames += t;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LOG->Warn("Stream reports no latency.");
|
||||||
mLatency = frames / 44100.0;
|
mLatency = frames / 44100.0;
|
||||||
LOG->Info("Frames of latency: %lu\n"
|
LOG->Info("Frames of latency: %lu\n"
|
||||||
"Seconds of latency: %f", frames, mLatency);
|
"Seconds of latency: %f", frames, mLatency);
|
||||||
@@ -98,9 +109,27 @@ RageSound_CA::RageSound_CA()
|
|||||||
delete mOutputDevice;
|
delete mOutputDevice;
|
||||||
RageException::ThrowNonfatal("Couldn't get Latency.");
|
RageException::ThrowNonfatal("Couldn't get Latency.");
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UInt32 bufferSize = mOutputDevice->GetIOBufferSize();
|
||||||
|
LOG->Info("I/O Buffer size: %lu", bufferSize);
|
||||||
|
}
|
||||||
|
catch (const CAException& e)
|
||||||
|
{
|
||||||
|
LOG->Warn("Could not determine buffer size.");
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mOutputDevice->AddPropertyListener(kAudioPropertyWildcardChannel,
|
||||||
|
kAudioPropertyWildcardSection,
|
||||||
|
kAudioDeviceProcessorOverload,
|
||||||
|
OverloadListener, this);
|
||||||
|
}
|
||||||
|
catch (const CAException& e)
|
||||||
|
{
|
||||||
|
LOG->Warn("Could not install the overload listener.");
|
||||||
|
}
|
||||||
|
|
||||||
AudioStreamID sID = mOutputDevice->GetStreamByIndex( kAudioDeviceSectionOutput, 0 );
|
|
||||||
CAAudioHardwareStream stream( sID );
|
|
||||||
|
|
||||||
vector<Desc> physicalFormats;
|
vector<Desc> physicalFormats;
|
||||||
GetPhysicalFormats( sID, physicalFormats );
|
GetPhysicalFormats( sID, physicalFormats );
|
||||||
@@ -189,6 +218,16 @@ OSStatus RageSound_CA::GetData(AudioDeviceID inDevice,
|
|||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSStatus RageSound_CA::OverloadListener(AudioDeviceID inDevice,
|
||||||
|
UInt32 inChannel,
|
||||||
|
Boolean isInput,
|
||||||
|
AudioDevicePropertyID inPropertyID,
|
||||||
|
void *inData)
|
||||||
|
{
|
||||||
|
LOG->Warn("Audio device overload.");
|
||||||
|
return noErr;
|
||||||
|
}
|
||||||
|
|
||||||
void RageSound_CA::SetupDecodingThread()
|
void RageSound_CA::SetupDecodingThread()
|
||||||
{
|
{
|
||||||
/* Increase the scheduling precedence of the decoder thread. */
|
/* Increase the scheduling precedence of the decoder thread. */
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ struct AudioTimeStamp;
|
|||||||
struct AudioBufferList;
|
struct AudioBufferList;
|
||||||
typedef unsigned long UInt32;
|
typedef unsigned long UInt32;
|
||||||
typedef UInt32 AudioDeviceID;
|
typedef UInt32 AudioDeviceID;
|
||||||
|
typedef UInt32 AudioDevicePropertyID;
|
||||||
|
typedef unsigned char Boolean;
|
||||||
typedef long OSStatus;
|
typedef long OSStatus;
|
||||||
class CAAudioHardwareDevice;
|
class CAAudioHardwareDevice;
|
||||||
class RageSoundBase;
|
class RageSoundBase;
|
||||||
@@ -25,6 +27,11 @@ private:
|
|||||||
AudioBufferList *outOutputData,
|
AudioBufferList *outOutputData,
|
||||||
const AudioTimeStamp *inOutputTime,
|
const AudioTimeStamp *inOutputTime,
|
||||||
void *inClientData);
|
void *inClientData);
|
||||||
|
static OSStatus OverloadListener(AudioDeviceID inDevice,
|
||||||
|
UInt32 inChannel,
|
||||||
|
Boolean isInput,
|
||||||
|
AudioDevicePropertyID inPropertyID,
|
||||||
|
void *inData);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void FillConverter(void *data, UInt32 dataByteSize);
|
void FillConverter(void *data, UInt32 dataByteSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user