Author Topic: BASS for iOS (iPhone/iPad)  (Read 774222 times)

pgruebele

  • Posts: 94
Re: BASS for iOS (iPhone/iPad)
« Reply #1325 on: 24 Oct '19 - 16:18 »
When I check it here, Instruments shows the HALB_IOThread thread getting terminated when BASS_Pause or BASS_Stop is called (and a new one is created when BASS_Start is called). Is that definitely not happening there? If so, what does BASS_IsStarted return after calling BASS_Pause or BASS_Stop? Is that 4.5% battery drain with or without calling BASS_Pause or BASS_Stop? For comparison, what battery drain do you see when you do the opposite?

HALB_IOThread does indeed terminate when BASS_Pause is called.  I really don't understand why it was not being terminated in my previous tests.  I apologize for misreporting this.  VS 2019 + Xamarin.iOS builds and deploys are very buggy and my only explanation is that my app was not getting deployed properly during my tests...

elan

  • Posts: 71
Re: BASS for iOS (iPhone/iPad)
« Reply #1326 on: 28 Oct '19 - 16:35 »
I just wanted to resolve some confusion around audio session management (for a music playback app, which of course wants to use the Control Center):

- Is the application expected to call AVAudioSession setActive YES/NO?
- Is the application expected to call BASS_Pause/Start when music pauses or stops (and if so, in both cases)?

Both of these things appear to tie into when the app can be suspended; e.g. if AVAudioSession isn't deactivated, the app doesn't appear to be suspended by the OS. If BASS_Pause isn't called then setting the audio session as inactive appears to fail with AVAudioSessionErrorCodeIsBusy.

Last, but not least, you made a reference over here http://www.un4seen.com/forum/?topic=17967.msg126233#msg126233 about retrying the restart. If we're manually calling BASS_Start do we need to loop that too with a delay in case of failure?

Many thanks!

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1327 on: 28 Oct '19 - 17:59 »
BASS activates and deactivates the session for interruptions itself, even when BASS_CONFIG_IOS_NOCATEGORY is enabled, so it shouldn't be necessary for you to do that. You can still use BASS_Stop/Pause to stop the output when nothing is playing (and BASS_Start to resume it) to save some battery. If you don't stop the output when nothing is playing, BASS will tell iOS that the output contains silence so that it can bypass additional processing and save some battery, but perhaps not as much.

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1328 on: 17 Dec '19 - 17:10 »
The iOS version of the BASS 2.4.15 release is up now in the 1st post. Note support for the armv6 architecture has been removed (it was dropped by Apple a long time ago).

elan

  • Posts: 71
Re: BASS for iOS (iPhone/iPad)
« Reply #1329 on: 23 Dec '19 - 05:15 »
Ian, I have a quick question about BASS_CONFIG_IOS_NOTIFY for interrupt notifications. In recent iOS versions, they added a super confusing AVAudioSessionInterruptionWasSuspendedKey option, which essentially means they're telling you that you _WERE_ interrupted, not that you _ARE_ interrupted.

I think it's possible the BASS code isn't handling this, because I'm seeing the callback get called telling me things got interrupted (and treating them internally as though they were) in this case (I set a separate observer to compare).

This leads to incorrect behavior, as the app behaves as if things were interrupted when it's really not.

My code to deal with this looks something like this, but as we've discussed before, it's not a good idea to double up the handling of interrupts between BASS and user code (right?)

Code: [Select]
  BOOL wasSuspended = notification.userInfo[AVAudioSessionInterruptionWasSuspendedKey] ? [notification.userInfo[AVAudioSessionInterruptionWasSuspendedKey] boolValue] : false;

  if (interruptionType == AVAudioSessionInterruptionTypeBegan)
  {
    // Let the audio player know, but only if it wasn't a confusing "was suspended" variant,
    // c.f. https://developer.apple.com/documentation/avfoundation/avaudiosessioninterruptionnotification
    //
    if (!wasSuspended)
      ; // handle
  }


Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1330 on: 23 Dec '19 - 16:21 »
I'll look into this. Is the issue that BASS is pausing its output when the interruption notification with AVAudioSessionInterruptionWasSuspendedKey is received, and it shouldn't be? If so, does calling BASS_Start in your own BASS_CONFIG_IOS_NOTIFY based interruption handler then fix the problem?

The BASS_CONFIG_IOS_NOTIFY option isn't really needed these days (since iOS 6), as apps are able to register for their own interruption notifications directly from iOS now, but you should use BASS_CONFIG_IOS_NOTIFY for the BASS_Start test above because it's guaranteed to be called after BASS has done its interruption handling.

elan

  • Posts: 71
Re: BASS for iOS (iPhone/iPad)
« Reply #1331 on: 23 Dec '19 - 21:44 »
Is the issue that BASS is pausing its output when the interruption notification with AVAudioSessionInterruptionWasSuspendedKey is received, and it shouldn't be?

Yes, that seems to be exactly the case.

If so, does calling BASS_Start in your own BASS_CONFIG_IOS_NOTIFY based interruption handler then fix the problem?

It doesn't seem to, no, and even if it did, we wouldn't be able to distinguish the "false" background interrupt from a real one, right? Because I think we'd only want to call BASS_Start during a fake one.

The timeline is:

1. Start app, init BASS, audio is paused, BASS is paused.
2. Put the app in the background
3. Try to resume playback from lock screen control center.
4. App starts up BASS and usually a fraction of a second of audio is heard, before...
5. BASS interrupt handler is called (falsely, because iOS is just like "hey, FYI i suspended you") and stops BASS. This is the main issue.
6. Even if I call BASS_Start here, it doesn't seem to make a difference (audio won't resume).

The BASS_CONFIG_IOS_NOTIFY option isn't really needed these days (since iOS 6), as apps are able to register for their own interruption notifications directly from iOS now, but you should use BASS_CONFIG_IOS_NOTIFY for the BASS_Start test above because it's guaranteed to be called after BASS has done its interruption handling.

I'm happy either way (BASS or our app handling it), but I think the issue is that with this bug, you can't disable BASS interrupt handling, right?

Let me know if you need more data or want me to try a build.

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1332 on: 3 Jan '20 - 12:54 »
A BASS update (2.4.15.1) is up in the 1st post to fix a bug that could result in the output being stopped and not resuming when BASS_CONFIG_DEV_NONSTOP is set to 0 on iOS (other platforms are unaffected).

Ashazy1234

  • Posts: 1
Re: BASS for iOS (iPhone/iPad)
« Reply #1333 on: 5 Jan '20 - 21:59 »
Thanks for posting this.Specifically the links.

vandenbrakel

  • Posts: 26
Re: BASS for iOS (iPhone/iPad)
« Reply #1334 on: 3 Mar '20 - 22:59 »
Thanks for reporting this, has been an issue for a while. Glad it's fixed. I could not find what was wrong with this play/pause issue... Also thanks to Ian for fixing.

Is the issue that BASS is pausing its output when the interruption notification with AVAudioSessionInterruptionWasSuspendedKey is received, and it shouldn't be?

Yes, that seems to be exactly the case.

If so, does calling BASS_Start in your own BASS_CONFIG_IOS_NOTIFY based interruption handler then fix the problem?

It doesn't seem to, no, and even if it did, we wouldn't be able to distinguish the "false" background interrupt from a real one, right? Because I think we'd only want to call BASS_Start during a fake one.

The timeline is:

1. Start app, init BASS, audio is paused, BASS is paused.
2. Put the app in the background
3. Try to resume playback from lock screen control center.
4. App starts up BASS and usually a fraction of a second of audio is heard, before...
5. BASS interrupt handler is called (falsely, because iOS is just like "hey, FYI i suspended you") and stops BASS. This is the main issue.
6. Even if I call BASS_Start here, it doesn't seem to make a difference (audio won't resume).

The BASS_CONFIG_IOS_NOTIFY option isn't really needed these days (since iOS 6), as apps are able to register for their own interruption notifications directly from iOS now, but you should use BASS_CONFIG_IOS_NOTIFY for the BASS_Start test above because it's guaranteed to be called after BASS has done its interruption handling.

I'm happy either way (BASS or our app handling it), but I think the issue is that with this bug, you can't disable BASS interrupt handling, right?

Let me know if you need more data or want me to try a build.

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1335 on: 20 Mar '20 - 16:27 »
The iOS version of the BASSmix 2.4.10 release is up now in the 1st post.

vandenbrakel

  • Posts: 26
Re: BASS for iOS (iPhone/iPad)
« Reply #1336 on: 20 Mar '20 - 22:03 »
The iOS version of the BASSmix 2.4.10 release is up now in the 1st post.

Are the release notes or changes available?

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1337 on: 23 Mar '20 - 14:03 »
The changelog can be found in the "History" section of the BASSMIX.TXT file. You can get that from the Windows/OSX/Linux packages on the BASS page, or view it online here:

   www.un4seen.com/doc/#bassmix/bassmix.html

vandenbrakel

  • Posts: 26
Re: BASS for iOS (iPhone/iPad)
« Reply #1338 on: 23 Mar '20 - 14:12 »
The changelog can be found in the "History" section of the BASSMIX.TXT file. You can get that from the Windows/OSX/Linux packages on the BASS page, or view it online here:

   www.un4seen.com/doc/#bassmix/bassmix.html

Ah great, thanks!

reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1339 on: 2 Apr '20 - 23:33 »
Problem with large embedded cover art in ALAC files.

When the cover art is larger than about 1MB I'm getting a BASS_ERROR_FILEFORM from

channel = Bass.BASS_StreamCreateURL(url, 0, BassFlag.BASS_SAMPLE_FLOAT | BassFlag.BASS_STREAM_PRESCAN | BassFlag.BASS_STREAM_DECODE, null, Intptr.Zero);

I've tried it without the PRESCAN flag, no difference. I can copy the same files onto the iDevice through Apple Music and they play fine.

Any ideas?

Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1340 on: 3 Apr '20 - 13:13 »
Please upload an affected file to have a look at here:

   ftp.un4seen.com/incoming/

reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1341 on: 3 Apr '20 - 16:15 »
Please upload an affected file to have a look at here:

   ftp.un4seen.com/incoming/
Uploaded one just now.
Edit:
If I convert the file to FLAC with the same cover art it plays using the flac plugin.
« Last Edit: 3 Apr '20 - 16:50 by reb »

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1342 on: 3 Apr '20 - 17:26 »
The uploaded file is playing fine here, so that's strange. Please confirm that you are using the latest BASS version (check with BASS_GetVersion).

reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1343 on: 3 Apr '20 - 18:11 »
The uploaded file is playing fine here, so that's strange. Please confirm that you are using the latest BASS version (check with BASS_GetVersion).
33820160

It's probably out of date, IIRC I think I updated it about a year ago.
I didn't see anything applicable in the changelog though it's possible I might have missed something.

reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1344 on: 3 Apr '20 - 18:31 »
The uploaded file is playing fine here, so that's strange. Please confirm that you are using the latest BASS version (check with BASS_GetVersion).
33820160

It's probably out of date, IIRC I think I updated it about a year ago.
I didn't see anything applicable in the changelog though it's possible I might have missed something.
Ok I just updated to latest 33820417 and it works now, sorry for not trying that first.

Salvo

  • Posts: 163
Re: BASS for iOS (iPhone/iPad)
« Reply #1345 on: 21 Apr '20 - 14:10 »
Hi IAN, I have a problem with building BASS on IOS.

The mistake is this:
""
Undefined symbols for architecture arm64 :
_CFReadStreamCreateForHTTPRequest from libbass.a
""

from a check on CFNetwork I saw that on IOS SDK 13.4 this procedure is deprecated.
Do you have a solution for this?

----------------------------
And yet another mistake:
Undefined symbol : _vDSP_fft_zip referenced from : _bass_channelGetData in libbass.a
where do i find this symbols _vDSP_fft_zip ?
I found under the Accelerate Framework a libvDSP.dylib library with _vDSP_fft_zip but it is a library for OSX and not for IOS.


« Last Edit: 21 Apr '20 - 14:49 by Salvo »

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1346 on: 21 Apr '20 - 15:46 »
The mistake is this:
""
Undefined symbols for architecture arm64 :
_CFReadStreamCreateForHTTPRequest from libbass.a
""

from a check on CFNetwork I saw that on IOS SDK 13.4 this procedure is deprecated.
Do you have a solution for this?

Although deprecated, CFReadStreamCreateForHTTPRequest should still be working. Are you using Delphi? I don't know if you're having the same issue but another user reported something similar with Delphi on iOS and provided a solution here:

   www.un4seen.com/forum/?topic=16518

And yet another mistake:
Undefined symbol : _vDSP_fft_zip referenced from : _bass_channelGetData in libbass.a
where do i find this symbols _vDSP_fft_zip ?
I found under the Accelerate Framework a libvDSP.dylib library with _vDSP_fft_zip but it is a library for OSX and not for IOS.

Again, I'm not sure if it's the same issue, but another user recently posted something very similiar looking, which they fixed by adding "Uses Macapi.VecLib":

   www.un4seen.com/forum/?topic=18879

Salvo

  • Posts: 163
Re: BASS for iOS (iPhone/iPad)
« Reply #1347 on: 21 Apr '20 - 18:22 »
The mistake is this:
""
Undefined symbols for architecture arm64 :
_CFReadStreamCreateForHTTPRequest from libbass.a
""

from a check on CFNetwork I saw that on IOS SDK 13.4 this procedure is deprecated.
Do you have a solution for this?

Although deprecated, CFReadStreamCreateForHTTPRequest should still be working. Are you using Delphi? I don't know if you're having the same issue but another user reported something similar with Delphi on iOS and provided a solution here:

   www.un4seen.com/forum/?topic=16518

And yet another mistake:
Undefined symbol : _vDSP_fft_zip referenced from : _bass_channelGetData in libbass.a
where do i find this symbols _vDSP_fft_zip ?
I found under the Accelerate Framework a libvDSP.dylib library with _vDSP_fft_zip but it is a library for OSX and not for IOS.

Again, I'm not sure if it's the same issue, but another user recently posted something very similiar looking, which they fixed by adding "Uses Macapi.VecLib":

   www.un4seen.com/forum/?topic=18879

I created this unit and now everything works.
Thank you
--------------
unit iOSapi.funzionimancanti;

interface

uses
 Macapi.ObjectiveC, Macapi.ObjCRuntime, Macapi.CoreFoundation,Macapi.vecLib;

const
 libCFNetwork = '/System/Library/Frameworks/CFNetwork.framework/CFNetwork';

implementation

function CFReadStreamCreateForHTTPRequest(CFAllocatorRef:Pointer ; CFHTTPMessageRef:Pointer):OSStatus; cdecl; external libCFNetwork name _PU + 'CFReadStreamCreateForHTTPRequest';

end.
--------------

alexanderbaars

  • Posts: 13
Re: BASS for iOS (iPhone/iPad)
« Reply #1348 on: 1 May '20 - 10:36 »
I have two questions. I notice the mp3 requests to apache 2.4.41 from bass are all HTTP/1.0.
Is there a way to make them HTTP/1.1?

Furthermore the useragent gets mangled and is logged in the server with strange characters.
Apache sometimes responses with a 400 error due to this. Omitting the useragent results in serving audio always.
How do I make bass serving the useragent header correctly?

I am using BASS_StreamCreateURL(path, 0, BASS_STREAM_DECODE, 0,0))
And set the useragent on bass initialisation using:
 
Code: [Select]
-(void) setUserAgent :(id)ua
{
    if(ua){
 
        if(BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, ua) == false){
            NSLog(@"bass useragent error: %i",BASS_ErrorGetCode());
        }else{
            NSLog(@"bass useragent set to: %@", ua);
        }
    }else{
        NSLog(@"bass useragent sent was empty");
    }
}
« Last Edit: 1 May '20 - 11:36 by alexanderbaars »

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1349 on: 1 May '20 - 15:31 »
I have two questions. I notice the mp3 requests to apache 2.4.41 from bass are all HTTP/1.0.
Is there a way to make them HTTP/1.1?

No, there isn't currently any way to request HTTP/1.1 as HTTP/1.0 should work fine for BASS's purposes. Are you having a problem with a particular URL? If so, please provide that to have a look at.

Furthermore the useragent gets mangled and is logged in the server with strange characters.
Apache sometimes responses with a 400 error due to this. Omitting the useragent results in serving audio always.
How do I make bass serving the useragent header correctly?

I am using BASS_StreamCreateURL(path, 0, BASS_STREAM_DECODE, 0,0))
And set the useragent on bass initialisation using:
 
Code: [Select]
-(void) setUserAgent :(id)ua
{
    if(ua){
 
        if(BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, ua) == false){
            NSLog(@"bass useragent error: %i",BASS_ErrorGetCode());
        }else{
            NSLog(@"bass useragent set to: %@", ua);
        }
    }else{
        NSLog(@"bass useragent sent was empty");
    }
}

BASS_CONFIG_NET_AGENT should be set to a string. If you have an NSString, you can do this:

Code: [Select]
BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, [ua UTF8String]);

If there's still a problem, please confirm what string you're using, eg. any exotic characters?