diff options
Diffstat (limited to 'src/components/media_manager/src/audio/from_mic_recorder_adapter.cc')
-rw-r--r-- | src/components/media_manager/src/audio/from_mic_recorder_adapter.cc | 83 |
1 files changed, 44 insertions, 39 deletions
diff --git a/src/components/media_manager/src/audio/from_mic_recorder_adapter.cc b/src/components/media_manager/src/audio/from_mic_recorder_adapter.cc index 7559512a8..ef9d5b8de 100644 --- a/src/components/media_manager/src/audio/from_mic_recorder_adapter.cc +++ b/src/components/media_manager/src/audio/from_mic_recorder_adapter.cc @@ -1,34 +1,34 @@ -/** -* Copyright (c) 2013, Ford Motor Company -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following -* disclaimer in the documentation and/or other materials provided with the -* distribution. -* -* Neither the name of the Ford Motor Company nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*/ +/* + * Copyright (c) 2014, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #include <string> #include "utils/threads/thread.h" @@ -44,18 +44,21 @@ FromMicRecorderAdapter::FromMicRecorderAdapter() : recorder_thread_(NULL) , output_file_("default_recorded_audio.wav") , kDefaultDuration(1000) - , duration_(0) { - duration_ = kDefaultDuration; + , duration_(kDefaultDuration) { + } FromMicRecorderAdapter::~FromMicRecorderAdapter() { - LOG4CXX_INFO(logger_, "FromMicRecorderAdapter::~FromMicRecorderAdapter()"); - StopActivity(current_application_); + LOG4CXX_AUTO_TRACE(logger_); + if (recorder_thread_) { + recorder_thread_->join(); + delete recorder_thread_->delegate(); + threads::DeleteThread(recorder_thread_); + } } void FromMicRecorderAdapter::StartActivity(int32_t application_key) { - LOG4CXX_INFO(logger_, "FromMicRecorderAdapter::StartActivity " - << application_key); + LOG4CXX_DEBUG(logger_, "Start with app " << application_key); if (application_key == current_application_) { LOG4CXX_WARN(logger_, "Running recording from mic for " << current_application_); @@ -86,8 +89,10 @@ void FromMicRecorderAdapter::StopActivity(int32_t application_key) { return; } - if (NULL != recorder_thread_) { - recorder_thread_->stop(); + if (recorder_thread_) { + recorder_thread_->join(); + delete recorder_thread_->delegate(); + threads::DeleteThread(recorder_thread_); recorder_thread_ = NULL; } current_application_ = 0; |