Fix microphone not restarting on reconnect
This commit is contained in:
@@ -161,6 +161,7 @@ void wivrn::android::audio::build_microphone(AAudioStreamBuilder * builder, int3
|
||||
aaudio_result_t result = AAudioStreamBuilder_openStream(builder, µphone);
|
||||
if (result != AAUDIO_OK)
|
||||
spdlog::error("Cannot create input stream: {}", AAudio_convertResultToText(result));
|
||||
mic_running = false;
|
||||
// Microphone is started manually by a tracking_control packet
|
||||
}
|
||||
|
||||
@@ -280,6 +281,9 @@ void wivrn::android::audio::set_mic_sate(bool running)
|
||||
if (not microphone)
|
||||
return;
|
||||
|
||||
auto old = mic_running.exchange(running);
|
||||
if (old == running)
|
||||
return;
|
||||
if (running)
|
||||
AAudioStream_requestStart(microphone);
|
||||
else
|
||||
|
||||
@@ -56,6 +56,7 @@ class audio
|
||||
std::atomic<bool> speaker_stop_ack = false;
|
||||
AAudioStreamStruct * microphone = nullptr;
|
||||
std::atomic<bool> microphone_stop_ack = false;
|
||||
std::atomic<bool> mic_running = false;
|
||||
|
||||
wivrn_session & session;
|
||||
xr::instance & instance;
|
||||
|
||||
@@ -353,7 +353,7 @@ void scenes::stream::operator()(to_headset::tracking_control && packet)
|
||||
{
|
||||
std::lock_guard lock(tracking_control_mutex);
|
||||
auto m = size_t(to_headset::tracking_control::id::microphone);
|
||||
if (tracking_control.enabled[m] != packet.enabled[m] and audio_handle)
|
||||
if (audio_handle)
|
||||
audio_handle->set_mic_sate(packet.enabled[m]);
|
||||
|
||||
tracking_control = packet;
|
||||
|
||||
Reference in New Issue
Block a user