Skip to content

Commit

Permalink
Fixed crash when playing with a shared pipe GrandOrgue#847
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Samarin committed Nov 17, 2021
1 parent 066ed95 commit 6b0bbcd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fixed crash when playing with a shared pipe https://github.com/GrandOrgue/grandorgue/issues/847
# 3.4.2 (2021-11-14)
- Added ASIO logo to About splash screen https://github.com/GrandOrgue/grandorgue/issues/823
- Upgraded PortAudio Library to the latest stable release, v19.7.0. The upgraded library corrects PortAudio errors in GrandOrgue on macOS 11.
Expand Down
4 changes: 2 additions & 2 deletions src/grandorgue/GODefinitionFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,10 @@ void GODefinitionFile::SwitchSample(const GOSoundProvider *pipe, GO_SAMPLER* han
m_soundengine->SwitchSample(pipe, handle);
}

void GODefinitionFile::UpdateVelocity(GO_SAMPLER* handle, unsigned velocity)
void GODefinitionFile::UpdateVelocity(const GOSoundProvider* pipe, GO_SAMPLER* handle, unsigned velocity)
{
if (m_soundengine)
m_soundengine->UpdateVelocity(handle, velocity);
m_soundengine->UpdateVelocity(pipe, handle, velocity);
}

void GODefinitionFile::SendMidiMessage(GOMidiEvent& e)
Expand Down
2 changes: 1 addition & 1 deletion src/grandorgue/GODefinitionFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class GODefinitionFile : public GOEventDistributor, private GOPipeUpdateCallback
GO_SAMPLER* StartSample(const GOSoundProvider *pipe, int sampler_group_id, unsigned audio_group, unsigned velocity, unsigned delay, uint64_t last_stop);
uint64_t StopSample(const GOSoundProvider *pipe, GO_SAMPLER* handle);
void SwitchSample(const GOSoundProvider *pipe, GO_SAMPLER* handle);
void UpdateVelocity(GO_SAMPLER* handle, unsigned velocity);
void UpdateVelocity(const GOSoundProvider* pipe, GO_SAMPLER* handle, unsigned velocity);

void SendMidiMessage(GOMidiEvent& e);
void SendMidiRecorderMessage(GOMidiEvent& e);
Expand Down
2 changes: 1 addition & 1 deletion src/grandorgue/GOSoundingPipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void GOSoundingPipe::Change(unsigned velocity, unsigned last_velocity)
else if (m_Instances && !velocity)
SetOff();
else if (m_Sampler && last_velocity != velocity)
m_organfile->UpdateVelocity(m_Sampler, velocity);
m_organfile->UpdateVelocity(GetSoundProvider(), m_Sampler, velocity);
}

void GOSoundingPipe::UpdateAmplitude()
Expand Down
8 changes: 6 additions & 2 deletions src/grandorgue/sound/GOSoundEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,12 +654,16 @@ void GOSoundEngine::SwitchSample(const GOSoundProvider *pipe, GO_SAMPLER* handle
handle->new_attack = m_CurrentTime + handle->delay;
}

void GOSoundEngine::UpdateVelocity(GO_SAMPLER* handle, unsigned velocity)
void GOSoundEngine::UpdateVelocity(const GOSoundProvider* pipe, GO_SAMPLER* handle, unsigned velocity)
{
assert(handle);
handle->velocity = velocity;
/* Concurrent update possible, as it just update a float */
handle->fader.SetVelocityVolume(handle->pipe->GetVelocityVolume(handle->velocity));
if (pipe && handle->pipe == pipe)
// we've just checked thar handle is still playing the same pipe
// may be handle is switched to another pipe after this checking
// but we don't want to lock it because this functionality is not so important
handle->fader.SetVelocityVolume(pipe->GetVelocityVolume(handle->velocity));
}

const std::vector<double>& GOSoundEngine::GetMeterInfo()
Expand Down
2 changes: 1 addition & 1 deletion src/grandorgue/sound/GOSoundEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class GOSoundEngine
GO_SAMPLER* StartSample(const GOSoundProvider *pipe, int sampler_group_id, unsigned audio_group, unsigned velocity, unsigned delay, uint64_t last_stop);
uint64_t StopSample(const GOSoundProvider *pipe, GO_SAMPLER* handle);
void SwitchSample(const GOSoundProvider *pipe, GO_SAMPLER* handle);
void UpdateVelocity(GO_SAMPLER* handle, unsigned velocity);
void UpdateVelocity(const GOSoundProvider* pipe, GO_SAMPLER* handle, unsigned velocity);

void GetAudioOutput(float *output_buffer, unsigned n_frames, unsigned audio_output, bool last);
void NextPeriod();
Expand Down

0 comments on commit 6b0bbcd

Please sign in to comment.