diff options
author | Geoffrey McRae <gnif@xbmc.org> | 2012-05-09 18:36:54 +1000 |
---|---|---|
committer | Geoffrey McRae <gnif@xbmc.org> | 2012-05-10 21:42:16 +1000 |
commit | c51d48331766a14e6ce0a4ce661f9ab1715a73dc (patch) | |
tree | 05da998775eba2ff2052b3755ba6204cc95bdc83 | |
parent | 7f57410c2085cbf1a9d3d1c6f4ac91e84d983e89 (diff) |
[AE][ALSA] added code to try an open 'Digital' devices as HDMI
Some intel cards report HDMI devies as 'Digital' and not 'HDMI', so we need to
check them for HDMI if we cant open them with the iec958 mode string.
-rw-r--r-- | xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp | 74 |
1 files changed, 56 insertions, 18 deletions
diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp index 7c3aa21c79..5e23579ec6 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp @@ -598,24 +598,35 @@ void CAESinkALSA::EnumerateDevicesEx(AEDeviceInfoList &list) CAEDeviceInfo info; std::string devname = snd_pcm_info_get_name(pcminfo); + bool maybeHDMI = false; + + /* detect HDMI */ if (devname.find("HDMI") != std::string::npos) { info.m_deviceType = AE_DEVTYPE_HDMI; dev_index = hdmi_index++; sstr << "hdmi"; } - else if (devname.find("Digital") != std::string::npos || - devname.find("IEC958" ) != std::string::npos) - { - info.m_deviceType = AE_DEVTYPE_IEC958; - dev_index = iec958_index++; - sstr << "iec958"; - } else - { - info.m_deviceType = AE_DEVTYPE_PCM; - dev_index = pcm_index++; - sstr << "hw"; + { + /* detect IEC958 */ + + /* some HDMI devices (intel) report Digital for HDMI also */ + if (devname.find("Digital") != std::string::npos) + maybeHDMI = true; + + if (maybeHDMI || devname.find("IEC958" ) != std::string::npos) + { + info.m_deviceType = AE_DEVTYPE_IEC958; + dev_index = iec958_index; /* dont increment, it might be HDMI */ + sstr << "iec958"; + } + else + { + info.m_deviceType = AE_DEVTYPE_PCM; + dev_index = pcm_index++; + sstr << "hw"; + } } /* build the driver string to pass to ALSA */ @@ -626,6 +637,40 @@ void CAESinkALSA::EnumerateDevicesEx(AEDeviceInfoList &list) info.m_displayName = snd_ctl_card_info_get_name(ctlinfo); info.m_displayNameExtra = devname; + /* open the device for testing */ + int err = snd_pcm_open_lconf(&pcmhandle, info.m_deviceName.c_str(), SND_PCM_STREAM_PLAYBACK, 0, config); + + /* if open of possible IEC958 failed and it could be HDMI, try as HDMI */ + if (err < 0 && maybeHDMI) + { + /* check for HDMI if it failed */ + sstr.str(std::string()); + dev_index = hdmi_index; + + sstr << "hdmi"; + sstr << ":CARD=" << snd_ctl_card_info_get_id(ctlinfo) << ",DEV=" << dev_index; + info.m_deviceName = sstr.str(); + err = snd_pcm_open_lconf(&pcmhandle, info.m_deviceName.c_str(), SND_PCM_STREAM_PLAYBACK, 0, config); + + /* if it was valid, increment the index and set the type */ + if (err >= 0) + { + ++hdmi_index; + info.m_deviceType = AE_DEVTYPE_HDMI; + } + } + + /* if it's still IEC958, increment the index */ + if (info.m_deviceType == AE_DEVTYPE_IEC958) + ++iec958_index; + + /* final error check */ + if (err < 0) + { + CLog::Log(LOGINFO, "CAESinkALSA::EnumerateDevicesEx - Unable to open %s for capability detection", strHwName.c_str()); + continue; + } + /* see if we can get ELD for this device */ if (info.m_deviceType == AE_DEVTYPE_HDMI) { @@ -640,13 +685,6 @@ void CAESinkALSA::EnumerateDevicesEx(AEDeviceInfoList &list) } } - /* open the device for testing */ - if (snd_pcm_open_lconf(&pcmhandle, info.m_deviceName.c_str(), SND_PCM_STREAM_PLAYBACK, 0, config) < 0) - { - CLog::Log(LOGINFO, "CAESinkALSA::EnumerateDevicesEx - Unable to open %s for capability detection", info.m_deviceName.c_str()); - continue; - } - /* ensure we can get a playback configuration for the device */ if (snd_pcm_hw_params_any(pcmhandle, hwparams) < 0) { |