iOS - Activate Audio Output in Background

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

iOS - Activate Audio Output in Background

powerqian
Hi Linphone Developer,

Recently I came across an issue that the call won't have audio input or output if the call is AUTO answered in BACKGROUND, e.g. the call is answered, connected, stream running completely in background without user doing anything.

My app have a requirement that the call can be auto answered based on some condition checking, and user won't need to unlock the phone to hear the remote party's voice. When I do this, there are errors like the followings constantly showing in console:

**** console output start ****
AudioUnit could not be started, current hw output latency [0.012766] input [0.000000] iobuf[0.023220] hw sample rate [44100.000000]

19:09:15.293 ERROR:     [0x541a000] >aurioc> 806: failed: '!pla' (enable 2, outf< 1 ch,      0 Hz, Float32> inf< 1 ch,      0 Hz, Float32>)

AudioUnit error for AudioUnitInitialize(card->io_unit): ret=unkown error (561015905) (/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:454)

io unit initialized

I/O unit latency [0.000000], quality [64]

AudioSession error for AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputLatency ,&hwinputlatencySize , &hwinputlatency): ret=kAudioSessionBadPropertySizeError (561211770) (/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:486)

19:09:15.296 ERROR:     [0x541a000] >aurioc> 806: failed: '!pla' (enable 2, outf< 1 ch,      0 Hz, Float32> inf< 1 ch,      0 Hz, Float32>)

AudioUnit error for (auresult = AudioOutputUnitStart(card->io_unit)): ret=unkown error (561015905) (/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:501)

AudioUnit could not be started, current hw output latency [0.012766] input [0.000000] iobuf[0.023220] hw sample rate [44100.000000]

19:09:15.404 ERROR:     [0x541a000] >aurioc> 806: failed: '!pla' (enable 2, outf< 1 ch,      0 Hz, Float32> inf< 1 ch,      0 Hz, Float32>)

AudioUnit error for AudioUnitInitialize(card->io_unit): ret=unkown error (561015905) (/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:454)

io unit initialized

I/O unit latency [0.000000], quality [64]

AudioSession error for AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputLatency ,&hwinputlatencySize , &hwinputlatency): ret=kAudioSessionBadPropertySizeError (561211770) (/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:486)

19:09:15.408 ERROR:     [0x541a000] >aurioc> 806: failed: '!pla' (enable 2, outf< 1 ch,      0 Hz, Float32> inf< 1 ch,      0 Hz, Float32>)

AudioUnit error for (auresult = AudioOutputUnitStart(card->io_unit)): ret=unkown error (561015905) (/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:501)

AudioUnit could not be started, current hw output latency [0.012766] input [0.000000] iobuf[0.023220] hw sample rate [44100.000000]
**** console output end ****

Those error messages are only shown after answering the call in background.

I'm sure that iOS can allow the app to do that since I've seen some app achieved this. I've tried many things to on Objective-C level such as

        NSError *setCategoryErr = nil;
        NSError *activationErr  = nil;

        [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryErr];
        [[AVAudioSession sharedInstance] setActive: YES error: &activationErr];
        [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

 to active audio in background when receiving and answering the call, but with no luck.

I also tried to set playback device to Audio Queue and Audio Unit, but all failed.

I understand this may not related to Linphone's use case, but I have completely no clue. Would you please provide me some guidance on how to achieve my purpose? Or maybe where to take a look and modify the source code in linphone library?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: iOS - Activate Audio Output in Background

Guillaume BIENKOWSKI-2

I think the app has to be in the foreground to be able to open audio or video input, this is a (welcome) Apple limitation.

When the audio is already running, this will work but the user *has* to place the app to the foreground at least when the session starts the first time.


Imagine the privacy consequences of allowing the audio input without the user having the choice to react.


Guillaume BIENKOWSKI

[hidden email]



On Thu, Jan 22, 2015 at 11:38 AM, Guillaume BIENKOWSKI <[hidden email]> wrote:

I think the app has to be in the foreground to be able to open audio or video input, this is a (welcome) Apple limitation.
When the audio is already running, this will work but the user *has* to place the app to the foreground at least when the session starts the first time.

Imagine the privacy consequences of allowing the audio input without the user having the choice to react.

Guillaume BIENKOWSKI
[hidden email]


On 22 Jan 2015, at 11:05, powerqian wrote:

Hi Linphone Developer,

Recently I came across an issue that the call won't have audio input or
output if the call is AUTO answered in BACKGROUND, e.g. the call is
answered, connected, stream running completely in background without user
doing anything.

My app have a requirement that the call can be auto answered based on some
condition checking, and user won't need to unlock the phone to hear the
remote party's voice. When I do this, there are errors like the followings
constantly showing in console:

**** console output start ****
AudioUnit could not be started, current hw output latency [0.012766] input
[0.000000] iobuf[0.023220] hw sample rate [44100.000000]

19:09:15.293 ERROR:     [0x541a000] >aurioc> 806: failed: '!pla' (enable 2,
outf< 1 ch,      0 Hz, Float32> inf< 1 ch,      0 Hz, Float32>)

AudioUnit error for AudioUnitInitialize(card->io_unit): ret=unkown error
(561015905)
(/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:454)

io unit initialized

I/O unit latency [0.000000], quality [64]

AudioSession error for
AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputLatency
,&hwinputlatencySize , &hwinputlatency):
ret=kAudioSessionBadPropertySizeError (561211770)
(/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:486)

19:09:15.296 ERROR:     [0x541a000] >aurioc> 806: failed: '!pla' (enable 2,
outf< 1 ch,      0 Hz, Float32> inf< 1 ch,      0 Hz, Float32>)

AudioUnit error for (auresult = AudioOutputUnitStart(card->io_unit)):
ret=unkown error (561015905)
(/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:501)

AudioUnit could not be started, current hw output latency [0.012766] input
[0.000000] iobuf[0.023220] hw sample rate [44100.000000]

19:09:15.404 ERROR:     [0x541a000] >aurioc> 806: failed: '!pla' (enable 2,
outf< 1 ch,      0 Hz, Float32> inf< 1 ch,      0 Hz, Float32>)

AudioUnit error for AudioUnitInitialize(card->io_unit): ret=unkown error
(561015905)
(/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:454)

io unit initialized

I/O unit latency [0.000000], quality [64]

AudioSession error for
AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputLatency
,&hwinputlatencySize , &hwinputlatency):
ret=kAudioSessionBadPropertySizeError (561211770)
(/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:486)

19:09:15.408 ERROR:     [0x541a000] >aurioc> 806: failed: '!pla' (enable 2,
outf< 1 ch,      0 Hz, Float32> inf< 1 ch,      0 Hz, Float32>)

AudioUnit error for (auresult = AudioOutputUnitStart(card->io_unit)):
ret=unkown error (561015905)
(/Users/Shared/Jenkins/Home/workspace/linphone-ios/submodules/build/..//linphone/mediastreamer2/src/audiofilters/msiounit.m:501)

AudioUnit could not be started, current hw output latency [0.012766] input
[0.000000] iobuf[0.023220] hw sample rate [44100.000000]
**** console output end ****

Those error messages are only shown after answering the call in background.

I'm sure that iOS can allow the app to do that since I've seen some app
achieved this. I've tried many things to on Objective-C level such as

     NSError *setCategoryErr = nil;
     NSError *activationErr  = nil;

     [[AVAudioSession sharedInstance] setCategory:
AVAudioSessionCategoryPlayback error: &setCategoryErr];
     [[AVAudioSession sharedInstance] setActive: YES error:
&activationErr];
     [[UIApplication sharedApplication]
beginReceivingRemoteControlEvents];

to active audio in background when receiving and answering the call, but
with no luck.

I also tried to set playback device to Audio Queue and Audio Unit, but all
failed.

I understand this may not related to Linphone's use case, but I have
completely no clue. Would you please provide me some guidance on how to
achieve my purpose? Or maybe where to take a look and modify the source code
in linphone library?

Thanks!



--
View this message in context: http://nongnu.13855.n7.nabble.com/iOS-Activate-Audio-Output-in-Background-tp195304.html
Sent from the linphone-developers mailing list archive at Nabble.com.

_______________________________________________
Linphone-developers mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/linphone-developers


_______________________________________________
Linphone-developers mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/linphone-developers
Reply | Threaded
Open this post in threaded view
|

Re: iOS - Activate Audio Output in Background

powerqian
Hi Guillaume,

Thanks for the reply.

I know app won't be allowed to record audio or video in the background, but what I mean is automatically play audio in the background. The call is answered in the background, the callee can hear caller's voice, but caller doesn't need and won't be able to hear callee's voice.

I am sure this is possible in iOS since I've seen app done like that. Just not sure which sound card is used and what needed to be coded to make it possible.

Just curious about whether those error logs are helpful or not, since those error code are only shown when I auto answered the call in background.