-
Notifications
You must be signed in to change notification settings - Fork 103
iOS SDK 向けの音声ミュート処理を修正する #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
patches/ios_audio_pause_resume.patch
Outdated
| + if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kStarted) { | ||
| + if (!audio_unit_->Stop()) { | ||
| + RTC_LOG(LS_WARNING) << "PauseRecording failed to stop audio unit"; | ||
| + return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
結局停止してない(recording_ フラグが落ちてない)のに戻り値を 0 として返すのは微妙そう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReinitAudioUnitForMicrophoneMute で切り出した部分は正常成功時以外はエラーログと -1 で返すようにしました
patches/ios_audio_pause_resume.patch
Outdated
| + } | ||
| + // audio_unit_->SetMicrophoneMute 実行のため AudioUnit を一度初期化解除します | ||
| + // SetMicrophoneMute(true) 実行後に再度 AudioUnit の初期化を行います | ||
| + if (audio_unit_ && audio_unit_->GetState() >= VoiceProcessingAudioUnit::kUninitialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このあたり、Stop, Uninitialize, SetMicrophoneMute(value), Initialize, Start を行う部分を関数にまとめた方が良さそう。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private 関数 AudioDeviceIOS::SetMicrophoneMute(Bool) で処理を切り出します
int32_t SetMicrophoneMute(bool enable) override; で定義済みだったため別名にします
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int32_t ReinitAudioUnitForMicrophoneMute(bool) で切り出しました
|
pause/resume でそれぞれ実行していた AudioUnit の再初期化 ~ SetMicrophonemute 呼び出し を |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
patches/ios_audio_pause_resume.patch
Outdated
| +int32_t AudioDeviceModuleIOS::PauseRecording() { | ||
| + RTC_DLOG(LS_INFO) << __FUNCTION__; | ||
| + CHECKinitialized_(); | ||
| + if (!Recording()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StopRecording() と同様の早期リターン用のチェックを追加しました
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
audio_device_module_ios.mm:655-667 を見る限り StopRecording() に早期リターンは無いみたいです。
patches/ios_audio_pause_resume.patch
Outdated
| + RTC_DLOG(LS_INFO) << __FUNCTION__; | ||
| + CHECKinitialized_(); | ||
| + int32_t result = audio_device_->ResumeRecording(); | ||
| + if (Recording()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StartRecording() と同様の早期リターン用のチェックを追加しました
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@melpon |
patches/ios_audio_pause_resume.patch
Outdated
| + RTC_LOG(LS_WARNING) << "PauseRecording called while not recording"; | ||
| + return 0; | ||
| + } | ||
| + // マイクミュートを有効化します |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
マイクミュートの有効化、日本語として分かりにくいので「マイクミュートにします」だけで良さそう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
マイクミュートします に修正しました
patches/ios_audio_pause_resume.patch
Outdated
| + RTC_LOG(LS_WARNING) << "ResumeRecording called while recording"; | ||
| + return 0; | ||
| + } | ||
| + // マイクミュートを無効化します |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こっちも「マイクミュートを解除します」で良さそう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
マイクミュートを解除します に修正しました
patches/ios_audio_pause_resume.patch
Outdated
| +int32_t AudioDeviceModuleIOS::PauseRecording() { | ||
| + RTC_DLOG(LS_INFO) << __FUNCTION__; | ||
| + CHECKinitialized_(); | ||
| + if (!Recording()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
audio_device_module_ios.mm:655-667 を見る限り StopRecording() に早期リターンは無いみたいです。
|
失礼しました StopRecording にはなかったです。ただこの早期リターン自体はやっておいてもいいかなと思いますが |
ということで、ここで早期リターンをする必要は無さそう。 |
|
なるほど。ログを出さないのたしかに。削除します |
melpon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそう
|
ありがとうございます🙇 |
#130 関連の修正です。
音声録音フラグの操作だけではマイクインジケータ消灯に不十分だったため追加の対応となります。
AudioDeviceIOS の pauseRecording/resumeRecording 内で
`VoiceProcessingAudioUnit:: SetMicrophoneMute(:) の実行により AudioDevice への音声入力を無効化/有効化するようにします。
iOS の AudioUnit の制約により、SetMicrophoneMute 実行時は AudioUnit の状態が
未初期化(VoiceProcessingAudioUnit::kUninitialized) である必要があるため、
pauseRecording/resumeRecording 内で AudioUnit の 停止 -> 未初期化処理 -> SetMicrophoneMute -> 初期化処理 -> 起動
というフローで処理します。