Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #27 from oleg68/debug/osx-crash
Browse files Browse the repository at this point in the history
Fixed crashing on OSX
  • Loading branch information
oleg68 authored May 5, 2021
2 parents c8ce7da + 81ad400 commit f885725
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 46 deletions.
24 changes: 15 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)

# setup compiler flags for debug vs release compiles
add_option(-Wall)
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_option(-O3)
add_option(-g)
add_definitions(-DNDEBUG)
add_option(-fomit-frame-pointer)
add_option(-funroll-loops)
add_option(-ffast-math)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_option(-g3)
else()
add_option(-O3)
add_option(-g)
add_definitions(-DNDEBUG)
add_option(-fomit-frame-pointer)
add_option(-funroll-loops)
add_option(-ffast-math)
endif ()

if (RTAUDIO_USE_JACK OR RTMIDI_USE_JACK OR GO_USE_JACK)
Expand Down Expand Up @@ -183,8 +185,6 @@ set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/license.txt)
set(CPACK_PACKAGE_CONTACT "osamarin68@gmail.com")
set(CPACK_PACKAGE_EXECUTABLES "GrandOrgue" "GrandOrgue")

set(CPACK_STRIP_FILES ON)

set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/" "/build-for/")

# components
Expand Down Expand Up @@ -251,6 +251,12 @@ elseif (WIN32)

elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CPACK_STRIP_FILES OFF)
else()
set(CPACK_STRIP_FILES ON)
endif()

set(CPACK_SYSTEM_NAME "linux")
set(CPACK_GENERATOR TGZ RPM DEB)

Expand Down
2 changes: 1 addition & 1 deletion build-scripts/for-osx/build-on-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rm -rf *
export LANG=C

OS_PRMS="-DDOCBOOK_DIR=/usr/local/opt/docbook-xsl/docbook-xsl"
GO_PRMS="-DCMAKE_BUILD_TYPE=Release $CMAKE_VERSION_PRMS"
GO_PRMS="-DCMAKE_BUILD_TYPE=Debug $CMAKE_VERSION_PRMS"
cmake -G "Unix Makefiles" $OS_PRMS $GO_PRMS . $SRC_DIR
make -k $PARALLEL_PRMS VERBOSE=1 package

Expand Down
3 changes: 2 additions & 1 deletion src/core/GOrgueBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ void GOrgueBitmap::ScaleBMP(wxImage& img, double scale, const wxRect& rect, GOrg
dc.DrawBitmap(orig, 0, 0, true);
bmp.SetMask(orig.GetMask());
wxImage img_result = bmp.ConvertToImage();
img_result.InitAlpha();
if (! img_result.HasAlpha())
img_result.InitAlpha();
memcpy(img_result.GetAlpha(), img.GetAlpha(), img.GetWidth() * img.GetHeight());

m_bmp = (wxBitmap)img_result.Scale(img.GetWidth() * scale, img.GetHeight() * scale, wxIMAGE_QUALITY_BICUBIC);
Expand Down
25 changes: 18 additions & 7 deletions src/grandorgue/GOGUIHW1Background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,53 @@ void GOGUIHW1Background::Init(GOrgueConfigReader& cfg, wxString group)
GOGUIControl::Init(cfg, group);
}

bool is_rect_valid(wxRect& rect) {
return rect.width > 0 && rect.height > 0;
}

void GOGUIHW1Background::Layout()
{
m_Images.clear();
wxRect rect;

rect = wxRect(0, 0, m_layout->GetCenterX(), m_metrics->GetScreenHeight());
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopBackgroundImageNum())));
if (is_rect_valid(rect))
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopBackgroundImageNum())));
rect = wxRect(m_layout->GetCenterX() + m_layout->GetCenterWidth(), 0,
m_metrics->GetScreenWidth() - (m_layout->GetCenterX() + m_layout->GetCenterWidth()), m_metrics->GetScreenHeight());
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopBackgroundImageNum())));
if (is_rect_valid(rect))
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopBackgroundImageNum())));
rect = wxRect(m_layout->GetCenterX(), 0, m_layout->GetCenterWidth(), m_metrics->GetScreenHeight());
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetConsoleBackgroundImageNum())));
if (is_rect_valid(rect))
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetConsoleBackgroundImageNum())));

if (m_metrics->HasPairDrawstopCols())
{
for (unsigned i = 0; i < (m_metrics->NumberOfDrawstopColsToDisplay() >> 2); i++)
{
rect = wxRect(i * (2 * m_metrics->GetDrawstopWidth() + 18) + m_layout->GetJambLeftX() - 5,
m_layout->GetJambLeftRightY(), 2 * m_metrics->GetDrawstopWidth() + 10, m_layout->GetJambLeftRightHeight());
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopInsetBackgroundImageNum())));
if (is_rect_valid(rect))
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopInsetBackgroundImageNum())));
rect = wxRect(i * (2 * m_metrics->GetDrawstopWidth() + 18) + m_layout->GetJambRightX() - 5,
m_layout->GetJambLeftRightY(), 2 * m_metrics->GetDrawstopWidth() + 10, m_layout->GetJambLeftRightHeight());
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopInsetBackgroundImageNum())));
if (is_rect_valid(rect))
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetDrawstopInsetBackgroundImageNum())));
}
}

if (m_metrics->HasTrimAboveExtraRows())
{
rect = wxRect(m_layout->GetCenterX(), m_layout->GetCenterY(), m_layout->GetCenterWidth(), 8);
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetKeyVertBackgroundImageNum())));
if (is_rect_valid(rect))
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetKeyVertBackgroundImageNum())));
}

if (m_layout->GetJambTopHeight() + m_layout->GetPistonTopHeight())
{
rect = wxRect(m_layout->GetCenterX(), m_layout->GetJambTopY(), m_layout->GetCenterWidth(), m_layout->GetJambTopHeight() + m_layout->GetPistonTopHeight());
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetKeyHorizBackgroundImageNum())));
if (is_rect_valid(rect))
m_Images.push_back(GOBackgroundImage(rect, m_panel->GetWood(m_metrics->GetKeyHorizBackgroundImageNum())));
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/grandorgue/GOSoundEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ GOSoundEngine::GOSoundEngine() :
m_AudioGroups(),
m_AudioOutputs(),
m_AudioRecorder(NULL),
m_TouchProcessor()
m_TouchProcessor(),
m_HasBeenSetup(false)
{
memset(&m_ResamplerCoefs, 0, sizeof(m_ResamplerCoefs));
m_SamplerPool.SetUsageLimit(2048);
Expand All @@ -74,10 +75,16 @@ GOSoundEngine::~GOSoundEngine()

void GOSoundEngine::Reset()
{
if (m_HasBeenSetup)
{
for (unsigned i = 0; i < m_Windchests.size(); i++)
m_Windchests[i]->Init(m_Tremulants);
}

m_Scheduler.Clear();
m_Scheduler.Clear();

if (m_HasBeenSetup)
{
for (unsigned i = 0; i < m_Tremulants.size(); i++)
m_Scheduler.Add(m_Tremulants[i]);
for (unsigned i = 0; i < m_Windchests.size(); i++)
Expand All @@ -90,7 +97,7 @@ void GOSoundEngine::Reset()
m_Scheduler.Add(m_ReleaseProcessor);
if (m_TouchProcessor)
m_Scheduler.Add(m_TouchProcessor.get());
}
m_UsedPolyphony = 0;

m_SamplerPool.ReturnAll();
Expand Down Expand Up @@ -237,6 +244,7 @@ void GOSoundEngine::StartSampler(GO_SAMPLER* sampler, int sampler_group_id, unsi

void GOSoundEngine::ClearSetup()
{
m_HasBeenSetup = false;
m_Scheduler.Clear();
m_Windchests.clear();
m_Tremulants.clear();
Expand All @@ -258,6 +266,7 @@ void GOSoundEngine::Setup(GrandOrgueFile* organ_file, unsigned release_count)
for(unsigned i = 0; i < organ_file->GetWindchestGroupCount(); i++)
m_Windchests.push_back(new GOSoundWindchestWorkItem(*this, organ_file->GetWindchest(i)));
m_TouchProcessor = std::unique_ptr<GOSoundTouchWorkItem>(new GOSoundTouchWorkItem(organ_file->GetMemoryPool()));
m_HasBeenSetup = true;
Reset();
}

Expand Down
2 changes: 2 additions & 0 deletions src/grandorgue/GOSoundEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class GOSoundEngine
GOSoundScheduler m_Scheduler;

struct resampler_coefs_s m_ResamplerCoefs;

bool m_HasBeenSetup;

/* samplerGroupID:
-1 .. -n Tremulants
Expand Down
9 changes: 7 additions & 2 deletions src/grandorgue/GOrgueProgressDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <wx/progdlg.h>
#include <wx/stopwatch.h>

#define DLG_MAX_VALUE 0x10000

GOrgueProgressDialog::GOrgueProgressDialog() :
m_dlg(NULL),
m_last(0),
Expand All @@ -43,7 +45,7 @@ void GOrgueProgressDialog::Setup(long max, const wxString& title, const wxString
{
if (m_dlg)
m_dlg->Destroy();
m_dlg = new wxProgressDialog(title, msg, 0x10000, NULL, wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME);
m_dlg = new wxProgressDialog(title, msg, DLG_MAX_VALUE, NULL, wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME);
m_last = 0;
m_const = 0;
m_value = 0;
Expand All @@ -70,7 +72,10 @@ bool GOrgueProgressDialog::Update(unsigned value, const wxString& msg)
if (m_last == wxGetUTCTime())
return true;
m_last = wxGetUTCTime();
if (!m_dlg->Update(0xffff * (m_value + m_const) / m_max, msg))

int newValue = (DLG_MAX_VALUE - 1) * (m_value + m_const) / m_max;

if (newValue <= DLG_MAX_VALUE && !m_dlg->Update(newValue, msg))
return false;
return true;
}
Expand Down
8 changes: 5 additions & 3 deletions src/grandorgue/GOrgueSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@ void GOrgueSound::CloseSound()
{
if (m_AudioOutputs[i].port)
{
m_AudioOutputs[i].port->Close();
delete m_AudioOutputs[i].port;
m_AudioOutputs[i].port = 0;
GOrgueSoundPort* const port = m_AudioOutputs[i].port;

m_AudioOutputs[i].port = NULL;
port->Close();
delete port;
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/grandorgue/GOrgueSoundRtPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ GOrgueSoundRtPort::~GOrgueSoundRtPort()
Close();
try
{
if (m_port)
delete m_port;
if (m_port) {
const RtAudio* port = m_port;

m_port = NULL;
delete port;
}
}
catch (RtAudioError &e)
{
Expand Down
12 changes: 8 additions & 4 deletions src/grandorgue/GrandOrgueFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,15 @@ GOrgueFrame::GOrgueFrame(wxFrame *frame, wxWindowID id, const wxString& title, c

GOrgueFrame::~GOrgueFrame()
{
if (m_doc)
delete m_doc;
if (m_doc) {
delete m_doc;
m_doc = NULL;
}
m_listener.SetCallback(NULL);
if (m_Help)
delete m_Help;
if (m_Help) {
delete m_Help;
m_Help = NULL;
}
}

void GOrgueFrame::UpdateVolumeControl(unsigned count)
Expand Down
6 changes: 3 additions & 3 deletions src/grandorgue/SettingsAudioGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ SettingsAudioGroup::SettingsAudioGroup(GOrgueSettings& settings, wxWindow* paren
m_Del = new wxButton(this, ID_AUDIOGROUP_DEL, _("&Delete"));
m_Del->Disable();

buttonSizer->Add(m_Add, 0, wxALIGN_LEFT | wxALL, 5);
buttonSizer->Add(m_Del, 0, wxALIGN_LEFT | wxALL, 5);
buttonSizer->Add(m_Change, 0, wxALIGN_RIGHT | wxALL, 5);
buttonSizer->Add(m_Add, 0, wxALL, 5);
buttonSizer->Add(m_Del, 0, wxALL, 5);
buttonSizer->Add(m_Change, 0, wxALL, 5);
topSizer->Add(buttonSizer, 0, wxALL, 5);

std::vector<wxString> audio_groups = m_Settings.GetAudioGroups();
Expand Down
10 changes: 5 additions & 5 deletions src/grandorgue/SettingsAudioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ SettingsAudioOutput::SettingsAudioOutput(GOrgueSound& sound, GOAudioGroupCallbac
m_Properties = new wxButton(this, ID_OUTPUT_PROPERTIES, _("Properties"));
m_Default = new wxButton(this, ID_OUTPUT_DEFAULT, _("Revert to Default"));

buttonSizer->Add(m_Add, 0, wxALIGN_LEFT | wxALL, 5);
buttonSizer->Add(m_Del, 0, wxALIGN_LEFT | wxALL, 5);
buttonSizer->Add(m_Change, 0, wxALIGN_RIGHT | wxALL, 5);
buttonSizer->Add(m_Properties, 0, wxALIGN_RIGHT | wxALL, 5);
buttonSizer->Add(m_Default, 0, wxALIGN_RIGHT | wxALL, 5);
buttonSizer->Add(m_Add, 0, wxALL, 5);
buttonSizer->Add(m_Del, 0, wxALL, 5);
buttonSizer->Add(m_Change, wxALL, 5);
buttonSizer->Add(m_Properties, 0, wxALL, 5);
buttonSizer->Add(m_Default, 0, wxALL, 5);
topSizer->Add(buttonSizer, 0, wxALL, 5);

m_AudioOutput->AddRoot(_("Audio Output"), -1, -1, new AudioItemData());
Expand Down
2 changes: 1 addition & 1 deletion src/grandorgue/SettingsDefaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ SettingsDefaults::SettingsDefaults(GOrgueSettings& settings, wxWindow* parent) :
m_MidiRecorderPath->SetPath(m_Settings.MidiRecorderPath());
m_MidiPlayerPath->SetPath(m_Settings.MidiPlayerPath());

topSizer->Add(item0, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5);
topSizer->Add(item0, 1, wxEXPAND | wxALL, 5);
topSizer->AddSpacer(5);
this->SetSizer(topSizer);
topSizer->FitInside(this);
Expand Down
6 changes: 3 additions & 3 deletions src/grandorgue/SettingsMidiDevices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ SettingsMidiDevices::SettingsMidiDevices(GOrgueSound& sound, wxWindow* parent) :
m_InOutDevice->Disable();
item4->Add(m_InOutDevice, 0, wxALL, 5);
item3->Add(item4, 0, wxALIGN_RIGHT | wxALL, 5);
topSizer->Add(item3, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5);
topSizer->Add(item3, 1, wxEXPAND | wxALL, 5);

choices.clear();
std::vector<bool> out_state;
Expand All @@ -94,7 +94,7 @@ SettingsMidiDevices::SettingsMidiDevices(GOrgueSound& sound, wxWindow* parent) :
item3->Add(m_OutDevices, 1, wxEXPAND | wxALL, 5);
wxBoxSizer* box = new wxBoxSizer(wxHORIZONTAL);
item3->Add(box);
box->Add(new wxStaticText(this, wxID_ANY, _("Send MIDI Recorder Output Stream to ")), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
box->Add(new wxStaticText(this, wxID_ANY, _("Send MIDI Recorder Output Stream to ")), 0, wxALIGN_CENTER_VERTICAL);
m_RecorderDevice = new wxChoice(this, ID_RECORDERDEVICE);
box->Add(m_RecorderDevice, 0);
m_RecorderDevice->Append(_("No device"));
Expand All @@ -107,7 +107,7 @@ SettingsMidiDevices::SettingsMidiDevices(GOrgueSound& sound, wxWindow* parent) :
m_RecorderDevice->SetSelection(m_RecorderDevice->GetCount() - 1);
}

topSizer->Add(item3, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5);
topSizer->Add(item3, 1, wxEXPAND | wxALL, 5);

topSizer->AddSpacer(5);
this->SetSizer(topSizer);
Expand Down
2 changes: 1 addition & 1 deletion src/grandorgue/SettingsOption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ SettingsOption::SettingsOption(GOrgueSettings& settings, wxWindow* parent) :
item9->Add(m_ODFCheck = new wxCheckBox(this, ID_ODF_CHECK, _("Perform strict ODF")), 0, wxEXPAND | wxALL, 5);
m_ODFCheck->SetValue(m_Settings.ODFCheck());

topSizer->Add(item0, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5);
topSizer->Add(item0, 1, wxEXPAND | wxALL, 5);
topSizer->AddSpacer(5);
this->SetScrollRate(5, 5);
this->SetSizer(topSizer);
Expand Down
2 changes: 1 addition & 1 deletion src/grandorgue/SettingsOrgan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SettingsOrgan::SettingsOrgan(GOrgueSettings& settings, GOrgueMidi& midi, wxWindo
buttonSizer->Add(m_Up, 0, wxALIGN_LEFT | wxALL, 5);
buttonSizer->Add(m_Top, 0, wxALIGN_LEFT | wxALL, 5);
buttonSizer->Add(m_Del, 0, wxALIGN_LEFT | wxALL, 5);
buttonSizer->Add(m_Properties, 0, wxALIGN_RIGHT | wxALL, 5);
buttonSizer->Add(m_Properties, 0, wxALIGN_LEFT | wxALL, 5);
topSizer->Add(buttonSizer, 0, wxALL, 5);

for(unsigned i = 0; i < m_Settings.GetOrganList().size(); i++)
Expand Down

0 comments on commit f885725

Please sign in to comment.