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

Last change on this file since 17 was 13, checked in by umoeller, 25 years ago

Updates for V0.9.6.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 25.5 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 */
176
177HINI sndOpenMmpmIni(HAB hab)
178{
179 HAB habDesktop = WinQueryAnchorBlock(HWND_DESKTOP);
180 CHAR szMMPM[CCHMAXPATH];
181 HINI hini = NULLHANDLE;
182
183 PSZ pszMMPMPath = getenv("MMBASE"); // V0.9.6 (2000-10-16) [umoeller]
184 if (pszMMPMPath)
185 {
186 // variable set:
187 PSZ p;
188 sprintf(szMMPM, "%s\\MMPM.INI", pszMMPMPath);
189 // kill semicolon if present
190 p = strchr(szMMPM, ';');
191 if (p)
192 *p = 0;
193 }
194 else
195 // variable not set (shouldn't happen): try boot drive
196 sprintf(szMMPM, "%c:\\MMOS2\\MMPM.INI", doshQueryBootDrive());
197 hini = PrfOpenProfile(habDesktop, szMMPM);
198 return (hini);
199}
200
201/*
202 *@@ sndQuerySystemSound:
203 * this gets a system sound from the MMPM.INI file.
204 * usIndex must be the sound to query. The following
205 * MMSOUND_* IDs are declared in syssound.h:
206 *
207 * Default system sounds (syssound.h):
208 * -- MMSOUND_WARNING 0
209 * -- MMSOUND_INFORMATION 1
210 * -- MMSOUND_ERROR 2
211 * -- MMSOUND_ANIMATEOPEN 3
212 * -- MMSOUND_ANIMATECLOSE 4
213 * -- MMSOUND_DRAG 5
214 * -- MMSOUND_DROP 6
215 * -- MMSOUND_SYSTEMSTARTUP 7
216 * -- MMSOUND_SHUTDOWN 8
217 * -- MMSOUND_SHREDDER 9
218 * -- MMSOUND_LOCKUP 10
219 * -- MMSOUND_ALARMCLOCK 11
220 * -- MMSOUND_PRINTERROR 12
221 *
222 * BTW, these values match those of the WinAlarm call
223 * (WA_* values), but only the first three are documented
224 * in PMREF and pmwin.h (WA_WARNING, WA_NOTE, WA_ERROR).
225 *
226 * New XWorkplace system sounds:
227 * -- MMSOUND_XFLD_SHUTDOWN 555
228 * -- MMSOUND_XFLD_RESTARTWPS 556
229 * -- MMSOUND_XFLD_CTXTOPEN 558
230 * -- MMSOUND_XFLD_CTXTSELECT 559
231 * -- MMSOUND_XFLD_CNRDBLCLK 560
232 *
233 * The string buffers are recommended to be at least
234 * CCHMAXPATH in size.
235 *
236 *@@changed V0.9.0 [umoeller]: this used to be cmnQuerySystemSound
237 *@@changed V0.9.0 [umoeller]: exported stuff to sndParseSoundData
238 *@@changed V0.9.6 (2000-10-16) [umoeller]: added proper HAB param
239 */
240
241BOOL sndQuerySystemSound(HAB hab, // in: caller's anchor block
242 USHORT usIndex, // in: sound index to query
243 PSZ pszDescr, // out: sound description, as displayed
244 // in the "Sound" object (ptr may be NULL)
245 PSZ pszFile, // out: sound file to (ptr may be NULL)
246 PULONG pulVolume) // out: sound volume (0-100).
247 // If the "Global volume" flag is
248 // set in MMPM.INI, this will return the global
249 // volume instead. Ptr may be NULL also.
250{
251 BOOL rc = FALSE;
252 HINI hiniMMPM = sndOpenMmpmIni(hab);
253 if (hiniMMPM)
254 {
255 CHAR szData[1000];
256 CHAR szData2[100];
257 CHAR szKey[10];
258 sprintf(szKey, "%d", usIndex);
259 PrfQueryProfileString(hiniMMPM,
260 MMINIKEY_SOUNDSETTINGS, "EnableSounds",
261 "TRUE", // default string
262 szData2, sizeof(szData2));
263 #ifdef DEBUG_SOUNDS
264 _Pmpf((" sounds enabled: %s", szData2));
265 #endif
266 if (strcmp(szData2, "TRUE") == 0)
267 // sounds enabled at all?
268 if (PrfQueryProfileString(hiniMMPM,
269 MMINIKEY_SYSSOUNDS, szKey,
270 ".",
271 szData, sizeof(szData)-1) > 3)
272 {
273 sndParseSoundData(szData,
274 pszDescr,
275 pszFile,
276 pulVolume);
277
278 // if "global volume" has been enabled,
279 // we do not return the value specified
280 // here, but the global value
281 PrfQueryProfileString(hiniMMPM,
282 MMINIKEY_SOUNDSETTINGS, "ApplyVolumeToAll",
283 "FALSE",
284 szData2, sizeof(szData2));
285 if (strcmp(szData2, "FALSE") != 0)
286 {
287 // global volume setting for all sounds
288 PrfQueryProfileString(hiniMMPM,
289 MMINIKEY_SOUNDSETTINGS, "Volume",
290 "100",
291 szData2, sizeof(szData2));
292 sscanf(szData2, "%lu", pulVolume);
293 }
294
295 rc = TRUE;
296 }
297
298 PrfCloseProfile(hiniMMPM);
299 }
300
301 return (rc);
302}
303
304/*
305 *@@ sndWriteSoundData:
306 * this sets a system sound in MMPM.INI.
307 * Gets called by sndSetSystemSound. As opposed
308 * to that function, this needs the profile handle
309 * of MMPM.INI.
310 *
311 * If (pszDescr == NULL), that sound entry is removed.
312 *
313 * Returns the return value of PrfWriteProfileString.
314 *
315 *@@added V0.9.0 [umoeller]
316 *@@changed V0.9.1 (99-12-30) [umoeller]: added delete support
317 *@@changed V0.9.6 (2000-10-16) [umoeller]: added MMPM/2 notify
318 */
319
320BOOL sndWriteSoundData(HINI hiniMMPM, // in: MMPM.INI handle (from sndOpenMmpmIni)
321 USHORT usIndex, // in: sound index
322 PSZ pszDescr, // in: sound name or NULL for removal
323 PSZ pszFile, // in: sound file
324 ULONG ulVolume) // in: sound volume
325{
326 BOOL brc = FALSE;
327 CHAR szKey[10];
328
329 sprintf(szKey, "%d", usIndex);
330 if (pszDescr)
331 {
332 CHAR szData[1000];
333 // format: soundfile#description#volume
334 sprintf(szData, "%s#%s#%lu", pszFile, pszDescr, ulVolume);
335 brc = PrfWriteProfileString(hiniMMPM,
336 MMINIKEY_SYSSOUNDS, szKey,
337 szData);
338 }
339 else
340 // pszDescr == NULL:
341 // delete entry
342 brc = PrfWriteProfileString(hiniMMPM,
343 MMINIKEY_SYSSOUNDS, szKey,
344 NULL);
345
346 if (brc)
347 // success:
348 if (usIndex < 100)
349 // one of the default OS/2 sounds has changed:
350 // we then need to notify MMPM/2...
351 // this is done by calling WinAlarm with 1000+index!
352 // sick stuff..
353 WinAlarm(HWND_DESKTOP, usIndex+1000); // V0.9.6 (2000-10-16) [umoeller]
354
355 return (brc);
356}
357
358/*
359 *@@ sndSetSystemSound:
360 * this sets a system sound in MMPM.INI by
361 * calling sndWriteSoundData.
362 * Returns FALSE if an error occured.
363 *
364 * See sndQuerySystemSound for the parameters.
365 *
366 *@@changed V0.9.0 [umoeller]: this used to be cmnSetSystemSound
367 *@@changed V0.9.0 [umoeller]: exported stuff to sndWriteSoundData
368 *@@changed V0.9.6 (2000-10-16) [umoeller]: added proper HAB param
369 */
370
371BOOL sndSetSystemSound(HAB hab,
372 USHORT usIndex,
373 PSZ pszDescr,
374 PSZ pszFile,
375 ULONG ulVolume)
376{
377 BOOL brc = FALSE;
378 HINI hiniMMPM = sndOpenMmpmIni(hab);
379 if (hiniMMPM)
380 {
381 brc = sndWriteSoundData(hiniMMPM, usIndex, pszDescr, pszFile, ulVolume);
382 PrfCloseProfile(hiniMMPM);
383 }
384 return (brc);
385}
386
387/*
388 *@@ sndDoesSchemeExist:
389 * returns TRUE if pszScheme already exists
390 * in OS2SYS.INI.
391 *
392 *@@added V0.9.0 [umoeller]
393 */
394
395BOOL sndDoesSchemeExist(PSZ pszScheme)
396{
397 // check in OS2SYS.INI's scheme list whether that
398 // scheme exists already
399 PSZ pszExisting = prfhQueryProfileData(HINI_SYSTEM,
400 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
401 pszScheme,
402 NULL);
403 if (pszExisting)
404 {
405 free(pszExisting);
406 return (TRUE);
407 }
408
409 return (FALSE);
410}
411
412/*
413 *@@ sndCreateSoundScheme:
414 * this creates a new sound scheme and copies
415 * the current data in MMPM.INI into it.
416 * No check is made for whether that sound
417 * scheme exists already (use sndDoesSchemeExist
418 * for that). Data is overwritten without further
419 * discussion.
420 *
421 * Returns:
422 * -- NO_ERROR
423 * -- ERROR_INVALID_HANDLE: hiniMMPM invalid
424 * -- ERROR_NO_DATA: scheme not found.
425 *
426 *@@added V0.9.0 [umoeller]
427 */
428
429APIRET sndCreateSoundScheme(HINI hiniMMPM, // in: MMPM.INI handle (from sndOpenMmpmIni)
430 PSZ pszNewScheme) // in: name of new scheme
431{
432 APIRET arc = NO_ERROR;
433 CHAR szNewAppName[200] = "PM_SOUNDS_";
434
435 // create a unique new application name for
436 // this scheme in OS2SYS.INI (this is how
437 // Warp 4 apparently does it)
438 strcat(szNewAppName, pszNewScheme); // PM_SOUNDS_blahblah
439 strupr(szNewAppName); // PM_SOUNDS_BLAHBLAH
440
441 if (hiniMMPM)
442 {
443 // get applications list for sounds list in MMPM.INI
444 PSZ pszKeysList = prfhQueryKeysForApp(hiniMMPM,
445 MMINIKEY_SYSSOUNDS); // "MMPM2_AlarmSounds"
446 if (pszKeysList)
447 {
448 PSZ pKey2 = pszKeysList;
449
450 CHAR szFile[CCHMAXPATH+50];
451 ULONG ulVolume,
452 ulKeyLen;
453
454 while (*pKey2 != 0)
455 {
456 // now copy this key to the new sound scheme;
457 // however, we can't just copy the whole key,
458 // but need to extract the file name and
459 // volume first.
460 // Warp 4 normally _only_ stores the file name
461 // in the sound schemes. Since we want the
462 // volume also, we add a null char after the
463 // file name and append the volume...
464
465 PSZ pSoundData = prfhQueryProfileData(hiniMMPM,
466 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds"
467 pKey2,
468 NULL);
469 if (pSoundData)
470 {
471 sndParseSoundData(pSoundData,
472 NULL, // we don't need the description
473 szFile,
474 &ulVolume);
475 ulKeyLen = strlen(szFile)+1; // go beyond null byte
476 ulKeyLen += sprintf(szFile+ulKeyLen,
477 "%lu",
478 ulVolume) + 1;
479 // and write to OS2SYS.INI
480 PrfWriteProfileData(HINI_SYSTEM,
481 szNewAppName,
482 pKey2,
483 szFile,
484 ulKeyLen);
485
486 free(pSoundData);
487 } // end if (pSoundData)
488
489 pKey2 += strlen(pKey2)+1;
490 } // end while (*pKey2 != 0)
491
492 free (pszKeysList);
493
494 // finally, store new scheme in schemes list
495 PrfWriteProfileString(HINI_SYSTEM,
496 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
497 pszNewScheme, // key is scheme name
498 szNewAppName); // data is new OS2SYS.INI application
499 }
500 else
501 arc = ERROR_NO_DATA;
502 }
503 else
504 arc = ERROR_INVALID_HANDLE;
505
506 return (arc);
507}
508
509/*
510 *@@ sndLoadSoundScheme:
511 * this loads the data in pszScheme (OS2SYS.INI)
512 * into MMPM.INI. Existing sound data
513 * in that profile will be overwritten.
514 *
515 * Note: Only those sounds in MMPM.INI will be
516 * overwritten for which a corresponding entry
517 * in the sound scheme exists. If it doesn't,
518 * the data in MMPM.INI for _that_ sound only
519 * will _not_ be changed. In other words, existing
520 * sound data will be merged with the scheme data.
521 *
522 * If you don't like this, delete the whole
523 * "MMPM2_AlarmSounds" application in MMPM.INI
524 * before calling this function.
525 *
526 * Returns:
527 * -- NO_ERROR
528 * -- ERROR_INVALID_HANDLE: hiniMMPM invalid
529 * -- ERROR_NO_DATA: scheme not found.
530 * -- ERROR_BAD_FORMAT: error in MMPM.INI data.
531 *
532 *@@added V0.9.0 [umoeller]
533 *@@changed V0.9.1 (99-12-20) [umoeller]: fixed memory leak
534 *@@changed V0.9.6 (2000-10-16) [umoeller]: added MMPM/2 notify
535 */
536
537APIRET sndLoadSoundScheme(HINI hiniMMPM, // in: HINI of ?:\MMOS2\MMPM.INI (PrfOpenProfile)
538 PSZ pszScheme) // in: scheme name
539{
540 APIRET arc = NO_ERROR;
541
542 _Pmpf(("Entering sndLoadSoundScheme"));
543
544 if (hiniMMPM)
545 {
546 // check in OS2SYS.INI's scheme list whether that
547 // scheme exists already
548 PSZ pszSchemeAppName = prfhQueryProfileData(HINI_SYSTEM,
549 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
550 pszScheme,
551 NULL);
552 _Pmpf((" pszSchemeAppName: %s", pszSchemeAppName));
553
554 if (pszSchemeAppName)
555 {
556 // now copy keys from OS2SYS.INI to MMPM.INI;
557 // since OS2SYS.INI _only_ has the file name
558 // (and _maybe_ the individual volume, if it
559 // was us who created the sound scheme --
560 // see sndCreateSoundScheme above), we need
561 // to go thru the MMPM.INI (!) sounds lists
562 // and merge the data in there with the
563 // corresponding sound data for the current
564 // scheme...
565
566 // get applications list for sounds list in MMPM.INI
567 PSZ pszMMPMKeysList = prfhQueryKeysForApp(hiniMMPM,
568 MMINIKEY_SYSSOUNDS); // "MMPM2_AlarmSounds"
569 if (pszMMPMKeysList)
570 {
571 PSZ pMMPMKey2 = pszMMPMKeysList,
572 pMMPMSoundData,
573 pSchemeSoundData;
574
575 CHAR szDescription[300]; // from MMPM.INI
576 CHAR szFile[CCHMAXPATH+50]; // from OS2SYS.INI
577 ULONG ulVolume; // from MMPM.INI _or_ OS2SYS.INI
578 CHAR szData[1000];
579
580 // go thru keys (numbers)
581 while (*pMMPMKey2 != 0)
582 {
583 ULONG cbSchemeSoundData = 0,
584 cbSchemeSoundFile = 0;
585
586 pMMPMSoundData = prfhQueryProfileData(hiniMMPM,
587 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds"
588 pMMPMKey2,
589 NULL);
590 pSchemeSoundData = prfhQueryProfileData(HINI_SYSTEM,
591 pszSchemeAppName,
592 pMMPMKey2,
593 &cbSchemeSoundData);
594
595 if ((pMMPMSoundData) && (pSchemeSoundData))
596 {
597 sndParseSoundData(pMMPMSoundData,
598 szDescription,
599 NULL, // we don't need the file
600 &ulVolume);
601 // now overwrite this data with scheme data
602 strcpy(szFile,
603 pSchemeSoundData); // up to first null byte
604 cbSchemeSoundFile = strlen(pSchemeSoundData)+1;
605 if (cbSchemeSoundData > cbSchemeSoundFile)
606 // this means we have an additional volume string
607 // after the null byte (sndCreateSoundScheme);
608 // copy it
609 sscanf(pSchemeSoundData + cbSchemeSoundFile,
610 "%lu",
611 &ulVolume);
612
613 // and write data to MMPM.INI
614 // format: soundfile#description#volume
615 sprintf(szData, "%s#%s#%lu", szFile, szDescription, ulVolume);
616 if (PrfWriteProfileString(hiniMMPM,
617 MMINIKEY_SYSSOUNDS, // "MMPM2_AlarmSounds"
618 pMMPMKey2, // key (decimal number)
619 szData))
620 {
621 // success:
622 USHORT usIndex = atoi(pMMPMKey2);
623 if (usIndex < 100)
624 // this was one of the default OS/2 sounds:
625 // notify MMPM/2 of the change... see sndWriteSoundData
626 // V0.9.6 (2000-10-16) [umoeller]
627 WinAlarm(HWND_DESKTOP, usIndex+1000);
628 }
629 }
630
631 if (pMMPMSoundData)
632 free(pMMPMSoundData);
633 if (pSchemeSoundData)
634 free(pSchemeSoundData);
635
636 pMMPMKey2 += strlen(pMMPMKey2)+1;
637 } // end while (*pMMPMKey2 != 0)
638
639 free (pszMMPMKeysList);
640 }
641 else
642 arc = ERROR_BAD_FORMAT;
643
644 free(pszSchemeAppName);
645 } // end if (pszSchemeAppName)
646 else
647 arc = ERROR_NO_DATA;
648 }
649 else
650 arc = ERROR_INVALID_HANDLE;
651
652 _Pmpf(("End of sndLoadSoundScheme, arc: %d", arc));
653 return (arc);
654}
655
656/*
657 *@@ sndDestroySoundScheme:
658 * destroys pszScheme in OS2SYS.INI;
659 * returns TRUE is pszScheme was found
660 * and deleted.
661 *
662 * See xsound.c for explanations.
663 *
664 * Returns:
665 * -- NO_ERROR
666 * -- ERROR_NO_DATA: scheme not found.
667 *
668 *@@added V0.9.0 [umoeller]
669 */
670
671APIRET sndDestroySoundScheme(PSZ pszScheme)
672{
673 APIRET arc = NO_ERROR;
674
675 // check in OS2SYS.INI's scheme list whether that
676 // scheme exists already
677 PSZ pszExisting = prfhQueryProfileData(HINI_SYSTEM,
678 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
679 pszScheme,
680 NULL);
681 if (pszExisting)
682 {
683 // delete whole existing PM_SOUNDS_BLAHBLAH application
684 PrfWriteProfileString(HINI_SYSTEM,
685 pszExisting, // application
686 NULL,
687 NULL);
688 // and delete entry in sound schemes list
689 PrfWriteProfileString(HINI_SYSTEM,
690 MMINIKEY_SOUNDSCHEMES, // "PM_SOUND_SCHEMES_LIST"
691 pszScheme,
692 NULL);
693 free(pszExisting);
694 }
695 else
696 arc = ERROR_NO_DATA;
697
698 return (arc);
699}
700
701
Note: See TracBrowser for help on using the repository browser.