Ejemplo n.º 1
0
void
queue_network_speaker_data(byte* inData, short inLength) {
    if(inLength > 0) {
        if(sSoundDataBuffers.getCountOfElements() > 0) {
            // Fill out a descriptor for a new chunk of storage
            NetworkSpeakerSoundBufferDescriptor theBufferDesc;
            theBufferDesc.mData     = sSoundDataBuffers.peek();
            sSoundDataBuffers.dequeue();
            theBufferDesc.mLength   = inLength;
            theBufferDesc.mFlags    = kSoundDataIsDisposable;
    
            // and copy the data
            memcpy(theBufferDesc.mData, inData, inLength);
    
            // If we're just turning on, prime the queue with a few buffers of noise.
            if(!sSpeakerIsOn) {
                for(int i = 0; i < kNumPumpPrimes; i++) {
                    sSoundBuffers.enqueue(sNoiseBufferDesc);
                }
    
                sSpeakerIsOn = true;
            }
    
            // Enqueue the actual sound data.
            sSoundBuffers.enqueue(theBufferDesc);
        }
        else {
            fdprintf("No sound data buffer space available - audio discarded");
        }
    }
}
Ejemplo n.º 2
0
void
close_network_speaker() {
    // Tell the audio system not to get our data anymore
	Mixer::instance()->StopNetworkAudio();

    // Bleed the queue dry of any leftover data
    NetworkSpeakerSoundBufferDescriptor*  theDesc;
    while((theDesc = dequeue_network_speaker_data()) != NULL) {
        if(is_sound_data_disposable(theDesc))
            release_network_speaker_buffer(theDesc->mData);
    }
    
    // Free the sound data buffers
    while(sSoundDataBuffers.getCountOfElements() > 0) {
        byte* theBuffer = sSoundDataBuffers.peek();
        delete [] theBuffer;
        sSoundDataBuffers.dequeue();
    }

    // Free the noise buffer and restore some values
    if(sNoiseBufferStorage != NULL) {
        delete [] sNoiseBufferStorage;
        sNoiseBufferStorage = NULL;
    }
    sDryDequeues    = 0;
    sSpeakerIsOn    = false;
    
    #ifdef SPEEX
    destroy_speex_decoder();
    #endif
}
Ejemplo n.º 3
0
int main()
{
	CircularQueue q;
	q.enqueue(1);
	q.enqueue(2);
	q.enqueue(3);
	q.enqueue(4);
	q.enqueue(5);

	q.display();
	q.dequeue();
	q.display();
	q.enqueue(6);

	q.display();
	q.dequeue();
	q.dequeue();
	q.dequeue();
	q.dequeue();
	q.dequeue();

return 0;
}