diff options
author | Dave Reisner <dreisner@archlinux.org> | 2013-08-23 08:33:36 -0400 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2013-08-23 08:33:36 -0400 |
commit | 0712d76b323494edb83d36867a6e34af12b20f19 (patch) | |
tree | 685763077cc32d38ed387915a8f50a2e98f18a17 | |
parent | 4204a29a0678d2384e4b88d4dc185b2da2e9bedf (diff) | |
download | mirror-ponymix-0712d76b323494edb83d36867a6e34af12b20f19.tar.gz mirror-ponymix-0712d76b323494edb83d36867a6e34af12b20f19.tar.bz2 mirror-ponymix-0712d76b323494edb83d36867a6e34af12b20f19.zip |
pulse: swap vectors rather than repopulating directly
-rw-r--r-- | pulse.cc | 31 |
1 files changed, 21 insertions, 10 deletions
@@ -284,12 +284,15 @@ T* PulseClient::find_fuzzy(vector<T>& haystack, const string& needle) { } void PulseClient::populate_cards() { - cards_.clear(); + vector<Card> cards; pa_operation* op = pa_context_get_card_info_list(context_, card_info_cb, - static_cast<void*>(&cards_)); + static_cast<void*>(&cards)); mainloop_iterate(op); pa_operation_unref(op); + + using std::swap; + swap(cards, cards_); } void PulseClient::populate_server_info() { @@ -301,31 +304,39 @@ void PulseClient::populate_server_info() { } void PulseClient::populate_sinks() { - sinks_.clear(); + vector<Device> sinks; pa_operation* op = pa_context_get_sink_info_list( - context_, device_info_cb, static_cast<void*>(&sinks_)); + context_, device_info_cb, static_cast<void*>(&sinks)); mainloop_iterate(op); pa_operation_unref(op); - sink_inputs_.clear(); + vector<Device> sink_inputs; op = pa_context_get_sink_input_info_list( - context_, device_info_cb, static_cast<void*>(&sink_inputs_)); + context_, device_info_cb, static_cast<void*>(&sink_inputs)); mainloop_iterate(op); pa_operation_unref(op); + + using std::swap; + swap(sinks, sinks_); + swap(sink_inputs, sink_inputs_); } void PulseClient::populate_sources() { - sources_.clear(); + vector<Device> sources; pa_operation* op = pa_context_get_source_info_list( - context_, device_info_cb, static_cast<void*>(&sources_)); + context_, device_info_cb, static_cast<void*>(&sources)); mainloop_iterate(op); pa_operation_unref(op); - source_outputs_.clear(); + vector<Device> source_outputs; op = pa_context_get_source_output_info_list( - context_, device_info_cb, static_cast<void*>(&source_outputs_)); + context_, device_info_cb, static_cast<void*>(&source_outputs)); mainloop_iterate(op); pa_operation_unref(op); + + using std::swap; + swap(sources, sources_); + swap(source_outputs, source_outputs_); } bool PulseClient::SetMute(Device& device, bool mute) { |