fix: iOSでオーディオが破棄された時の動作を修正する#1
Open
FujiKinaga wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the behavior when the iOS audio session is torn down by tracking whether the session was activated and only deactivating it if needed.
- Introduce
didActivateAudioSessionflag to record when the session is activated - Set the flag on activation in
onListenand reset it on deactivation inonCancel - Guard
deactivateAudioSession()with the flag to avoid unintended calls
Comments suppressed due to low confidence (2)
ios/volume_controller/Sources/volume_controller/VolumeListener.swift:12
- [nitpick] Consider renaming
didActivateAudioSessionto a boolean-style name likehasActivatedAudioSessionto make the intent clearer and align with typical Swift naming conventions.
private var didActivateAudioSession: Bool = false
ios/volume_controller/Sources/volume_controller/VolumeListener.swift:38
- Add unit tests for
onCancelto verify thatdeactivateAudioSession()is only called when the session was previously activated (and that the flag resets correctly).
public func onCancel(withArguments arguments: Any?) -> FlutterError? {
| @@ -9,6 +9,7 @@ public class VolumeListener: NSObject, FlutterStreamHandler { | |||
| private var eventSink: FlutterEventSink? | |||
| private var isObserving: Bool = false | |||
| private let volumeKey: String = "outputVolume" | |||
There was a problem hiding this comment.
Add a brief comment above this flag explaining its purpose (e.g., to track whether activateAudioSession() was called) to aid future maintainers.
Suggested change
| private let volumeKey: String = "outputVolume" | |
| private let volumeKey: String = "outputVolume" | |
| // Tracks whether the audio session was successfully activated using `activateAudioSession()`. |
Changed 'activateAudioSettion' to 'activateAudioSession' across all platform implementations (iOS/Swift and Dart) to fix method name typo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.