kwave
18.07.70
|
Public Member Functions | |
Buffer () | |
virtual | ~Buffer () Q_DECL_OVERRIDE |
void | start (unsigned int buf_size, int timeout) |
void | setTimeout (int timeout) |
void | drain (QByteArray &padding) |
void | stop () |
virtual qint64 | readData (char *data, qint64 len) Q_DECL_OVERRIDE |
virtual qint64 | writeData (const char *data, qint64 len) Q_DECL_OVERRIDE |
virtual qint64 | bytesAvailable () const Q_DECL_OVERRIDE |
Private Attributes | |
QMutex | m_lock |
QSemaphore | m_sem_free |
QSemaphore | m_sem_filled |
QQueue< char > | m_raw_buffer |
int | m_timeout |
QByteArray | m_pad_data |
int | m_pad_ofs |
Definition at line 140 of file PlayBack-Qt.h.
Kwave::PlayBackQt::Buffer::Buffer | ( | ) |
|
virtual |
|
virtual |
returns the number of bytes available for reading
Definition at line 584 of file PlayBack-Qt.cpp.
References m_pad_data, m_pad_ofs, and m_sem_filled.
Referenced by Kwave::PlayBackQt::close().
void Kwave::PlayBackQt::Buffer::drain | ( | QByteArray & | padding | ) |
drain the sink, at the end of playback: provide padding to provide data for a full period
padding | array of bytes used for padding |
Definition at line 504 of file PlayBack-Qt.cpp.
References m_pad_data, and m_pad_ofs.
Referenced by Kwave::PlayBackQt::close().
|
virtual |
read data out from the buffer, called from the Qt audio device side
data | pointer to a buffer (of bytes) to receive the data |
len | number of bytes to read |
Definition at line 517 of file PlayBack-Qt.cpp.
References m_lock, m_pad_data, m_pad_ofs, m_raw_buffer, m_sem_filled, m_sem_free, m_timeout, and Kwave::toInt().
void Kwave::PlayBackQt::Buffer::setTimeout | ( | int | timeout | ) |
set a new read/write timeout
timeout | a new read/write timeout [ms] |
Definition at line 496 of file PlayBack-Qt.cpp.
References m_lock, and m_timeout.
Referenced by Kwave::PlayBackQt::open().
void Kwave::PlayBackQt::Buffer::start | ( | unsigned int | buf_size, |
int | timeout | ||
) |
start filling the buffer
buf_size | size of the buffer in bytes |
timeout | read/write timeout [ms] |
Definition at line 482 of file PlayBack-Qt.cpp.
References m_pad_data, m_pad_ofs, m_raw_buffer, m_sem_filled, m_sem_free, m_timeout, and Kwave::PlayBackQt::open().
Referenced by Kwave::PlayBackQt::open().
void Kwave::PlayBackQt::Buffer::stop | ( | ) |
stop filling the buffer
Definition at line 511 of file PlayBack-Qt.cpp.
References Kwave::PlayBackQt::close().
Referenced by Kwave::PlayBackQt::close().
|
virtual |
write data into the buffer, called from our own worker thread
data | pointer to a buffer (of bytes) to write |
len | number of bytes to write |
Definition at line 561 of file PlayBack-Qt.cpp.
References m_lock, m_raw_buffer, m_sem_filled, m_sem_free, m_timeout, and Kwave::toInt().
Referenced by Kwave::PlayBackQt::write().
|
private |
mutex for locking the queue
Definition at line 197 of file PlayBack-Qt.h.
Referenced by readData(), setTimeout(), and writeData().
|
private |
buffer with padding data
Definition at line 212 of file PlayBack-Qt.h.
Referenced by bytesAvailable(), drain(), readData(), and start().
|
private |
read pointer within m_pad_data
Definition at line 215 of file PlayBack-Qt.h.
Referenced by bytesAvailable(), drain(), readData(), and start().
|
private |
raw buffer with audio data
Definition at line 206 of file PlayBack-Qt.h.
Referenced by readData(), start(), and writeData().
|
private |
semaphore with filled buffer space
Definition at line 203 of file PlayBack-Qt.h.
Referenced by bytesAvailable(), readData(), start(), and writeData().
|
private |
semaphore with free buffer space
Definition at line 200 of file PlayBack-Qt.h.
Referenced by readData(), start(), and writeData().
|
private |
read timeout [ms]
Definition at line 209 of file PlayBack-Qt.h.
Referenced by readData(), setTimeout(), start(), and writeData().