{"id":21,"date":"2008-09-01T14:55:27","date_gmt":"2008-09-01T18:55:27","guid":{"rendered":"httpss:\/\/www.powenko.com\/blog\/?p=21"},"modified":"2008-09-01T18:58:44","modified_gmt":"2008-09-01T22:58:44","slug":"iphone-crashlading-example-has-no-sound-probelm","status":"publish","type":"post","link":"https:\/\/www.powenko.com\/wordpress\/?p=21","title":{"rendered":"iPhone, CrashLading example has no sound probelm."},"content":{"rendered":"<p>The iPhone SDK 2.0 CrashLading example has no sound probelm, In my simulator and device, a lot of developer encounter same problem, below is my solution,<\/p>\n<p><code><br \/>\nNSString *file = [bundle pathForResource:@\"Start\" ofType:@\"caf\"];<br \/>\nNSURL *url =[NSURL fileURLWithPath:file];<br \/>\nSystemSoundID *outSystemSoundID;<\/p>\n<p>AudioServicesCreateSystemSoundID( (CFURLRef) url, &amp;outSystemSoundID );<br \/>\nAudioServicesPlaySystemSound( outSystemSoundID );<br \/>\nAudioServicesDisposeSystemSoundID( outSystemSoundID );<br \/>\n<\/code><\/p>\n<p>It can play the sound. <\/p>\n<p>Solution 2, if you add below code in your program, you can play the background sound and looping in the code with current OpenAL lib,<br \/>\n<code><br \/>\n\t\/\/Setup sound engine. Run  it at 44Khz to match the sound files<br \/>\n\tSoundEngine_Initialize(44100);<br \/>\n\t\/\/ Assume the listener is in the center at the start. The sound will pan as the position of the rocket changes.<br \/>\n\tSoundEngine_SetListenerPosition(0.0, 0.0, kListenerDistance);<\/p>\n<p>\tSoundEngine_LoadBackgroundMusicTrack([[bundle pathForResource:@\"Failure\" ofType:@\"caf\"] UTF8String], true, true);<br \/>\n\tSoundEngine_StartBackgroundMusic();<br \/>\n<\/code><\/p>\n<p>Let focus the bug, in my Mac, tracking the bug this happen in below code.<\/p>\n<p><code><br \/>\n\talGenBuffers(1, &outBufferID);<br \/>\n\t\t\t\tAssertNoOALError(\"Error generating buffer\\n\", fail);<br \/>\n<\/code><br \/>\n check the OpenAL document,<br \/>\nhttpss:\/\/connect.creativelabs.com\/openal\/Documentation\/OpenAL%201.1%20Specification.htm<\/p>\n<p>Allocation of object names does not imply immediate allocation of resources or creation of objects: the implementation is free to defer this until a given object is actually used in mutator calls. The names are written at the memory location specified by the caller.<\/p>\n<p>End of today, I still don&#8217;t know how to create and use &#8220;alGenBuffers&#8221; function to fix this bug.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The iPhone SDK 2.0 CrashLading example has no sound pro [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/21"}],"collection":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21"}],"version-history":[{"count":0,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}