source: trunk/src/helpers/syssound.c@ 20

Last change on this file since 20 was 18, checked in by umoeller, 25 years ago

Tons of updates.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 25.9 KB
Line 
1
2/*
3 *@@sourcefile syssound.c:
4 * this has code for querying and manipulating the
5 * system sounds, which are stored in MMPM.INI in
6 * the MMOS2 directory. Also, we have support for
7 * manipulating Warp 4 sound schemes in here too.
8 * This code works on Warp 3 also.
9 *
10 * Usage: All OS/2 programs.
11 *
12 * Some of this code used to be in XWorkplace's main\common.c,
13 * as far as the regular system sounds were concerned.
14 * However, all this code has been greatly reworked
15 * and extended with V0.9.0.
16 *
17 * <B>About system sound configuration data</B>
18 *
19 * The current system sounds are stored in ?:\MMOS2\MMPM.INI.
20 *
21 * These are the general flags in the "MMPM2_AlarmSoundsData"
22 * application:
23 * -- If "EnableSounds" is FALSE, all system sounds are disabled.
24 * This defaults to TRUE (tested).
25 * -- If "ApplyVolumeToAll" is TRUE, the same volume is used for
26 * all sounds. This defaults to FALSE (tested).
27 * -- If ApplyVolumeToAll is TRUE, "Volume" is used for the
28 * global volume. Otherwise, the individual sound volumes
29 * (below) will be used.
30 *
31 * "MMPM2_AlarmSounds" then has all the system sounds. The keys
32 * in that application are numerical indices, which are listed
33 * in syssound.h.
34 *
35 * Each sound data block in there consists of three elements:
36 + soundfile#description#volume
37 * where "description" is what is listed in the "Sound" object.
38 * "volume" is only used when "ApplyVolumeToAll" (above) is FALSE.
39 *
40 * We have functions in this code file for decoding/setting this
41 * (sndParseSoundData, sndQuerySystemSound, sndWriteSoundData,
42 * sndSetSystemSound).
43 *
44 * By contrast (and for no real reason), Warp 4 stores the
45 * "sound schemes" in OS2SYS.INI. I stuck with that for compatibility,
46 * although this prevents several users from having different
47 * sound schemes. What the heck.
48 *
49 * Anyways, the "PM_SOUND_SCHEMES_LIST" application is a directory of
50 * schemes, which in turn point to other applications in OS2SYS.INI
51 * which have the actual sound scheme data. All these applications
52 * appear to start with "PM_SOUND_xxx" by convention.
53 *
54 * Note that as opposed to the sound data in MMPM.INI, only the
55 * sound file name is stored here (not the three elements as
56 * described above). We slightly extend that mechanism to add an
57 * additional volume data field after the first null byte. This
58 * allows the default WPSound object to still be able to read
59 * the sound scheme data (it apparently uses PrfQueryProfileString)
60 * while the XWorkplace sound object replacement (XWPSound) can
61 * still store volume data as well.
62 *
63 * I have created more functions in this code file to easily load and
64 * store sound schemes (sndDoesSchemeExist, sndCreateSoundScheme,
65 * sndLoadSoundScheme, sndDestroySoundScheme).
66 *
67 * Note: Version numbering in this file relates to XWorkplace version
68 * numbering.
69 *
70 *@@header "helpers\syssound.h"
71 *@@added V0.9.0 [umoeller]
72 */
73
74#define OS2EMX_PLAIN_CHAR
75 // this is needed for "os2emx.h"; if this is defined,
76 // emx will define PSZ as _signed_ char, otherwise
77 // as unsigned char
78
79#define INCL_DOSERRORS
80#define INCL_WINSHELLDATA
81#include <os2.h>
82
83#include <stdlib.h>
84#include <stdio.h>
85#include <string.h>
86
87#include "setup.h" // code generation and debugging options
88
89#include "helpers\dosh.h"
90#include "helpers\prfh.h"
91
92#include "helpers\syssound.h"
93
94#pragma hdrstop
95
96/*
97 *@@category: Helpers\Profile (INI) helpers\System sounds
98 */
99
100/*
101 *@@ sndParseSoundData:
102 * this helper func splits the system sound data
103 * passed to it into three buffers.
104 * Each key data in there has the following format:
105 + soundfile#description#volume.
106 *
107 * This is copied into the three specified buffers.
108 * You can set any buffer pointer to NULL if you're
109 * not interested in that data.
110 *
111 * Returns the number of items successfully parsed,
112 * which should be 3.
113 *
114 *@@added V0.9.0 [umoeller]
115 */
116
117ULONG sndParseSoundData(PSZ pszSoundData, // in: INI data from MMPM.INI
118 PSZ pszDescr, // out: sound description, as displayed
119 // in the "Sound" object (ptr may be NULL)
120 PSZ pszFile, // out: sound file to (ptr may be NULL)
121 PULONG pulVolume) // out: sound volume (0-100). Note:
122 // this always returns the individual sound volume,
123 // even if "Global volume" is set in MMPM.INI.
124{
125 PSZ p1 = pszSoundData, p2;
126 ULONG ulrc = 0;
127 // get sound file
128 p2 = strchr(p1, '#');
129 if (p2)
130 {
131 ulrc++;
132 if (pszFile)
133 {
134 strncpy(pszFile, p1, p2-p1);
135 pszFile[p2-p1] = '\0';
136 }
137 p1 = p2+1;
138
139 // get sound description
140 p2 = strchr(p1, '#');
141 if (p2)
142 {
143 ulrc++;
144 if (pszDescr)
145 {
146 strncpy(pszDescr, p1, p2-p1);
147 pszDescr[p2-p1] = '\0';
148 }
149 p1 = p2+1;
150
151 // get volume (0-100)
152 if (pulVolume)
153 {
154 // individual volume settings per sound
155 sscanf(p1, "%lu", pulVolume);
156 ulrc++;
157 }
158 }
159 }
160
161 return (ulrc);
162}
163
164/*
165 *@@ sndOpenMmpmIni:
166 * this opens \MMOS2\MMPM.INI on the
167 * boot drive and returns the profile
168 * handle (or NULLHANDLE upon errors).
169 * Use PrfCloseProfile to close the
170 * profile again.
171 *
172 *@@added V0.9.1 (99-12-19) [umoeller]
173 *@@changed V0.9.6 (2000-10-16) [umoeller]: now using MMBASE environment variable
174 *@@changed V0.9.6 (2000-10-16) [umoeller]: added proper HAB param
175 *@@changed V0.9.7 (2000-12-17) [umoeller]: fixed broken MMBASE handling
176 */
177
178HINI sndOpenMmpmIni(HAB hab)
179{
180 HAB habDesktop = WinQueryAnchorBlock(HWND_DESKTOP);
181 CHAR szMMPM[CCHMAXPATH];
182 HINI hini = NULLHANDLE;
183
184 PSZ pszMMPMPath = getenv("MMBASE"); // V0.9.6 (2000-10-16) [umoeller]
185 if (pszMMPMPath)
186 {
187 // variable set:
188 PSZ p;
189
190 strcpy(szMMPM, pszMMPMPath); // V0.9.7 (2000-12-17) [umoeller]
191
192 // kill semicolon if present
193 p = strchr(szMMPM, ';');
194 if (p)
195 *p = 0;
196
197 strcat(szMMPM, "\\MMPM.INI");
198 }
199 else
200 // variable not set (shouldn't happen): try boot drive
201 sprintf(szMMPM, "%c:\\MMOS2\\MMPM.INI", doshQueryBootDrive());
202 hini = PrfOpenProfile(habDesktop, szMMPM);
203 return (hini);
204}
205
206/*
207 *@@ sndQuerySystemSound:
208 * this gets a system sound from the MMPM.INI file.
209 * usIndex must be the sound to query. The following
210 * MMSOUND_* IDs are declared in syssound.h:
211 *
212 * Default system sounds (syssound.h):
213 * -- MMSOUND_WARNING 0
214 * -- MMSOUND_INFORMATION 1
215 * -- MMSOUND_ERROR 2
216 * -- MMSOUND_ANIMATEOPEN 3
217 * -- MMSOUND_ANIMATECLOSE 4
218 * -- MMSOUND_DRAG 5
219 * -- MMSOUND_DROP 6
220 * -- MMSOUND_SYSTEMSTARTUP 7
221 * -- MMSOUND_SHUTDOWN 8
222 * -- MMSOUND_SHREDDER 9
223 * -- MMSOUND_LOCKUP 10
224 * -- MMSOUND_ALARMCLOCK 11
225 * -- MMSOUND_PRINTERROR 12
226 *
227 * BTW, these values match those of the WinAlarm call
228 * (WA_* values), but only the first three are documented
229 * in PMREF and pmwin.h (WA_WARNING, WA_NOTE, WA_ERROR).
230 *
231 * New XWorkplace system sounds:
232 * -- MMSOUND_XFLD_SHUTDOWN 555
233 * -- MMSOUND_XFLD_RESTARTWPS 556
234 * -- MMSOUND_XFLD_CTXTOPEN 558
235 * -- MMSOUND_XFLD_CTXTSELECT 559
236 * -- MMSOUND_XFLD_CNRDBLCLK 560
237 *
238 * The string buffers are recommended to be at least
239 * CCHMAXPATH in size.
240 *
241 *@@changed V0.9.0 [umoeller]: this used to be cmnQuerySystemSound
242 *@@changed V0.9.0 [umoeller]: exported stuff to sndParseSoundData
243 *@@changed V0.9.6 (2000-10-16) [umoeller]: added proper HAB param
244 */
245
246BOOL sndQuerySystemSound(HAB hab, // in: caller's anchor block
247 USHORT usIndex, // in: sound index to query
248 PSZ pszDescr, // out: sound description, as displayed
249 // in the "Sound" object (ptr may be NULL)
250 PSZ pszFile, // out: sound file to (ptr may be NULL)
251 PULONG pulVolume) // out: sound volume (0-100).
252 // If the "Global volume" flag is
253 // set in MMPM.INI, this will return the global
254 // volume instead. Ptr may be NULL also.
255{
256 BOOL rc = FALSE;
257 HINI hiniMMPM = sndOpenMmpmIni(hab);
258
259 #ifdef DEBUG_SOUNDS
260 _Pmpf((__FUNCTION__ ": entering, hiniMMPM is 0x%lX", hiniMMPM));
261 #endif
262
263 if (hiniMMPM)
264 {
265 CHAR szData[1000];
266 CHAR szData2[100];
267 CHAR szKey[10];
268 sprintf(szKey, "%d", usIndex);
269 PrfQueryProfileString(hiniMMPM,
270 MMINIKEY_SOUNDSETTINGS, "EnableSounds",
271 "TRUE", // default string
272 szData2, sizeof(szData2));
273 #ifdef DEBUG_SOUNDS
274 _Pmpf((" sounds enabled: %s", szData2));
275 #endif
276 if (strcmp(szData2, "TRUE") == 0)
277 // sounds enabled at all?
278 if (PrfQueryProfileString(hiniMMPM,
279 MMINIKEY_SYSSOUNDS, szKey,
280 ".",
281 szData, sizeof(szData)-1) > 3)
282 {
283 sndParseSoundData(szData,
284 pszDescr,
285 pszFile,
286 pulVolume);
287
288 // if "global volume" has been enabled,
289 // we do not return the value specified
290 // here, but the global value
291 PrfQueryProfileString(hiniMMPM,
292 MMINIKEY_SOUNDSETTINGS, "ApplyVolumeToAll",
293 "FALSE",
294 szData2, sizeof(szData2));
295 if (strcmp(szData2, "FALSE") != 0)
296 {
297 // global volume setting for all sounds
298 PrfQueryProfileString(hiniMMPM,
299 MMINIKEY_SOUNDSETTINGS, "Volume",
300 "100",
301 szData2, sizeof(szData2));
302 sscanf(szData2, "%lu", pulVolume);
303 }
304
305 rc = TRUE;
306 }
307
308 PrfCloseProfile(hiniMMPM);
309 }
310
311 return (rc);
312}
313
314/*
315 *@@ sndWriteSoundData:
316 * this sets a system sound in MMPM.INI.
317 * Gets called by sndSetSystemSound. As opposed
318 * to that function, this needs the profile handle
319 * of MMPM.INI.
320 *
321 * If (pszDescr == NULL), that sound entry is removed.
322 *
323 * Returns the return value of PrfWriteProfileString.
324 *
325 *@@added V0.9.0 [umoeller]
326 *@@changed V0.9.1 (99-12-30) [umoeller]: added delete support
327 *@@changed V0.9.6 (2000-10-16) [umoeller]: added MMPM/2 notify
328 */
329
330BOOL sndWriteSoundData(HINI hiniMMPM, // in: MMPM.INI handle (from sndOpenMmpmIni)
331 USHORT usIndex, // in: sound index
332 PSZ pszDescr, // in: sound name or NULL for removal
333 PSZ pszFile, // in: sound file
334 ULONG ulVolume) // in: sound volume
335{
336 BOOL brc = FALSE;
337 CHAR szKey[10];
338
339 sprintf(szKey, "%d", usIndex);
340 if (pszDescr)
341 {
342 CHAR szData[1000];
343 // format: soundfile#description#volume
344 sprintf(szData, "%s#%s#%lu", pszFile, pszDescr, ulVolume);
345 brc = PrfWriteProfileString(hiniMMPM,
346 MMINIKEY_SYSSOUNDS, szKey,
347 szData);
348 }
349 else
350 // pszDescr == NULL:
351 // delete entry
352 brc = PrfWriteProfileString(hiniMMPM,
353 MMINIKEY_SYSSOUNDS, szKey,
354 NULL);
355
356 if (brc)
357 // success:
358 if (usIndex < 100)
359 // one of the default OS/2 sounds has changed:
360 // we then need to notify MMPM/2...
361 // this is done by calling WinAlarm with 1000+index!
362 // sick stuff..
363 WinAlarm(HWND_DESKTOP, usIndex+1000); // V0.9.6 (2000-10-16) [umoeller]
364
365 return (brc);
366}
367
368/*
369 *@@ sndSetSystemSound:
370 * this sets a system sound in MMPM.INI by
371 * calling sndWriteSoundData.
372 * Returns FALSE if an error occured.
373 *
374 * See sndQuerySystemSound for the parameters.
375 *
376 *@@changed V0.9.0 [umoeller]: this used to be cmnSetSystemSound
377 *@@changed V0.9.0 [umoeller]: exported stuff to sndWriteSoundData
378 *@@changed V0.9.6 (2000-10-16) [umoeller]: added proper HAB param
379 */
380
381BOOL sndSetSystemSound(HAB hab,
382 USHORT usIndex,
383 PSZ pszDescr,
384 PSZ pszFile,
385 ULONG ulVolume)
386{
387 BOOL brc = FALSE;
388 HINI hiniMMPM = sndOpenMmpmIni(hab);
389 if (hiniMMPM)
390 {
391 brc = sndWriteSoundData(hiniMMPM, usIndex, pszDescr, pszFile, ulVolume);
392 PrfCloseProfile(hiniMMPM);
393 }
394 return (brc);
395}
396
397/*
398 *@@ sndDoesSchemeExist:
399 * returns TRUE if pszScheme already exists
400 * in OS2SYS.INI.
401 *
402 *@@added V0.9.0 [umoeller]
403 */
404
405BOOL sndDoesSchemeExist(PSZ pszScheme)
406{
407 // check in OS2SYS.INI's scheme list whether that
408 // scheme exists already
409 PSZ pszExisting = prfhQueryProfileData(HINI_SYSTEM,
410 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
411 pszScheme,
412 NULL);
413 if (pszExisting)
414 {
415 free(pszExisting);
416 return (TRUE);
417 }
418
419 return (FALSE);
420}
421
422/*
423 *@@ sndCreateSoundScheme:
424 * this creates a new sound scheme and copies
425 * the current data in MMPM.INI into it.
426 * No check is made for whether that sound
427 * scheme exists already (use sndDoesSchemeExist
428 * for that). Data is overwritten without further
429 * discussion.
430 *
431 * Returns:
432 * -- NO_ERROR
433 * -- ERROR_INVALID_HANDLE: hiniMMPM invalid
434 * -- ERROR_NO_DATA: scheme not found.
435 *
436 *@@added V0.9.0 [umoeller]
437 */
438
439APIRET sndCreateSoundScheme(HINI hiniMMPM, // in: MMPM.INI handle (from sndOpenMmpmIni)
440 PSZ pszNewScheme) // in: name of new scheme
441{
442 APIRET arc = NO_ERROR;
443 CHAR szNewAppName[200] = "PM_SOUNDS_";
444
445 // create a unique new application name for
446 // this scheme in OS2SYS.INI (this is how
447 // Warp 4 apparently does it)
448 strcat(szNewAppName, pszNewScheme); // PM_SOUNDS_blahblah
449 strupr(szNewAppName); // PM_SOUNDS_BLAHBLAH
450
451 if (hiniMMPM)
452 {
453 // get applications list for sounds list in MMPM.INI
454 PSZ pszKeysList = prfhQueryKeysForApp(hiniMMPM,
455 MMINIKEY_SYSSOUNDS); // "MMPM2_AlarmSounds"
456 if (pszKeysList)
457 {
458 PSZ pKey2 = pszKeysList;
459
460 CHAR szFile[CCHMAXPATH+50];
461 ULONG ulVolume,
462 ulKeyLen;
463
464 while (*pKey2 != 0)
465 {
466 // now copy this key to the new sound scheme;
467 // however, we can't just copy the whole key,
468 // but need to extract the file name and
469 // volume first.
470 // Warp 4 normally _only_ stores the file name
471 // in the sound schemes. Since we want the
472 // volume also, we add a null char after the
473 // file name and append the volume...
474
475 PSZ pSoundData = prfhQueryProfileData(hiniMMPM,
476 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds"
477 pKey2,
478 NULL);
479 if (pSoundData)
480 {
481 sndParseSoundData(pSoundData,
482 NULL, // we don't need the description
483 szFile,
484 &ulVolume);
485 ulKeyLen = strlen(szFile)+1; // go beyond null byte
486 ulKeyLen += sprintf(szFile+ulKeyLen,
487 "%lu",
488 ulVolume) + 1;
489 // and write to OS2SYS.INI
490 PrfWriteProfileData(HINI_SYSTEM,
491 szNewAppName,
492 pKey2,
493 szFile,
494 ulKeyLen);
495
496 free(pSoundData);
497 } // end if (pSoundData)
498
499 pKey2 += strlen(pKey2)+1;
500 } // end while (*pKey2 != 0)
501
502 free (pszKeysList);
503
504 // finally, store new scheme in schemes list
505 PrfWriteProfileString(HINI_SYSTEM,
506 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
507 pszNewScheme, // key is scheme name
508 szNewAppName); // data is new OS2SYS.INI application
509 }
510 else
511 arc = ERROR_NO_DATA;
512 }
513 else
514 arc = ERROR_INVALID_HANDLE;
515
516 return (arc);
517}
518
519/*
520 *@@ sndLoadSoundScheme:
521 * this loads the data in pszScheme (OS2SYS.INI)
522 * into MMPM.INI. Existing sound data
523 * in that profile will be overwritten.
524 *
525 * Note: Only those sounds in MMPM.INI will be
526 * overwritten for which a corresponding entry
527 * in the sound scheme exists. If it doesn't,
528 * the data in MMPM.INI for _that_ sound only
529 * will _not_ be changed. In other words, existing
530 * sound data will be merged with the scheme data.
531 *
532 * If you don't like this, delete the whole
533 * "MMPM2_AlarmSounds" application in MMPM.INI
534 * before calling this function.
535 *
536 * Returns:
537 * -- NO_ERROR
538 * -- ERROR_INVALID_HANDLE: hiniMMPM invalid
539 * -- ERROR_NO_DATA: scheme not found.
540 * -- ERROR_BAD_FORMAT: error in MMPM.INI data.
541 *
542 *@@added V0.9.0 [umoeller]
543 *@@changed V0.9.1 (99-12-20) [umoeller]: fixed memory leak
544 *@@changed V0.9.6 (2000-10-16) [umoeller]: added MMPM/2 notify
545 */
546
547APIRET sndLoadSoundScheme(HINI hiniMMPM, // in: HINI of ?:\MMOS2\MMPM.INI (PrfOpenProfile)
548 PSZ pszScheme) // in: scheme name
549{
550 APIRET arc = NO_ERROR;
551
552 #ifdef DEBUG_SOUNDS
553 _Pmpf(("Entering sndLoadSoundScheme"));
554 #endif
555
556 if (hiniMMPM)
557 {
558 // check in OS2SYS.INI's scheme list whether that
559 // scheme exists already
560 PSZ pszSchemeAppName = prfhQueryProfileData(HINI_SYSTEM,
561 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
562 pszScheme,
563 NULL);
564 #ifdef DEBUG_SOUNDS
565 _Pmpf((" pszSchemeAppName: %s", pszSchemeAppName));
566 #endif
567
568 if (pszSchemeAppName)
569 {
570 // now copy keys from OS2SYS.INI to MMPM.INI;
571 // since OS2SYS.INI _only_ has the file name
572 // (and _maybe_ the individual volume, if it
573 // was us who created the sound scheme --
574 // see sndCreateSoundScheme above), we need
575 // to go thru the MMPM.INI (!) sounds lists
576 // and merge the data in there with the
577 // corresponding sound data for the current
578 // scheme...
579
580 // get applications list for sounds list in MMPM.INI
581 PSZ pszMMPMKeysList = prfhQueryKeysForApp(hiniMMPM,
582 MMINIKEY_SYSSOUNDS); // "MMPM2_AlarmSounds"
583 if (pszMMPMKeysList)
584 {
585 PSZ pMMPMKey2 = pszMMPMKeysList,
586 pMMPMSoundData,
587 pSchemeSoundData;
588
589 CHAR szDescription[300]; // from MMPM.INI
590 CHAR szFile[CCHMAXPATH+50]; // from OS2SYS.INI
591 ULONG ulVolume; // from MMPM.INI _or_ OS2SYS.INI
592 CHAR szData[1000];
593
594 // go thru keys (numbers)
595 while (*pMMPMKey2 != 0)
596 {
597 ULONG cbSchemeSoundData = 0,
598 cbSchemeSoundFile = 0;
599
600 pMMPMSoundData = prfhQueryProfileData(hiniMMPM,
601 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds"
602 pMMPMKey2,
603 NULL);
604 pSchemeSoundData = prfhQueryProfileData(HINI_SYSTEM,
605 pszSchemeAppName,
606 pMMPMKey2,
607 &cbSchemeSoundData);
608
609 if ((pMMPMSoundData) && (pSchemeSoundData))
610 {
611 sndParseSoundData(pMMPMSoundData,
612 szDescription,
613 NULL, // we don't need the file
614 &ulVolume);
615 // now overwrite this data with scheme data
616 strcpy(szFile,
617 pSchemeSoundData); // up to first null byte
618 cbSchemeSoundFile = strlen(pSchemeSoundData)+1;
619 if (cbSchemeSoundData > cbSchemeSoundFile)
620 // this means we have an additional volume string
621 // after the null byte (sndCreateSoundScheme);
622 // copy it
623 sscanf(pSchemeSoundData + cbSchemeSoundFile,
624 "%lu",
625 &ulVolume);
626
627 // and write data to MMPM.INI
628 // format: soundfile#description#volume
629 sprintf(szData, "%s#%s#%lu", szFile, szDescription, ulVolume);
630 if (PrfWriteProfileString(hiniMMPM,
631 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds"
632 pMMPMKey2, // key (decimal number)
633 szData))
634 {
635 // success:
636 USHORT usIndex = atoi(pMMPMKey2);
637 if (usIndex < 100)
638 // this was one of the default OS/2 sounds:
639 // notify MMPM/2 of the change... see sndWriteSoundData
640 // V0.9.6 (2000-10-16) [umoeller]
641 WinAlarm(HWND_DESKTOP, usIndex+1000);
642 }
643 }
644
645 if (pMMPMSoundData)
646 free(pMMPMSoundData);
647 if (pSchemeSoundData)
648 free(pSchemeSoundData);
649
650 pMMPMKey2 += strlen(pMMPMKey2)+1;
651 } // end while (*pMMPMKey2 != 0)
652
653 free (pszMMPMKeysList);
654 }
655 else
656 arc = ERROR_BAD_FORMAT;
657
658 free(pszSchemeAppName);
659 } // end if (pszSchemeAppName)
660 else
661 arc = ERROR_NO_DATA;
662 }
663 else
664 arc = ERROR_INVALID_HANDLE;
665
666 #ifdef DEBUG_SOUNDS
667 _Pmpf(("End of sndLoadSoundScheme, arc: %d", arc));
668 #endif
669 return (arc);
670}
671
672/*
673 *@@ sndDestroySoundScheme:
674 * destroys pszScheme in OS2SYS.INI;
675 * returns TRUE is pszScheme was found
676 * and deleted.
677 *
678 * See xsound.c for explanations.
679 *
680 * Returns:
681 * -- NO_ERROR
682 * -- ERROR_NO_DATA: scheme not found.
683 *
684 *@@added V0.9.0 [umoeller]
685 */
686
687APIRET sndDestroySoundScheme(PSZ pszScheme)
688{
689 APIRET arc = NO_ERROR;
690
691 // check in OS2SYS.INI's scheme list whether that
692 // scheme exists already
693 PSZ pszExisting = prfhQueryProfileData(HINI_SYSTEM,
694 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
695 pszScheme,
696 NULL);
697 if (pszExisting)
698 {
699 // delete whole existing PM_SOUNDS_BLAHBLAH application
700 PrfWriteProfileString(HINI_SYSTEM,
701 pszExisting, // application
702 NULL,
703 NULL);
704 // and delete entry in sound schemes list
705 PrfWriteProfileString(HINI_SYSTEM,
706 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
707 pszScheme,
708 NULL);
709 free(pszExisting);
710 }
711 else
712 arc = ERROR_NO_DATA;
713
714 return (arc);
715}
716
717
Note: See TracBrowser for help on using the repository browser.