diff --git a/hu/hu.proto b/hu/hu.proto index 9a72d7da..f7adac67 100644 --- a/hu/hu.proto +++ b/hu/hu.proto @@ -583,7 +583,7 @@ message AudioFocusRequest { AUDIO_FOCUS_GAIN = 1; AUDIO_FOCUS_GAIN_TRANSIENT = 2; - AUDIO_FOCUS_UNKNOWN = 3; + AUDIO_FOCUS_GAIN_NAVI = 3; AUDIO_FOCUS_RELEASE = 4; } required AUDIO_FOCUS focus_type = 1; diff --git a/mazda/callbacks.cpp b/mazda/callbacks.cpp index 86c3467b..a3e7979c 100644 --- a/mazda/callbacks.cpp +++ b/mazda/callbacks.cpp @@ -40,6 +40,8 @@ int MazdaEventCallbacks::MediaPacket(int chan, uint64_t timestamp, const byte *b int MazdaEventCallbacks::MediaStart(int chan) { if (chan == AA_CH_MIC) { + // We ignored transient requests to avoid capturing phone calls so we handle the request here + audioMgrClient->audioMgrRequestAudioFocus(AudioManagerClient::FocusType::TRANSIENT); printf("SHAI1 : Mic Started\n"); micInput.Start(g_hu); } @@ -90,9 +92,7 @@ void MazdaEventCallbacks::AudioFocusRequest(int chan, const HU::AudioFocusReques //The chan passed here is always AA_CH_CTR but internally we pass the channel AA means if (request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_RELEASE) { audioMgrClient->audioMgrReleaseAudioFocus(); - } else if (request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_GAIN_TRANSIENT) { - audioMgrClient->audioMgrRequestAudioFocus(AudioManagerClient::FocusType::TRANSIENT); //assume navigation - } else if (request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_GAIN || request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_UNKNOWN) { + } else if (request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_GAIN || request.focus_type() == HU::AudioFocusRequest::AUDIO_FOCUS_GAIN_NAVI) { audioMgrClient->audioMgrRequestAudioFocus(AudioManagerClient::FocusType::PERMANENT); //assume media } @@ -388,7 +388,7 @@ void AudioManagerClient::populateStreamTable() // Create and register stream (only if we need to) if (aaSessionID < 0) { - logw("When using the USB stream we should never have to register since it should be already there"); + //logw("When using the USB stream we should never have to register since it should be already there"); aaRegisterStream(); } } @@ -501,6 +501,7 @@ void AudioManagerClient::Notify(const std::string &signalName, const std::string auto result = json::parse(payload); std::string streamName = result["streamName"].get(); std::string newFocus = result["newFocus"].get(); + std::string focusType = result["focusType"].get(); auto findIt = streamToSessionIds.find(streamName); int eventSessionID = -1; @@ -524,12 +525,12 @@ void AudioManagerClient::Notify(const std::string &signalName, const std::string if (eventSessionID == aaSessionID) { - bool hasFocus = newFocus == "gained"; - if (hasFocus) + if (newFocus == "gained") { requestPending = false; + pendingFocus = FocusType::PERMANENT; } - else + else if (newFocus != "temporarilyLost") { releasePending = false; pendingFocus = FocusType::NONE; @@ -540,7 +541,10 @@ void AudioManagerClient::Notify(const std::string &signalName, const std::string currentFocus = pendingFocus; callbacks.AudioFocusHappend(currentFocus); } - pendingFocus = FocusType::NONE; + if (newFocus != "temporarilyLost") + { + pendingFocus = FocusType::NONE; + } } } } diff --git a/mazda/outputs.cpp b/mazda/outputs.cpp index fb48587c..f563789c 100644 --- a/mazda/outputs.cpp +++ b/mazda/outputs.cpp @@ -248,32 +248,7 @@ void VideoOutput::input_thread_func() //Make the music button play/pause case KEY_E: printf("KEY_E\n"); - //The FAV key basically does this right? We need a normal Play/Pause button scanCode = HUIB_PLAYPAUSE; - /* - if (hasMediaAudioFocus) - { - if (isPressed) - { - pass_key_to_mzd(event.type, event.code, event.value); - } - else - { - scanCode = HUIB_PLAYPAUSE; - } - } - else - { - if (isPressed) - { - scanCode = HUIB_PLAYPAUSE; - } - else - { - pass_key_to_mzd(event.type, event.code, event.value); - } - } - */ break; case KEY_LEFTBRACE: printf("KEY_LEFTBRACE (next track with media focus: %i)\n", hasMediaAudioFocus ? 1 : 0);