diff options
Diffstat (limited to 'modules/audio_device/dummy/file_audio_device.cc')
-rw-r--r-- | modules/audio_device/dummy/file_audio_device.cc | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/modules/audio_device/dummy/file_audio_device.cc b/modules/audio_device/dummy/file_audio_device.cc index c68e7bba1a..e345a16c44 100644 --- a/modules/audio_device/dummy/file_audio_device.cc +++ b/modules/audio_device/dummy/file_audio_device.cc @@ -216,10 +216,13 @@ int32_t FileAudioDevice::StartPlayout() { } } - _ptrThreadPlay.reset(new rtc::PlatformThread( - PlayThreadFunc, this, "webrtc_audio_module_play_thread", - rtc::kRealtimePriority)); - _ptrThreadPlay->Start(); + _ptrThreadPlay = rtc::PlatformThread::SpawnJoinable( + [this] { + while (PlayThreadProcess()) { + } + }, + "webrtc_audio_module_play_thread", + rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kRealtime)); RTC_LOG(LS_INFO) << "Started playout capture to output file: " << _outputFilename; @@ -233,10 +236,8 @@ int32_t FileAudioDevice::StopPlayout() { } // stop playout thread first - if (_ptrThreadPlay) { - _ptrThreadPlay->Stop(); - _ptrThreadPlay.reset(); - } + if (!_ptrThreadPlay.empty()) + _ptrThreadPlay.Finalize(); MutexLock lock(&mutex_); @@ -276,11 +277,13 @@ int32_t FileAudioDevice::StartRecording() { } } - _ptrThreadRec.reset(new rtc::PlatformThread( - RecThreadFunc, this, "webrtc_audio_module_capture_thread", - rtc::kRealtimePriority)); - - _ptrThreadRec->Start(); + _ptrThreadRec = rtc::PlatformThread::SpawnJoinable( + [this] { + while (RecThreadProcess()) { + } + }, + "webrtc_audio_module_capture_thread", + rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kRealtime)); RTC_LOG(LS_INFO) << "Started recording from input file: " << _inputFilename; @@ -293,10 +296,8 @@ int32_t FileAudioDevice::StopRecording() { _recording = false; } - if (_ptrThreadRec) { - _ptrThreadRec->Stop(); - _ptrThreadRec.reset(); - } + if (!_ptrThreadRec.empty()) + _ptrThreadRec.Finalize(); MutexLock lock(&mutex_); _recordingFramesLeft = 0; @@ -439,18 +440,6 @@ void FileAudioDevice::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { _ptrAudioBuffer->SetPlayoutChannels(0); } -void FileAudioDevice::PlayThreadFunc(void* pThis) { - FileAudioDevice* device = static_cast<FileAudioDevice*>(pThis); - while (device->PlayThreadProcess()) { - } -} - -void FileAudioDevice::RecThreadFunc(void* pThis) { - FileAudioDevice* device = static_cast<FileAudioDevice*>(pThis); - while (device->RecThreadProcess()) { - } -} - bool FileAudioDevice::PlayThreadProcess() { if (!_playing) { return false; |