mirror of https://github.com/jonthysell/MacLO.git
Simplified sound by removing sound channel creation
This commit is contained in:
parent
e76fd25c07
commit
2f818e73b8
22
src/Sounds.c
22
src/Sounds.c
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) Jon Thysell <http://jonthysell.com>
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include <GestaltEqu.h>
|
||||
|
||||
#include "Sounds.h"
|
||||
|
||||
#define SndBaseResId 8192
|
||||
|
@ -12,23 +10,11 @@
|
|||
#define DoneSndResID (RetrySndResID + 1)
|
||||
|
||||
#define DefaultEnabled true
|
||||
#define PlaySoundsAsync true
|
||||
#define PlaySoundsAsync false
|
||||
|
||||
void Sounds_Init(Sounds *pSounds)
|
||||
{
|
||||
OSErr err;
|
||||
int32_t sysVersion;
|
||||
|
||||
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)
|
||||
|
@ -54,7 +40,7 @@ void Sounds_PlayClickSnd(const Sounds *pSounds)
|
|||
if (pSounds->Enabled)
|
||||
{
|
||||
HLock(pSounds->ClickSnd);
|
||||
SndPlay(pSounds->SndChannel, pSounds->ClickSnd, PlaySoundsAsync);
|
||||
SndPlay(nil, pSounds->ClickSnd, PlaySoundsAsync);
|
||||
HUnlock(pSounds->ClickSnd);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +50,7 @@ void Sounds_PlayRetrySnd(const Sounds *pSounds)
|
|||
if (pSounds->Enabled)
|
||||
{
|
||||
HLock(pSounds->RetrySnd);
|
||||
SndPlay(pSounds->SndChannel, pSounds->RetrySnd, PlaySoundsAsync);
|
||||
SndPlay(nil, pSounds->RetrySnd, PlaySoundsAsync);
|
||||
HUnlock(pSounds->RetrySnd);
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +60,7 @@ void Sounds_PlayDoneSnd(const Sounds *pSounds)
|
|||
if (pSounds->Enabled)
|
||||
{
|
||||
HLock(pSounds->DoneSnd);
|
||||
SndPlay(pSounds->SndChannel, pSounds->DoneSnd, PlaySoundsAsync);
|
||||
SndPlay(nil, pSounds->DoneSnd, PlaySoundsAsync);
|
||||
HUnlock(pSounds->DoneSnd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
typedef struct sSounds
|
||||
{
|
||||
bool Enabled;
|
||||
SndChannelPtr SndChannel;
|
||||
Handle ClickSnd;
|
||||
Handle RetrySnd;
|
||||
Handle DoneSnd;
|
||||
|
|
Loading…
Reference in New Issue