Single button/command to switch audio output between analog, digital?
#16
any adding would be done by a dev - it's not like everybody under the sun can commit to our svn.

if you don't commit a patch (and get it accepted) you'll have to keep compiling it yourself. afaik t3ch only builds our svn so the key to getting it in there is getting us to accept it...
Reply
#17
Sorry. I wasn't implying I would be adding or commiting anything. Quite the opposite in fact.

I just wanted to make sure I wasn't wasting my and everyone elses time by writing a "me only" change that others may also find useful but be unable to use. I'd rather get it coded correctly for the benefit of all from the start, but I don't know enough about what I'm doing to know how my changes affect the rest of the code, hence my asking lots of (probably stupid) questions.

On the subject of stupid questions, what is the difference between what I'm doing (ie changing bits of the code in a txt editor) and a "patch"? If I did want to "commit a patch" is it just a matter of telling you what I added where, or is there a lot more to it?
Reply
#18
see, that wasn't so bad, was it?

i suggested to use application.cpp so that you could macro it to switch on startup. (you may need to delay that sequence until xbmc is fully operational, after the splash is gone.) plus from there, it'll always work as its a global action. so if you're watching a photo slide show with music, you could switch back and forth if you wanted. don't know why you would, but you could Smile

personally, i would also add a toggle action, say "ToggleAudioMode" which switches between the two. (I know you want to explicitly enable one or the other, so for that you need two discreet actions.)

re: passthru... if you have digital output enabled, the passthru options are available as settings in the gui. so, switch to digital output, and then enable them. those settings should stick, even if you switch back to analog. but obviously, they wont work unless you switch back to digital mode.

snippet assuming a toggle action:
Code:
// switch mode if digital output is allowed
int mode =  g_guiSettings.GetInt("audiooutput.mode");
if (g_audioConfig.HasDigitalOutput() && mode == AUDIO_ANALOG)
  g_guiSettings.SetInt("audiooutput.mode", AUDIO_DIGITAL);
else
  g_guiSettings.SetInt("audiooutput.mode", AUDIO_ANALOG);

// no change, so just return
if (g_guiSettings.GetInt("audiooutput.mode") == mode)
  return true;

// re-enable ac3 and dts passthru
if (g_guiSettings.GetInt("audiooutput.mode") == AUDIO_DIGITAL)
{
  g_audioConfig.SetAC3Enabled(g_guiSettings.GetBool("audiooutput.ac3passthrough"));
  g_audioConfig.SetDTSEnabled(g_guiSettings.GetBool("audiooutput.dtspassthrough"));
  // on xbox, these need to be written to the eeprom
  if (g_audioConfig.NeedsSave())
    g_audioConfig.Save();
}

Restart();
return true;
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#19
Just some programming Q's
why is "audiooutput.mode" an int, and not bool?
why do you want to copy g_guiSettings.GetInt("audiooutput.mode") to int mode? is it so you don't have to call that function so often?

/Tomas

kraqh3d Wrote:
Code:
// switch mode if digital output is allowed
int mode =  g_guiSettings.GetInt("audiooutput.mode");
if (g_audioConfig.HasDigitalOutput() && mode == AUDIO_ANALOG)
  g_guiSettings.SetInt("audiooutput.mode", AUDIO_DIGITAL);
else
  g_guiSettings.SetInt("audiooutput.mode", AUDIO_ANALOG);

// no change, so just return
if (g_guiSettings.GetInt("audiooutput.mode") == mode)
  return true;

// re-enable ac3 and dts passthru
if (g_guiSettings.GetInt("audiooutput.mode") == AUDIO_DIGITAL)
{
  g_audioConfig.SetAC3Enabled(g_guiSettings.GetBool("audiooutput.ac3passthrough"));
  g_audioConfig.SetDTSEnabled(g_guiSettings.GetBool("audiooutput.dtspassthrough"));
  // on xbox, these need to be written to the eeprom
  if (g_audioConfig.NeedsSave())
    g_audioConfig.Save();
}

Restart();
return true;
Reply
#20
why is it an int? i honestly dont know. just because? it could be a bool assuming theres only ever two modes.

i saved the "existing" mode as "mode" so that the code could check if anything's changed. if the mode's really changed then the

if (g_guiSettings.GetInt("audiooutput.mode") == mode)

test will fail and it'll go on to do the other stuff.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#21
OMG!!!1 we can free 3 bytes!!1 Wink

ok, I read it again and now I understand the second thing.


kraqh3d Wrote:why is it an int? i honestly dont know. just because? it could be a bool assuming theres only ever two modes.

i saved the "existing" mode as "mode" so that the code could check if anything's changed. if the mode's really changed then the

if (g_guiSettings.GetInt("audiooutput.mode") == mode)

test will fail and it'll go on to do the other stuff.
Reply
#22
You shouldn't have to touch the passthrough settings - they'll still be enabled even if you're using analog out (they just get ignored in that case).
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#23
Excellent!

Thanks for all your help everyone.

Hopefully I'll get a spare few minutes later today to give it all a try...I'll report back as to how it all goes.
Reply
#24
Unfortunately Mr. Spanner has just met Mr Works...Sad

I just discovered I need XDK and MS Visual C++ to be able to compile my own build. I've compiled a few Skins and I thought this would be the same process, but obviously it's not...bugger.

Oh well, Thanks again to everyone for their help, but the project is on hold until I can get the needed software.
Reply
#25
you can test it on the multi-platform version. you can build xbmc for windows on completely free software. nothing special required.
http://wiki.xbmc.org/?title=HOW-TO_compi...ource_code
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#26
Good idea, but my Windows box isn't set up for HTPC use...I don't even think it has an SPDIF output...so I wouldn't be able to test anything with it.
Reply
#27
Smile 
watzen Wrote:OMG!!!1 we can free 3 bytes!!1 Wink

Since the CPU is 32 bit it can only access 4 bytes. If it should access these 4 bytes individually it would need to know how to OR the content to get the value Wink I'm pretty sure that no compiler does this since it would slow down the application overall, so I guess it's safe to say that an INT and BOOL takes up 4 bytes and are equally fast to address. So nothing can be safed. Ofcourse logically it makes sense if indeed only two values are possible, to have it either as a BOOL or enum. type (eg. amAnalog, amDigital)
Reply
#28
Please stop bashing a n00b that is reading the guides on cplusplus.com, and is at least trying... Tongue

ultrabrutal Wrote:Since the CPU is 32 bit it can only access 4 bytes. If it should access these 4 bytes individually it would need to know how to OR the content to get the value Wink I'm pretty sure that no compiler does this since it would slow down the application overall, so I guess it's safe to say that an INT and BOOL takes up 4 bytes and are equally fast to address. So nothing can be safed. Ofcourse logically it makes sense if indeed only two values are possible, to have it either as a BOOL or enum. type (eg. amAnalog, amDigital)
Reply
#29
educating is not the same as bashing Wink
Reply
#30
As I haven't had any luck obtaining the required software to compile this for XBox myself, and the Atlantis new feature freeze is (I assume) over, could I ask if this can now become a "feature request"?

Hopefully most of the work has been done in the discussion above, and it won't take too long for someone to incorporate...pleaseHuh Smile
Reply

Logout Mark Read Team Forum Stats Members Help
Single button/command to switch audio output between analog, digital?0