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

Side by Side Diff: webrtc/modules/audio_device/test/func_test_manager.cc

Issue 2054373002: FileWrapper[Impl] modifications and actually remove the "Impl" class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix use of ASSERT instead of ASSERT_TRUE in test Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 // ---------------------------------------------------------------------------- 164 // ----------------------------------------------------------------------------
165 // AudioTransportImpl::SetFilePlayout 165 // AudioTransportImpl::SetFilePlayout
166 // ---------------------------------------------------------------------------- 166 // ----------------------------------------------------------------------------
167 167
168 int32_t AudioTransportImpl::SetFilePlayout(bool enable, const char* fileName) 168 int32_t AudioTransportImpl::SetFilePlayout(bool enable, const char* fileName)
169 { 169 {
170 _playFromFile = enable; 170 _playFromFile = enable;
171 if (enable) 171 if (enable)
172 { 172 return _playFile.OpenFile(fileName, true) ? 0 : -1;
173 return (_playFile.OpenFile(fileName, true, true, false)); 173 _playFile.CloseFile();
174 } else 174 return 0;
175 {
176 _playFile.Flush();
177 return (_playFile.CloseFile());
178 }
179 } 175 }
180 ;
181 176
182 void AudioTransportImpl::SetFullDuplex(bool enable) 177 void AudioTransportImpl::SetFullDuplex(bool enable)
183 { 178 {
184 _fullDuplex = enable; 179 _fullDuplex = enable;
185 180
186 for (AudioPacketList::iterator iter = _audioList.begin(); 181 for (AudioPacketList::iterator iter = _audioList.begin();
187 iter != _audioList.end(); ++iter) { 182 iter != _audioList.end(); ++iter) {
188 delete *iter; 183 delete *iter;
189 } 184 }
190 _audioList.clear(); 185 _audioList.clear();
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 TEST_LOG("ERROR: unable to resample from %d to %d\n" , 450 TEST_LOG("ERROR: unable to resample from %d to %d\n" ,
456 samplesPerSecIn, samplesPerSec); 451 samplesPerSecIn, samplesPerSec);
457 } 452 }
458 } 453 }
459 nSamplesOut = nSamples; 454 nSamplesOut = nSamples;
460 delete packet; 455 delete packet;
461 } 456 }
462 } 457 }
463 } // if (_fullDuplex) 458 } // if (_fullDuplex)
464 459
465 if (_playFromFile && _playFile.Open()) 460 if (_playFromFile && _playFile.is_open()) {
466 { 461 int16_t fileBuf[480];
467 int16_t fileBuf[480];
468 462
469 // read mono-file 463 // read mono-file
470 int32_t len = _playFile.Read((int8_t*) fileBuf, 2 * nSamples); 464 int32_t len = _playFile.Read((int8_t*)fileBuf, 2 * nSamples);
471 if (len != 2 * (int32_t) nSamples) 465 if (len != 2 * (int32_t)nSamples) {
472 { 466 _playFile.Rewind();
473 _playFile.Rewind(); 467 _playFile.Read((int8_t*)fileBuf, 2 * nSamples);
474 _playFile.Read((int8_t*) fileBuf, 2 * nSamples); 468 }
469
470 // convert to stero if required
471 if (nChannels == 1) {
472 memcpy(audioSamples, fileBuf, 2 * nSamples);
473 } else {
474 // mono sample from file is duplicated and sent to left and right
475 // channels
476 int16_t* audio16 = (int16_t*)audioSamples;
477 for (size_t i = 0; i < nSamples; i++) {
478 (*audio16) = fileBuf[i]; // left
479 audio16++;
480 (*audio16) = fileBuf[i]; // right
481 audio16++;
475 } 482 }
476 483 }
477 // convert to stero if required 484 } // if (_playFromFile && _playFile.is_open())
478 if (nChannels == 1)
479 {
480 memcpy(audioSamples, fileBuf, 2 * nSamples);
481 } else
482 {
483 // mono sample from file is duplicated and sent to left and right
484 // channels
485 int16_t* audio16 = (int16_t*) audioSamples;
486 for (size_t i = 0; i < nSamples; i++)
487 {
488 (*audio16) = fileBuf[i]; // left
489 audio16++;
490 (*audio16) = fileBuf[i]; // right
491 audio16++;
492 }
493 }
494 } // if (_playFromFile && _playFile.Open())
495 485
496 _playCount++; 486 _playCount++;
497 487
498 if (_playCount % 100 == 0) 488 if (_playCount % 100 == 0)
499 { 489 {
500 bool addMarker(true); 490 bool addMarker(true);
501 491
502 if (_speakerVolume) 492 if (_speakerVolume)
503 { 493 {
504 uint32_t maxVolume(0); 494 uint32_t maxVolume(0);
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 2727
2738 TEST_LOG("\n"); 2728 TEST_LOG("\n");
2739 PRINT_TEST_RESULTS; 2729 PRINT_TEST_RESULTS;
2740 2730
2741 return 0; 2731 return 0;
2742 } 2732 }
2743 2733
2744 } // namespace webrtc 2734 } // namespace webrtc
2745 2735
2746 // EOF 2736 // EOF
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/dummy/file_audio_device.cc ('k') | webrtc/modules/audio_processing/audio_processing_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698