Skip to content

Commit

Permalink
Voice: Stop previous handle only if the new one exists
Browse files Browse the repository at this point in the history
  • Loading branch information
julianxhokaxhiu committed Aug 4, 2023
1 parent c6cdca7 commit 2c67293
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,18 +1085,18 @@ bool NxAudioEngine::playVoice(const char* name, int slot, float volume)

if (trace_all || trace_voice) ffnx_trace("NxAudioEngine::%s: slot[%d] %s\n", __func__, slot, filename);

// Stop any previously playing voice
if (_engine.isValidVoiceHandle(_currentVoice[slot].handle))
if (exists)
{
_engine.stop(_currentVoice[slot].handle);
// Stop any previously playing voice
if (_engine.isValidVoiceHandle(_currentVoice[slot].handle))
{
_engine.stop(_currentVoice[slot].handle);

delete _currentVoice[slot].stream;
delete _currentVoice[slot].stream;

_currentVoice[slot].handle = NXAUDIOENGINE_INVALID_HANDLE;
}
_currentVoice[slot].handle = NXAUDIOENGINE_INVALID_HANDLE;
}

if (exists)
{
_currentVoice[slot].stream = new SoLoud::VGMStream();

SoLoud::result res = _currentVoice[slot].stream->load(filename);
Expand Down

0 comments on commit 2c67293

Please sign in to comment.