13
0

don't let enumerated device list strings go out of scope.

This commit is contained in:
Robin Gareus 2014-06-23 12:16:35 +02:00
parent fb51bdb892
commit 07fafac36e
4 changed files with 17 additions and 11 deletions

View File

@ -39,6 +39,8 @@ using namespace ARDOUR;
static std::string s_instance_name;
size_t AlsaAudioBackend::_max_buffer_size = 8192;
std::vector<std::string> AlsaAudioBackend::_midi_options;
std::vector<AudioBackend::DeviceStatus> AlsaAudioBackend::_audio_device_status;
std::vector<AudioBackend::DeviceStatus> AlsaAudioBackend::_midi_device_status;
AlsaAudioBackend::AlsaAudioBackend (AudioEngine& e, AudioBackendInfo& info)
: AudioBackend (e, info)
@ -87,13 +89,13 @@ AlsaAudioBackend::is_realtime () const
std::vector<AudioBackend::DeviceStatus>
AlsaAudioBackend::enumerate_devices () const
{
std::vector<AudioBackend::DeviceStatus> s;
_audio_device_status.clear();
std::map<std::string, std::string> devices;
get_alsa_audio_device_names(devices);
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end(); ++i) {
s.push_back (DeviceStatus (i->first, true));
_audio_device_status.push_back (DeviceStatus (i->first, true));
}
return s;
return _audio_device_status;
}
void
@ -415,7 +417,7 @@ AlsaAudioBackend::enumerate_midi_options () const
std::vector<AudioBackend::DeviceStatus>
AlsaAudioBackend::enumerate_midi_devices () const
{
std::vector<AudioBackend::DeviceStatus> s;
_midi_device_status.clear();
std::map<std::string, std::string> devices;
if (_midi_driver_option == _("ALSA raw devices")) {
@ -423,14 +425,12 @@ AlsaAudioBackend::enumerate_midi_devices () const
}
else if (_midi_driver_option == _("ALSA sequencer")) {
get_alsa_sequencer_names (devices);
} else {
return s;
}
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end(); ++i) {
s.push_back (DeviceStatus (i->first, true));
_midi_device_status.push_back (DeviceStatus (i->first, true));
}
return s;
return _midi_device_status;
}
int

View File

@ -303,6 +303,9 @@ class AlsaAudioBackend : public AudioBackend {
bool _measure_latency;
static std::vector<std::string> _midi_options;
static std::vector<AudioBackend::DeviceStatus> _audio_device_status;
static std::vector<AudioBackend::DeviceStatus> _midi_device_status;
std::string _audio_device;
std::string _midi_driver_option;

View File

@ -33,6 +33,7 @@ using namespace ARDOUR;
static std::string s_instance_name;
size_t DummyAudioBackend::_max_buffer_size = 8192;
std::vector<std::string> DummyAudioBackend::_midi_options;
std::vector<AudioBackend::DeviceStatus> DummyAudioBackend::_device_status;
DummyAudioBackend::DummyAudioBackend (AudioEngine& e, AudioBackendInfo& info)
: AudioBackend (e, info)
@ -76,9 +77,10 @@ DummyAudioBackend::is_realtime () const
std::vector<AudioBackend::DeviceStatus>
DummyAudioBackend::enumerate_devices () const
{
std::vector<AudioBackend::DeviceStatus> s;
s.push_back (DeviceStatus (_("Dummy"), true));
return s;
if (_device_status.empty()) {
_device_status.push_back (DeviceStatus (_("Dummy"), true));
}
return _device_status;
}
std::vector<float>

View File

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