Is there a way to manage two audio cards ?
#1
(this is AudioEngine related)

I'd like a way to handle audio only files through a different card (let's say a high definition DAC).
Normal video file's audio is fine through HDMI out (so everything is balanced, filtered and adapted to video, courtesy of my AVR-260) but when I'm trying to hear some audio I'd prefer a "different" "audio path", one that skip 7.1 equalization (YPAO, Audissey, other similar stuff you know), volume balancing and filtering (i.e. 80 Hz and below to subwoofer) to send pure 2.0 "as is" to the amplifier stage (that's a Rotel RB-1552 in my case).
I know I can switch the front drivers from one source to another with a preamplifier... the whole problem is having XBMC to switch back and forth between 7.1 HDMI and 2.0 Analog, depending on which file I'm playing... and changing audio card in the process.

It's just me / there's a way to script that ?
Reply
#2
You can try my patch, it works on linux:

http://paste.ubuntu.com/1356690/

See forum thread:

http://forum.xbmc.org/showthread.php?tid=137359
Reply
#3
Thank you, I'll try it.
Reply
#4
I would like to try out the patch either, but it cannot be found in the paste bin. I would be thankful if somebody could post it again.

Carsten
Reply
#5
here is the patch again. don't know if it works with the latest frodo. sorry for not reading/ answering your pms.

Code:
diff --git a/language/English/strings.po b/language/English/strings.po
index d024f3d..90a189a 100644
--- a/language/English/strings.po
+++ b/language/English/strings.po
@@ -2275,7 +2275,13 @@ msgctxt "#597"
msgid "Repeat: All"
msgstr ""

-#empty strings from id 598 to 599
+msgctxt "#598"
+msgid "Audio output device stereo"
+msgstr "Stereo output device"
+
+msgctxt "#599"
+msgid "Audio output device music"
+msgstr "Music output device"

msgctxt "#600"
msgid "Rip audio CD"
diff --git a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp
index b73b43e..50dcdd2 100644
--- a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp
+++ b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp
@@ -23,6 +23,7 @@
#include <iterator>

#include "system.h"
+#include "Application.h"
#include "utils/log.h"
#include "utils/TimeUtils.h"
#include "utils/MathUtils.h"
@@ -115,7 +116,7 @@ CSoftAE::~CSoftAE()

IAESink *CSoftAE::GetSink(AEAudioFormat &newFormat, bool passthrough, std::string &device)
{
-  device = passthrough ? m_passthroughDevice : m_device;
+  device = passthrough ? m_passthroughDevice : device;

   /* if we are raw, force the sample rate */
   if (AE_IS_RAW(newFormat.m_dataFormat))
@@ -187,6 +188,8 @@ void CSoftAE::InternalOpenSink()
   bool wasRawPassthrough      = m_rawPassthrough;
   bool reInit                 = false;

+  int m_channels = 0;
+
   LoadSettings();

   /* initialize for analog output */
@@ -238,6 +241,8 @@ void CSoftAE::InternalOpenSink()
       }
     }

+    m_channels = newFormat.m_channelLayout.Count();
+
     /* if the stream is paused we cant use it for anything else */
     if (m_masterStream->m_paused)
       m_masterStream = NULL;
@@ -254,7 +259,23 @@ void CSoftAE::InternalOpenSink()
   if (m_transcode || m_rawPassthrough)
     device = m_passthroughDevice;
   else
+    {
+    if (g_application.IsPlayingAudio())
+    {
+    device = m_devicemusic;
+    }
+    else if (!g_application.IsPlayingAudio() && m_channels == 2)
+    {
+    device = m_devicestereo;
+    }
+    else
+    {
     device = m_device;
+    }
+    }

   CAESinkFactory::ParseDevice(device, driver);
   if (driver.empty() && m_sink)
@@ -518,6 +539,8 @@ void CSoftAE::OnSettingsChange(const std::string& setting)
{
   if (setting == "audiooutput.passthroughdevice" ||
       setting == "audiooutput.audiodevice"       ||
+      setting == "audiooutput.audiodevicestereo"       ||
+      setting == "audiooutput.audiodevicemusic"       ||
       setting == "audiooutput.mode"              ||
       setting == "audiooutput.ac3passthrough"    ||
       setting == "audiooutput.dtspassthrough"    ||
@@ -575,8 +598,14 @@ void CSoftAE::LoadSettings()

   /* get the output devices and ensure they exist */
   m_device            = g_guiSettings.GetString("audiooutput.audiodevice");
+  m_devicemusic            = g_guiSettings.GetString("audiooutput.audiodevicemusic");
+  m_devicestereo            = g_guiSettings.GetString("audiooutput.audiodevicestereo");
   m_passthroughDevice = g_guiSettings.GetString("audiooutput.passthroughdevice");
+
+
   VerifySoundDevice(m_device           , false);
+  VerifySoundDevice(m_devicemusic           , false);
+  VerifySoundDevice(m_devicestereo           , false);
   VerifySoundDevice(m_passthroughDevice, true );

   m_transcode = (
@@ -613,6 +642,7 @@ void CSoftAE::VerifySoundDevice(std::string& device, bool passthrough)

   /* if the device wasnt found, set it to the first viable output */
   device = firstDevice;
+  CLog::Log(LOGINFO, "CSoftAE::VerifySoundDevice device wasnt found - set it to the first viable output");
}

inline void CSoftAE::GetDeviceFriendlyName(std::string &device)
diff --git a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.h b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.h
index bb21d7d..db7f6d8 100644
--- a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.h
+++ b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.h
@@ -127,6 +127,8 @@ private:

   enum AEStdChLayout m_stdChLayout;
   std::string m_device;
+  std::string m_devicestereo;
+  std::string m_devicemusic;
   std::string m_passthroughDevice;
   std::string m_deviceFriendlyName;
   bool m_audiophile;
diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp
index 2d99d3b..e96f87b 100644
--- a/xbmc/settings/GUISettings.cpp
+++ b/xbmc/settings/GUISettings.cpp
@@ -508,6 +508,8 @@ void CGUISettings::Initialize()
#else
   AddSeparator(ao, "audiooutput.sep1");
   AddString   (ao, "audiooutput.audiodevice"      , 545, CStdString(CAEFactory::GetDefaultDevice(false)), SPIN_CONTROL_TEXT);
+  AddString   (ao, "audiooutput.audiodevicestereo", 598, CStdString(CAEFactory::GetDefaultDevice(false)), SPIN_CONTROL_TEXT);
+  AddString   (ao, "audiooutput.audiodevicemusic" , 599, CStdString(CAEFactory::GetDefaultDevice(false)), SPIN_CONTROL_TEXT);
   AddString   (ao, "audiooutput.passthroughdevice", 546, CStdString(CAEFactory::GetDefaultDevice(true )), SPIN_CONTROL_TEXT);
   AddSeparator(ao, "audiooutput.sep2");
#endif
diff --git a/xbmc/settings/GUIWindowSettingsCategory.cpp b/xbmc/settings/GUIWindowSettingsCategory.cpp
index f3dd58b..887ed8a 100644
--- a/xbmc/settings/GUIWindowSettingsCategory.cpp
+++ b/xbmc/settings/GUIWindowSettingsCategory.cpp
@@ -564,6 +564,18 @@ void CGUIWindowSettingsCategory::CreateSettings()
       FillInAudioDevices(pSetting);
       continue;
     }
+    else if (strSetting.Equals("audiooutput.audiodevicestereo"))
+    {
+      AddSetting(pSetting, group->GetWidth(), iControlID);
+      FillInAudioDevices(pSetting);
+      continue;
+    }
+    else if (strSetting.Equals("audiooutput.audiodevicemusic"))
+    {
+      AddSetting(pSetting, group->GetWidth(), iControlID);
+      FillInAudioDevices(pSetting);
+      continue;
+    }
     else if (strSetting.Equals("audiooutput.passthroughdevice"))
     {
       AddSetting(pSetting, group->GetWidth(), iControlID);
@@ -1965,6 +1977,16 @@ void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingC
#endif
     }
#if !defined(TARGET_DARWIN)
+    else if (strSetting.Equals("audiooutput.audiodevicestereo"))
+    {
+      CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
+      g_guiSettings.SetString("audiooutput.audiodevicestereo", m_AnalogAudioSinkMap[pControl->GetCurrentLabel()]);
+    }
+    else if (strSetting.Equals("audiooutput.audiodevicemusic"))
+    {
+      CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
+      g_guiSettings.SetString("audiooutput.audiodevicemusic", m_AnalogAudioSinkMap[pControl->GetCurrentLabel()]);
+    }
     else if (strSetting.Equals("audiooutput.passthroughdevice"))
     {
       CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
@@ -2859,10 +2881,19 @@ void CGUIWindowSettingsCategory::FillInPvrStartLastChannel(CSetting *pSetting)

void CGUIWindowSettingsCategory::FillInAudioDevices(CSetting* pSetting, bool Passthrough)
{
+  CStdString strSetting = pSetting->GetSetting();
+
   CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
   pControl->Clear();

-  CStdString currentDevice = Passthrough ? g_guiSettings.GetString("audiooutput.passthroughdevice") : g_guiSettings.GetString("audiooutput.audiodevice");
+  CStdString currentDevice;
+
+  if (Passthrough)
+    currentDevice = g_guiSettings.GetString("audiooutput.passthroughdevice");
+  else
+  {
+    currentDevice = g_guiSettings.GetString(strSetting);
+  }

   if (Passthrough)
   {

setup GUI to English or fix the English/strings.po link/ text
Reply
#6
Thank you!

I will try it out as soon as possible.

Greetings

Carsten
Reply
#7
cert_ I have successfully compiled your patch into my build but the other ALSA device does not show. I believe it may be my .asoundrc. Would you mind sharing the .asoundrc you refer to with "music" and "stereo" in your blog?
Reply

Logout Mark Read Team Forum Stats Members Help
Is there a way to manage two audio cards ?0