https://git.reactos.org/?p=reactos.git;a=commitdiff;h=da528a660623f5a64c60e5...
commit da528a660623f5a64c60e5101556c89d73b0df28 Author: Stanislav Motylkov x86corez@gmail.com AuthorDate: Fri Jan 11 12:59:37 2019 +0300 Commit: Giannis Adamopoulos gadamopoulos@reactos.org CommitDate: Fri Jan 11 13:08:24 2019 +0200
[MMSYS] Properly select current MIDI output device
CORE-15582 --- dll/cpl/mmsys/audio.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/dll/cpl/mmsys/audio.c b/dll/cpl/mmsys/audio.c index fa3a3e1e12..e6a1358bd5 100644 --- a/dll/cpl/mmsys/audio.c +++ b/dll/cpl/mmsys/audio.c @@ -116,6 +116,18 @@ InitAudioDlg(HWND hwnd) } else { + WCHAR DefaultDevice[MAX_PATH] = {0}; + HKEY hKey; + DWORD dwSize = sizeof(DefaultDevice); + UINT DefaultIndex = 0; + + if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\Microsoft\Windows\CurrentVersion\Multimedia\MIDIMap", 0, KEY_READ, &hKey) == ERROR_SUCCESS) + { + RegQueryValueExW(hKey, L"szPname", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize); + DefaultDevice[MAX_PATH-1] = L'\0'; + RegCloseKey(hKey); + } + for (uIndex = 0; uIndex < DevsNum; uIndex++) { if (midiOutGetDevCaps(uIndex, &midiOutCaps, sizeof(midiOutCaps))) @@ -126,10 +138,11 @@ InitAudioDlg(HWND hwnd) if (CB_ERR != Res) { SendMessage(hCB, CB_SETITEMDATA, Res, (LPARAM) uIndex); - // TODO: Getting default device - SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0); + if (!wcsicmp(midiOutCaps.szPname, DefaultDevice)) + DefaultIndex = Res; } } + SendMessage(hCB, CB_SETCURSEL, (WPARAM) DefaultIndex, 0); } }