MusicSequenceFileLoad在iOS10上返回-1(AudioToolbox/MusicPlayer) [英] MusicSequenceFileLoad Returns -1 on iOS10 (AudioToolbox/MusicPlayer)

查看:111
本文介绍了MusicSequenceFileLoad在iOS10上返回-1(AudioToolbox/MusicPlayer)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新10/9/2016::我在2016年9月22日与苹果公司共同打开了Radar#28425770,以解决以下缺陷,它们刚刚被标记为重复(与Radar#28327056相同) ),因此这似乎是iOS10中的一个已知错误.

UPDATE 10/9/2016: I had opened up Radar #28425770 with Apple on 9/22/2016 for the following defect and they have just marked is as a duplicate (of Radar #28327056), so this appears to be a known bug within iOS10.

我在调用AudioToolbox/MusicPlayer API方法"MusicSequenceFileLoad()"以将MIDI文件的内容(从给定的URL)加载到iOS10 iPad Pro(WiFi型号)的音乐序列中时遇到错误,并且非常感谢社区提供的调试帮助.

I've encountered an error invoking the AudioToolbox / MusicPlayer API method "MusicSequenceFileLoad()" to load the contents of a MIDI file (from the given URL) into a music sequence on an iOS10 iPad Pro (wifi model) and would greatly appreciate some assistance from the community in debugging this.

到目前为止我已经能够进行的研究/观察:

Research / observations I've been able to make thus far:

  • 此代码已经在iOS7、8和9的生产环境中正常运行了2年以上,并且在iOS 10 Simulator上运行也没有问题,但仅在iOS 10.0.1 iPad Pro Wifi上返回了错误模型.

  • This code has been working without issue in production on iOS7, 8, and 9 for 2+ years and also runs without issue on the iOS 10 Simulator but returns an error only on a iOS 10.0.1 iPad Pro Wifi Model.

我无法在其他设备上重新创建,还请一些朋友也尝试一下.经过测试的设备没有问题:iPhone 6 +,iPad Mini 4th Gen,iPad Pro Cellular.

I was not able to recreate on other devices and also asked some friends to try as well. Devices tested without issue: iPhone 6+, iPad Mini 4th Gen, iPad Pro Cellular.

第一次显示使用此MIDI文件的VC,所有处理都将运行,没有任何问题.只是第二次(有时是第三次)在应用程序崩溃的情况下加载了VC.可以始终100%地重新创建该问题.

The first time the VC is displayed which uses this MIDI file all processing runs without any issues. It's only the second time (or sometimes third) that the VC is loaded where the app crashes. The issue can be recreated consistently 100% of the time.

从调用此函数检查OSStatus结果代码只是返回值-1,并不表示失败的原因.

Checking the OSStatus result code from calling this function simply returns a value of -1 and does not indicate the reason for the failure.

在Xcode中调试时,没有崩溃报告,异常信息或调用堆栈.

No crash report, exception information or call stack is available when debugging within Xcode.

有关内存管理问题(分配,泄漏,僵尸)的分析,未显示与崩溃有关的任何信息;启用僵尸对象"选项不会显示任何僵尸对象.

Profiling for memory management issues (allocations, leaks, zombies), has not shown any information related to the crash; turning on the Zombie Objects option did not reveal any Zombie Objects.

分析应用程序没有发现未释放内存的任何区域.

Analyzing the application did not reveal any areas where memory was not being released.

将对象更改为静态没有任何影响,因此这似乎与内存无关.

Changing the objects to be static did not have any impact so this seems that it would not be memory related.

如果有人对我可以调试此问题的其他方式有任何建议,将不胜感激.我本来以为它可能与内存管理有关,但是从我看到的情况来看,我可以适当地处理内存(对应用程序使用ARC并根据需要释放C-API对象),并且分析并没有发现我可以看到的任何问题.

If anyone has any suggestions on other ways in which I could debug this issue it would be greatly appreciated. I originally thought it could be related to memory management however from what I can see I am handling memory appropriately (using ARC for the application and releasing C-API objects as needed) and profiling has not revealed any issues that I can see.

代码示例:

@property (readwrite, nonatomic) MusicPlayer midiMusicPlayer;
@property (readwrite, atomic) MusicSequence masterMidiMusicSequence;

- (void)initializeMusicPlayerAndMasterSequenceWithFile:(NSString *)midiFilename
{
    CheckError(NewMusicPlayer(&_midiMusicPlayer), "NewMusicPlayer: _midiMusicPlayer");
    CheckError(NewMusicSequence(&_masterMidiMusicSequence), "NewMusicSequence: _masterMidiMusicSequence");

    NSString *midiFilePath = [NSBundle pathForResource:midiFilename
                                                ofType:@"mid"
                               checkDocumentsDirectory:YES];
    NSURL *midiFileURL = [NSURL fileURLWithPath:midiFilePath];

    // Crash is encountered on the following line:
    CheckError(MusicSequenceFileLoad(self.masterMidiMusicSequence, (__bridge CFURLRef)midiFileURL, 0, 0), "MusicSequenceFileLoad");
}

推荐答案

我通过

I received some guidance from an Apple engineer via the Core Audio Mailing List and have successfully implemented the proposed work-around for this issue in iOS10.

通过在失败的调用后将"errno"值更新为0,随后对"MusicSequenceFileLoad"的调用将生成成功的响应.因此,我将代码修改如下:

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
    }
}

...,其中CheckError()函数仅根据已知的OSStatus代码检查OSStatus返回值,类似于 Chris Adamson从他的博客文章/演示文稿"Core Audio Cranks It Up" ).

... where the CheckError() function simply checks the OSStatus return value against known OSStatus codes and is similar to this one on GitHub (originally created by Chris Adamson from his blog post / presentation "Core Audio Cranks It Up").

我了解到,根据Core Audio Mailing List上发布的内容,有望在将来的iOS更新中解决此问题.

I understand that this issue is expected to be resolved in a future iOS update according to what was posted on the Core Audio Mailing List.

这篇关于MusicSequenceFileLoad在iOS10上返回-1(AudioToolbox/MusicPlayer)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆