Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CoreAE: validate that matrix fit's in mixer size

  • Loading branch information...
commit 6fa41fdae912be624871f5e0c6b74e6806cfa03f 1 parent 5f4d052
@elupus elupus authored
Showing with 26 additions and 0 deletions.
  1. +26 −0 xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioMixMap.cpp
View
26 xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioMixMap.cpp
@@ -205,6 +205,32 @@ bool CCoreAudioMixMap::SetMixingMatrix(CAUMatrixMixer *mixerUnit,
if (!mixerUnit || !inputFormat || !fmt)
return false;
+ // Fetch the mixing unit size
+ UInt32 dims[2];
+ UInt32 size = sizeof(dims);
+ AudioUnitGetProperty(mixerUnit->GetUnit(),
+ kAudioUnitProperty_MatrixDimensions, kAudioUnitScope_Global, 0, dims, &size);
+
+ if(inputFormat->mChannelsPerFrame + channelOffset > dims[0])
+ {
+ CLog::Log(LOGERROR, "CCoreAudioMixMap::SetMixingMatrix - input format doesn't fit mixer size %u+%u > %u"
+ , inputFormat->mChannelsPerFrame, channelOffset, dims[0]);
+ return false;
+ }
+
+ if(fmt->mChannelsPerFrame > dims[1])
+ {
+ CLog::Log(LOGERROR, "CCoreAudioMixMap::SetMixingMatrix - ouput format doesn't fit mixer size %u > %u"
+ , fmt->mChannelsPerFrame, dims[0]);
+ return false;
+ }
+
+ if(fmt->mChannelsPerFrame < dims[1])
+ {
+ CLog::Log(LOGWARNING, "CCoreAudioMixMap::SetMixingMatrix - ouput format doesn't specify all outputs %u < %u"
+ , fmt->mChannelsPerFrame, dims[0]);
+ }
+
// Configure the mixing matrix
Float32* val = (Float32*)*mixMap;
for (UInt32 i = 0; i < inputFormat->mChannelsPerFrame; ++i)
Please sign in to comment.
Something went wrong with that request. Please try again.