iPhone, CrashLading example has no sound probelm.

iPhone, CrashLading example has no sound probelm.

    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,


    NSString *file = [bundle pathForResource:@"Start" ofType:@"caf"];
    NSURL *url =[NSURL fileURLWithPath:file];
    SystemSoundID *outSystemSoundID;

    AudioServicesCreateSystemSoundID( (CFURLRef) url, &outSystemSoundID );
    AudioServicesPlaySystemSound( outSystemSoundID );
    AudioServicesDisposeSystemSoundID( outSystemSoundID );

    It can play the sound.

    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,

    //Setup sound engine. Run it at 44Khz to match the sound files
    SoundEngine_Initialize(44100);
    // Assume the listener is in the center at the start. The sound will pan as the position of the rocket changes.
    SoundEngine_SetListenerPosition(0.0, 0.0, kListenerDistance);

    SoundEngine_LoadBackgroundMusicTrack([[bundle pathForResource:@"Failure" ofType:@"caf"] UTF8String], true, true);
    SoundEngine_StartBackgroundMusic();

    Let focus the bug, in my Mac, tracking the bug this happen in below code.


    alGenBuffers(1, &outBufferID);
    AssertNoOALError("Error generating buffer\n", fail);

    check the OpenAL document,
    httpss://connect.creativelabs.com/openal/Documentation/OpenAL%201.1%20Specification.htm

    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.

    End of today, I still don’t know how to create and use “alGenBuffers” function to fix this bug.