Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: webrtc/modules/audio_device/dummy/file_audio_device_factory.cc

Issue 2250853002: Add code for dummy file audio to fallback to dummy audio. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/audio_device/audio_device_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/audio_device/dummy/file_audio_device_factory.h" 11 #include "webrtc/modules/audio_device/dummy/file_audio_device_factory.h"
12 12
13 #include <cstdlib> 13 #include <cstdlib>
14 #include <cstring> 14 #include <cstring>
15 15
16 #include "webrtc/base/logging.h"
16 #include "webrtc/modules/audio_device/dummy/file_audio_device.h" 17 #include "webrtc/modules/audio_device/dummy/file_audio_device.h"
17 18
18 namespace webrtc { 19 namespace webrtc {
19 20
20 bool FileAudioDeviceFactory::_isConfigured = false; 21 bool FileAudioDeviceFactory::_isConfigured = false;
21 char FileAudioDeviceFactory::_inputAudioFilename[MAX_FILENAME_LEN] = ""; 22 char FileAudioDeviceFactory::_inputAudioFilename[MAX_FILENAME_LEN] = "";
22 char FileAudioDeviceFactory::_outputAudioFilename[MAX_FILENAME_LEN] = ""; 23 char FileAudioDeviceFactory::_outputAudioFilename[MAX_FILENAME_LEN] = "";
23 24
24 FileAudioDevice* FileAudioDeviceFactory::CreateFileAudioDevice( 25 FileAudioDevice* FileAudioDeviceFactory::CreateFileAudioDevice(
25 const int32_t id) { 26 const int32_t id) {
26 // Bail out here if the files haven't been set explicitly. 27 // Bail out here if the files haven't been set explicitly.
28 // audio_device_impl.cc should then fall back to dummy audio.
27 if (!_isConfigured) { 29 if (!_isConfigured) {
28 printf("Was compiled with WEBRTC_DUMMY_AUDIO_PLAY_STATIC_FILE " 30 LOG(LS_WARNING) << "WebRTC configured with WEBRTC_DUMMY_FILE_DEVICES but "
29 "but did not set input/output files to use. Bailing out.\n"); 31 << "no device files supplied. Will fall back to dummy "
30 std::exit(1); 32 << "audio.";
33
34 return nullptr;
31 } 35 }
32 return new FileAudioDevice(id, _inputAudioFilename, _outputAudioFilename); 36 return new FileAudioDevice(id, _inputAudioFilename, _outputAudioFilename);
33 } 37 }
34 38
35 void FileAudioDeviceFactory::SetFilenamesToUse( 39 void FileAudioDeviceFactory::SetFilenamesToUse(
36 const char* inputAudioFilename, const char* outputAudioFilename) { 40 const char* inputAudioFilename, const char* outputAudioFilename) {
37 #ifdef WEBRTC_DUMMY_FILE_DEVICES 41 #ifdef WEBRTC_DUMMY_FILE_DEVICES
38 assert(strlen(inputAudioFilename) < MAX_FILENAME_LEN && 42 assert(strlen(inputAudioFilename) < MAX_FILENAME_LEN &&
39 strlen(outputAudioFilename) < MAX_FILENAME_LEN); 43 strlen(outputAudioFilename) < MAX_FILENAME_LEN);
40 44
41 // Copy the strings since we don't know the lifetime of the input pointers. 45 // Copy the strings since we don't know the lifetime of the input pointers.
42 strncpy(_inputAudioFilename, inputAudioFilename, MAX_FILENAME_LEN); 46 strncpy(_inputAudioFilename, inputAudioFilename, MAX_FILENAME_LEN);
43 strncpy(_outputAudioFilename, outputAudioFilename, MAX_FILENAME_LEN); 47 strncpy(_outputAudioFilename, outputAudioFilename, MAX_FILENAME_LEN);
44 _isConfigured = true; 48 _isConfigured = true;
45 #else 49 #else
46 // Sanity: must be compiled with the right define to run this. 50 // Sanity: must be compiled with the right define to run this.
47 printf("Trying to use dummy file devices, but is not compiled " 51 printf("Trying to use dummy file devices, but is not compiled "
48 "with WEBRTC_DUMMY_FILE_DEVICES. Bailing out.\n"); 52 "with WEBRTC_DUMMY_FILE_DEVICES. Bailing out.\n");
49 std::exit(1); 53 std::exit(1);
50 #endif 54 #endif
51 } 55 }
52 56
53 } // namespace webrtc 57 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/audio_device_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698