From d8a72f0ab24f7b6df63a3d0448b170c03c26aa48 Mon Sep 17 00:00:00 2001 From: noahric Date: Wed, 17 Aug 2016 15:14:48 -0700 Subject: [PATCH] Close input file in FileAudioDevice::StopRecording. Also added some more logging, to help track down start/stop, start failure, and the name of the file used. BUG= Review-Url: https://codereview.webrtc.org/2253763002 Cr-Commit-Position: refs/heads/master@{#13802} --- .../audio_device/dummy/file_audio_device.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/webrtc/modules/audio_device/dummy/file_audio_device.cc b/webrtc/modules/audio_device/dummy/file_audio_device.cc index bbc4dd8c4d..777086855e 100644 --- a/webrtc/modules/audio_device/dummy/file_audio_device.cc +++ b/webrtc/modules/audio_device/dummy/file_audio_device.cc @@ -7,6 +7,7 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ +#include "webrtc/base/logging.h" #include "webrtc/base/platform_thread.h" #include "webrtc/modules/audio_device/dummy/file_audio_device.h" #include "webrtc/system_wrappers/include/sleep.h" @@ -198,7 +199,7 @@ int32_t FileAudioDevice::StartPlayout() { // PLAYOUT if (!_outputFilename.empty() && !_outputFile.OpenFile(_outputFilename.c_str(), false)) { - printf("Failed to open playout file %s!\n", _outputFilename.c_str()); + LOG(LS_ERROR) << "Failed to open playout file: " << _outputFilename; _playing = false; delete [] _playoutBuffer; _playoutBuffer = NULL; @@ -209,6 +210,9 @@ int32_t FileAudioDevice::StartPlayout() { PlayThreadFunc, this, "webrtc_audio_module_play_thread")); _ptrThreadPlay->Start(); _ptrThreadPlay->SetPriority(rtc::kRealtimePriority); + + LOG(LS_INFO) << "Started playout capture to output file: " + << _outputFilename; return 0; } @@ -230,6 +234,9 @@ int32_t FileAudioDevice::StopPlayout() { delete [] _playoutBuffer; _playoutBuffer = NULL; _outputFile.CloseFile(); + + LOG(LS_INFO) << "Stopped playout capture to output file: " + << _outputFilename; return 0; } @@ -250,8 +257,7 @@ int32_t FileAudioDevice::StartRecording() { if (!_inputFilename.empty() && !_inputFile.OpenFile(_inputFilename.c_str(), true)) { - printf("Failed to open audio input file %s!\n", - _inputFilename.c_str()); + LOG(LS_ERROR) << "Failed to open audio input file: " << _inputFilename; _recording = false; delete[] _recordingBuffer; _recordingBuffer = NULL; @@ -264,6 +270,9 @@ int32_t FileAudioDevice::StartRecording() { _ptrThreadRec->Start(); _ptrThreadRec->SetPriority(rtc::kRealtimePriority); + LOG(LS_INFO) << "Started recording from input file: " + << _inputFilename; + return 0; } @@ -285,6 +294,10 @@ int32_t FileAudioDevice::StopRecording() { delete [] _recordingBuffer; _recordingBuffer = NULL; } + _inputFile.CloseFile(); + + LOG(LS_INFO) << "Stopped recording from input file: " + << _inputFilename; return 0; }