Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions audio/audio_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ void AudioState::AddSendingStream(webrtc::AudioSendStream* stream,
if (!adm->Recording()) {
if (adm->InitRecording() == 0) {
if (recording_enabled_) {
#if defined(WEBRTC_WIN)
if (adm->BuiltInAECIsAvailable() && !adm->Playing()) {
if (!adm->PlayoutIsInitialized()) {
adm->InitPlayout();
}
adm->StartPlayout();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you write a comment explaining why this is needed? Seems weird to require playout for recording.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is caused here https://github.com/webrtc-sdk/webrtc/blob/main/modules/audio_device/win/audio_device_core_win.cc#L2353. If the built-in AEC is enabled, opening the Recording alone will fail to create hRecThread, resulting in no sound captured by the send stream.

But if StartPlayOut is called early, it works both ways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code here is a bit strange, with the built-in AEC enabled, recording/playout cannot be started independently. ,

}
#endif
adm->StartRecording();
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions modules/audio_device/win/audio_device_core_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2356,7 +2356,7 @@ int32_t AudioDeviceWindowsCore::StartRecording() {
}
}

RTC_DCHECK(_hRecThread);
RTC_DCHECK(_hRecThread == NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is fixed in m97.

_hRecThread = CreateThread(NULL, 0, lpStartAddress, this, 0, NULL);
if (_hRecThread == NULL) {
RTC_LOG(LS_ERROR) << "failed to create the recording thread";
Expand Down Expand Up @@ -2493,7 +2493,7 @@ int32_t AudioDeviceWindowsCore::StartPlayout() {
MutexLock lockScoped(&mutex_);

// Create thread which will drive the rendering.
RTC_DCHECK(_hPlayThread);
RTC_DCHECK(_hPlayThread == NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is fixed in m97.

_hPlayThread = CreateThread(NULL, 0, WSAPIRenderThread, this, 0, NULL);
if (_hPlayThread == NULL) {
RTC_LOG(LS_ERROR) << "failed to create the playout thread";
Expand Down