13
0

statically allocate midi-options

fixes possible segfault when the data in the vector
goes out of scope due to RVO.
This commit is contained in:
Robin Gareus 2014-06-23 11:56:58 +02:00
parent 371bf59a94
commit fb51bdb892
4 changed files with 18 additions and 10 deletions

View File

@ -38,6 +38,7 @@ using namespace ARDOUR;
static std::string s_instance_name;
size_t AlsaAudioBackend::_max_buffer_size = 8192;
std::vector<std::string> AlsaAudioBackend::_midi_options;
AlsaAudioBackend::AlsaAudioBackend (AudioEngine& e, AudioBackendInfo& info)
: AudioBackend (e, info)
@ -403,11 +404,12 @@ AlsaAudioBackend::midi_device_info(std::string const name) const {
std::vector<std::string>
AlsaAudioBackend::enumerate_midi_options () const
{
std::vector<std::string> m;
m.push_back (_("None"));
m.push_back (_("ALSA raw devices"));
m.push_back (_("ALSA sequencer"));
return m;
if (_midi_options.empty()) {
_midi_options.push_back (_("None"));
_midi_options.push_back (_("ALSA raw devices"));
_midi_options.push_back (_("ALSA sequencer"));
}
return _midi_options;
}
std::vector<AudioBackend::DeviceStatus>

View File

@ -302,6 +302,7 @@ class AlsaAudioBackend : public AudioBackend {
bool _freewheeling;
bool _measure_latency;
static std::vector<std::string> _midi_options;
std::string _audio_device;
std::string _midi_driver_option;

View File

@ -32,6 +32,7 @@ using namespace ARDOUR;
static std::string s_instance_name;
size_t DummyAudioBackend::_max_buffer_size = 8192;
std::vector<std::string> DummyAudioBackend::_midi_options;
DummyAudioBackend::DummyAudioBackend (AudioEngine& e, AudioBackendInfo& info)
: AudioBackend (e, info)
@ -249,15 +250,17 @@ DummyAudioBackend::systemic_output_latency () const
return _systemic_output_latency;
}
/* MIDI */
std::vector<std::string>
DummyAudioBackend::enumerate_midi_options () const
{
std::vector<std::string> m;
m.push_back (_("1 in, 1 out"));
m.push_back (_("2 in, 2 out"));
m.push_back (_("8 in, 8 out"));
return m;
if (_midi_options.empty()) {
_midi_options.push_back (_("1 in, 1 out"));
_midi_options.push_back (_("2 in, 2 out"));
_midi_options.push_back (_("8 in, 8 out"));
}
return _midi_options;
}
int

View File

@ -292,6 +292,8 @@ class DummyAudioBackend : public AudioBackend {
private:
std::string _instance_name;
static std::vector<std::string> _midi_options;
bool _running;
bool _freewheeling;