Hello,
I am new to CoreAudio Programming and I have a problem with an AudioQueue. I use it to play a simple short sound but I need to control the volume, that is why I don't use SystemSounds instead. I am trying to play an audioqueue without having to initialize it from scratch every time I use it. For example, I don't want to open the associated file every time I play the sound. To do so, I have tried to customize the playBackCallback function from SpeakHere iPhone sample code. It is pretty much the same as the one used in AudioQueue Services Programming guide. I have just set mCurrentPacket to 0 every time I call the callback function. It seems to work well because it reads the same number of packets with audiofileReadPackets everytime I call it. The problem is that the sound is actually played only when I call AudioQueueStart for the first time. To be more specific, I have a button that is supposed to play a sound when I press it. It works when I press it for the first time but it does not as of the second time. I have tried debugging a number of parameters including everything I could in the callback function, and the behavour seems to be the same except that the sound is actully played only at the first attempt.
I was therefore wondering if is technically possible to play an AudioQueue again and again without having to initialize it from scratch ( which means calling CFURLCreateFromFileSystemRepresentation and AudioQueueNewOutput ).
I hope the formulation of my question is not too bad and you will be able to help me.
Kind regards |