| OLD | NEW |
| 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 Loading... |
| 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)); |
| 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 Loading... |
| 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 { |
| 467 int16_t fileBuf[480]; | 462 int16_t fileBuf[480]; |
| 468 | 463 |
| 469 // read mono-file | 464 // read mono-file |
| 470 int32_t len = _playFile.Read((int8_t*) fileBuf, 2 * nSamples); | 465 int32_t len = _playFile.Read((int8_t*) fileBuf, 2 * nSamples); |
| 471 if (len != 2 * (int32_t) nSamples) | 466 if (len != 2 * (int32_t) nSamples) |
| 472 { | 467 { |
| 473 _playFile.Rewind(); | 468 _playFile.Rewind(); |
| 474 _playFile.Read((int8_t*) fileBuf, 2 * nSamples); | 469 _playFile.Read((int8_t*) fileBuf, 2 * nSamples); |
| 475 } | 470 } |
| 476 | 471 |
| 477 // convert to stero if required | 472 // convert to stero if required |
| 478 if (nChannels == 1) | 473 if (nChannels == 1) |
| 479 { | 474 { |
| 480 memcpy(audioSamples, fileBuf, 2 * nSamples); | 475 memcpy(audioSamples, fileBuf, 2 * nSamples); |
| 481 } else | 476 } else |
| 482 { | 477 { |
| 483 // mono sample from file is duplicated and sent to left and right | 478 // mono sample from file is duplicated and sent to left and right |
| 484 // channels | 479 // channels |
| 485 int16_t* audio16 = (int16_t*) audioSamples; | 480 int16_t* audio16 = (int16_t*) audioSamples; |
| 486 for (size_t i = 0; i < nSamples; i++) | 481 for (size_t i = 0; i < nSamples; i++) |
| 487 { | 482 { |
| 488 (*audio16) = fileBuf[i]; // left | 483 (*audio16) = fileBuf[i]; // left |
| 489 audio16++; | 484 audio16++; |
| 490 (*audio16) = fileBuf[i]; // right | 485 (*audio16) = fileBuf[i]; // right |
| 491 audio16++; | 486 audio16++; |
| 492 } | 487 } |
| 493 } | 488 } |
| 494 } // if (_playFromFile && _playFile.Open()) | 489 } // if (_playFromFile && _playFile.is_open()) |
| 495 | 490 |
| 496 _playCount++; | 491 _playCount++; |
| 497 | 492 |
| 498 if (_playCount % 100 == 0) | 493 if (_playCount % 100 == 0) |
| 499 { | 494 { |
| 500 bool addMarker(true); | 495 bool addMarker(true); |
| 501 | 496 |
| 502 if (_speakerVolume) | 497 if (_speakerVolume) |
| 503 { | 498 { |
| 504 uint32_t maxVolume(0); | 499 uint32_t maxVolume(0); |
| (...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2737 | 2732 |
| 2738 TEST_LOG("\n"); | 2733 TEST_LOG("\n"); |
| 2739 PRINT_TEST_RESULTS; | 2734 PRINT_TEST_RESULTS; |
| 2740 | 2735 |
| 2741 return 0; | 2736 return 0; |
| 2742 } | 2737 } |
| 2743 | 2738 |
| 2744 } // namespace webrtc | 2739 } // namespace webrtc |
| 2745 | 2740 |
| 2746 // EOF | 2741 // EOF |
| OLD | NEW |