Move MidiSynth locking out of the setState method
This commit is contained in:
parent
5dad1688d4
commit
29a4ac329a
@ -51,9 +51,7 @@ static void MidiSynth_Destruct(MidiSynth *self)
|
|||||||
|
|
||||||
static inline void MidiSynth_setState(MidiSynth *self, ALenum state)
|
static inline void MidiSynth_setState(MidiSynth *self, ALenum state)
|
||||||
{
|
{
|
||||||
WriteLock(&self->Lock);
|
|
||||||
ExchangeInt(&self->State, state);
|
ExchangeInt(&self->State, state);
|
||||||
WriteUnlock(&self->Lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ALuint64 MidiSynth_getTime(const MidiSynth *self)
|
ALuint64 MidiSynth_getTime(const MidiSynth *self)
|
||||||
@ -199,7 +197,6 @@ static ALenum FSynth_loadSoundfont(FSynth *self, const char *filename)
|
|||||||
|
|
||||||
static void FSynth_setState(FSynth *self, ALenum state)
|
static void FSynth_setState(FSynth *self, ALenum state)
|
||||||
{
|
{
|
||||||
WriteLock(&STATIC_CAST(MidiSynth, self)->Lock);
|
|
||||||
if(state == AL_PLAYING)
|
if(state == AL_PLAYING)
|
||||||
{
|
{
|
||||||
if(self->FontID == FLUID_FAILED)
|
if(self->FontID == FLUID_FAILED)
|
||||||
@ -215,8 +212,7 @@ static void FSynth_setState(FSynth *self, ALenum state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExchangeInt(&STATIC_CAST(MidiSynth, self)->State, state);
|
MidiSynth_setState(STATIC_CAST(MidiSynth, self), state);
|
||||||
WriteUnlock(&STATIC_CAST(MidiSynth, self)->Lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FSynth_update(FSynth *self, ALCdevice *device)
|
static void FSynth_update(FSynth *self, ALCdevice *device)
|
||||||
@ -518,28 +514,32 @@ done:
|
|||||||
|
|
||||||
AL_API void AL_APIENTRY alMidiPlaySOFT(void)
|
AL_API void AL_APIENTRY alMidiPlaySOFT(void)
|
||||||
{
|
{
|
||||||
ALCdevice *device;
|
|
||||||
ALCcontext *context;
|
ALCcontext *context;
|
||||||
|
MidiSynth *synth;
|
||||||
|
|
||||||
context = GetContextRef();
|
context = GetContextRef();
|
||||||
if(!context) return;
|
if(!context) return;
|
||||||
|
|
||||||
device = context->Device;
|
synth = context->Device->Synth;
|
||||||
V(device->Synth,setState)(AL_PLAYING);
|
WriteLock(&synth->Lock);
|
||||||
|
V(synth,setState)(AL_PLAYING);
|
||||||
|
WriteUnlock(&synth->Lock);
|
||||||
|
|
||||||
ALCcontext_DecRef(context);
|
ALCcontext_DecRef(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
AL_API void AL_APIENTRY alMidiPauseSOFT(void)
|
AL_API void AL_APIENTRY alMidiPauseSOFT(void)
|
||||||
{
|
{
|
||||||
ALCdevice *device;
|
|
||||||
ALCcontext *context;
|
ALCcontext *context;
|
||||||
|
MidiSynth *synth;
|
||||||
|
|
||||||
context = GetContextRef();
|
context = GetContextRef();
|
||||||
if(!context) return;
|
if(!context) return;
|
||||||
|
|
||||||
device = context->Device;
|
synth = context->Device->Synth;
|
||||||
V(device->Synth,setState)(AL_PAUSED);
|
WriteLock(&synth->Lock);
|
||||||
|
V(synth,setState)(AL_PAUSED);
|
||||||
|
WriteUnlock(&synth->Lock);
|
||||||
|
|
||||||
ALCcontext_DecRef(context);
|
ALCcontext_DecRef(context);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user