Skip to content

Commit 1088ac7

Browse files
committed
Added a small patch to confirm that all splitter channels have gone before turning the microphone off
1 parent 6c1433e commit 1088ac7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

source/MicroBitAudio.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ MicroBitAudio::MicroBitAudio(NRF52Pin &pin, NRF52Pin &speaker, NRF52ADC &adc, NR
8383

8484
// Register listener for splitter events
8585
if(EventModel::defaultEventBus){
86+
EventModel::defaultEventBus->listen(rawSplitter->id, DEVICE_EVT_ANY, this, &MicroBitAudio::onSplitterEvent, MESSAGE_BUS_LISTENER_IMMEDIATE);
8687
EventModel::defaultEventBus->listen(DEVICE_ID_SPLITTER, DEVICE_EVT_ANY, this, &MicroBitAudio::onSplitterEvent, MESSAGE_BUS_LISTENER_IMMEDIATE);
8788
}
8889
}
@@ -94,7 +95,8 @@ void MicroBitAudio::onSplitterEvent(MicroBitEvent e){
9495
if(e.value == SPLITTER_ACTIVATE_CHANNEL)
9596
activateMic();
9697
else if (e.value == SPLITTER_DEACTIVATE_CHANNEL)
97-
deactivateMic();
98+
if( splitter->numberChannels <= 0 && rawSplitter->numberChannels <= 0 ) // Only deactivate if we have no more channels to serve!
99+
deactivateMic();
98100
}
99101

100102
/**

0 commit comments

Comments
 (0)