From cb7972dba3c3da665ce779cf8b78ef83bfefc256 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Wed, 12 Oct 2016 11:32:16 -0400 Subject: Fix SEGFAULT in media_manager_impl.cc when EXTENDED_MEDIA_MODE=ON media_manager_impl.cc tries to make an A2DPSourcePlayerAdapter using the protocol handler before it is set, causing the program to SEGFAULT. This commit moves this creation to the PlayA2DPSource method and adds an explicit check to make sure that the protocol handler is set beforehand. --- src/components/media_manager/src/media_manager_impl.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/components/media_manager/src') diff --git a/src/components/media_manager/src/media_manager_impl.cc b/src/components/media_manager/src/media_manager_impl.cc index e531894b27..b89fc4c71f 100644 --- a/src/components/media_manager/src/media_manager_impl.cc +++ b/src/components/media_manager/src/media_manager_impl.cc @@ -114,8 +114,6 @@ void MediaManagerImpl::Init() { #if defined(EXTENDED_MEDIA_MODE) LOG4CXX_INFO(logger_, "Called Init with default configuration."); - a2dp_player_ = - new A2DPSourcePlayerAdapter(protocol_handler_->get_session_observer()); from_mic_recorder_ = new FromMicRecorderAdapter(); #endif @@ -157,6 +155,14 @@ void MediaManagerImpl::Init() { void MediaManagerImpl::PlayA2DPSource(int32_t application_key) { LOG4CXX_AUTO_TRACE(logger_); + +#if defined(EXTENDED_MEDIA_MODE) + if (!a2dp_player_ && protocol_handler_) { + a2dp_player_ = + new A2DPSourcePlayerAdapter(protocol_handler_->get_session_observer()); + } +#endif + if (a2dp_player_) { a2dp_player_->StartActivity(application_key); } -- cgit v1.2.1