From 2734f9c7f8a5898293d236043c9f5e32c8ebe309 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 18 Nov 2017 18:21:22 -0500 Subject: [PATCH] Update device name in AudioInterface choice widget only when deviceId changes --- src/core/AudioInterface.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/AudioInterface.cpp b/src/core/AudioInterface.cpp index be3102ab..990f134e 100644 --- a/src/core/AudioInterface.cpp +++ b/src/core/AudioInterface.cpp @@ -318,6 +318,7 @@ struct AudioItem : MenuItem { }; struct AudioChoice : ChoiceButton { + int lastDeviceId = -1; AudioInterface *audioInterface; void onAction(EventAction &e) override { Menu *menu = gScene->createMenu(); @@ -341,8 +342,11 @@ struct AudioChoice : ChoiceButton { } } void step() override { - std::string name = audioInterface->getDeviceName(audioInterface->deviceId); - text = ellipsize(name, 24); + if (lastDeviceId != audioInterface->deviceId) { + std::string name = audioInterface->getDeviceName(audioInterface->deviceId); + text = ellipsize(name, 24); + lastDeviceId = audioInterface->deviceId; + } } };