Skip to content

Commit

Permalink
Handle request in MediaStart()
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevelopment committed Dec 11, 2017
2 parents 854b430 + 9811aa8 commit ca792ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hu/hu.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion mazda/callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -90,7 +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 || 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
}

Expand Down
3 changes: 3 additions & 0 deletions mazda/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ static void gps_thread_func(std::condition_variable& quitcv, std::mutex& quitmut

location->set_accuracy(static_cast<int32_t>(data.horizontalAccuracy * 1E3));

#ifdef NAV_DEBUG
printf("GPS data: %d %d %f %f %d %f %f %f %f \n",data.positionAccuracy, data.uTCtime, data.latitude, data.longitude, data.altitude, data.heading, data.velocity, data.horizontalAccuracy, data.verticalAccuracy);
#endif
s.hu_aap_enc_send_message(0, AA_CH_SEN, HU_SENSOR_CHANNEL_MESSAGE::SensorEvent, sensorEvent);
});
}
Expand Down

0 comments on commit ca792ad

Please sign in to comment.