Author Topic: iOS: BASS_ERROR_UNKNOWN on BASS_Start  (Read 525 times)

elan

  • Posts: 33
iOS: BASS_ERROR_UNKNOWN on BASS_Start
« on: 27 Jun '19 - 08:21 »
Core version 2.4.14.6
Mixer version 2.4.9.0
FX version 2.4.12.0

We're seeing a sporadic case where roughly:

1. User listening to music.
2. User uses Siri to place a call.
3. User hangs up call.
4. Music never resumes and has to kill the app.

When the call is made, we call BASS_Pause and then call BASS_Start when resuming. This usually works just fine, but in this case, the BASS_Start returns BASS_ERROR_UNKNOWN, and seemingly the only way to get audio to work again is to kill and restart the app.

Any ideas?

Ian @ un4seen

  • Administrator
  • Posts: 22249
Re: iOS: BASS_ERROR_UNKNOWN on BASS_Start
« Reply #1 on: 27 Jun '19 - 13:42 »
BASS should automatically handle pausing and resuming for interruptions, so you should not need to call BASS_Pause and BASS_Start then. Does the problem still happen if you remove those calls? Please also confirm what audio session settings you are using, either via the BASS_CONFIG_IOS_xxx config options or directly.

elan

  • Posts: 33
Re: iOS: BASS_ERROR_UNKNOWN on BASS_Start
« Reply #2 on: 27 Jun '19 - 22:48 »
Using:

  BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 0);

And

  [session setCategory:AVAudioSessionCategoryPlayback error:&error];

And then handling audioSessionInterrupted and audioRouteChanged ourselves in the iOS code and using them to manually call pause/resume, as well as calling "AVAudioSession.sharedInstance setActive" as appropriate.

It may be that we're doing a bit too much ourselves, but it shouldn't actually cause a problem like this, right? We found that we had to call BASS_Pause after pausing in general to deal with some iOS 11 changes around how player controls show up in the control center.

Ian @ un4seen

  • Administrator
  • Posts: 22249
Re: iOS: BASS_ERROR_UNKNOWN on BASS_Start
« Reply #3 on: 28 Jun '19 - 12:50 »
If you're handling the audio session settings yourself then you should set BASS_CONFIG_IOS_NOCATEGORY to 1, which tells BASS to not handle the settings. If you're using AVAudioSession:setActive, also check that that's successful. If the problem persists after that then I may need to send you a debug version to get more info.

elan

  • Posts: 33
Re: iOS: BASS_ERROR_UNKNOWN on BASS_Start
« Reply #4 on: 29 Jun '19 - 21:34 »
I tried setting BASS_CONFIG_IOS_NOCATEGORY to 1, but per the documentation, "BASS_CONFIG_DEV_BUFFER settings will have no effect in that case".

This means that the reported latency went from 138ms to 42ms, which I'm worried will have an effect. We're setting (note not using BASS_CONFIG_DEV_BUFFER):

  BASS_SetConfig(BASS_CONFIG_DEV_PERIOD, 150);
  BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD, 75);
  BASS_SetConfig(BASS_CONFIG_BUFFER, 150);

It seems slightly odd that changing category would affect buffer sizing control?

Ian @ un4seen

  • Administrator
  • Posts: 22249
Re: iOS: BASS_ERROR_UNKNOWN on BASS_Start
« Reply #5 on: 1 Jul '19 - 12:34 »
When handling the audio session stuff yourself, you can use setPreferredIOBufferDuration to apply the BASS_CONFIG_DEV_PERIOD setting, something like this:

Code: [Select]
[session setPreferredIOBufferDuration:0.150 error:&error];

elan

  • Posts: 33
Re: iOS: BASS_ERROR_UNKNOWN on BASS_Start
« Reply #6 on: 1 Jul '19 - 20:37 »
Ah, you're awesome, thank you very much!