NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums General General Discussion v
« Previous 1 … 24 25 26 27 28 … 159 Next »
Windows Audio - Toggling between 2.0 and 5.1 output

 
  • 0 Vote(s) - 0 Average
Windows Audio - Toggling between 2.0 and 5.1 output
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#1
2012-01-05, 08:05 PM
Has anybody ever come across a (command-line) tool for doing this? Or better yet, know what registry settings need to be tweaked to do it?

Iain
ElihuRozen
Offline

Senior Member

Massachusetts, USA
Posts: 514
Threads: 51
Joined: Apr 2006
#2
2012-01-06, 03:07 PM
A long time ago I wrote a GUI app to do this. It was just changing a registry setting. I don't have the source on my work computer, but will look for it later when I get home.

I glanced around the registry but couldn't find the setting. I think I found it originally by exporting my registry, changing the setting via the Control Panel applet, exporting the registry again & comparing the two text files.
ShiningDragon
Offline

Posting Freak

Germany
Posts: 1,493
Threads: 146
Joined: Sep 2005
#3
2012-01-06, 07:58 PM
Hi imilne Smile

Hopefully this one could bring you one step further:
http://superuser.com/a/347120

imilne Wrote:Or better yet, know what registry settings need to be tweaked to do it?
As far is i am understanding the situation, all the settings are storen within an own GUID within the registry, depending on the audio device.
So you have first to find out the correct GUID for every audio device/renderer before changing the registry to 2.0 or 5.1.
You like nPVR? Then please help pay the bills, and keep the project alive!

My happy NextPVR family

Frei nach Dieter Nuhr: Wenn man keine Ahnung hat, einfach mal die Fresse halten.
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#4
2012-01-07, 03:58 PM
Thanks for that. It's looking like that'll be the only way as it's specific to each audio device. Shame.

Iain
ShiningDragon
Offline

Posting Freak

Germany
Posts: 1,493
Threads: 146
Joined: Sep 2005
#5
2012-01-07, 05:47 PM
Yeah, i am sorry. This was one think i thought about using your AudioAdjust plugin (because my HDMI Renderer is connected to a 2.0 setup, while my realtek renderer is connected to a 5.1 setup).
But i can not imagine that it should be the only way to switch the channels. There are enough games outside (like wow as an example) which are able to switch the audio setup. But i can't find any infos for switches at this part.
You like nPVR? Then please help pay the bills, and keep the project alive!

My happy NextPVR family

Frei nach Dieter Nuhr: Wenn man keine Ahnung hat, einfach mal die Fresse halten.
ElihuRozen
Offline

Senior Member

Massachusetts, USA
Posts: 514
Threads: 51
Joined: Apr 2006
#6
2012-01-09, 02:37 AM
Hi,

I found my code. It's nine or ten years old. I'm not sure what version of Windows I was using back then. It is in C++. Even if you don't know C++, you can probably figure out what I did. One function reads it & the other sets it. I looks like it searches through the sub-keys until it finds the one with the right settings & uses that. If you have any questions, I'll try to answer.
Code:
int CSpeakersDlg::GetCurrentValue()
{
    HKEY hKeyPCI, hKey, hKey2;
    int nResult;
    DWORD dwIndex, dwSize, dwType, dwDataConf, dwDataType, dwNumKeys, dwLongest;
    char szName[MAX_PATH], *ptr;
    FILETIME ftTime;
    char *szKeys[10];

    nResult= RegOpenKeyEx(HKEY_CURRENT_CONFIG, "System\\CurrentControlSet\\Enum\\PCI",0, KEY_READ, &hKeyPCI);

    if (nResult != ERROR_SUCCESS)
    {
        return -1;
    }

    nResult = RegQueryInfoKey(hKeyPCI, NULL, NULL, NULL, &dwNumKeys, &dwLongest,NULL, NULL, NULL, NULL,NULL, NULL);
    // dwLongest doesn't include trailing NULL.  We add a second NULL at end
    ptr = (char *)malloc(sizeof(char) * ((dwLongest + 1) * dwNumKeys) + 1);
    
    for (dwIndex = 0; dwIndex < dwNumKeys; dwIndex++)
    {
        dwSize = sizeof(szName);// build char array of names, then go through that
        nResult = RegEnumKeyEx(hKeyPCI, dwIndex, szName, &dwSize, NULL, NULL, NULL, &ftTime);
        strcpy(ptr, szName);
        szKeys[dwIndex] = ptr;
        ptr += strlen(szKeys[dwIndex]) + 1;
    }
    *(++ptr) = 0;

    for (dwIndex = 0; dwIndex < dwNumKeys; dwIndex++)
    {
        wsprintf(szName, "System\\CurrentControlSet\\Enum\\PCI\\%s", szKeys[dwIndex]);
        nResult = RegOpenKeyEx(HKEY_CURRENT_CONFIG, szName, 0, KEY_READ, &hKey);
        if (nResult != ERROR_SUCCESS)
        {
            // error
        }
        dwSize = sizeof(szName);
        nResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL, NULL, NULL, &ftTime);
        strcat(szName, "\\DirectSound"); // \\Speaker Configuration");
        nResult = RegOpenKeyEx(hKey, szName, 0, KEY_READ, &hKey2);
        if (nResult == ERROR_SUCCESS)
        {// we have our key
            //csKey = szName;
            csKey = "System\\CurrentControlSet\\Enum\\PCI\\";
            csKey = csKey + szKeys[dwIndex] + "\\" + szName;
            wsprintf(szName, "%s\\Speaker Configuration", csKey);
            nResult = RegOpenKeyEx(HKEY_CURRENT_CONFIG, szName, 0, KEY_READ, &hKey);
            dwSize = sizeof(dwDataConf);
            nResult = RegQueryValueEx(hKey, "Speaker Configuration", NULL, &dwType, (unsigned char *)&dwDataConf, &dwSize);
            wsprintf(szName, "%s\\Speaker Type", csKey);
            nResult = RegOpenKeyEx(HKEY_CURRENT_CONFIG, szName, 0, KEY_READ, &hKey);
            dwSize = sizeof(dwDataType);
            nResult = RegQueryValueEx(hKey, "Speaker Type", NULL, &dwType, (unsigned char *)&dwDataType, &dwSize);
            if ((dwDataConf == 0x000140004) && (dwDataType == 1))
            {
                return 1;
            }
            else if ((dwDataConf == 0x00000001) && (dwDataType == 0))
            {
                return 0;
            }
            else if ((dwDataConf == 0x000a0004) && (dwDataType == 3))
            {
                return 2;
            }
            // do something with it - read values save key or key name?
            return -1;
        }
        
        
    }
    return -1;
}

void CSpeakersDlg::SetCurrentValue(int value)
{
    HKEY hKey;
    int nResult;
    DWORD dwType, dwConf;
    CString csName;

    if (value == 0)
    {
        dwConf = 0x00000001;
        dwType = 0;
    }
    else if (value == 1)
    {
        dwConf = 0x00140004;
        dwType = 1;
    }
    else if (value == 2)
    {
        dwConf = 0x000a0004;
        dwType = 3;
    }
    else
    {
        return;
    }

    csName = csKey + "\\Speaker Configuration";
    nResult = RegOpenKeyEx(HKEY_CURRENT_CONFIG, csName, 0, KEY_WRITE, &hKey);
    if (nResult != ERROR_SUCCESS)
    {
        return;
    }
    RegSetValueEx(hKey, "Speaker Configuration", 0, REG_DWORD, (unsigned char *)&dwConf, sizeof(DWORD));

    csName = csKey + "\\Speaker Type";
    nResult = RegOpenKeyEx(HKEY_CURRENT_CONFIG, csName, 0, KEY_WRITE, &hKey);
    if (nResult != ERROR_SUCCESS)
    {
        return;
    }
    RegSetValueEx(hKey, "Speaker Type", 0, REG_DWORD, (unsigned char *)&dwType, sizeof(DWORD));

    return;
}
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple PIP windows in Firefox Graham 0 1,684 2020-09-25, 11:45 AM
Last Post: Graham
  Why Do People Upgrade to Windows 10? ga_mueller 12 7,980 2019-08-11, 01:21 PM
Last Post: Ludron
  Windows 10 Ramdrive for buffer PaulW 1 1,692 2018-10-16, 10:45 PM
Last Post: gEd
  Downgrade Windows Reddwarf 9 4,297 2017-05-26, 07:12 PM
Last Post: tonyjohn29
  Windows 10 Preview removes command prompt p37307 13 5,477 2016-12-10, 03:49 AM
Last Post: johnsonx42
  Windows 10 Update September 29, 2016 — KB3194496 p37307 0 2,603 2016-09-30, 09:32 AM
Last Post: p37307
  Windows 10 Anniversary NPVR fullscreen flicker and freeze fix p37307 1 3,157 2016-08-11, 02:59 AM
Last Post: sub
  windows 10 jrhcom 3 3,234 2015-10-07, 10:43 PM
Last Post: jrhcom
  Windows 10 DVD Player app craigrs84 10 6,594 2015-09-10, 11:06 PM
Last Post: sub
  NPVR getting some props now that Windows Media Center is going away pcostanza 6 3,983 2015-08-24, 10:20 PM
Last Post: johnsonx42

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode