diff --git a/src/MacLO.pi.bin b/src/MacLO.pi.bin index ff7f326..2bdb471 100644 Binary files a/src/MacLO.pi.bin and b/src/MacLO.pi.bin differ diff --git a/src/MacLO.pi.rsrc.bin b/src/MacLO.pi.rsrc.bin index 99d58e0..d7b2249 100644 Binary files a/src/MacLO.pi.rsrc.bin and b/src/MacLO.pi.rsrc.bin differ diff --git a/src/Sounds.c b/src/Sounds.c index 00c2731..84f7003 100644 --- a/src/Sounds.c +++ b/src/Sounds.c @@ -1,9 +1,13 @@ // Copyright (c) Jon Thysell // Licensed under the MIT License. +#include + #include "Sounds.h" -#define ClickSndResID BaseResID +#define SndBaseResId 8192 + +#define ClickSndResID SndBaseResId #define RetrySndResID (ClickSndResID + 1) #define DoneSndResID (RetrySndResID + 1) @@ -12,9 +16,19 @@ void Sounds_Init(Sounds *pSounds) { - pSounds->Enabled = DefaultEnabled; + OSErr err; + int32_t sysVersion; - SndNewChannel(&(pSounds->SndChannel), 0, 0, nil); + pSounds->Enabled = DefaultEnabled; + pSounds->SndChannel = nil; + + err = Gestalt(gestaltSystemVersion, &sysVersion); + if (err == noErr && sysVersion >= 0x0700) + { + // Only create a shared sound channel on System 7 + // or above in order to cheaply support async sound + SndNewChannel(&(pSounds->SndChannel), 0, 0, nil); + } pSounds->ClickSnd = GetResource('snd ', ClickSndResID); if (pSounds->ClickSnd == nil) @@ -39,7 +53,9 @@ void Sounds_PlayClickSnd(const Sounds *pSounds) { if (pSounds->Enabled) { + HLock(pSounds->ClickSnd); SndPlay(pSounds->SndChannel, pSounds->ClickSnd, PlaySoundsAsync); + HUnlock(pSounds->ClickSnd); } } @@ -47,7 +63,9 @@ void Sounds_PlayRetrySnd(const Sounds *pSounds) { if (pSounds->Enabled) { + HLock(pSounds->RetrySnd); SndPlay(pSounds->SndChannel, pSounds->RetrySnd, PlaySoundsAsync); + HUnlock(pSounds->RetrySnd); } } @@ -55,6 +73,8 @@ void Sounds_PlayDoneSnd(const Sounds *pSounds) { if (pSounds->Enabled) { + HLock(pSounds->DoneSnd); SndPlay(pSounds->SndChannel, pSounds->DoneSnd, PlaySoundsAsync); + HUnlock(pSounds->DoneSnd); } }