Fix sounds on system 6

This commit is contained in:
Jon Thysell 2021-11-11 15:00:53 -08:00
parent 15378f1077
commit efaf627495
3 changed files with 23 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,9 +1,13 @@
// Copyright (c) Jon Thysell <http://jonthysell.com>
// Licensed under the MIT License.
#include <GestaltEqu.h>
#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);
}
}