IDZAQAudioPlayer icon indicating copy to clipboard operation
IDZAQAudioPlayer copied to clipboard

Audio Queue Errors Result in Asserts.

Open iosdevzone opened this issue 11 years ago • 3 comments

Currently Audio Queue errors will cause assertions, they should be handled correctly, that is reported to caller of the player.

iosdevzone avatar Apr 06 '13 08:04 iosdevzone

Do you mind sharing what do you plan to resolve those assertions? Thanks.

zwang avatar Nov 06 '15 07:11 zwang

@zwang This code was sample code for a blog post, so really I wasn't planning to resolve them, the reason for this issue was to alert folks that might want to use this code in production that they would need to resolve them in an appropriate way for their app.

If your app is purely Objective C then you could use exceptions, although this is unpopular in ObjC it has minimal code impact and most of the places where the asserts are unrecoverable, server issues where all you could do is pop a dialog and ask users to contact support.

Another approach is to pass in an NSError. This is already done for initWithDecoder but does not handle all cases (i.e. errors are used if buffer allocation fails, but asserts if the audio queue cannot be created).

For simpler routines like play and pause you could either pass in an error or save the error as a member variable. Then calling code could check the boolean return and decide the appropriate action to take.

So, some if this is a matter of taste and coding style. I didn't want to be too prescriptive in the blog post about this.

iosdevzone avatar Nov 06 '15 18:11 iosdevzone

@iosdevzone I understand your decision. I don't think you need to. Thank you very much for sharing your thoughts. It will be very helpful when I start to add more error handling into it for my project.

Thank you! You are awesome! :+1:

zwang avatar Nov 08 '15 06:11 zwang