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
11 changes: 11 additions & 0 deletions audio/audio_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ void AudioState::RemoveSendingStream(webrtc::AudioSendStream* stream) {
UpdateAudioTransportWithSendingStreams();
if (sending_streams_.empty()) {
config_.audio_device_module->StopRecording();
#if defined(WEBRTC_IOS)
auto* adm = config_.audio_device_module.get();
if (adm->Playing()) {
adm->StopPlayout();
if (adm->InitPlayout() == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

what does this mean? we are starting playout after stopping it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Through repeated tests, when the mode is changed to playback, the RTCAudioSession must be reset to stop the capture of the microphone.

Copy link
Member Author

@cloudwebrtc cloudwebrtc Nov 12, 2022

Choose a reason for hiding this comment

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

I'll add a commen describing the intent of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

got it, so it'd have to be restarted after Playout is stopped?

Copy link
Member Author

@cloudwebrtc cloudwebrtc Nov 12, 2022

Choose a reason for hiding this comment

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

If playout is stopped, we should not need to restart it, only need to deal with adm->StopRecording() && adm->Playing()

It means that after the last audio send stream is closed, 1,stop recording, 2, and then reset to release the mic capture state.

if (playout_enabled_) {
adm->StartPlayout();
}
}
}
#endif
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/objc/api/peerconnection/RTCAudioDeviceModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

NS_ASSUME_NONNULL_BEGIN

typedef void (^RTCOnAudioDevicesDidUpdate)();
typedef void (^RTCOnAudioDevicesDidUpdate)(void);

RTC_OBJC_EXPORT
@interface RTC_OBJC_TYPE (RTCAudioDeviceModule) : NSObject
Expand Down
4 changes: 2 additions & 2 deletions sdk/objc/components/audio/RTCAudioSession+Configuration.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
@implementation RTC_OBJC_TYPE (RTCAudioSession)
(Configuration)

- (BOOL)setConfiguration : (RTC_OBJC_TYPE(RTCAudioSessionConfiguration) *)configuration error
: (NSError **)outError {
- (BOOL)setConfiguration: (RTC_OBJC_TYPE(RTCAudioSessionConfiguration) *)configuration
error: (NSError **)outError {
return [self setConfiguration:configuration
active:NO
shouldSetActive:NO
Expand Down
11 changes: 5 additions & 6 deletions sdk/objc/components/audio/RTCAudioSession+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ NS_ASSUME_NONNULL_BEGIN

@class RTC_OBJC_TYPE(RTCAudioSessionConfiguration);

@interface RTC_OBJC_TYPE (RTCAudioSession)
()
@interface RTC_OBJC_TYPE (RTCAudioSession)()

/** Number of times setActive:YES has succeeded without a balanced call to
* setActive:NO.
*/
@property(nonatomic, readonly) int activationCount;
/** Number of times setActive:YES has succeeded without a balanced call to
* setActive:NO.
*/
@property(nonatomic, readonly) int activationCount;

/** The number of times `beginWebRTCSession` was called without a balanced call
* to `endWebRTCSession`.
Expand Down
4 changes: 2 additions & 2 deletions sdk/objc/components/audio/RTCAudioSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ RTC_OBJC_EXPORT
* returned.
* `lockForConfiguration` must be called first.
*/
- (BOOL)setConfiguration : (RTC_OBJC_TYPE(RTCAudioSessionConfiguration) *)configuration error
: (NSError **)outError;
- (BOOL)setConfiguration: (RTC_OBJC_TYPE(RTCAudioSessionConfiguration) *)configuration
error: (NSError **)outError;

/** Convenience method that calls both setConfiguration and setActive.
* `lockForConfiguration` must be called first.
Expand Down