float AEDeviceEnumerationOSX::ScoreFormat(const AudioStreamBasicDescription &formatDesc, const AEAudioFormat &format) const { float score = 0; if (format.m_dataFormat == AE_FMT_AC3 || format.m_dataFormat == AE_FMT_DTS) { if (formatDesc.mFormatID == kAudioFormat60958AC3 || formatDesc.mFormatID == 'IAC3' || formatDesc.mFormatID == kAudioFormatAC3) { if (formatDesc.mSampleRate == format.m_sampleRate && formatDesc.mBitsPerChannel == CAEUtil::DataFormatToBits(format.m_dataFormat) && formatDesc.mChannelsPerFrame == format.m_channelLayout.Count()) { // perfect match score = FLT_MAX; } } } if (format.m_dataFormat == AE_FMT_AC3 || format.m_dataFormat == AE_FMT_DTS || format.m_dataFormat == AE_FMT_EAC3) { // we should be able to bistreaming in PCM if the samplerate, bitdepth and channels match if (formatDesc.mSampleRate == format.m_sampleRate && formatDesc.mBitsPerChannel == CAEUtil::DataFormatToBits(format.m_dataFormat) && formatDesc.mChannelsPerFrame == format.m_channelLayout.Count() && formatDesc.mFormatID == kAudioFormatLinearPCM) { score = FLT_MAX / 2; } } else { // non-passthrough, whatever works is fine if (formatDesc.mFormatID == kAudioFormatLinearPCM) { score += scoreSampleRate(formatDesc.mSampleRate, format.m_sampleRate); if (formatDesc.mChannelsPerFrame == format.m_channelLayout.Count()) score += 5; else if (formatDesc.mChannelsPerFrame > format.m_channelLayout.Count()) score += 1; if (format.m_dataFormat == AE_FMT_FLOAT || format.m_dataFormat == AE_FMT_FLOATP) { // for float, prefer the highest bitdepth we have if (formatDesc.mBitsPerChannel >= 16) score += (formatDesc.mBitsPerChannel / 8); } else { if (formatDesc.mBitsPerChannel == CAEUtil::DataFormatToBits(format.m_dataFormat)) score += 5; else if (formatDesc.mBitsPerChannel == CAEUtil::DataFormatToBits(format.m_dataFormat)) score += 1; } } } return score; }
float AEDeviceEnumerationOSX::ScoreFormat(const AudioStreamBasicDescription &formatDesc, const AEAudioFormat &format) const { float score = 0; if (format.m_streamInfo.m_type != CAEStreamInfo::STREAM_TYPE_NULL) { if (formatDesc.mBitsPerChannel != 16) return score; if (formatDesc.mSampleRate != format.m_sampleRate) return score; if (formatDesc.mChannelsPerFrame != format.m_channelLayout.Count()) return score; score += 5; if (formatDesc.mFormatID == kAudioFormat60958AC3 || formatDesc.mFormatID == 'IAC3' || formatDesc.mFormatID == kAudioFormatAC3) { score += 1; } } // non-passthrough, whatever works is fine else if (formatDesc.mFormatID == kAudioFormatLinearPCM) { score += scoreSampleRate(formatDesc.mSampleRate, format.m_sampleRate); if (formatDesc.mChannelsPerFrame == format.m_channelLayout.Count()) score += 5; else if (formatDesc.mChannelsPerFrame > format.m_channelLayout.Count()) score += 1; if (format.m_dataFormat == AE_FMT_FLOAT || format.m_dataFormat == AE_FMT_FLOATP) { // for float, prefer the highest bitdepth we have if (formatDesc.mBitsPerChannel >= 16) score += (formatDesc.mBitsPerChannel / 8); } else { if (formatDesc.mBitsPerChannel == CAEUtil::DataFormatToBits(format.m_dataFormat)) score += 5; else if (formatDesc.mBitsPerChannel == CAEUtil::DataFormatToBits(format.m_dataFormat)) score += 1; } } return score; }