![]() |
|
[PATCH] Dual Audio Output support for XBMC (Eden Updated) - Printable Version +- XBMC Community Forum (http://forum.xbmc.org) +-- Forum: Development (/forumdisplay.php?fid=32) +--- Forum: Development (/forumdisplay.php?fid=93) +--- Thread: [PATCH] Dual Audio Output support for XBMC (Eden Updated) (/showthread.php?tid=86038) |
- schumi2004 - 2011-11-14 21:18 Leopold Wrote:It's easier than you might think. Start here Thanks, i'll try that. I'm running a pre-eden build here on a fusion system but the instructions are the same i guess? (if the patch gets out) First going to try a Dharma build instead. - Leopold - 2011-11-14 22:40 uspino Wrote:Awesome! Works as a charm. I had some trouble setting up the audio thrugh HDMI but the "plughw:1,7" ended up working for me. Yeah as mentioned previously this is a known issue. I have a problem that when playing music the hdmi audio output begins to stutter after playing for a while. The analog output is always fine though and videos through hdmi are also fine. Have you noticed this? Here's my debug log in case an expert knows what the problem is. I assume it has something to do with this: 19:08:25 T:3009342320 M:1343725568 DEBUG: CALSADirectSound::AddPackets - buffer underun (tried to write 1024 frames) 19:08:29 T:3009342320 M:1343852544 WARNING: CALSADirectSound::GetSpace - get space failed. err: -32 (Broken pipe) 19:08:42 T:3020216128 M:1343750144 WARNING: Previous line repeats 5 times. - ubuntuf4n - 2011-11-26 02:34 dharma patch works perfect on win7. - armitatz - 2011-11-28 19:31 Perfect! However I have a small note. I have a dv5 pavillion as a media center with xbmc live installed. This is connected through hdmi to an LG lw5500. Also it has an external sound blaster and the card is connected through spdif to my pioneer vsx1014 receiver. I have configured the first audio output to be to the hdmi and the second to be the creative optical. The two outputs have a small time difference caused by the tv!. The tv is delaying the sound because as all modern tv's applies image processing to the movie thus delaying the sound (~100-200ms). The receiver does not delay the sound. This creates the bathtub effect that has been described before in this thread. After I saw the files of the patch (I'm not an experienced programmer ...) I saw that the solution creates a second sound object and it is send to the second output. I don't know how to do it but perhaps by adding a second delay option in the sound delay menu and applying only to the second sound object the problem could be solved? - darkscout - 2011-11-28 20:11 armitatz Wrote:Perfect! Possible, but I doubt you'll ever get it perfect. But that does sound like it might be fun to dig into. It all depends on when they inject the sound delay. - armitatz - 2011-11-29 10:03 True. The first thing to do is to find the SetDelay function and how it is stored inside. After that I see two ways. A "dirty" one and a "cleaner". The dirty way could be to set the delay of hdmi always to 0.0 since the hdmi signal is handled by the tv's and they take care of the synchronization with the image. After that you could set the delay from the settings only for the second output that goes to the receiver or the external devices. The cleaner way would be to add to the gui a second slider for the second output and have a second delay value for the second output. So when the second player calls to the GetDelay function to give it the correct value. Since each sound objects has a GetDelay function it would be fairly easy for an interested reader
- armitatz - 2011-11-29 15:12 After some search I found the following in the https://github.com/xbmc/xbmc/blob/Dharma/xbmc/settings/VideoSettings.cpp there is the definition of CVideoSettings. There it has (at line 52) m_AudioDelay = 0.0f; by adding a m_AudioDelay2 = 0.0f; you could add a second setting that vould be used for the second audio. Also in https://github.com/xbmc/xbmc/blob/Dharma/xbmc/GUIDialogAudioSubtitleSettings.cpp at line 58 there is the definition of the menu item define AUDIO_SETTINGS_DELAY 3 you can do the following two steps step 1. adjust the #define block from #define AUDIO_SETTINGS_VOLUME 1 #define AUDIO_SETTINGS_VOLUME_AMPLIFICATION 2 #define AUDIO_SETTINGS_DELAY 3 #define AUDIO_SETTINGS_STREAM 4 #define AUDIO_SETTINGS_OUTPUT_TO_ALL_SPEAKERS 5 #define AUDIO_SETTINGS_DIGITAL_ANALOG 6// separator 7 #define SUBTITLE_SETTINGS_ENABLE 8 #define SUBTITLE_SETTINGS_DELAY 9 #define SUBTITLE_SETTINGS_STREAM 10 #define SUBTITLE_SETTINGS_BROWSER 11 #define AUDIO_SETTINGS_MAKE_DEFAULT 12 to #define AUDIO_SETTINGS_VOLUME 1 #define AUDIO_SETTINGS_VOLUME_AMPLIFICATION 2 #define AUDIO_SETTINGS_DELAY 3 #define AUDIO_SETTINGS_DELAY 4 #define AUDIO_SETTINGS_STREAM 5 #define AUDIO_SETTINGS_OUTPUT_TO_ALL_SPEAKERS 6 #define AUDIO_SETTINGS_DIGITAL_ANALOG 7 // separator 8 #define SUBTITLE_SETTINGS_ENABLE 9 #define SUBTITLE_SETTINGS_DELAY 10 #define SUBTITLE_SETTINGS_STREAM 11 #define SUBTITLE_SETTINGS_BROWSER 12 #define AUDIO_SETTINGS_MAKE_DEFAULT 13 step 2. add the following line AddSlider(AUDIO_SETTINGS_DELAY2, 297, &g_settings.m_currentVideoSettings.m_AudioDelay2, -g_advancedSettings.m_videoAudioDelayRange, .025f, g_advancedSettings.m_videoAudioDelayRange, FormatDelay); This way we add an extra menu item for the second delay and also we see that the audio delay setting is stored in the m_AudioDelay & m_AudioDelay2 variables. The problem is that I don't know how to compile the xbmc and apply patches in order to check these settings. I 'll try to find it in the next few days
- darkscout - 2011-11-29 16:02 Depending on: 1) How much I party this weekend. 2) How much I work on homework this weekend. I need to update my git repository to the latest anyway. I may take a stab at this. Even more fun: "Stadium Effect" turn the stereo on to a much lower volume and delay it by a second
- armitatz - 2011-11-30 12:18 After digging inside the code a bit I saw that there are lots of GetDelay() functions. My guess is that there are small delays used for syncing the audio and the video inside every frame and a big delay that is stored in the m_AudioDelay variable. So the timing is based on the m_AudioDelay (based on the setting) -/+ GetDelay(for micro adjustments). The above are my guesses. Perhaps if there was a better explanation somewhere we could sort it out. Also I found in the https://github.com/xbmc/xbmc/blob/master/xbmc/Application.h a declaration of int GetAudioDelay() const; (line 172) and in https://github.com/xbmc/xbmc/blob/master/xbmc/Application.cpp (line 5018) the function int CApplication::GetAudioDelay() const. This is the only place where the m_AudioDelay variable is mentioned and I can't find any other place. In order to have a second delay we could add a new line in Application.h int GetAudioDelay2() const; and in Application.cpp int CApplication::GetAudioDelay2() const { // converts delay2 to a percentage return int(((float)(g_settings.m_currentVideoSettings.m_AudioDelay2 + g_advancedSettings.m_videoAudioDelayRange)) / (2 * g_advancedSettings.m_videoAudioDelayRange)*100.0f + 0.5f); } this would use the m_AudioDelay2 as mentioned before. The last step would be to find where the second audio object is used and make any getdelay calls to be routed to a getdelay2 function that would use the m_AudioDelay2 variable. - DDDamian - 2011-11-30 18:34 If it helps anyone: many amps have an analog "Pre-out" which can be routed to your Zone 2 input via RCA patch cables. No sync issues, no dual outputs required. Great for second room, back porch, garden etc. |