audio_manager: move std::functions in SetOutManager/SetInManager

Prevents unnecessary reallocations in the event the captured variables
are larger than the internal std::function buffer.
master
Lioncash 2022-09-21 09:32:12 +07:00
parent da0fd51642
commit e48e22eb52
1 changed files with 2 additions and 2 deletions

@ -25,7 +25,7 @@ Result AudioManager::SetOutManager(BufferEventFunc buffer_func) {
const auto index{events.GetManagerIndex(Event::Type::AudioOutManager)}; const auto index{events.GetManagerIndex(Event::Type::AudioOutManager)};
if (buffer_events[index] == nullptr) { if (buffer_events[index] == nullptr) {
buffer_events[index] = buffer_func; buffer_events[index] = std::move(buffer_func);
needs_update = true; needs_update = true;
events.SetAudioEvent(Event::Type::AudioOutManager, true); events.SetAudioEvent(Event::Type::AudioOutManager, true);
} }
@ -41,7 +41,7 @@ Result AudioManager::SetInManager(BufferEventFunc buffer_func) {
const auto index{events.GetManagerIndex(Event::Type::AudioInManager)}; const auto index{events.GetManagerIndex(Event::Type::AudioInManager)};
if (buffer_events[index] == nullptr) { if (buffer_events[index] == nullptr) {
buffer_events[index] = buffer_func; buffer_events[index] = std::move(buffer_func);
needs_update = true; needs_update = true;
events.SetAudioEvent(Event::Type::AudioInManager, true); events.SetAudioEvent(Event::Type::AudioInManager, true);
} }