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}
This commit is contained in:
noahric 2016-08-17 15:14:48 -07:00 committed by Commit bot
parent 78810b633c
commit d8a72f0ab2

View File

@ -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;
}