google / oboe

Oboe is a C++ library that makes it easy to build high-performance audio apps on Android.
Apache License 2.0
3.72k stars 571 forks source link

ErrorIllegalArgument when trying to start an input stream #1363

Closed naveenspace7 closed 3 years ago

naveenspace7 commented 3 years ago

Android version(s): 10 Android device(s): Google Pixel 2 Oboe version: 1.6.0 App name used for testing: Custom app.

Short description I am trying to create and start a stream for recording. Opening the stream seems to work fine (returns OK) and starting a stream returns error: ErrorIllegalArgument. I followed the example from oboe repository: LiveEffect.

Steps to reproduce: The source to reproduce this issue is added to this Github repository, nothing out of the ordinary I suppose.

    builder->setDeviceId(VoiceRecognition);
    builder->setDirection(Direction::Input);
    builder->setSharingMode(SharingMode::Exclusive);
    builder->setPerformanceMode(PerformanceMode::LowLatency);
    builder->setAudioApi(AudioApi::AAudio);
    builder->setFormat(AudioFormat::I16);
    builder->setChannelCount(ChannelCount::Stereo);
    builder->setFormatConversionAllowed(true);

    resultState = builder.openStream(&mStream);
    if (resultState != Result::OK)
    {
        LOGE("Error while opening stream: %s", convertToText(resultState));
        return false;
    }

    resultState = mStream->requestStart(); // this call fails
    if (resultState != Result::OK)
    {
        LOGE("Error while requesting the stream to start: %s", convertToText(resultState));
        return false;
    }

Expected behavior The function to start the input stream should return OK

Actual behavior But in this case it returns ErrorIllegalArgument.

Device Google Pixel 2

Any additional context

Log here:

2021-07-26 15:23:22.118 8563-8563/com.example.nativeexample W/NativeExample: record button is clicked
2021-07-26 15:23:22.119 8563-8563/com.example.nativeexample I/OboeAudio: openStream() INPUT -------- OboeVersion1.6.0 --------
2021-07-26 15:23:22.121 8563-8563/com.example.nativeexample D/OboeAudio: AAudioLoader():  dlopen(libaaudio.so) returned 0x1f637ef94b23e199
2021-07-26 15:23:22.121 8563-8563/com.example.nativeexample I/AAudio: AAudioStreamBuilder_openStream() called ----------------------------------------
2021-07-26 15:23:22.121 8563-8563/com.example.nativeexample I/AudioStreamBuilder: rate   =      0, channels  = 2, format   = 1, sharing = EX, dir = INPUT
2021-07-26 15:23:22.121 8563-8563/com.example.nativeexample I/AudioStreamBuilder: device =      6, sessionId = -1, perfMode = 12, callback: OFF with frames = 0
2021-07-26 15:23:22.121 8563-8563/com.example.nativeexample I/AudioStreamBuilder: usage  =      1, contentType = 2, inputPreset = 6, allowedCapturePolicy = 0
2021-07-26 15:23:22.134 8563-8563/com.example.nativeexample D/AudioStreamInternal_Client: open() original HW burst = 96, minMicros = 2000 => SW burst = 96
2021-07-26 15:23:22.134 8563-8563/com.example.nativeexample I/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for s#1 ----------------
2021-07-26 15:23:22.134 8563-8563/com.example.nativeexample D/OboeAudio: AudioStreamAAudio.open() format=1, sampleRate=48000, capacity = 1536
2021-07-26 15:23:22.134 8563-8563/com.example.nativeexample D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK
2021-07-26 15:23:22.134 8563-8563/com.example.nativeexample D/AAudio: AAudioStream_requestStart(s#1) called --------------
2021-07-26 15:23:22.228 8563-8563/com.example.nativeexample D/AAudio: AAudioStream_requestStart(s#1) returned -898 ---------
2021-07-26 15:23:22.228 8563-8563/com.example.nativeexample E/AudioEngine: Error while requesting the stream to start: ErrorIllegalArgument
2021-07-26 15:23:22.229 8563-8563/com.example.nativeexample W/NativeExample: Failed to start recording
naveenspace7 commented 3 years ago

Apparently I messed up with the permissions. I fixed that and it works fine now.