summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSho Amano <samano@xevo.com>2018-03-27 03:35:24 +0900
committerjacobkeeler <jacob.keeler@livioradio.com>2018-04-05 16:12:51 -0400
commit70953440b8bca01bd63eaeba3db47e4f9fe64454 (patch)
tree49cd64adaf6a86537ee2c42ceef322eafd3669ec
parent61fd83fed0dc584019b305bebc82512d2c42b9e7 (diff)
downloadsdl_core-hotfix/unregister_during_audio_pass_thru.tar.gz
Fix/unregister while audio pass thru (#1757)hotfix/unregister_during_audio_pass_thru
* fix build error in MockMediaManager * Add SetMockMediaManager * add AudioPassThru start/stop tests * Add new BeginAudioPassThru() and EndAudioPassThru() methods * fix: don't terminate AudioPassThru when another app is unregistered * Append DEPRECATED macro only in interface header file and mock file. * Use @deprecated comments
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h25
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc31
-rw-r--r--src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc5
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc8
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc117
-rw-r--r--src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc3
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc41
-rw-r--r--src/components/include/application_manager/application_manager.h21
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h6
-rw-r--r--src/components/include/test/media_manager/mock_media_manager.h2
10 files changed, 234 insertions, 25 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index 3e7fab60fb..286ad87018 100644
--- a/src/components/application_manager/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/include/application_manager/application_manager_impl.h
@@ -478,18 +478,35 @@ class ApplicationManagerImpl
uint32_t GetNextHMICorrelationID() OVERRIDE;
/* @brief Starts audio passthru process
+ * @deprecated Use BeginAudioPassThru(uint32_t app_id) instead
*
* @return true on success, false if passthru is already in process
*/
bool BeginAudioPassThrough() OVERRIDE;
+ /**
+ * @brief Starts AudioPassThru process by given application
+ * @param app_id ID of the application which starts the process
+ * @return true if AudioPassThru can be started, false otherwise
+ */
+ bool BeginAudioPassThru(uint32_t app_id) OVERRIDE;
+
/*
* @brief Finishes already started audio passthru process
+ * @deprecated Use EndAudioPassThru(uint32_t app_id) instead
*
* @return true on success, false if passthru is not active
*/
bool EndAudioPassThrough() OVERRIDE;
+ /**
+ * @brief Finishes already started AudioPassThru process by given application
+ * @param app_id ID of the application which started the process
+ * @return true if AudioPassThru process has been started with given
+ * application and thus it can be stopped, false otherwise
+ */
+ bool EndAudioPassThru(uint32_t app_id) OVERRIDE;
+
/*
* @brief Retrieves driver distraction state
*
@@ -1702,6 +1719,7 @@ class ApplicationManagerImpl
std::map<uint32_t, TimevalStruct> tts_global_properties_app_list_;
bool audio_pass_thru_active_;
+ uint32_t audio_pass_thru_app_id_;
sync_primitives::Lock audio_pass_thru_lock_;
sync_primitives::Lock tts_global_properties_app_list_lock_;
hmi_apis::Common_DriverDistractionState::eType driver_distraction_state_;
@@ -1820,6 +1838,13 @@ class ApplicationManagerImpl
*/
void AddMockApplication(ApplicationSharedPtr mock_app);
+ /**
+ * @brief set a mock media manager without running Init(). Only for unit
+ * testing.
+ * @param mock_app the mock app to be registered
+ */
+ void SetMockMediaManager(media_manager::MediaManager* mock_media_manager);
+
private:
#endif
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index f16c21ea84..248b54fee5 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -143,6 +143,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
: settings_(am_settings)
, applications_list_lock_(true)
, audio_pass_thru_active_(false)
+ , audio_pass_thru_app_id_(0)
, driver_distraction_state_(
hmi_apis::Common_DriverDistractionState::INVALID_ENUM)
, is_vr_session_strated_(false)
@@ -784,6 +785,17 @@ bool ApplicationManagerImpl::BeginAudioPassThrough() {
}
}
+bool ApplicationManagerImpl::BeginAudioPassThru(uint32_t app_id) {
+ sync_primitives::AutoLock lock(audio_pass_thru_lock_);
+ if (audio_pass_thru_active_) {
+ return false;
+ } else {
+ audio_pass_thru_active_ = true;
+ audio_pass_thru_app_id_ = app_id;
+ return true;
+ }
+}
+
bool ApplicationManagerImpl::EndAudioPassThrough() {
sync_primitives::AutoLock lock(audio_pass_thru_lock_);
if (audio_pass_thru_active_) {
@@ -794,6 +806,17 @@ bool ApplicationManagerImpl::EndAudioPassThrough() {
}
}
+bool ApplicationManagerImpl::EndAudioPassThru(uint32_t app_id) {
+ sync_primitives::AutoLock lock(audio_pass_thru_lock_);
+ if (audio_pass_thru_active_ && audio_pass_thru_app_id_ == app_id) {
+ audio_pass_thru_active_ = false;
+ audio_pass_thru_app_id_ = 0;
+ return true;
+ } else {
+ return false;
+ }
+}
+
hmi_apis::Common_DriverDistractionState::eType
ApplicationManagerImpl::driver_distraction_state() const {
return driver_distraction_state_;
@@ -3222,9 +3245,8 @@ void ApplicationManagerImpl::UnregisterApplication(
commands_holder_->Clear(app_to_remove);
- if (audio_pass_thru_active_) {
+ if (EndAudioPassThru(app_id)) {
// May be better to put this code in MessageHelper?
- EndAudioPassThrough();
StopAudioPassThru(app_id);
MessageHelper::SendStopAudioPathThru(*this);
}
@@ -4441,6 +4463,11 @@ void ApplicationManagerImpl::AddMockApplication(ApplicationSharedPtr mock_app) {
apps_size_ = applications_.size();
applications_list_lock_.Release();
}
+
+void ApplicationManagerImpl::SetMockMediaManager(
+ media_manager::MediaManager* mock_media_manager) {
+ media_manager_ = mock_media_manager;
+}
#endif // BUILD_TESTS
#ifdef SDL_REMOTE_CONTROL
struct MobileAppIdPredicate {
diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
index 0bd83078e5..fb168e4256 100644
--- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
@@ -66,9 +66,10 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
const bool result = PrepareResultForMobileResponse(
result_code, HmiInterfaces::HMI_INTERFACE_UI);
if (result) {
- bool ended_successfully = application_manager_.EndAudioPassThrough();
+ uint32_t app_id = connection_key();
+ bool ended_successfully = application_manager_.EndAudioPassThru(app_id);
if (ended_successfully) {
- application_manager_.StopAudioPassThru(connection_key());
+ application_manager_.StopAudioPassThru(app_id);
}
}
diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
index a05d41c098..20076ac50c 100644
--- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
@@ -311,7 +311,8 @@ void PerformAudioPassThruRequest::SendRecordStartNotification() {
void PerformAudioPassThruRequest::StartMicrophoneRecording() {
LOG4CXX_AUTO_TRACE(logger_);
- application_manager_.BeginAudioPassThrough();
+ uint32_t app_id = connection_key();
+ application_manager_.BeginAudioPassThru(app_id);
application_manager_.StartAudioPassThruThread(
connection_key(),
@@ -370,9 +371,10 @@ bool PerformAudioPassThruRequest::IsWhiteSpaceExist() {
void PerformAudioPassThruRequest::FinishTTSSpeak() {
LOG4CXX_AUTO_TRACE(logger_);
- if (application_manager_.EndAudioPassThrough()) {
+ uint32_t app_id = connection_key();
+ if (application_manager_.EndAudioPassThru(app_id)) {
LOG4CXX_DEBUG(logger_, "Stop AudioPassThru.");
- application_manager_.StopAudioPassThru(connection_key());
+ application_manager_.StopAudioPassThru(app_id);
}
if (!IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS)) {
LOG4CXX_WARN(logger_, "TTS Speak is inactive.");
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc
index e54bc612ca..c922c227bb 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -47,6 +47,7 @@
#include "application_manager/test/include/application_manager/mock_message_helper.h"
#include "connection_handler/mock_connection_handler.h"
#include "hmi_message_handler/mock_hmi_message_handler.h"
+#include "media_manager/mock_media_manager.h"
#include "policy/mock_policy_settings.h"
#include "policy/usage_statistics/mock_statistics_manager.h"
#include "protocol/bson_object_keys.h"
@@ -824,6 +825,122 @@ TEST_F(ApplicationManagerImplTest,
EXPECT_EQ(new_application_id, app_impl->app_id());
}
+TEST_F(ApplicationManagerImplTest, StartStopAudioPassThru) {
+ std::string dummy_file_name;
+ ON_CALL(mock_application_manager_settings_, recording_file_name())
+ .WillByDefault(ReturnRef(dummy_file_name));
+
+ NiceMock<test::components::media_manager_test::MockMediaManager>
+ mock_media_manager;
+ app_manager_impl_->SetMockMediaManager(&mock_media_manager);
+
+ const uint32_t app_id = 65537;
+ const int32_t max_duration = 1000;
+ // below are not used
+ const int32_t correlation_id = 0;
+ const int32_t sampling_rate = 0;
+ const int32_t bits_per_sample = 0;
+ const int32_t audio_type = 0;
+
+ EXPECT_CALL(mock_media_manager,
+ StartMicrophoneRecording(app_id, _, max_duration))
+ .WillOnce(Return());
+ EXPECT_CALL(mock_media_manager, StopMicrophoneRecording(app_id))
+ .WillOnce(Return());
+
+ bool result = app_manager_impl_->BeginAudioPassThru(app_id);
+ EXPECT_TRUE(result);
+ if (result) {
+ app_manager_impl_->StartAudioPassThruThread(app_id,
+ correlation_id,
+ max_duration,
+ sampling_rate,
+ bits_per_sample,
+ audio_type);
+ }
+
+ result = app_manager_impl_->EndAudioPassThru(app_id);
+ EXPECT_TRUE(result);
+ if (result) {
+ app_manager_impl_->StopAudioPassThru(app_id);
+ }
+}
+
+TEST_F(ApplicationManagerImplTest, UnregisterAnotherAppDuringAudioPassThru) {
+ std::string dummy_file_name;
+ ON_CALL(mock_application_manager_settings_, recording_file_name())
+ .WillByDefault(ReturnRef(dummy_file_name));
+
+ const uint32_t app_id_1 = 65537;
+ const uint32_t app_id_2 = 65538;
+
+ std::string dummy_mac_address;
+ utils::SharedPtr<MockApplication> mock_app_1 =
+ utils::SharedPtr<MockApplication>(new MockApplication());
+ EXPECT_CALL(*mock_app_1, app_id()).WillRepeatedly(Return(app_id_1));
+ EXPECT_CALL(*mock_app_1, device()).WillRepeatedly(Return(0));
+ EXPECT_CALL(*mock_app_1, mac_address())
+ .WillRepeatedly(ReturnRef(dummy_mac_address));
+ EXPECT_CALL(*mock_app_1, policy_app_id()).WillRepeatedly(Return(""));
+ EXPECT_CALL(*mock_app_1, protocol_version())
+ .WillRepeatedly(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4));
+
+ utils::SharedPtr<MockApplication> mock_app_2 =
+ utils::SharedPtr<MockApplication>(new MockApplication());
+ EXPECT_CALL(*mock_app_2, app_id()).WillRepeatedly(Return(app_id_2));
+ EXPECT_CALL(*mock_app_2, device()).WillRepeatedly(Return(0));
+ EXPECT_CALL(*mock_app_2, mac_address())
+ .WillRepeatedly(ReturnRef(dummy_mac_address));
+ EXPECT_CALL(*mock_app_2, policy_app_id()).WillRepeatedly(Return(""));
+ EXPECT_CALL(*mock_app_2, protocol_version())
+ .WillRepeatedly(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4));
+
+ NiceMock<test::components::media_manager_test::MockMediaManager>
+ mock_media_manager;
+ app_manager_impl_->SetMockMediaManager(&mock_media_manager);
+
+ app_manager_impl_->AddMockApplication(mock_app_1);
+ app_manager_impl_->AddMockApplication(mock_app_2);
+
+ const int32_t max_duration = 1000;
+ // below are not used
+ const int32_t correlation_id = 0;
+ const int32_t sampling_rate = 0;
+ const int32_t bits_per_sample = 0;
+ const int32_t audio_type = 0;
+
+ EXPECT_CALL(mock_media_manager,
+ StartMicrophoneRecording(app_id_2, _, max_duration))
+ .WillOnce(Return());
+ EXPECT_CALL(mock_media_manager, StopMicrophoneRecording(app_id_2))
+ .WillOnce(Return());
+
+ // app 2 starts Audio Pass Thru
+ bool result = app_manager_impl_->BeginAudioPassThru(app_id_2);
+ EXPECT_TRUE(result);
+ if (result) {
+ app_manager_impl_->StartAudioPassThruThread(app_id_2,
+ correlation_id,
+ max_duration,
+ sampling_rate,
+ bits_per_sample,
+ audio_type);
+ }
+
+ // while running APT, app 1 is unregistered
+ app_manager_impl_->UnregisterApplication(
+ app_id_1, mobile_apis::Result::SUCCESS, false, true);
+
+ // confirm that APT is still running
+ result = app_manager_impl_->EndAudioPassThru(app_id_2);
+ EXPECT_TRUE(result);
+ if (result) {
+ app_manager_impl_->StopAudioPassThru(app_id_2);
+ }
+}
+
} // application_manager_test
} // namespace components
} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
index 33733f63ed..6b1d909121 100644
--- a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
@@ -67,6 +67,7 @@ class EndAudioPassThruRequestTest
TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) {
const uint32_t kConnectionKey = 2u;
+ const uint32_t app_id = kConnectionKey;
MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
(*command_msg)[am::strings::params][am::strings::connection_key] =
@@ -83,7 +84,7 @@ TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) {
Event event(hmi_apis::FunctionID::UI_EndAudioPassThru);
event.set_smart_object(*event_msg);
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
MessageSharedPtr ui_command_result;
EXPECT_CALL(
diff --git a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
index 6c35a5372a..a27bac970c 100644
--- a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
+++ b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
@@ -128,6 +128,8 @@ class PerformAudioPassThruRequestTest
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ (*message_)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
command_sptr_ =
CreateCommand<am::commands::PerformAudioPassThruRequest>(message_);
@@ -160,10 +162,15 @@ TEST_F(PerformAudioPassThruRequestTest, OnTimeout_GENERIC_ERROR) {
am::mobile_api::Result::GENERIC_ERROR;
(*msg_ui)[am::strings::msg_params][am::strings::success] = false;
+ MessageSharedPtr message =
+ utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map);
+ (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+
utils::SharedPtr<PerformAudioPassThruRequest> command =
- CreateCommand<PerformAudioPassThruRequest>();
+ CreateCommand<PerformAudioPassThruRequest>(message);
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
EXPECT_CALL(
@@ -232,7 +239,8 @@ TEST_F(PerformAudioPassThruRequestTest,
event_ui.set_smart_object(*response_ui);
MessageSharedPtr response_to_mobile;
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillRepeatedly(Return(true));
EXPECT_CALL(
app_mngr_,
@@ -362,7 +370,8 @@ TEST_F(PerformAudioPassThruRequestTest,
hmi_apis::Common_Result::GENERIC_ERROR;
event.set_smart_object(*message_);
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
@@ -536,7 +545,8 @@ TEST_F(
}
// Start microphone recording cals
- EXPECT_CALL(app_mngr_, BeginAudioPassThrough());
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id));
EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _));
CallRun caller(*command_sptr_);
@@ -581,7 +591,8 @@ TEST_F(PerformAudioPassThruRequestTest,
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
// Start microphone recording cals
- EXPECT_CALL(app_mngr_, BeginAudioPassThrough());
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id));
EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _));
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
@@ -617,7 +628,8 @@ TEST_F(PerformAudioPassThruRequestTest,
caller_speak();
// Second call for test correct behavior of UI_PerformAudioPassThru event
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
EXPECT_CALL(app_mngr_, StopAudioPassThru(_)).Times(0);
ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
@@ -641,7 +653,8 @@ TEST_F(PerformAudioPassThruRequestTest,
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, BeginAudioPassThrough()).WillOnce(Return(true));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(
app_mngr_,
@@ -664,8 +677,9 @@ TEST_F(PerformAudioPassThruRequestTest,
msg_params_[am::strings::connection_key] = kConnectionKey;
msg_params_[am::strings::function_id] = kFunctionId;
+ uint32_t app_id = kConnectionKey;
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, BeginAudioPassThrough()).WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(
app_mngr_,
@@ -683,8 +697,9 @@ TEST_F(PerformAudioPassThruRequestTest,
TEST_F(PerformAudioPassThruRequestTest, OnEvent_DefaultCase) {
am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM);
+ uint32_t app_id = kConnectionKey;
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).Times(0);
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).Times(0);
CallOnEvent caller(*command_sptr_, event);
caller();
@@ -703,7 +718,8 @@ TEST_F(PerformAudioPassThruRequestTest, Init_CorrectTimeout) {
TEST_F(PerformAudioPassThruRequestTest,
onTimeOut_ttsSpeakNotActive_DontSendHMIReqeust) {
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
// For setting current_state_ -> kCompleted
@@ -717,7 +733,8 @@ TEST_F(PerformAudioPassThruRequestTest,
TEST_F(PerformAudioPassThruRequestTest,
DISABLED_onTimeOut_ttsSpeakActive_SendHMIReqeust) {
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
EXPECT_CALL(*application_sptr_, hmi_level())
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index eb9159f0b3..c7a50199b1 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -390,17 +390,34 @@ class ApplicationManager {
virtual void EndNaviServices(uint32_t app_id) = 0;
/* @brief Starts audio passthru process
+ * @deprecated Use BeginAudioPassThru(uint32_t app_id) instead
*
* @return true on success, false if passthru is already in process
*/
- virtual bool BeginAudioPassThrough() = 0;
+ DEPRECATED virtual bool BeginAudioPassThrough() = 0;
+
+ /**
+ * @brief Starts AudioPassThru process by given application
+ * @param app_id ID of the application which starts the process
+ * @return true if AudioPassThru can be started, false otherwise
+ */
+ virtual bool BeginAudioPassThru(uint32_t app_id) = 0;
/*
* @brief Finishes already started audio passthru process
+ * @deprecated Use EndAudioPassThru(uint32_t app_id) instead
*
* @return true on success, false if passthru is not active
*/
- virtual bool EndAudioPassThrough() = 0;
+ DEPRECATED virtual bool EndAudioPassThrough() = 0;
+
+ /**
+ * @brief Finishes already started AudioPassThru process by given application
+ * @param app_id ID of the application which started the process
+ * @return true if AudioPassThru process has been started with given
+ * application and thus it can be stopped, false otherwise
+ */
+ virtual bool EndAudioPassThru(uint32_t app_id) = 0;
virtual void ConnectToDevice(const std::string& device_mac) = 0;
diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h
index 58edcb637a..452a1e6c39 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -161,8 +161,10 @@ class MockApplicationManager : public application_manager::ApplicationManager {
MOCK_METHOD0(GetNextHMICorrelationID, uint32_t());
MOCK_METHOD0(GenerateNewHMIAppID, uint32_t());
MOCK_METHOD1(EndNaviServices, void(uint32_t app_id));
- MOCK_METHOD0(BeginAudioPassThrough, bool());
- MOCK_METHOD0(EndAudioPassThrough, bool());
+ DEPRECATED MOCK_METHOD0(BeginAudioPassThrough, bool());
+ MOCK_METHOD1(BeginAudioPassThru, bool(uint32_t app_id));
+ DEPRECATED MOCK_METHOD0(EndAudioPassThrough, bool());
+ MOCK_METHOD1(EndAudioPassThru, bool(uint32_t app_id));
MOCK_METHOD1(ConnectToDevice, void(const std::string& device_mac));
MOCK_METHOD0(OnHMIStartedCooperation, void());
MOCK_CONST_METHOD0(IsHMICooperating, bool());
diff --git a/src/components/include/test/media_manager/mock_media_manager.h b/src/components/include/test/media_manager/mock_media_manager.h
index 9cd2a05fc0..b58cfab5d7 100644
--- a/src/components/include/test/media_manager/mock_media_manager.h
+++ b/src/components/include/test/media_manager/mock_media_manager.h
@@ -56,7 +56,7 @@ class MockMediaManager : public media_manager::MediaManager {
protocol_handler::ServiceType service_type));
MOCK_METHOD2(FramesProcessed,
void(int32_t application_key, int32_t frame_number));
- MOCK_CONST_METHOD0(settings, const MediaManagerSettings&());
+ MOCK_CONST_METHOD0(settings, const media_manager::MediaManagerSettings&());
};
} // namespace media_manager_test