ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

audio.c
Go to the documentation of this file.
00001 /*
00002  *
00003  * PROJECT:         ReactOS Multimedia Control Panel
00004  * FILE:            dll/cpl/mmsys/mmsys.c
00005  * PURPOSE:         ReactOS Multimedia Control Panel
00006  * PROGRAMMER:      Thomas Weidenmueller <w3seek@reactos.com>
00007  *                  Johannes Anderwald <janderwald@reactos.com>
00008  *                  Dmitry Chapyshev <dmitry@reactos.org>
00009  */
00010 
00011 #include "mmsys.h"
00012 
00013 VOID
00014 InitAudioDlg(HWND hwnd)
00015 {
00016     WAVEOUTCAPSW waveOutputPaps;
00017     WAVEINCAPS waveInputPaps;
00018     MIDIOUTCAPS midiOutCaps;
00019     TCHAR szNoDevices[256];
00020     UINT DevsNum;
00021     UINT uIndex;
00022     HWND hCB;
00023     LRESULT Res;
00024 
00025     LoadString(hApplet, IDS_NO_DEVICES, szNoDevices, sizeof(szNoDevices) / sizeof(TCHAR));
00026 
00027     // Init sound playback devices list
00028     hCB = GetDlgItem(hwnd, IDC_DEVICE_PLAY_LIST);
00029 
00030     DevsNum = waveOutGetNumDevs();
00031     if (DevsNum < 1)
00032     {
00033         Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
00034         SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0);
00035     }
00036     else
00037     {
00038         WCHAR DefaultDevice[MAX_PATH] = {0};
00039         HKEY hKey;
00040         DWORD dwSize = sizeof(DefaultDevice);
00041         UINT DefaultIndex = 0;
00042 
00043         if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Multimedia\\Sound Mapper", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
00044         {
00045             RegQueryValueExW(hKey, L"Playback", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
00046             DefaultDevice[MAX_PATH-1] = L'\0';
00047             RegCloseKey(hKey);
00048         }
00049 
00050         for (uIndex = 0; uIndex < DevsNum; uIndex++)
00051         {
00052             if (waveOutGetDevCapsW(uIndex, &waveOutputPaps, sizeof(waveOutputPaps)))
00053                 continue;
00054 
00055             Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM) waveOutputPaps.szPname);
00056 
00057             if (CB_ERR != Res)
00058             {
00059                 SendMessage(hCB, CB_SETITEMDATA, Res, (LPARAM) uIndex);
00060                 if (!wcsicmp(waveOutputPaps.szPname, DefaultDevice))
00061                     DefaultIndex = Res;
00062             }
00063         }
00064         SendMessage(hCB, CB_SETCURSEL, (WPARAM) DefaultIndex, 0);
00065     }
00066 
00067     // Init sound recording devices list
00068     hCB = GetDlgItem(hwnd, IDC_DEVICE_REC_LIST);
00069 
00070     DevsNum = waveInGetNumDevs();
00071     if (DevsNum < 1)
00072     {
00073         Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
00074         SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0);
00075     }
00076     else
00077     {
00078         WCHAR DefaultDevice[MAX_PATH] = {0};
00079         HKEY hKey;
00080         DWORD dwSize = sizeof(DefaultDevice);
00081         UINT DefaultIndex = 0;
00082 
00083         if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Multimedia\\Sound Mapper", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
00084         {
00085             RegQueryValueExW(hKey, L"Record", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
00086             DefaultDevice[MAX_PATH-1] = L'\0';
00087             RegCloseKey(hKey);
00088         }
00089 
00090 
00091         for (uIndex = 0; uIndex < DevsNum; uIndex++)
00092         {
00093             if (waveInGetDevCaps(uIndex, &waveInputPaps, sizeof(waveInputPaps)))
00094                 continue;
00095 
00096             Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM) waveInputPaps.szPname);
00097 
00098             if (CB_ERR != Res)
00099             {
00100                 SendMessage(hCB, CB_SETITEMDATA, Res, (LPARAM) uIndex);
00101                 if (!wcsicmp(waveInputPaps.szPname, DefaultDevice))
00102                     DefaultIndex = Res;
00103             }
00104         }
00105         SendMessage(hCB, CB_SETCURSEL, (WPARAM) DefaultIndex, 0);
00106     }
00107 
00108     // Init MIDI devices list
00109     hCB = GetDlgItem(hwnd, IDC_DEVICE_MIDI_LIST);
00110 
00111     DevsNum = midiOutGetNumDevs();
00112     if (DevsNum < 1)
00113     {
00114         Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
00115         SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0);
00116     }
00117     else
00118     {
00119         for (uIndex = 0; uIndex < DevsNum; uIndex++)
00120         {
00121             if (midiOutGetDevCaps(uIndex, &midiOutCaps, sizeof(midiOutCaps)))
00122                 continue;
00123 
00124             Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM) midiOutCaps.szPname);
00125 
00126             if (CB_ERR != Res)
00127             {
00128                 SendMessage(hCB, CB_SETITEMDATA, Res, (LPARAM) uIndex);
00129                 // TODO: Getting default device
00130                 SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0);
00131             }
00132         }
00133     }
00134 }
00135 
00136 static UINT
00137 GetDevNum(HWND hControl, DWORD Id)
00138 {
00139     int iCurSel;
00140     UINT DevNum;
00141 
00142     iCurSel = SendMessage(hControl, CB_GETCURSEL, 0, 0);
00143 
00144     if (iCurSel == CB_ERR)
00145         return 0;
00146 
00147     DevNum = (UINT) SendMessage(hControl, CB_GETITEMDATA, iCurSel, 0);
00148     if (DevNum == (UINT) CB_ERR)
00149         return 0;
00150 
00151     if (mixerGetID((HMIXEROBJ)IntToPtr(DevNum), &DevNum, Id) != MMSYSERR_NOERROR)
00152         return 0;
00153 
00154     return DevNum;
00155 }
00156 
00157 /* Audio property page dialog callback */
00158 INT_PTR CALLBACK
00159 AudioDlgProc(HWND hwndDlg,
00160              UINT uMsg,
00161              WPARAM wParam,
00162              LPARAM lParam)
00163 {
00164     UNREFERENCED_PARAMETER(lParam);
00165     UNREFERENCED_PARAMETER(wParam);
00166     UNREFERENCED_PARAMETER(hwndDlg);
00167 
00168     switch(uMsg)
00169     {
00170         case WM_INITDIALOG:
00171         {
00172             UINT NumWavOut = waveOutGetNumDevs();
00173 
00174             InitAudioDlg(hwndDlg);
00175 
00176             if (!NumWavOut)
00177             {
00178                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVICE_PLAY_LIST),     FALSE);
00179                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVICE_REC_LIST),      FALSE);
00180                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVICE_MIDI_LIST),     FALSE);
00181                 EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_DEV_CHECKBOX), FALSE);
00182                 EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME1_BTN),          FALSE);
00183                 EnableWindow(GetDlgItem(hwndDlg, IDC_ADV2_BTN),             FALSE);
00184                 EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME2_BTN),          FALSE);
00185                 EnableWindow(GetDlgItem(hwndDlg, IDC_ADV1_BTN),             FALSE);
00186                 EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME3_BTN),          FALSE);
00187                 EnableWindow(GetDlgItem(hwndDlg, IDC_ADV3_BTN),             FALSE);
00188             }
00189         }
00190         break;
00191 
00192         case WM_COMMAND:
00193         {
00194             STARTUPINFO si;
00195             PROCESS_INFORMATION pi;
00196             WCHAR szPath[MAX_PATH];
00197 
00198             switch(LOWORD(wParam))
00199             {
00200                 case IDC_VOLUME1_BTN:
00201                 {
00202                     wsprintf(szPath, L"sndvol32.exe -d %d",
00203                              GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_PLAY_LIST), MIXER_OBJECTF_WAVEOUT));
00204 
00205                     ZeroMemory(&si, sizeof(si));
00206                     si.cb = sizeof(si);
00207                     si.wShowWindow = SW_SHOW;
00208 
00209                     CreateProcess(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
00210                 }
00211                 break;
00212 
00213                 case IDC_ADV2_BTN:
00214                 {
00215 
00216                 }
00217                 break;
00218 
00219                 case IDC_VOLUME2_BTN:
00220                 {
00221                     wsprintf(szPath, L"sndvol32.exe -r -d %d",
00222                              GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_REC_LIST), MIXER_OBJECTF_WAVEIN));
00223 
00224                     ZeroMemory(&si, sizeof(si));
00225                     si.cb = sizeof(si);
00226                     si.wShowWindow = SW_SHOW;
00227 
00228                     CreateProcess(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
00229                 }
00230                 break;
00231 
00232                 case IDC_ADV1_BTN:
00233                 {
00234 
00235                 }
00236                 break;
00237 
00238                 case IDC_VOLUME3_BTN:
00239                 {
00240                     wsprintf(szPath, L"sndvol32.exe -d %d",
00241                              GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_MIDI_LIST), MIXER_OBJECTF_MIDIOUT));
00242 
00243                     ZeroMemory(&si, sizeof(si));
00244                     si.cb = sizeof(si);
00245                     si.wShowWindow = SW_SHOW;
00246 
00247                     CreateProcess(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
00248                 }
00249                 break;
00250 
00251                 case IDC_ADV3_BTN:
00252                 {
00253 
00254                 }
00255                 break;
00256             }
00257         }
00258         break;
00259     }
00260 
00261     return FALSE;
00262 }

Generated on Fri May 25 2012 04:19:04 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.