bool CCoreAudioAEHALIOS::InitializePCMEncoded(ICoreAudioSource *pSource, AEAudioFormat &format) { if (!InitializePCM(pSource, format, false)) return false; return true; }
bool CCoreAudioAEHALIOS::Initialize(ICoreAudioSource *ae, bool passThrough, AEAudioFormat &format, AEDataFormat rawDataFormat, std::string &device, float initVolume) { m_ae = (CCoreAudioAE *)ae; if (!m_ae) return false; m_initformat = format; m_Passthrough = passThrough; m_encoded = false; m_OutputBufferIndex = 0; m_rawDataFormat = rawDataFormat; m_initVolume = initVolume; if (format.m_channelLayout.Count() == 0) { CLog::Log(LOGERROR, "CCoreAudioAEHALIOS::Initialize - Unable to open the requested channel layout"); return false; } if (device.find("CoreAudio:")) device.erase(0, strlen("CoreAudio:")); // If this is a passthrough (AC3/DTS) stream, attempt to handle it natively if (m_Passthrough) { m_encoded = false; } // If this is a PCM stream, or we failed to handle a passthrough stream natively, // prepare the standard interleaved PCM interface if (!m_encoded) { // If we are here and this is a passthrough stream, native handling failed. // Try to handle it as IEC61937 data over straight PCM (DD-Wav) bool configured = false; if (m_Passthrough) { CLog::Log(LOGDEBUG, "CCoreAudioAEHALIOS::Initialize: No suitable AC3 output format found. Attempting DD-Wav."); configured = InitializePCMEncoded(ae, format); } else { // Standard PCM data configured = InitializePCM(ae, format, true); } if (!configured) // No suitable output format was able to be configured return false; } if (m_audioGraph) m_audioGraph->ShowGraph(); m_Initialized = true; return true; }
bool CCoreAudioAEHALOSX::InitializePCMEncoded(ICoreAudioSource *pSource, AEAudioFormat &format, AudioDeviceID outputDevice) { // Prevent any other application from using this device. m_AudioDevice->SetHogStatus(true); // Try to disable mixing support. Effectiveness depends on the device. m_AudioDevice->SetMixingSupport(false); // Set the Sample Rate as defined by the spec. m_AudioDevice->SetNominalSampleRate((float)format.m_sampleRate); if (!InitializePCM(pSource, format, false, outputDevice)) return false; return true; }
bool CCoreAudioAEHALOSX::Initialize(ICoreAudioSource *ae, bool passThrough, AEAudioFormat &format, AEDataFormat rawDataFormat, std::string &device, float initVolume) { // Reset all the devices to a default 'non-hog' and mixable format. // If we don't do this we may be unable to find the Default Output device. // (e.g. if we crashed last time leaving it stuck in AC-3 mode) CCoreAudioHardware::ResetAudioDevices(); m_ae = (CCoreAudioAE*)ae; if (!m_ae) return false; m_initformat = format; m_rawDataFormat = rawDataFormat; m_Passthrough = passThrough; m_encoded = false; m_OutputBufferIndex = 0; m_initVolume = initVolume; if (format.m_channelLayout.Count() == 0) { CLog::Log(LOGERROR, "CCoreAudioAEHALOSX::Initialize - " "Unable to open the requested channel layout"); return false; } if (device.find("CoreAudio:") != std::string::npos) device.erase(0, strlen("CoreAudio:")); AudioDeviceID outputDevice = CCoreAudioHardware::FindAudioDevice(device); if (!outputDevice) { // Fall back to the default device if no match is found CLog::Log(LOGWARNING, "CCoreAudioAEHALOSX::Initialize: " "Unable to locate configured device, falling-back to the system default."); outputDevice = CCoreAudioHardware::GetDefaultOutputDevice(); if (!outputDevice) // Not a lot to be done with no device. TODO: Should we just grab the first existing device? return false; } // Attach our output object to the device m_AudioDevice->Open(outputDevice); m_AudioDevice->SetHogStatus(false); m_AudioDevice->SetMixingSupport(true); // If this is a passthrough (AC3/DTS) stream, attempt to handle it natively if (m_Passthrough) m_encoded = InitializeEncoded(outputDevice, format); // If this is a PCM stream, or we failed to handle a passthrough stream natively, // prepare the standard interleaved PCM interface if (!m_encoded) { // If we are here and this is a passthrough stream, native handling failed. // Try to handle it as IEC61937 data over straight PCM (DD-Wav) bool configured = false; if (m_Passthrough) { CLog::Log(LOGDEBUG, "CCoreAudioAEHALOSX::Initialize: " "No suitable AC3 output format found. Attempting DD-Wav."); configured = InitializePCMEncoded(ae, format, outputDevice); } else { // Standard PCM data configured = InitializePCM(ae, format, true, outputDevice); } // No suitable output format was able to be configured if (!configured) return false; } m_Initialized = true; return true; }