1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
/*************************************************************************
RecordThread.h - thread for lowlevel audio recording
-------------------
begin : Mon Oct 20 2003
copyright : (C) 2003 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RECORD_THREAD_H
#define RECORD_THREAD_H
#include "config.h"
#include <QByteArray>
#include <QQueue>
#include <QRecursiveMutex>
#include "libkwave/WorkerThread.h"
namespace Kwave
{
class RecordDevice;
class RecordThread: public Kwave::WorkerThread
{
Q_OBJECT
public:
/** Constructor */
RecordThread();
/** Destructor */
~RecordThread() override;
/** does the recording */
void run() override;
/**
* Select a new record device.
* @param device a RecordDevice that is opened and set up for reading
* @note this must not be called during recording
*/
void setRecordDevice(Kwave::RecordDevice *device);
/**
* Set the number of buffers and their size
* @param count the number of buffer, minimum allowed is two
* @param size the number of bytes for each buffer
* @return number of allocated buffers or -ENOMEM if less than two
* @note this must not be called during recording
*/
int setBuffers(unsigned int count, unsigned int size);
/** Returns the amount of remaining empty buffers */
unsigned int remainingBuffers();
/** Returns the number of queued filled buffers */
unsigned int queuedBuffers();
/** De-queues a buffer from the m_full_queue. */
QByteArray dequeue();
signals:
/**
* emitted when a buffer was full and has been de-queued
* with dequeue()
*/
void bufferFull();
/**
* emitted when the recording stops or aborts
* @param errorcode zero if stopped normally or a negative
* error code if aborted
*/
void stopped(int errorcode);
private:
/** lock for protecting the queues */
QRecursiveMutex m_lock;
/** the device used as source */
Kwave::RecordDevice *m_device;
/** queue with empty buffers for raw input data */
QQueue<QByteArray>m_empty_queue;
/** queue with filled buffers with raw input data */
QQueue<QByteArray>m_full_queue;
/** number of buffers to allocate */
unsigned int m_buffer_count;
/** size of m_buffer in bytes */
unsigned int m_buffer_size;
};
}
#endif /* RECORD_THREAD_H */
//***************************************************************************
//***************************************************************************
|