Logo Search packages:      
Sourcecode: akode version File versions  Download package

bool aKode::AudioBuffer::put ( AudioFrame buf,
bool  blocking = false 
)

Puts the AudioFrame buf into the buffer. If blocking is set to true, put will block until the buffer is not full. Returns true if succesfull.

Note:
That put will fail even if blocking is set, if flush or release is called.

Definition at line 41 of file audiobuffer.cpp.

                                                    {
    pthread_mutex_lock(&mutex);
    if (released) goto fail;
    flushed = false;
    if ((writePos+1) % length == readPos) {
        if (blocking) {
            pthread_cond_wait(&not_full, &mutex);
            if (flushed || released) goto fail;
        }
        else
            goto fail;
    }

    takeover(&buffer[writePos], buf);
    writePos = (writePos+1) % length;

    pthread_cond_signal(&not_empty);
    pthread_mutex_unlock(&mutex);
    return true;
fail:
    pthread_mutex_unlock(&mutex);
    return false;
}


Generated by  Doxygen 1.6.0   Back to index