Changeset 184 for trunk/src/helpers/syssound.c
- Timestamp:
- Jul 5, 2002, 9:13:36 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/syssound.c
r167 r184 21 21 * These are the general flags in the "MMPM2_AlarmSoundsData" 22 22 * application: 23 * 23 24 * -- If "EnableSounds" is FALSE, all system sounds are disabled. 24 25 * This defaults to TRUE (tested). 26 * 25 27 * -- If "ApplyVolumeToAll" is TRUE, the same volume is used for 26 28 * all sounds. This defaults to FALSE (tested). 29 * 27 30 * -- If ApplyVolumeToAll is TRUE, "Volume" is used for the 28 31 * global volume. Otherwise, the individual sound volumes … … 34 37 * 35 38 * Each sound data block in there consists of three elements: 39 * 36 40 + soundfile#description#volume 41 * 37 42 * where "description" is what is listed in the "Sound" object. 38 43 * "volume" is only used when "ApplyVolumeToAll" (above) is FALSE. … … 114 119 * 115 120 *@@added V0.9.0 [umoeller] 116 */ 117 118 ULONG sndParseSoundData(PSZ pszSoundData, // in: INI data from MMPM.INI 121 *@@changed V0.9.20 (2002-07-03) [umoeller]: optimized 122 */ 123 124 ULONG sndParseSoundData(PCSZ pszSoundData, // in: INI data from MMPM.INI 119 125 PSZ pszDescr, // out: sound description, as displayed 120 126 // in the "Sound" object (ptr may be NULL) … … 124 130 // even if "Global volume" is set in MMPM.INI. 125 131 { 126 P SZp1 = pszSoundData, p2;132 PCSZ p1 = pszSoundData, p2; 127 133 ULONG ulrc = 0; 128 134 // get sound file 129 p2 = strchr(p1, '#'); 130 if (p2) 135 if (p2 = strchr(p1, '#')) 131 136 { 132 137 ulrc++; 133 138 if (pszFile) 134 139 { 135 strncpy(pszFile, p1, p2 -p1);140 strncpy(pszFile, p1, p2 - p1); 136 141 pszFile[p2-p1] = '\0'; 137 142 } … … 139 144 140 145 // get sound description 141 p2 = strchr(p1, '#'); 142 if (p2) 146 if (p2 = strchr(p1, '#')) 143 147 { 144 148 ulrc++; … … 154 158 { 155 159 // individual volume settings per sound 156 sscanf(p1, "%lu", pulVolume); 160 *pulVolume = atoi(p1); // V0.9.20 (2002-07-03) [umoeller] 161 // sscanf(p1, "%lu", pulVolume); 157 162 ulrc++; 158 163 } … … 160 165 } 161 166 162 return (ulrc);167 return ulrc; 163 168 } 164 169 … … 173 178 VOID sndQueryMmpmIniPath(PSZ pszMMPM) // out: fully q'fied MMPM.INI 174 179 { 175 PSZ pszMMPMPath = getenv("MMBASE"); // V0.9.6 (2000-10-16) [umoeller]176 if (pszMMPMPath )180 PSZ pszMMPMPath; 181 if (pszMMPMPath = getenv("MMBASE")) // V0.9.6 (2000-10-16) [umoeller] 177 182 { 178 183 // variable set: … … 182 187 183 188 // kill semicolon if present 184 p = strchr(pszMMPM, ';'); 185 if (p) 189 if (p = strchr(pszMMPM, ';')) 186 190 *p = 0; 187 191 … … 211 215 HAB habDesktop = WinQueryAnchorBlock(HWND_DESKTOP); 212 216 CHAR szMMPM[CCHMAXPATH]; 213 HINI hini = NULLHANDLE;214 217 215 218 sndQueryMmpmIniPath(szMMPM); 216 219 217 hini = PrfOpenProfile(habDesktop, szMMPM); 218 return (hini); 220 return PrfOpenProfile(habDesktop, szMMPM); 219 221 } 220 222 … … 324 326 } 325 327 326 return (rc);328 return rc; 327 329 } 328 330 … … 345 347 BOOL sndWriteSoundData(HINI hiniMMPM, // in: MMPM.INI handle (from sndOpenMmpmIni) 346 348 USHORT usIndex, // in: sound index 347 P SZ pszDescr,// in: sound name or NULL for removal348 P SZ pszFile,// in: sound file349 PCSZ pszDescr, // in: sound name or NULL for removal 350 PCSZ pszFile, // in: sound file 349 351 ULONG ulVolume) // in: sound volume 350 352 { … … 359 361 sprintf(szData, "%s#%s#%lu", pszFile, pszDescr, ulVolume); 360 362 brc = PrfWriteProfileString(hiniMMPM, 361 MMINIKEY_SYSSOUNDS, szKey, 363 MMINIKEY_SYSSOUNDS, 364 szKey, 362 365 szData); 363 366 } … … 366 369 // delete entry 367 370 brc = PrfWriteProfileString(hiniMMPM, 368 MMINIKEY_SYSSOUNDS, szKey, 371 MMINIKEY_SYSSOUNDS, 372 szKey, 369 373 NULL); 370 374 … … 396 400 BOOL sndSetSystemSound(HAB hab, 397 401 USHORT usIndex, 398 P SZ pszDescr,399 P SZ pszFile,402 PCSZ pszDescr, 403 PCSZ pszFile, 400 404 ULONG ulVolume) 401 405 { 402 406 BOOL brc = FALSE; 403 HINI hiniMMPM = sndOpenMmpmIni(hab);404 if (hiniMMPM )407 HINI hiniMMPM; 408 if (hiniMMPM = sndOpenMmpmIni(hab)) 405 409 { 406 410 brc = sndWriteSoundData(hiniMMPM, usIndex, pszDescr, pszFile, ulVolume); 407 411 PrfCloseProfile(hiniMMPM); 408 412 } 413 409 414 return brc; 410 415 } … … 415 420 * in OS2SYS.INI. 416 421 * 422 * If so, and *ppszRealScheme is != NULL, it 423 * is set to the key name found. Since the 424 * scheme names are case-insensitive, this 425 * check is necessary to delete the original 426 * scheme for overwrites. The caller is 427 * responsible for free()ing *ppszRealScheme 428 * then. 429 * 417 430 *@@added V0.9.0 [umoeller] 418 */ 419 420 BOOL sndDoesSchemeExist(PSZ pszScheme) 421 { 431 *@@changed V0.9.20 (2002-07-03) [umoeller]: check has to be case-insensitive, fixed; changed prototype 432 */ 433 434 BOOL sndDoesSchemeExist(PCSZ pcszScheme, 435 PSZ *ppszRealScheme) // out: actual key name (ptr can be NULL) 436 { 437 BOOL fExists = FALSE; 438 PSZ pszKeysList; 439 if (!prfhQueryKeysForApp(HINI_SYSTEM, 440 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST" 441 &pszKeysList)) 442 { 443 PSZ pKey2 = pszKeysList; 444 while (*pKey2) 445 { 446 if (!stricmp(pKey2, pcszScheme)) 447 { 448 fExists = TRUE; 449 450 if (ppszRealScheme) 451 *ppszRealScheme = strdup(pKey2); 452 453 break; 454 } 455 456 pKey2 += strlen(pKey2)+1; // next key 457 } 458 459 free(pszKeysList); 460 } 461 462 return fExists; 463 464 /* old code V0.9.20 (2002-07-03) [umoeller] 422 465 // check in OS2SYS.INI's scheme list whether that 423 466 // scheme exists already … … 433 476 434 477 return (FALSE); 478 */ 479 435 480 } 436 481 … … 453 498 454 499 APIRET sndCreateSoundScheme(HINI hiniMMPM, // in: MMPM.INI handle (from sndOpenMmpmIni) 455 P SZ pszNewScheme)// in: name of new scheme500 PCSZ pszNewScheme) // in: name of new scheme 456 501 { 457 502 APIRET arc = NO_ERROR; … … 489 534 // file name and append the volume... 490 535 491 PSZ pSoundData = prfhQueryProfileData(hiniMMPM, 536 PSZ pSoundData; 537 if (pSoundData = prfhQueryProfileData(hiniMMPM, 492 538 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds" 493 539 pKey2, 494 NULL); 495 if (pSoundData) 540 NULL)) 496 541 { 497 542 sndParseSoundData(pSoundData, … … 521 566 PrfWriteProfileString(HINI_SYSTEM, 522 567 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST" 523 pszNewScheme, // key is scheme name568 (PSZ)pszNewScheme, // key is scheme name 524 569 szNewAppName); // data is new OS2SYS.INI application 525 570 } … … 562 607 563 608 APIRET sndLoadSoundScheme(HINI hiniMMPM, // in: HINI of ?:\MMOS2\MMPM.INI (PrfOpenProfile) 564 P SZ pszScheme)// in: scheme name609 PCSZ pszScheme) // in: scheme name 565 610 { 566 611 APIRET arc = NO_ERROR; … … 702 747 */ 703 748 704 APIRET sndDestroySoundScheme(P SZ pszScheme)749 APIRET sndDestroySoundScheme(PCSZ pszScheme) 705 750 { 706 751 APIRET arc = NO_ERROR; 707 752 708 753 // check in OS2SYS.INI's scheme list whether that 709 // scheme exists already 710 PSZ pszExisting = prfhQueryProfileData(HINI_SYSTEM, 754 // scheme exists 755 PSZ pszExisting; 756 if (pszExisting = prfhQueryProfileData(HINI_SYSTEM, 711 757 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST" 712 758 pszScheme, 713 NULL); 714 if (pszExisting) 759 NULL)) 715 760 { 716 761 // delete whole existing PM_SOUNDS_BLAHBLAH application … … 722 767 PrfWriteProfileString(HINI_SYSTEM, 723 768 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST" 724 pszScheme,769 (PSZ)pszScheme, 725 770 NULL); 726 771 free(pszExisting);
Note:
See TracChangeset
for help on using the changeset viewer.