Re: MusicSequenceFileLoad Returns -1 on iOS10 (AudioToolbox/MusicPlayer)

2016-10-19 Thread Sven Thoennissen
Hello,

for the sake of the list archive I'd like to add that the same problem occurs 
when trying to load a SoundFont into an AVAudioUnitSampler (when being invoked 
on a background thread). The result code is -10871 (kAudioUnitErr_InvalidFile).
It can be solved with the same workaround:

// May be called in other thread than the main thread

AudioUnit audioUnit = config->samplerAudioUnit;

AUSamplerInstrumentData instData;
instData.fileURL = url;
instData.bankLSB = kAUSampler_DefaultBankLSB;
instData.bankMSB = kAUSampler_DefaultMelodicBankMSB;
instData.presetID = presetNo;
instData.instrumentType = kInstrumentType_SF2Preset;

errno = 0; // Workaround for iOS bug; AudioUnitSetProperty() may fail when 
invoked on different thread than main thread

// Load soundfont preset by setting the kAUSamplerProperty_LoadPresetFromBank 
property
OSStatus result;
result = AudioUnitSetProperty(audioUnit, kAUSamplerProperty_LoadInstrument, 
kAudioUnitScope_Global, 0, &instData, sizeof(AUSamplerInstrumentData));
if (result != noErr) {
DLog(@"Could not load preset %u from soundfont '%@': result=%d", 
presetNo, ((__bridge NSURL *)url).lastPathComponent, (int)result);
} else {
DLog(@"Loaded preset %u from soundfont '%@'", presetNo, ((__bridge 
NSURL *)url).lastPathComponent);
OSAtomicTestAndSet(0, &config->presetLoaded);
}


Best regards,
Sven


> Am 14.10.2016 um 21:00 schrieb coreaudio-api-requ...@lists.apple.com:
> 
>> I cannot promise the specific release in which this will be fixed, but the 
>> problem is understood, and I can tell you that if you can force ‘errno’ to 
>> reset to 0, any following call to MusicSequenceFileLoadData() will succeed.
>> 
>> -DS

 ___
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list  (Coreaudio-api@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: MusicSequenceFileLoad Returns -1 on iOS10 (AudioToolbox/MusicPlayer)

2016-10-13 Thread Douglas Scott
You should actually be able to set errno to 0 *before* the first call, and it 
should never return failure unless there was actually a real problem with 
permissions, etc.

-DS

> On Oct 13, 2016, at 3:46 PM, down to this  wrote:
> 
> Just wanted to follow up regarding this. As per the work-around the Douglas 
> Scott suggested below, I've implemented this successfully in my app and it is 
> working without issues. 
> 
> For those who are unaware (as I was), the 'errno' value can simply be set 
> directly. By updating the "errno" value to 0 after a failed call, subsequent 
> calls to 'MusicSequenceFileLoad' generate a successful response. Therefore, 
> I've amended my code as follows:
> 
> OSStatus statusOfInitialAttempt = 
> CheckError(MusicSequenceFileLoad(self.masterMidiMusicSequence, (__bridge 
> CFURLRef)midiFileURL, 0, 0), "MusicSequenceFileLoad");
> if (statusOfInitialAttempt == -1) {
> errno = 0;
> 
> OSStatus statusOfSecondAttempt = 
> CheckErrorAndReturnOnFailure(MusicSequenceFileLoad(self.masterMidiMusicSequence,
>  (__bridge CFURLRef)midiFileURL, 0, 0), "MusicSequenceFileLoad");
> 
> if (statusOfSecondAttempt == -1) {
> // Handle error case
> }
> }
> Thanks Douglas for your help with this!
> 
> Best,
> 
> Derek
> 
> 
> Date: Sun, 09 Oct 2016 22:15:03 -0700
> From: Douglas Scott mailto:douglas_sc...@apple.com>>
> To: Sven Thoennissen mailto:bioch...@me.com>>
> Cc: coreaudio-api@lists.apple.com <mailto:coreaudio-api@lists.apple.com>
> Subject: Re: MusicSequenceFileLoad Returns -1 on iOS10
> (AudioToolbox/MusicPlayer)
> Message-ID: <43be2217-7a15-4f03-9338-728acd0ff...@apple.com 
> <mailto:43be2217-7a15-4f03-9338-728acd0ff...@apple.com>>
> Content-Type: text/plain; charset="utf-8"
> 
> I cannot promise the specific release in which this will be fixed, but the 
> problem is understood, and I can tell you that if you can force ‘errno’ to 
> reset to 0, any following call to MusicSequenceFileLoadData() will succeed.
> 
> -DS
> ___
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list  (Coreaudio-api@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/coreaudio-api/douglas_scott%40apple.com
> 
> This email sent to douglas_sc...@apple.com

 ___
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list  (Coreaudio-api@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: MusicSequenceFileLoad Returns -1 on iOS10 (AudioToolbox/MusicPlayer)

2016-10-13 Thread down to this
Just wanted to follow up regarding this. As per the work-around the Douglas
Scott suggested below, I've implemented this successfully in my app and it
is working without issues.

For those who are unaware (as I was), the 'errno' value can simply be set
directly. By updating the "errno" value to 0 after a failed call,
subsequent calls to 'MusicSequenceFileLoad' generate a successful response.
Therefore, I've amended my code as follows:

OSStatus statusOfInitialAttempt =
CheckError(MusicSequenceFileLoad(self.masterMidiMusicSequence,
(__bridge CFURLRef)midiFileURL, 0, 0), "MusicSequenceFileLoad");if
(statusOfInitialAttempt == -1) {
errno = 0;

OSStatus statusOfSecondAttempt =
CheckErrorAndReturnOnFailure(MusicSequenceFileLoad(self.masterMidiMusicSequence,
(__bridge CFURLRef)midiFileURL, 0, 0), "MusicSequenceFileLoad");

if (statusOfSecondAttempt == -1) {
// Handle error case
}}

Thanks Douglas for your help with this!

Best,

Derek


Date: Sun, 09 Oct 2016 22:15:03 -0700
> From: Douglas Scott 
> To: Sven Thoennissen 
> Cc: coreaudio-api@lists.apple.com
> Subject: Re: MusicSequenceFileLoad Returns -1 on iOS10
> (AudioToolbox/MusicPlayer)
> Message-ID: <43be2217-7a15-4f03-9338-728acd0ff...@apple.com>
> Content-Type: text/plain; charset="utf-8"
>
> I cannot promise the specific release in which this will be fixed, but the
> problem is understood, and I can tell you that if you can force ‘errno’ to
> reset to 0, any following call to MusicSequenceFileLoadData() will succeed.
>
> -DS
>
 ___
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list  (Coreaudio-api@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: MusicSequenceFileLoad Returns -1 on iOS10 (AudioToolbox/MusicPlayer)

2016-10-09 Thread Douglas Scott
I cannot promise the specific release in which this will be fixed, but the 
problem is understood, and I can tell you that if you can force ‘errno’ to 
reset to 0, any following call to MusicSequenceFileLoadData() will succeed.

-DS

> On Oct 9, 2016, at 2:18 PM, Sven Thoennissen  wrote:
> 
> Hello Derek,
> 
> For me using MusicSequenceFileLoadData() works ok, when the .mid file is 
> previously loaded using UIDocument.
> 
> Best,
> Sven
> 
>> Am 09.10.2016 um 21:00 schrieb coreaudio-api-requ...@lists.apple.com 
>> :
>> 
>> Two questions:
>> 
>> #1. Is the planned fix for this scheduled in an upcoming beta? I've just
>> tested this with 10.1 Beta 2 and the issue is still occurring in this
>> update.
>> 
>> #2. Is there any known work-around for this? I'm happy to patch my app with
>> a work-around but everything I have tried thus far has not been successful.
>> 
>> Best,
>> 
>> Derek
> 
> ___
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list  (Coreaudio-api@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/coreaudio-api/douglas_scott%40apple.com
> 
> This email sent to douglas_sc...@apple.com

 ___
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list  (Coreaudio-api@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: MusicSequenceFileLoad Returns -1 on iOS10 (AudioToolbox/MusicPlayer)

2016-10-09 Thread Sven Thoennissen
Hello Derek,

For me using MusicSequenceFileLoadData() works ok, when the .mid file is 
previously loaded using UIDocument.

Best,
Sven

> Am 09.10.2016 um 21:00 schrieb coreaudio-api-requ...@lists.apple.com:
> 
> Two questions:
> 
> #1. Is the planned fix for this scheduled in an upcoming beta? I've just
> tested this with 10.1 Beta 2 and the issue is still occurring in this
> update.
> 
> #2. Is there any known work-around for this? I'm happy to patch my app with
> a work-around but everything I have tried thus far has not been successful.
> 
> Best,
> 
> Derek

 ___
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list  (Coreaudio-api@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: MusicSequenceFileLoad Returns -1 on iOS10 (AudioToolbox/MusicPlayer)

2016-10-09 Thread down to this
Quick follow up on this - I had opened up Radar #28425770 for this issue on
9/22/2016 and noticed today that it was recently updated to "Duplicate of
28327056 (Open)".

Two questions:

#1. Is the planned fix for this scheduled in an upcoming beta? I've just
tested this with 10.1 Beta 2 and the issue is still occurring in this
update.

#2. Is there any known work-around for this? I'm happy to patch my app with
a work-around but everything I have tried thus far has not been successful.

Best,

Derek

Date: Fri, 23 Sep 2016 07:41:32 +0900
> From: down to this 
> To: coreaudio-api@lists.apple.com
> Subject: Re: MusicSequenceFileLoad Crash on iOS10
> (AudioToolbox/MusicPlayer)
> Message-ID:
>  gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Sven -
>
> Thanks for the followup on this! Sounds like we may be experiencing a
> slightly different issue. I haven't had any problems loading MIDI files on
> iOS9 (or 8 or 7 actually).
>
>
> Douglas -
>
> Some additional information that I've confirmed:
>
> - MusicSequenceFileLoad() is simply returning a -1 (not crashing).
>
> - I was able to test myself on an iPad Mini 4th Gen and iPhone 6+ and
> was not able to reproduce the issue on these devices.
>
> - I asked a friend to try on his iPad Pro (Cellular) and he was _not_
> able to reproduce it.
>
> - Seems that this is only happening on my iPad Pro (Wifi) model - but
> I haven't been able to find anyone else with an iPad Pro Wifi to
> confirm it happens on other devices as well.
>
> - I tried making the object that calls these MIDI functions static
> just to rule out the possibility of memory issues and the problem was
> still able to be recreated.
>
>
> I opened Radar #28425770 and have attached a sample project which is
> actually my actual app with pretty much everything except this issue
> cut out of it. This includes all MIDI files as well. This issue
> happens regardless of which MIDI file is used.
>
>
> Thanks for your support Douglas!
>
> Best,
>
> Derek
>
 ___
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list  (Coreaudio-api@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to arch...@mail-archive.com