audiotoolbox - iOS: Is this an audio-session simulator bug? keywords: kAudioSessionProperty_AudioRoute kAudioSessionUnsupportedPropertyError -
can confirm whether indeed bug? ( if go off , file apple ).
attempting fetch kaudiosessionproperty_audioroute returning error code kaudiosessionunsupportedpropertyerror on version of simulator prior 4.3 ( latest version @ time of writing ).
this 1 dead easy reproduce.
start new project ( using xcode 4.0.2 build 4a2002a, standard build ), window-based project "audiosessionbug"
include audiotoolbox framework
replace application delegate's .m file following:
// // audiosessionbugappdelegate.m // audiosessionbug // // created pi on 02/07/2011. // copyright 2011 pi. rights reserved. // #import "audiosessionbugappdelegate.h" #import <audiotoolbox/audiotoolbox.h> #define set_property( prop, type, val ) \ { \ osstatus ret = audiosessionsetproperty( prop, sizeof( type ), &(type){ val } ); \ if ( ret != kaudiosessionnoerror ) \ { \ nslog( @"audiosessionsetproperty failed for: %s!", #prop ); \ return; \ } \ } enum { kno = 0, kyes = 1 }; // - - - @interface audiosessionbugappdelegate ( ) - (void) setupsession; @end // - - - @implementation audiosessionbugappdelegate @synthesize window=_window; - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point customization after application launch. [self.window makekeyandvisible]; [self setupsession]; return yes; } - (void) setupsession { osstatus result = audiosessioninitialize( null, null, null, null ); assert( result == kaudiosessionnoerror ); set_property( kaudiosessionproperty_audiocategory, uint32, kaudiosessioncategory_playandrecord ); // make sure headphones plugged in! { // http://stackoverflow.com/questions/2753562/what-kind-of-routes-could-i-get-back-from-kaudiosessionproperty-audioroute-proper cfstringref state = nil; uint32 propertysize = sizeof(cfstringref); osstatus status = audiosessiongetproperty( kaudiosessionproperty_audioroute, &propertysize, &state ); if ( status == kaudiosessionunsupportedpropertyerror ) { nslog( @" wtf? getting kaudiosessionproperty_audioroute gives kaudiosessionunsupportedpropertyerror ?!?!? " ); } nslog( @" ok - done! " ); exit( 1 ); } } - (void)dealloc { [_window release]; [super dealloc]; } @end
check works.
now change deployment target prior 4.3. 4.2.
run again on ipad simulator 4.3 -- ok
run again on ipad simulator 4.2 -- fail
i received following confirmation apple:
this bug fixed in 4.3 , have no plans fix bugs in earlier builds of simulator.
Comments
Post a Comment