Skip to content
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

[LiveEffect] No audio output on a One Plus One running Android 4.4.4 (CyanogenMod) #203

Closed
vbarthel-fr opened this issue Sep 2, 2018 · 8 comments
Assignees
Milestone

Comments

@vbarthel-fr
Copy link
Contributor

The sample LiveEffect does not seem to work as expected on a One Plus One running Android 4.4.4.

After pressing the "start" button, the UI freezes for ~10 seconds and when the "stop" button finally appears, there is no audio output.

Here are the logs:

09-02 18:18:42.934 5727-5727/com.google.sample.oboe.liveeffect I/OboeAudio: AudioStreamOpenSLES::open(chans:2, rate:0)
09-02 18:18:42.934 5727-5727/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStreamOpenSLES(): mFramesPerCallback = 192
    AudioStreamOpenSLES(): mBytesPerCallback = 768
09-02 18:18:42.934 5727-5727/com.google.sample.oboe.liveeffect W/OboeAudio: configurePerformanceMode() not supported until N_MR1
09-02 18:18:42.944 5727-5727/com.google.sample.oboe.liveeffect W/AUDIO-APP: Stream is NOT low latency.Check your requested format, sample rate and channel count
09-02 18:18:42.944 5727-5727/com.google.sample.oboe.liveeffect I/OboeAudio: AudioStreamOpenSLES::open(chans:2, rate:48000)
09-02 18:18:42.944 5727-5727/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStreamOpenSLES(): mFramesPerCallback = 192
    AudioStreamOpenSLES(): mBytesPerCallback = 768
09-02 18:18:42.944 5727-5727/com.google.sample.oboe.liveeffect W/OboeAudio: configurePerformanceMode() not supported until N_MR1
09-02 18:18:42.944 5727-5727/com.google.sample.oboe.liveeffect W/AudioRecord: AUDIO_INPUT_FLAG_FAST denied by client
09-02 18:18:42.944 5727-5727/com.google.sample.oboe.liveeffect D/OboeAudio: FifoProcessor: capacityInFrames = 3072, bytesPerFrame = 4
09-02 18:18:42.944 5727-5727/com.google.sample.oboe.liveeffect W/AUDIO-APP: Stream is NOT low latency.Check your requested format, sample rate and channel count
09-02 18:18:42.944 5727-5727/com.google.sample.oboe.liveeffect D/OboeAudio: AudioInputStreamOpenSLES::requestStart()
    AudioInputStreamOpenSLES::setRecordState(3)
    AudioOutputStreamOpenSLES(): requestStart()
    AudioOutputStreamOpenSLES(): setPlayState()
09-02 18:18:53.034 5727-5880/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_OTHER
09-02 18:18:53.044 5727-5727/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_OTHER
09-02 18:18:53.044 5727-5878/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_FIFO
09-02 18:18:53.054 5727-5727/com.google.sample.oboe.liveeffect I/Choreographer: Skipped 637 frames!  The application may be doing too much work on its main thread.

According to the Choreographer, ~600 frames were skipped. I have tried to identify the source of the freeze, and I have narrowed it down to the (*mRecordInterface)->SetRecordState(mRecordInterface, newState) call.

In the fileAudioInputStreamOpenSLES.cpp, inside the AudioInputStreamOpenSLES::setRecordState method, I have added the following lines:

    auto startTime = AudioClock::getNanoseconds();
    SLresult slResult = (*mRecordInterface)->SetRecordState(mRecordInterface, newState);
    auto elapsedTime = AudioClock::getNanoseconds() - startTime;
    LOGD("SetRecordState(%d) took %lld ns", newState, elapsedTime);

output:

09-02 18:22:35.444 6108-6108/com.google.sample.oboe.liveeffect D/OboeAudio: SetRecordState(3) took 10091784214 ns

That's about 10 seconds, that could explain the ~600 frames skipped.

Note: If I force the input and the output channel count to oboe::ChannelCount::Mono, the UI does not freeze and the "live effect" can be heard.

In file LiveEffectEngine.h:

    int32_t mInputChannelCount = oboe::ChannelCount::Mono;
    int32_t mOutputChannelCount = oboe::ChannelCount::Mono;

Here are the logs when the channel counts are forced to oboe::ChannelCount::Mono:

09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect I/OboeAudio: AudioStreamOpenSLES::open(chans:1, rate:0)
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStreamOpenSLES(): mFramesPerCallback = 192
    AudioStreamOpenSLES(): mBytesPerCallback = 384
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect W/OboeAudio: configurePerformanceMode() not supported until N_MR1
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect W/AUDIO-APP: Stream is NOT low latency.Check your requested format, sample rate and channel count
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect I/OboeAudio: AudioStreamOpenSLES::open(chans:1, rate:48000)
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStreamOpenSLES(): mFramesPerCallback = 192
    AudioStreamOpenSLES(): mBytesPerCallback = 384
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect W/OboeAudio: configurePerformanceMode() not supported until N_MR1
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect W/AudioRecord: AUDIO_INPUT_FLAG_FAST denied by client
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect D/OboeAudio: FifoProcessor: capacityInFrames = 3072, bytesPerFrame = 2
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect W/AUDIO-APP: Stream is NOT low latency.Check your requested format, sample rate and channel count
09-02 18:29:56.824 6430-6430/com.google.sample.oboe.liveeffect D/OboeAudio: AudioInputStreamOpenSLES::requestStart()
    AudioInputStreamOpenSLES::setRecordState(3)
09-02 18:29:57.044 6430-6430/com.google.sample.oboe.liveeffect D/OboeAudio: SetRecordState(3) took 213248698
    AudioOutputStreamOpenSLES(): requestStart()
    AudioOutputStreamOpenSLES(): setPlayState()
09-02 18:29:57.044 6430-6430/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_OTHER
09-02 18:29:57.044 6430-6537/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_FIFO
09-02 18:29:57.054 6430-6539/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_OTHER

No frames skipped and the audio output works as expected.

I will try to test the LiveEffect sample on other devices running Android KitKat to see if I can reproduce it.

@philburk
Copy link
Collaborator

philburk commented Sep 3, 2018

Thanks for the report.

Is your "OnePlus One" running a Cyanogen Mod version of KitKat?

That's about 10 seconds, that could explain the ~600 frames skipped.

600 frames at 48000 Hz is only 12.5 msec. That seems unrelated to the 10 second hang.

It is common when using input and output streams to lose a few frames while the streams are getting synchronized.

The key issue is that it hangs when starting a stereo stream but not a mono stream.

I will try to test the LiveEffect sample on other devices running Android KitKat to see
if I can reproduce it.

That would be extremely helpful. Thank you. We can't fix KitKat at this point. But we may be able to add a workaround in Oboe, like do mono-to-stereo conversion.

@vbarthel-fr
Copy link
Contributor Author

Thanks for your answer!

Is your "OnePlus One" running a Cyanogen Mod version of KitKat?

Yes it is! Here are some additional details about the phone I used for the test:

  • Model Number: A0001
  • Cyanogen OS version: 11.0-XNPH05Q
  • Android version: 4.4.4
  • Baseband version: MPSS.DI.2.0.1.c7-00020-M8974AAAAANPZM-1
  • Kernel version: 3.4.0-cyanogenmod-gc73a4ec build04@cyanogenmod
  • CPU: ARMv7 Processor rev 1 (v7l)
  • Build date: Wed Jan 28 11:27:53 PST 2015
  • Build number: KTU84Q

600 frames at 48000 Hz is only 12.5 msec. That seems unrelated to the 10 second hang.

Sorry I should have been more clear in my original post. When I mentioned the 600 frames, I meant 600 display frames and not 600 audio frames. I got those numbers from the android.view.Choreographer logs (See the last lines of the first log report of my original post):

09-02 18:18:53.054 5727-5727/com.google.sample.oboe.liveeffect I/Choreographer: Skipped 637 frames!  The application may be doing too much work on its main thread.

From my understanding, the call to (*mRecordInterface)->SetRecordState(mRecordInterface, newState) is made synchronously on the main thread in response to the user click on the start button. Measuring an elapsed time of ~10sec for the setRecordState call seemed to explain the info log of the Choreographer complaining about the ~600 display frames skipped (at a rate of 60 display frames per second).

@vbarthel-fr
Copy link
Contributor Author

I have just tested on a Nexus 5 running Android 4.4.4, and the LiveEffect sample works as expected. No freezes when clicking on the Start button, and the audio output works correctly.

Here are the logs:

09-03 13:45:45.223 4450-4450/com.google.sample.oboe.liveeffect I/OboeAudio: AudioStreamOpenSLES::open(chans:2, rate:0)
09-03 13:45:45.223 4450-4450/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStreamOpenSLES(): mFramesPerCallback = 192
    AudioStreamOpenSLES(): mBytesPerCallback = 768
09-03 13:45:45.233 4450-4450/com.google.sample.oboe.liveeffect W/OboeAudio: configurePerformanceMode() not supported until N_MR1
09-03 13:45:45.333 4450-4450/com.google.sample.oboe.liveeffect W/AUDIO-APP: Stream is NOT low latency.Check your requested format, sample rate and channel count
09-03 13:45:45.333 4450-4450/com.google.sample.oboe.liveeffect I/OboeAudio: AudioStreamOpenSLES::open(chans:2, rate:48000)
09-03 13:45:45.333 4450-4450/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStreamOpenSLES(): mFramesPerCallback = 192
    AudioStreamOpenSLES(): mBytesPerCallback = 768
09-03 13:45:45.333 4450-4450/com.google.sample.oboe.liveeffect W/OboeAudio: configurePerformanceMode() not supported until N_MR1
09-03 13:45:45.333 4450-4450/com.google.sample.oboe.liveeffect W/AudioRecord: AUDIO_INPUT_FLAG_FAST denied by client
09-03 13:45:45.343 4450-4450/com.google.sample.oboe.liveeffect D/OboeAudio: FifoProcessor: capacityInFrames = 3072, bytesPerFrame = 4
09-03 13:45:45.343 4450-4450/com.google.sample.oboe.liveeffect W/AUDIO-APP: Stream is NOT low latency.Check your requested format, sample rate and channel count
09-03 13:45:45.343 4450-4450/com.google.sample.oboe.liveeffect D/OboeAudio: AudioInputStreamOpenSLES::requestStart()
    AudioInputStreamOpenSLES::setRecordState(3)
09-03 13:45:45.433 4450-4450/com.google.sample.oboe.liveeffect D/OboeAudio: SetRecordState(3) took 96358176
    AudioOutputStreamOpenSLES(): requestStart()
    AudioOutputStreamOpenSLES(): setPlayState()
09-03 13:45:45.433 4450-4601/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_OTHER
09-03 13:45:45.503 4450-4450/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_OTHER
09-03 13:45:45.503 4450-4599/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_FIFO

@vbarthel-fr
Copy link
Contributor Author

I have just tested on a HTC One running Android 4.4.4 (CyanogenMod): no freezes when clicking on the start button, but the audio output does not work correctly. There is no audio output.

Here are the logs:

09-03 13:54:51.613 14312-14312/com.google.sample.oboe.liveeffect D/com.google.sample.oboe.liveEffect.MainActivity: Attempting to start
09-03 13:54:51.613 14312-14312/com.google.sample.oboe.liveeffect I/OboeAudio: AudioStreamOpenSLES::open(chans:2, rate:0)
09-03 13:54:51.623 14312-14312/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStreamOpenSLES(): mFramesPerCallback = 192
    AudioStreamOpenSLES(): mBytesPerCallback = 768
09-03 13:54:51.623 14312-14312/com.google.sample.oboe.liveeffect W/OboeAudio: configurePerformanceMode() not supported until N_MR1
09-03 13:54:51.643 14312-14312/com.google.sample.oboe.liveeffect W/AUDIO-APP: Stream is NOT low latency.Check your requested format, sample rate and channel count
09-03 13:54:51.643 14312-14312/com.google.sample.oboe.liveeffect I/OboeAudio: AudioStreamOpenSLES::open(chans:2, rate:48000)
09-03 13:54:51.643 14312-14312/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStreamOpenSLES(): mFramesPerCallback = 192
    AudioStreamOpenSLES(): mBytesPerCallback = 768
09-03 13:54:51.643 14312-14312/com.google.sample.oboe.liveeffect W/OboeAudio: configurePerformanceMode() not supported until N_MR1
09-03 13:54:51.643 14312-14312/com.google.sample.oboe.liveeffect W/AudioRecord: AUDIO_INPUT_FLAG_FAST denied by client
09-03 13:54:51.643 14312-14312/com.google.sample.oboe.liveeffect D/OboeAudio: FifoProcessor: capacityInFrames = 3072, bytesPerFrame = 4
09-03 13:54:51.643 14312-14312/com.google.sample.oboe.liveeffect W/AUDIO-APP: Stream is NOT low latency.Check your requested format, sample rate and channel count
09-03 13:54:51.643 14312-14312/com.google.sample.oboe.liveeffect D/OboeAudio: AudioInputStreamOpenSLES::requestStart()
    AudioInputStreamOpenSLES::setRecordState(3)
09-03 13:54:51.803 14312-14312/com.google.sample.oboe.liveeffect D/OboeAudio: SetRecordState(3) took 169952392
09-03 13:54:51.823 14312-14312/com.google.sample.oboe.liveeffect D/OboeAudio: AudioOutputStreamOpenSLES(): requestStart()
    AudioOutputStreamOpenSLES(): setPlayState()
09-03 13:54:51.823 14312-14772/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_OTHER
09-03 13:54:51.853 14312-14312/com.google.sample.oboe.liveeffect D/OboeAudio: AudioStream::fireCallback() scheduler = SCHED_OTHER

Forcing the input/output channel counts to oboe::ChannelCount::Mono in the LiveEffectEngine.h file "solves" the audio problem.

@vbarthel-fr
Copy link
Contributor Author

vbarthel-fr commented Sep 6, 2018

I have just tested the LiveEffect sample on a Samsung S4 Zoom running Android 4.4.2: everything works as expected. No freezes when clicking on the Start button, and the audio output works correctly.

  • Model: Samsung Galaxy S4 Zoom
  • Model Number: SM-C101
  • Android version: 4.4.2
  • Baseband version: C101XXUBNK1
  • Kernel version: 3.0.31-3470144 dpi@SWDD6205 Add code to handle disconnects #1 Wed Dec 3 15:34:56 KST 2014
  • Build Number: KOT49H.C101XXUBNL1

@dturner
Copy link
Collaborator

dturner commented Sep 6, 2018

Need to add the following to oboe:

If cyanogenmod and 4.4.4 and channel count is unspecified:
default the channel count to 1.

@dturner dturner self-assigned this Sep 6, 2018
@dturner
Copy link
Collaborator

dturner commented Sep 6, 2018

Add isCyanogenMod() method

@dturner dturner added this to the v1.0 milestone Sep 6, 2018
@philburk philburk changed the title [LiveEffect] No audio output on a One Plus One running Android 4.4.4 [LiveEffect] No audio output on a One Plus One running Android 4.4.4 (CyanogenMod) Sep 6, 2018
@dturner dturner modified the milestones: v1.0, future Sep 18, 2018
@dturner
Copy link
Collaborator

dturner commented Jun 11, 2019

Sorry, this is going to affect such a small number of users I'm going to close it as "wont fix"

@dturner dturner closed this as completed Jun 11, 2019
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

No branches or pull requests

3 participants