Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!claris!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Sys 6.0 sound manager on a plus Keywords: Sound Manager Message-ID: <14896@apple.Apple.COM> Date: 28 Jul 88 23:52:58 GMT References: <2238@munnari.oz> Reply-To: lsr@apple.apple.com.UUCP (Larry Rosenstein) Organization: Advanced Technology Group, Apple Computer Lines: 68 In article <2238@munnari.oz> castan@munnari.oz (Jason Castan) writes: >I call SndDisposeChannel - here is the problem. On a mac ][ this is ok - works with no problems, on a plus - it bombs (deleting SndDisposeChannel stops the bomb). Does anyone know if SndPlay destroys the channel itself? (which would be a >prblem when playing async - like I am). The code looks something like: When I was writing TimeKeeper (which plays a snd resource asynchronously), I found that if you did not call SndDisposeChannel, you would disable the SysBeep call on a Mac II. Therefore, I call SndDisposeChannel whenever the sound is done. The exact same code worked fine on a Mac Plus under System 6.0 (without recompiling). The relevant procedures follow: { This plays the snd resource in gChime, or SysBeep if something goes wrong.} PROCEDURE Chime; VAR err: OSErr; BEGIN err := 1; { default so SysBeep will get called } DisposeChannel; { this also stops the sound } IF gChime <> NIL THEN BEGIN LoadResource(gChime); IF gChime^ <> NIL THEN BEGIN IF gSndChan = NIL THEN IF SndNewChannel(gSndChan, 0, 0, @ChanCallBack) = noErr THEN ; err := SndPlay(gSndChan, gChime, TRUE); END; END; IF err <> noErr THEN SysBeep(1); gSoundDone := gSndChan = NIL; gSoundStart := TickCount; IF NOT gSoundDone THEN err := SndDoCommand(gSndChan, gSndCallBack, FALSE); END; PROCEDURE DisposeChannel; BEGIN IF gSndChan <> NIL THEN IF SndDisposeChannel(gSndChan, TRUE) = noErr THEN gSndChan := NIL; gSoundDone := TRUE; END; The call back routine simply sets up A5 (because it is called at interrupt level) and sets the gSoundDone boolean. I haven't had any reports of TimeKeeper crashing when trying to play its sound. I even call DisposeChannel before the sound is finished, which immediately terminates the sound. Therefore, I don't think the problem is a bug in the Mac Plus Sound Manager. Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 46-B Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr