Kodi Community Forum
[PATCH] Dual Audio Output support for XBMC (Eden Updated) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+--- Thread: [PATCH] Dual Audio Output support for XBMC (Eden Updated) (/showthread.php?tid=86038)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48


- armitatz - 2011-11-29

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 Big Grin


- armitatz - 2011-11-29

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 Smile


- darkscout - 2011-11-29

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 Smile


- armitatz - 2011-11-30

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

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.


- darkscout - 2011-11-30

How does this 'pre-out' get the HDMI signal that is going to my TV and route it via SPDIF to my receiver?


- DDDamian - 2011-11-30

Removed as a courtesy.


- armitatz - 2011-12-05

I tried in the weekend to compile the xbmc for windows inside visual studio and I managed to make it run. But when I try to play a video I get the error message in the log that "ffmpeg libraries cannot be found". I don't get errors in compiling the opengl debug version but I can't make it play a video.
I want to try to add a second delay option in the menu but I can't.
Does anybody know a way to make the ffmpeg libraries found?


- Jean-Max - 2011-12-05

Hello,

Congratulations Smile: It's a VERY interesting and so USEFUL work !

I should be so happy to have these dual audio (HDMI and Analogic) :

- on my ZBOX HD-ID11 (Openelec eden ion i386)
- and on my ZBOX Nano AD10 (Openlec eden fusion x64)

-> Do you think patch can be adapted to these 2 configurations ?

Thanks for all Smile


- darkscout - 2011-12-05

Shouldn't be a problem. If you're running Dharma just follow the instructions for adding a DA patch.

I've been busy with finals/tests/homework so I've been lazy but there is a Pre-Eden from about a month ago.


- schumi2004 - 2011-12-05

darkscout Wrote:Shouldn't be a problem. If you're running Dharma just follow the instructions for adding a DA patch.

I've been busy with finals/tests/homework so I've been lazy but there is a Pre-Eden from about a month ago.

You mean this ?
http://forum.xbmc.org/showpost.php?p=921827&postcount=282


- darkscout - 2011-12-05

Yep. That'll get you the Eden I made. It should work (it compiled). I need to update it. Maybe after finals (and I'll also add the sync as was suggested earlier).


- schumi2004 - 2011-12-06

darkscout Wrote:Yep. That'll get you the Eden I made. It should work (it compiled). I need to update it. Maybe after finals (and I'll also add the sync as was suggested earlier).

I gave it a try but it seems i'm missing some libs.
I think i'll wait when it's updated and has a easier way to apply patch. (linux isn't my thing)

Thanks anyway Wink


- apex82 - 2011-12-07

Ok so I have read all 33 pages and am still stuck trying to get this to work on ubuntu!

Using ubuntu 11.04

I copied the linux .bin posted on the first page over the xbmc.bin in my user/lib/xbmc folder. After that, I try to open XBMC and absolutely nothing happens... not even a black window or anything.

Please help
Thanks


- darkscout - 2011-12-07

apex82 Wrote:Ok so I have read all 33 pages and am still stuck trying to get this to work on ubuntu!

Using ubuntu 11.04

I copied the linux .bin posted on the first page over the xbmc.bin in my user/lib/xbmc folder. After that, I try to open XBMC and absolutely nothing happens... not even a black window or anything.

Please help
Thanks

I guess I'm missing where that's at.