Android Oboe Library: 2 streams recording from 2 recording devices possible?

烈酒焚心 提交于 2019-12-20 06:24:17

问题


  • Device: HUAWEI P smart

  • Android-Version: 8.0.0

  • Generic Application:
    RecDev1 -> PlayDev1
    RecDev2 -> PlayDev2
    "simultaneous streaming"
    where
    RecDev can be built-in mic, USB-mic or headset-mic
    and
    PlayDev can be built-in speaker, USB-speaker or headset-speaker
    any input and output device shall be streamed "SIMULTANEOUSLY" in any combination as shown above.

  • Example Application (all devices with "1" channel):
    Guitar -> wired-mic -> [(processing)] -> built-in-Speaker
    Voice -> built-in mic -> [(processing)] -> wired-speaker
    "simultaneous streaming"

  • Code:
    is just an extended version of the sample "LiveEffect" provided by oboe.
    Up to now I tried:
    . straight forward extension
    . LiveEffectEngine no longer singleton (2 instances with own long mEngineHandle)
    . use of 2 separate threads
    . set a callback for the recording stream(s)

  • Note:
    I get the warning Stream is NOT low latency for all 4 streams but all parameters match:
    SharingMode::Exclusive PerformanceMode::LowLatency (not accepted) mSampleRate 48000 (default of PlaybackDevice) AudioFormat::I16

with OpenSL-ES API: I cannot start the second recordingStream, stream->requestStart() returns "ErrorInternal"

with AAudio API: I cannot open the second recordingStream, builder.openStream() returns "ErrorInvalidState"

In both cases I call builder->setCallback(nullptr) so I thought using separate threads might help, but this didn't solve the problem.

Any ideas?


回答1:


Android does not allow you to open input (ie recording) audio streams to more than one audio device at the same time. This use case is not supported.

Perhaps if you explain why you want to record from different built-in microphones at the same time I could suggest a workaround.

Update: The term Audio Device refers to a device capable or receiving or sending audio. An audio device can have multiple microphones and/or speakers attached to it, and these are represented as different channels.




回答2:


** according to Don Turner's answer: "Android does not allow you to open input (ie recording) audio streams to more than one audio device at the same time. This use case is not supported."

** More clearly:
- Android does NOT support recording from more than ONE input devices at the same time.
- Android does NOT support playback to more than ONE output devices at the same time.
- and for sure, the combination of the 2 points above does NOT work either.

** This can be easily tested e.g. by running 2 instances of this AAudio Sample in parallel and selecting different output devices. This will just NOT work!

** This VERY IMPORTANT CONSTRAINT is not mentioned anywhere in the official documentation!!!

** Therefore, the following "example use case" is NOT supported by Android (oboe, aaudio, opensl es):

USB-Audio-In ---> In-line-speaker
and at the same time
Mic ----> USB-Audio-Out

** I am quite disappointed, I spent time and money to start something based on this, assuming this was "basic" functionality...now I have to give up :-(

** If I find the right place, then I will enter a "request" to support this "feature", e.g. in AAudio.

** Hope this helps other people before they invest too much time in something beyond the current capabilities offered by Android and the corresponding libraries.


** A possible workaround indicated by donturner would be instead using a special USB-soundcard with 2 inputs and 2 outputs which are just separate channels in the same device. Unfortunately, this does not really work for me because I was targeting a low-cost solution without additional hardware (using the headset interface).



来源:https://stackoverflow.com/questions/53796802/android-oboe-library-2-streams-recording-from-2-recording-devices-possible

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!