kwave
18.07.70
|
#include <Record-Qt.h>
Signals | |
void | sigCreateRequested (QAudioFormat &format, unsigned int buffer_size) |
void | sigCloseRequested () |
Public Member Functions | |
RecordQt () | |
virtual | ~RecordQt () Q_DECL_OVERRIDE |
virtual QString | open (const QString &dev) Q_DECL_OVERRIDE |
virtual Kwave::byte_order_t | endianness () Q_DECL_OVERRIDE |
virtual Kwave::SampleFormat::Format | sampleFormat () Q_DECL_OVERRIDE |
virtual int | setSampleFormat (Kwave::SampleFormat::Format new_format) Q_DECL_OVERRIDE |
virtual QList< Kwave::SampleFormat::Format > | detectSampleFormats () Q_DECL_OVERRIDE |
virtual int | bitsPerSample () Q_DECL_OVERRIDE |
virtual int | setBitsPerSample (unsigned int new_bits) Q_DECL_OVERRIDE |
virtual QList< unsigned int > | supportedBits () Q_DECL_OVERRIDE |
virtual Kwave::Compression::Type | compression () Q_DECL_OVERRIDE |
virtual int | setCompression (Kwave::Compression::Type new_compression) Q_DECL_OVERRIDE |
virtual QList< Kwave::Compression::Type > | detectCompressions () Q_DECL_OVERRIDE |
virtual double | sampleRate () Q_DECL_OVERRIDE |
virtual int | setSampleRate (double &new_rate) Q_DECL_OVERRIDE |
virtual QList< double > | detectSampleRates () Q_DECL_OVERRIDE |
virtual int | tracks () Q_DECL_OVERRIDE |
virtual int | setTracks (unsigned int &tracks) Q_DECL_OVERRIDE |
virtual int | detectTracks (unsigned int &min, unsigned int &max) Q_DECL_OVERRIDE |
virtual int | close () Q_DECL_OVERRIDE |
virtual int | read (QByteArray &buffer, unsigned int offset) Q_DECL_OVERRIDE |
virtual QStringList | supportedDevices () Q_DECL_OVERRIDE |
![]() | |
RecordDevice () | |
virtual | ~RecordDevice () |
virtual QString | fileFilter () |
Private Slots | |
void | createInMainThread (QAudioFormat &format, unsigned int buffer_size) |
void | closeInMainThread () |
void | notified () |
Private Member Functions | |
int | initialize (unsigned int buffer_size) |
void | scanDevices () |
QAudioDeviceInfo | deviceInfo (const QString &device) const |
Private Attributes | |
QMutex | m_lock |
QMap< QString, QString > | m_device_name_map |
QList< QAudioDeviceInfo > | m_available_devices |
QAudioInput * | m_input |
QIODevice * | m_source |
Kwave::SampleFormat::Format | m_sample_format |
quint8 | m_tracks |
double | m_rate |
Kwave::Compression::Type | m_compression |
unsigned int | m_bits_per_sample |
QString | m_device |
bool | m_initialized |
QSemaphore | m_sem |
Definition at line 46 of file Record-Qt.h.
Kwave::RecordQt::RecordQt | ( | ) |
Constructor
Definition at line 60 of file Record-Qt.cpp.
References closeInMainThread(), Kwave::connect(), createInMainThread(), sigCloseRequested(), and sigCreateRequested().
|
virtual |
Destructor
Definition at line 86 of file Record-Qt.cpp.
References close().
|
virtual |
Returns the current resolution in bits per sample or a negative error code if failed
Implements Kwave::RecordDevice.
Definition at line 164 of file Record-Qt.cpp.
References m_bits_per_sample.
|
virtual |
Close the device
Implements Kwave::RecordDevice.
Definition at line 344 of file Record-Qt.cpp.
References closeInMainThread(), m_lock, and sigCloseRequested().
Referenced by open(), setBitsPerSample(), setCompression(), setSampleFormat(), setSampleRate(), setTracks(), and ~RecordQt().
|
privateslot |
handles the request to close the device, running in the context of the main thread
Definition at line 327 of file Record-Qt.cpp.
References m_initialized, m_input, and m_source.
Referenced by close(), and RecordQt().
|
virtual |
Returns the current compression type (0==none)
Implements Kwave::RecordDevice.
Definition at line 201 of file Record-Qt.cpp.
References m_compression.
|
privateslot |
handles the request to create the device, running in the context of the main thread
format | reference to the audio format specification |
buffer_size | size of the audio buffer in bytes |
Definition at line 492 of file Record-Qt.cpp.
References BUFFER_SIZE_OVERCOMMIT, Kwave::connect(), m_input, m_lock, m_sem, m_source, and notified().
Referenced by initialize(), and RecordQt().
|
virtual |
Gets a list of supported compression types. If no compression is supported, the list might be empty.
Implements Kwave::RecordDevice.
Definition at line 217 of file Record-Qt.cpp.
References Kwave::Compression::NONE.
|
virtual |
Gets a list of supported sample formats.
Implements Kwave::RecordDevice.
Definition at line 107 of file Record-Qt.cpp.
References deviceInfo(), Kwave::SampleFormat::Float, m_device, m_lock, Kwave::SampleFormat::Signed, and Kwave::SampleFormat::Unsigned.
|
virtual |
get a list of supported sample rates
Implements Kwave::RecordDevice.
Definition at line 241 of file Record-Qt.cpp.
References deviceInfo(), m_device, and m_lock.
|
virtual |
Detect the minimum and maximum number of tracks. If the detection fails, minimum and maximum are set to zero.
min | receives the lowest supported number of tracks |
max | receives the highest supported number of tracks |
Implements Kwave::RecordDevice.
Definition at line 279 of file Record-Qt.cpp.
References deviceInfo(), m_device, m_lock, and Kwave::toUint().
|
private |
Gets the full device info of a playback device, identified by the device name.
device | name of the device or empty string for default |
Definition at line 304 of file Record-Qt.cpp.
References DEFAULT_DEVICE, m_available_devices, and m_device_name_map.
Referenced by detectSampleFormats(), detectSampleRates(), detectTracks(), endianness(), initialize(), open(), and supportedBits().
|
virtual |
Returns the current endianness (big/little)
Implements Kwave::RecordDevice.
Definition at line 138 of file Record-Qt.cpp.
References Kwave::BigEndian, deviceInfo(), Kwave::LittleEndian, m_device, m_lock, and Kwave::UnknownEndian.
|
private |
Initialize the audio device with current parameters and prepare it for recording.
buffer_size | size of the audio buffer in bytes |
Definition at line 432 of file Record-Qt.cpp.
References _, createInMainThread(), deviceInfo(), m_bits_per_sample, m_device, m_rate, m_tracks, sigCreateRequested(), and Kwave::toInt().
Referenced by read().
|
privateslot |
called when recorded data gets available
Definition at line 514 of file Record-Qt.cpp.
References m_sem.
Referenced by createInMainThread().
|
virtual |
Open the record device.
dev | path of the record device |
QString() | if successful |
QString::number(ENODEV) | if device not found |
QString::number(EBUSY) | if device is busy |
QString(...) | device specific error message (already translated) |
Implements Kwave::RecordDevice.
Definition at line 391 of file Record-Qt.cpp.
References close(), deviceInfo(), m_device, m_lock, and scanDevices().
|
virtual |
Read the raw audio data from the record device.
buffer | array of bytes to receive the audio data might be resized for alignment |
offset | offset in bytes within the buffer |
Implements Kwave::RecordDevice.
Definition at line 357 of file Record-Qt.cpp.
References BUFFER_SIZE_OVERCOMMIT, initialize(), m_initialized, m_input, m_sem, m_source, RECORD_POLL_TIMEOUT, and Kwave::toInt().
|
virtual |
Returns the current sample format (signed/unsigned)
Implements Kwave::RecordDevice.
Definition at line 92 of file Record-Qt.cpp.
References m_sample_format.
|
virtual |
Returns the current sample rate of the device
Implements Kwave::RecordDevice.
Definition at line 225 of file Record-Qt.cpp.
References m_rate.
|
private |
scan all PulseAudio source, re-creates m_device_list
Definition at line 520 of file Record-Qt.cpp.
References _, DBG, m_available_devices, and m_device_name_map.
Referenced by open(), and supportedDevices().
|
virtual |
Set the resolution in bits per sample
new_bits | resolution [bits/sample] |
Implements Kwave::RecordDevice.
Definition at line 170 of file Record-Qt.cpp.
References close(), and m_bits_per_sample.
|
virtual |
Try to set a new compression type.
new_compression | the identifier of the new compression |
Implements Kwave::RecordDevice.
Definition at line 207 of file Record-Qt.cpp.
References close(), and m_compression.
|
virtual |
Try to set a new sample format (signed/unsigned)
new_format | the identifier for the new format |
Implements Kwave::RecordDevice.
Definition at line 98 of file Record-Qt.cpp.
References close(), and m_sample_format.
|
virtual |
Try to set a new sample rate.
new_rate | the sample rate to be set [samples/second], can be modified and rounded up/down to the nearest supported sample rate if the underlying driver supports that. |
Implements Kwave::RecordDevice.
Definition at line 231 of file Record-Qt.cpp.
References close(), and m_rate.
|
virtual |
Try to set a new number of tracks.
tracks | the number of tracks to be set, can be modified and decreased to the next supported number of tracks if the underlying driver supports that. |
Implements Kwave::RecordDevice.
Definition at line 268 of file Record-Qt.cpp.
References close(), m_tracks, and tracks().
|
signal |
request closeInMainThread()
Referenced by close(), and RecordQt().
|
signal |
request createInMainThread()
format | reference to the audio format specification |
buffer_size | size of the audio buffer in bytes |
Referenced by initialize(), and RecordQt().
|
virtual |
Detect a list of supported bits per sample.
Implements Kwave::RecordDevice.
Definition at line 180 of file Record-Qt.cpp.
References deviceInfo(), m_device, m_lock, and Kwave::toUint().
|
virtual |
return a string list with supported device names
Implements Kwave::RecordDevice.
Definition at line 412 of file Record-Qt.cpp.
References _, DEFAULT_DEVICE, m_available_devices, m_device_name_map, m_lock, and scanDevices().
|
virtual |
Returns the current number of tracks
Implements Kwave::RecordDevice.
Definition at line 262 of file Record-Qt.cpp.
References m_tracks.
Referenced by setTracks().
|
private |
list of available Qt output devices
Definition at line 250 of file Record-Qt.h.
Referenced by deviceInfo(), scanDevices(), and supportedDevices().
|
private |
resolution [bits per sample]
Definition at line 271 of file Record-Qt.h.
Referenced by bitsPerSample(), initialize(), and setBitsPerSample().
|
private |
compression mode
Definition at line 268 of file Record-Qt.h.
Referenced by compression(), and setCompression().
|
private |
encoded name of the sink
Definition at line 274 of file Record-Qt.h.
Referenced by detectSampleFormats(), detectSampleRates(), detectTracks(), endianness(), initialize(), open(), and supportedBits().
|
private |
dictionary for translating verbose device names into Qt audio output device names (key = verbose name, data = Qt output device name)
Definition at line 247 of file Record-Qt.h.
Referenced by deviceInfo(), scanDevices(), and supportedDevices().
|
private |
true if initialize() has been successfully been run
Definition at line 277 of file Record-Qt.h.
Referenced by closeInMainThread(), and read().
|
private |
Qt audio input instance
Definition at line 253 of file Record-Qt.h.
Referenced by closeInMainThread(), createInMainThread(), and read().
|
private |
mutex for locking the streaming thread against main thread
Definition at line 240 of file Record-Qt.h.
Referenced by close(), createInMainThread(), detectSampleFormats(), detectSampleRates(), detectTracks(), endianness(), open(), supportedBits(), and supportedDevices().
|
private |
sample rate
Definition at line 265 of file Record-Qt.h.
Referenced by initialize(), sampleRate(), and setSampleRate().
|
private |
sample format (signed int, unsigned int, float, ...
Definition at line 259 of file Record-Qt.h.
Referenced by sampleFormat(), and setSampleFormat().
|
private |
semaphore for signaling "data available"
Definition at line 280 of file Record-Qt.h.
Referenced by createInMainThread(), notified(), and read().
|
private |
QIODevice for reading the data
Definition at line 256 of file Record-Qt.h.
Referenced by closeInMainThread(), createInMainThread(), and read().
|
private |
number of tracks [0...N-1]
Definition at line 262 of file Record-Qt.h.
Referenced by initialize(), setTracks(), and tracks().