Skip to content

Fix audio volume UI indicator under silent system environments - #559

Open
temcguir wants to merge 4 commits into
google:mainfrom
temcguir:fix-cuttlefish-audio-ui-silent
Open

Fix audio volume UI indicator under silent system environments#559
temcguir wants to merge 4 commits into
google:mainfrom
temcguir:fix-cuttlefish-audio-ui-silent

Conversation

@temcguir

Copy link
Copy Markdown
Collaborator

During video recording, Jetpack Camera visually indicates whether the audio stream is currently capturing sound. Previously, this indicator relied solely on checking if the audio amplitude was strictly greater than 0.0. However, in certain environments (like cuttlefish emulators) or completely silent physical spaces, CameraX can report an active audio stream that accurately returns an amplitude of 0.0 or a state of AUDIO_STATE_SOURCE_SILENCED.

This PR decouples the audio stream status from its mathematical amplitude by:

  1. Introducing AudioStreamState as a modeled state corresponding to androidx.camera.video.AudioStats.
  2. Tracking isAudioStreamActive alongside the numerical amplitude inside AudioUiState.
  3. Updating the CaptureScreenComponents to display the active microphone toggle if the stream is confirmed active, even if the realtime amplitude happens to be zero.

@temcguir
temcguir force-pushed the fix-cuttlefish-audio-ui-silent branch from 91a37ed to dd69560 Compare August 10, 2026 17:55

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors video recording states to use a new AudioStreamState sealed interface instead of a raw amplitude value, allowing more granular tracking of the audio stream (e.g., active, silenced, muted). However, several critical issues were identified: throwing an IllegalStateException on duplicate start events combined with enabling the capture button during the initialization phase creates a high risk of application crashes due to race conditions. Additionally, the logic for isAudioStreamActive should be updated to include the Silenced state to support silent environments properly, and the KDoc for AudioUiState.Enabled.On needs to be updated to document the new parameter.

During video recording, Jetpack Camera visually indicates whether the audio stream is currently capturing sound. Previously, this indicator relied solely on checking if the audio amplitude was strictly greater than 0.0. However, in certain environments (like cuttlefish emulators) or completely silent physical spaces, CameraX can report an active audio stream that accurately returns an amplitude of 0.0 or a state of AUDIO_STATE_SOURCE_SILENCED.

This PR decouples the audio stream status from its mathematical amplitude by modeling the CameraX AudioStats explicitly as an AudioStreamState, evaluating it for UI display logic independent of the visualizer amplitude metric.
@temcguir
temcguir force-pushed the fix-cuttlefish-audio-ui-silent branch from dd69560 to 3a255da Compare August 10, 2026 18:01
@temcguir
temcguir requested a review from Kimblebee August 10, 2026 18:24
@temcguir
temcguir requested a review from Kimblebee August 13, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants