-
Notifications
You must be signed in to change notification settings - Fork 620
OboeTester_ScreenRotation
This document explains how OboeTester handles device rotation, why audio streams are preserved when the screen rotates, and how Android's dynamic audio policies can affect audio streams during orientation changes.
In a standard Android application, rotating the device from portrait to landscape (or vice versa) triggers a configuration change that destroys and recreates the active Activity. For real-time audio apps, this default behavior is highly disruptive because recreating the activity would tear down and recreate the active Oboe audio streams, resetting the test in progress.
To prevent this, OboeTester configures its activities in AndroidManifest.xml with the android:configChanges attribute:
android:configChanges="orientation|screenSize|keyboardHidden|screenLayout|smallestScreenSize"-
No Stream Teardowns: The
Activityremains alive during rotation. - Uninterrupted Testing: Audio streams, native callback loops, and ongoing measurements (such as latency or glitch detection) continue to run smoothly without resetting.
- Visual Adaptation: The UI layout adjusts to fit the new screen dimensions without destroying the JNI bridges or native state.
While the Oboe audio stream itself remains open and running, the Android OS may dynamically modify its underlying audio routing and policies as the physical orientation changes. This can lead to unexpected audio behavior mid-test:
Many modern smartphones and tablets physically swap the audio output channels (Left and Right) dynamically as the device rotates. This is done to ensure that physical "Left" always corresponds to the speaker on the left side of the screen from the user's perspective.
- Acoustic Impact: If you are running a stereo output test, you may experience a brief volume dip, phase alignment shift, or transient glitch when the hardware switches the channel routing during rotation.
Android's audio framework applies different acoustic tuning profiles depending on the device orientation and how it is held:
- Microphone Switching: In portrait mode, the system might route audio from the bottom microphone (optimized for handheld telephony). In landscape mode, it may switch to a top or back microphone (optimized for video recording or speakerphone use).
- Noise Suppression & Gain: The orientation change can trigger different software gain controls, echo cancellation profiles, or noise reduction filters.
- Acoustic Impact: This can cause sudden changes in input volume, frequency response, or phase during a Tap-to-Tone or Round-Trip Latency test.
The physical handling of the device changes when rotating.
- Acoustic Impact: You or the user may inadvertently cover the microphone or speaker ports with hands or a tablet stand when rotating, dramatically altering the measured latency or volume.
To get consistent, accurate results when using OboeTester:
- Lock Your Orientation First: Choose the target orientation (typically portrait) before starting sensitive measurements.
- Avoid Rotating Mid-Test: Try not to rotate the device while running active latency, glitch, or data path tests, as the OS audio policy changes can introduce artificial anomalies.
- Be Mindful of Stereo Tuning: If testing stereo performance, be aware that channel routing and speaker tuning may differ between landscape and portrait orientations.
- Apps Using Oboe or AAudio
- Tech Notes
- Buffer Size, Capacity and Bursts
- Glitches and Latency
- How to Avoid Crashes
- Bluetooth Audio
- Using Audio Effects with Oboe
- Disconnected Streams
- Assert in releaseBuffer()
- Crash during callback after routing
- Using ADPF for High‐Quality Audio Performance
- Using FullDuplexStream for Synchronized IO
- Using Offload Playback for Power‐Saving
- OboeTester Instructions
- Quirks and Bugs
- Developer Notes