oboe icon indicating copy to clipboard operation
oboe copied to clipboard

Sound distorted when dropped to background.

Open nocola opened this issue 5 years ago • 3 comments

Android Version(s): 10 Android Device(s): Samsung galaxy 7, Samsung Galaxy M10 Oboe Version: 1.3

Short Description Sound becomes "darth vader like" if app drops to background.

Steps To Reproduce Create streams in/out with 1 channel. Start it and after mechanism was successfully started drop app to background.

Expected behavior Normal sound like it was before.

Actual behavior Sound becomes distorted.

Additional context I found that system changes channels to stereo it causes distortion. And my fix was simply init with 2 channel and reduce channels to mono.

I remember that problem was in android 8.0.

nocola avatar Apr 28 '20 17:04 nocola

Mono/stereo issue may be related to #824

philburk avatar Apr 29 '20 17:04 philburk

Thanks for filing this. A few questions...

What app is this? Are you using a foreground service? Would it be possible to get a systrace whilst the "darth vader" voice is occurring?

dturner avatar Apr 29 '20 17:04 dturner

This app consists of Mic recording -> Audio Processing -> Playback. Yes we using foreground service.

Sound is really like Stereo considered as Mono. That is a problem - why system turns mono to stereo. And my quick fix was init input stream with 2 channels.

That is my log. /////////////////////////////////// Before start 2020-04-30 00:19:45.007 13163-13163/D/AudioManager: requestAudioFocus status : 1 2020-04-30 00:19:45.009 13163-13163/ I/JNI_NATIVE_AUDIO: configure 2020-04-30 00:19:45.013 13163-13163/ I/ACodec: [] Now uninitialized 2020-04-30 00:19:45.013 13163-15052/ I/ACodec: [] onAllocateComponent 2020-04-30 00:19:45.015 13163-15052/ I/OMXClient: IOmx service obtained 2020-04-30 00:19:45.018 13163-15052/ I/ACodec: [OMX.google.aac.encoder] Now Loaded 2020-04-30 00:19:45.019 13163-15052/I/ACodec: app-pid(13163) 2020-04-30 00:19:45.020 13163-15052/ I/ACodec: [OMX.google.aac.encoder] Now Loaded->Idle 2020-04-30 00:19:45.033 13163-15052/ I/ACodec: [OMX.google.aac.encoder] Now Idle->Executing 2020-04-30 00:19:45.035 13163-13163/ I/JNI_NATIVE_AUDIO: start 2020-04-30 00:19:45.035 13163-15052/ I/ACodec: [OMX.google.aac.encoder] Now Executing 2020-04-30 00:19:45.035 13163-13163/ I/JNI_NATIVE_AUDIO: openAllStreams 2020-04-30 00:19:45.035 13163-13163/ I/JNI_NATIVE_AUDIO: openPlaybackStream 2020-04-30 00:19:45.035 13163-13163/ I/JNI_NATIVE_AUDIO: setupPlaybackStreamParameters 2020-04-30 00:19:45.035 13163-13163/ I/JNI_NATIVE_AUDIO: setupCommonStreamParameters 2020-04-30 00:19:45.035 13163-13163/ D/OboeAudio: openStream() OUTPUT -------- OboeVersion1.3.3 -------- 2020-04-30 00:19:45.036 13163-13163/ D/OboeAudio: AAudioLoader(): dlopen(libaaudio.so) returned 0x9a382e6d 2020-04-30 00:19:45.036 13163-13163/ D/OboeAudio: AudioStreamAAudio() call isSupported() 2020-04-30 00:19:45.037 13163-13163/ D/AAudio: AAudioStreamBuilder_openStream() called ---------------------------------------- 2020-04-30 00:19:45.037 13163-13163/ D/AudioStreamBuilder: build() EXCLUSIVE sharing mode not supported. Use SHARED. 2020-04-30 00:19:45.037 13163-13163/ I/AAudioStream: open() rate = 48000, channels = 2, format = 1, sharing = SH, dir = OUTPUT 2020-04-30 00:19:45.037 13163-13163/ I/AAudioStream: open() device = 1441, sessionId = 0, perfMode = 12, callback: ON with frames = 256 2020-04-30 00:19:45.037 13163-13163/ I/AAudioStream: open() usage = 1, contentType = 2, inputPreset = 6 2020-04-30 00:19:45.037 13163-13163/ D/AudioStreamTrack: open(), request notificationFrames = -8, frameCount = 0 2020-04-30 00:19:45.040 13163-13163/ I/AudioTrack: AUDIO_OUTPUT_FLAG_FAST successful; frameCount 0 -> 1920 2020-04-30 00:19:45.042 13163-13163/ D/AudioTrack: setVolume(1.000000, 1.000000) pid : 13163 2020-04-30 00:19:45.042 13163-13163/ W/AudioStreamTrack: open() flags changed from 0x00000104 to 0x00100004 2020-04-30 00:19:45.042 13163-13163/ D/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for (0xeca0fbc0) ---------------- 2020-04-30 00:19:45.043 13163-13163/ D/OboeAudio: AudioStreamAAudio.open() app format = 1 2020-04-30 00:19:45.043 13163-13163/ D/OboeAudio: AudioStreamAAudio.open() sample rate = 48000 2020-04-30 00:19:45.043 13163-13163/D/OboeAudio: AudioStreamAAudio.open() capacity = 1920 2020-04-30 00:19:45.043 13163-13163/D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK, mAAudioStream = 0xeca0fbc0 2020-04-30 00:19:45.043 13163-13163/ I/JNI_NATIVE_AUDIO: openRecordingStream 2020-04-30 00:19:45.043 13163-13163/ I/JNI_NATIVE_AUDIO: setupRecordingStreamParameters 2020-04-30 00:19:45.043 13163-13163/ I/JNI_NATIVE_AUDIO: setupCommonStreamParameters 2020-04-30 00:19:45.043 13163-13163/ D/OboeAudio: openStream() INPUT -------- OboeVersion1.3.3 -------- 2020-04-30 00:19:45.043 13163-13163/ D/OboeAudio: AudioStreamAAudio() call isSupported() 2020-04-30 00:19:45.043 13163-13163/D/AAudio: AAudioStreamBuilder_openStream() called ---------------------------------------- 2020-04-30 00:19:45.044 13163-13163/I/AAudioStream: open() rate = 48000, channels = 1, format = 1, sharing = SH, dir = INPUT 2020-04-30 00:19:45.044 13163-13163/I/AAudioStream: open() device = 9, sessionId = 0, perfMode = 12, callback: OFF with frames = 0 2020-04-30 00:19:45.044 13163-13163/I/AAudioStream: open() usage = 1, contentType = 2, inputPreset = 6 2020-04-30 00:19:45.060 13163-13163/I/AudioRecord: AUDIO_INPUT_FLAG_FAST successful; frameCount 0 -> 4096 2020-04-30 00:19:45.061 13163-13163/W/AudioStreamRecord: open() flags changed from 0x00000005 to 0x00000001 2020-04-30 00:19:45.062 13163-13163/D/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for (0xeca0fd00) ---------------- 2020-04-30 00:19:45.062 13163-13163/D/OboeAudio: AudioStreamAAudio.open() app format = 1 2020-04-30 00:19:45.062 13163-13163/D/OboeAudio: AudioStreamAAudio.open() sample rate = 48000 2020-04-30 00:19:45.062 13163-13163/D/OboeAudio: AudioStreamAAudio.open() capacity = 4096 2020-04-30 00:19:45.062 13163-13163/D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK, mAAudioStream = 0xeca0fd00 2020-04-30 00:19:45.062 13163-13163/I/JNI_NATIVE_AUDIO: 224 startStream 2020-04-30 00:19:45.062 13163-13163/D/AAudio: AAudioStream_requestStart(0xeca0fbc0) called -------------- 2020-04-30 00:19:45.062 13163-13163/I/AudioTrack: updateAudioTranstionLength FadeIn[0] FadeOut[0] FadeInRing[0] 2020-04-30 00:19:45.068 13163-13163/D/AAudio: AAudioStream_requestStart(0xeca0fbc0) returned 0 --------- 2020-04-30 00:19:45.068 13163-15056/D/OboeAudio: AudioStream::fireDataCallback() scheduler = SCHED_FIFO 2020-04-30 00:19:45.068 13163-13163/I/JNI_NATIVE_AUDIO: Start stream. OK 2020-04-30 00:19:45.068 13163-13163/I/JNI_NATIVE_AUDIO: Stream: FPB = 240, PM = LowLatency, SM = Shared, SR = 48000 2020-04-30 00:19:45.068 13163-13163/I/JNI_NATIVE_AUDIO: 224 startStream 2020-04-30 00:19:45.068 13163-13163/D/AAudio: AAudioStream_requestStart(0xeca0fd00) called -------------- 2020-04-30 00:19:45.068 13163-13554/D/AudioStreamLegacy: onAudioDeviceUpdate() deviceId 1441 2020-04-30 00:19:45.336 13163-13163/D/AAudio: AAudioStream_requestStart(0xeca0fd00) returned 0 --------- 2020-04-30 00:19:45.336 13163-13163/I/JNI_NATIVE_AUDIO: Start stream. OK 2020-04-30 00:19:45.336 13163-13163/I/JNI_NATIVE_AUDIO: Stream: FPB = 240, PM = LowLatency, SM = Shared, SR = 48000 2020-04-30 00:19:45.336 13163-13163/I/JNI_NATIVE_AUDIO: rec Api = AAudio 2020-04-30 00:19:45.336 13163-13163/I/JNI_NATIVE_AUDIO: play Api = AAudio 2020-04-30 00:19:45.337 13163-13554/D/AudioStreamLegacy: onAudioDeviceUpdate() deviceId 9 2020-04-30 00:19:45.369 13163-13163/D/ DService: Service onCreate 2020-04-30 00:19:45.373 13163-13163/D/ DService: Service onStartCommand = START_PROFILE 2020-04-30 00:19:45.655 13163-13196/W/MediaPlayer-JNI: MediaPlayer finalized without being released 2020-04-30 00:19:45.679 13163-13196/W/MediaPlayer-JNI: MediaPlayer finalized without being released 2020-04-30 00:19:45.932 13163-14754/D/FA: Connected to remote service ////////////////////// Here sound is good and it is a start of dropping to background //////////////////////// D/ViewRootImpl@833bc61[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 2020-04-30 00:20:01.674 13163-13163/D/InputMethodManager: prepareNavigationBarInfo() DecorView@572f386[MainActivity] 2020-04-30 00:20:01.674 13163-13163/D/InputMethodManager: getNavigationBarColor() -855310 2020-04-30 00:20:01.692 13163-13163/D/ViewRootImpl@833bc61[MainActivity]: stopped(true) old=false 2020-04-30 00:20:01.746 13163-13460/W/libEGL: EGLNativeWindowType 0xec3ef808 disconnect failed 2020-04-30 00:20:01.746 13163-13460/D/OpenGLRenderer: eglDestroySurface = 0xe4fcf7e0, 0xec3ef800 2020-04-30 00:20:01.761 13163-13163/D/ViewRootImpl@833bc61[MainActivity]: Relayout returned: old=[0,0][720,1520] new=[0,0][720,1520] result=0x5 surface={false 0} changed=true 2020-04-30 00:20:01.905 13163-13163/D/InputTransport: Input channel destroyed: fd=94 2020-04-30 00:20:01.916 13163-14754/D/FA: Connected to remote service 2020-04-30 00:20:02.289 13163-13163/D/ViewRootImpl@833bc61[MainActivity]: Relayout returned: old=[0,0][720,1520] new=[0,0][720,1520] result=0x1 surface={false 0} changed=false 2020-04-30 00:20:03.723 13163-14754/D/FA: Application going to the background /////////////////////////////////////////////////////////// Sound is destroyed

nocola avatar Apr 29 '20 21:04 nocola