From 07fafac36e4599738009d49ce1ccac8cfa2a7450 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 23 Jun 2014 12:16:35 +0200 Subject: [PATCH] don't let enumerated device list strings go out of scope. --- libs/backends/alsa/alsa_audiobackend.cc | 16 ++++++++-------- libs/backends/alsa/alsa_audiobackend.h | 3 +++ libs/backends/dummy/dummy_audiobackend.cc | 8 +++++--- libs/backends/dummy/dummy_audiobackend.h | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc index a61d3a1869..a411916c68 100644 --- a/libs/backends/alsa/alsa_audiobackend.cc +++ b/libs/backends/alsa/alsa_audiobackend.cc @@ -39,6 +39,8 @@ using namespace ARDOUR; static std::string s_instance_name; size_t AlsaAudioBackend::_max_buffer_size = 8192; std::vector AlsaAudioBackend::_midi_options; +std::vector AlsaAudioBackend::_audio_device_status; +std::vector AlsaAudioBackend::_midi_device_status; AlsaAudioBackend::AlsaAudioBackend (AudioEngine& e, AudioBackendInfo& info) : AudioBackend (e, info) @@ -87,13 +89,13 @@ AlsaAudioBackend::is_realtime () const std::vector AlsaAudioBackend::enumerate_devices () const { - std::vector s; + _audio_device_status.clear(); std::map devices; get_alsa_audio_device_names(devices); for (std::map::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 AlsaAudioBackend::enumerate_midi_devices () const { - std::vector s; + _midi_device_status.clear(); std::map 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::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 diff --git a/libs/backends/alsa/alsa_audiobackend.h b/libs/backends/alsa/alsa_audiobackend.h index 089420e78e..6f54ba2f1c 100644 --- a/libs/backends/alsa/alsa_audiobackend.h +++ b/libs/backends/alsa/alsa_audiobackend.h @@ -303,6 +303,9 @@ class AlsaAudioBackend : public AudioBackend { bool _measure_latency; static std::vector _midi_options; + static std::vector _audio_device_status; + static std::vector _midi_device_status; + std::string _audio_device; std::string _midi_driver_option; diff --git a/libs/backends/dummy/dummy_audiobackend.cc b/libs/backends/dummy/dummy_audiobackend.cc index dc53010443..3a969aa479 100644 --- a/libs/backends/dummy/dummy_audiobackend.cc +++ b/libs/backends/dummy/dummy_audiobackend.cc @@ -33,6 +33,7 @@ using namespace ARDOUR; static std::string s_instance_name; size_t DummyAudioBackend::_max_buffer_size = 8192; std::vector DummyAudioBackend::_midi_options; +std::vector DummyAudioBackend::_device_status; DummyAudioBackend::DummyAudioBackend (AudioEngine& e, AudioBackendInfo& info) : AudioBackend (e, info) @@ -76,9 +77,10 @@ DummyAudioBackend::is_realtime () const std::vector DummyAudioBackend::enumerate_devices () const { - std::vector 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 diff --git a/libs/backends/dummy/dummy_audiobackend.h b/libs/backends/dummy/dummy_audiobackend.h index 638bb9f312..70aec34ecd 100644 --- a/libs/backends/dummy/dummy_audiobackend.h +++ b/libs/backends/dummy/dummy_audiobackend.h @@ -293,6 +293,7 @@ class DummyAudioBackend : public AudioBackend { private: std::string _instance_name; static std::vector _midi_options; + static std::vector _device_status; bool _running; bool _freewheeling;