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

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

Gets one AudioFrame from the buffer. If blocking is set to true, get will block until the buffer is not empty. Returns true if succesfull.

Note:
That get will fail even if blocking is set if release is called.

Definition at line 65 of file audiobuffer.cpp.

References empty().

                                                    {
    pthread_mutex_lock(&mutex);
    if (released) goto fail;
    if (readPos == writePos || paused) {
        if (blocking && !m_eof) {
            pthread_cond_wait(&not_empty, &mutex);
            if (released) goto fail;
            if (empty()) goto fail;
        }
        else
            goto fail;
    }

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

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


Generated by  Doxygen 1.6.0   Back to index