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

Last change on this file since 55 was 21, checked in by umoeller, 25 years ago

Final changes for 0.9.7, i hope...

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