kwave
18.07.70
|
#include <Record-ALSA.h>
Public Member Functions | |
RecordALSA () | |
virtual | ~RecordALSA () Q_DECL_OVERRIDE |
virtual QString | open (const QString &dev) Q_DECL_OVERRIDE |
virtual int | read (QByteArray &buffer, unsigned int offset) Q_DECL_OVERRIDE |
virtual int | close () Q_DECL_OVERRIDE |
virtual QStringList | supportedDevices () Q_DECL_OVERRIDE |
virtual int | detectTracks (unsigned int &min, unsigned int &max) Q_DECL_OVERRIDE |
virtual int | setTracks (unsigned int &tracks) Q_DECL_OVERRIDE |
virtual int | tracks () Q_DECL_OVERRIDE |
virtual QList< double > | detectSampleRates () Q_DECL_OVERRIDE |
virtual int | setSampleRate (double &new_rate) Q_DECL_OVERRIDE |
virtual double | sampleRate () Q_DECL_OVERRIDE |
virtual QList< Kwave::Compression::Type > | detectCompressions () Q_DECL_OVERRIDE |
virtual int | setCompression (Kwave::Compression::Type new_compression) Q_DECL_OVERRIDE |
virtual Kwave::Compression::Type | compression () Q_DECL_OVERRIDE |
virtual QList< unsigned int > | supportedBits () Q_DECL_OVERRIDE |
virtual int | setBitsPerSample (unsigned int new_bits) Q_DECL_OVERRIDE |
virtual int | bitsPerSample () Q_DECL_OVERRIDE |
virtual QList< Kwave::SampleFormat::Format > | detectSampleFormats () Q_DECL_OVERRIDE |
virtual int | setSampleFormat (Kwave::SampleFormat::Format new_format) Q_DECL_OVERRIDE |
virtual Kwave::SampleFormat::Format | sampleFormat () Q_DECL_OVERRIDE |
virtual Kwave::byte_order_t | endianness () Q_DECL_OVERRIDE |
![]() | |
RecordDevice () | |
virtual | ~RecordDevice () |
virtual QString | fileFilter () |
Private Member Functions | |
void | detectSupportedFormats () |
int | initialize () |
int | mode2format (Kwave::Compression::Type compression, int bits, Kwave::SampleFormat::Format sample_format) |
void | scanDevices () |
QString | alsaDeviceName (const QString &name) |
Private Attributes | |
snd_pcm_t * | m_handle |
snd_pcm_hw_params_t * | m_hw_params |
snd_pcm_sw_params_t * | m_sw_params |
int | m_open_result |
unsigned int | m_tracks |
double | m_rate |
Kwave::Compression::Type | m_compression |
unsigned int | m_bits_per_sample |
unsigned int | m_bytes_per_sample |
Kwave::SampleFormat::Format | m_sample_format |
QList< int > | m_supported_formats |
bool | m_initialized |
unsigned int | m_buffer_size |
snd_pcm_uframes_t | m_chunk_size |
Static Private Attributes | |
static QMap< QString, QString > | m_device_list |
Definition at line 44 of file Record-ALSA.h.
Kwave::RecordALSA::RecordALSA | ( | ) |
Constructor
Definition at line 198 of file Record-ALSA.cpp.
References m_hw_params, and m_sw_params.
|
virtual |
Destructor
Definition at line 214 of file Record-ALSA.cpp.
References close(), m_hw_params, and m_sw_params.
|
private |
Translate a verbose device name into a ALSA hardware device name.
name | verbose name of the device |
Definition at line 1105 of file Record-ALSA.cpp.
References _, DBG, m_device_list, name, and scanDevices().
Referenced by open().
|
virtual |
Returns the current resolution in bits per sample or a negative error code if failed
Implements Kwave::RecordDevice.
Definition at line 899 of file Record-ALSA.cpp.
References m_bits_per_sample.
|
virtual |
Close the device
Implements Kwave::RecordDevice.
Definition at line 662 of file Record-ALSA.cpp.
References m_handle, m_initialized, m_open_result, and m_supported_formats.
Referenced by open(), and ~RecordALSA().
|
virtual |
Returns the current compression type (0==none)
Implements Kwave::RecordDevice.
Definition at line 858 of file Record-ALSA.cpp.
References m_compression.
Referenced by detectCompressions().
|
virtual |
Gets a list of supported compression types. If no compression is supported, the list might be empty.
Implements Kwave::RecordDevice.
Definition at line 827 of file Record-ALSA.cpp.
References _known_formats, compression(), compression_of(), and m_supported_formats.
|
virtual |
Gets a list of supported sample formats.
Implements Kwave::RecordDevice.
Definition at line 905 of file Record-ALSA.cpp.
References _known_formats, compression_of(), m_bits_per_sample, m_compression, m_supported_formats, sample_format_of(), and Kwave::toInt().
|
virtual |
get a list of supported sample rates
Implements Kwave::RecordDevice.
Definition at line 719 of file Record-ALSA.cpp.
References ELEMENTS_OF, m_handle, and m_hw_params.
|
private |
Walk through the list of all known formats and collect the ones that are supported into "m_supported_formats".
Definition at line 222 of file Record-ALSA.cpp.
References _known_formats, m_handle, m_hw_params, and m_supported_formats.
Referenced by open().
|
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 684 of file Record-ALSA.cpp.
References m_handle, and m_hw_params.
|
virtual |
Returns the current endianness (big/little)
Implements Kwave::RecordDevice.
Definition at line 950 of file Record-ALSA.cpp.
References _known_formats, endian_of(), m_bits_per_sample, m_compression, m_sample_format, mode2format(), and Kwave::UnknownEndian.
|
private |
Initialize the ALSA device with current parameters and prepare it for recording.
Definition at line 329 of file Record-ALSA.cpp.
References _known_formats, DBG, Kwave::TypesMap< IDX, DATA >::description(), Kwave::TypesMap< IDX, DATA >::findFromData(), m_bits_per_sample, m_buffer_size, m_bytes_per_sample, m_chunk_size, m_compression, m_handle, m_hw_params, m_initialized, m_rate, m_sample_format, m_sw_params, m_tracks, mode2format(), name, Kwave::toInt(), and Kwave::toUint().
Referenced by read().
|
private |
create a ALSA device format (enum) from parameters.
compression | the compression type |
bits | the number of bits per sample, related to the decoded stream |
sample_format | the sample format, as defined in libaudiofile (signed or unsigned) |
Definition at line 800 of file Record-ALSA.cpp.
References _known_formats, compression_of(), m_supported_formats, and sample_format_of().
Referenced by endianness(), and initialize().
|
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::number(EINVAL) | on invalid parameters |
QString(...) | device specific error message (already translated) |
Implements Kwave::RecordDevice.
Definition at line 274 of file Record-ALSA.cpp.
References _, alsaDeviceName(), close(), DBG, detectSupportedFormats(), m_handle, m_initialized, and m_open_result.
|
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 528 of file Record-ALSA.cpp.
References initialize(), m_bytes_per_sample, m_chunk_size, m_handle, m_initialized, m_open_result, m_rate, Kwave::toInt(), and Kwave::toUint().
|
virtual |
Returns the current sample format (signed/unsigned)
Implements Kwave::RecordDevice.
Definition at line 944 of file Record-ALSA.cpp.
References m_sample_format.
|
virtual |
Returns the current sample rate of the device
Implements Kwave::RecordDevice.
Definition at line 794 of file Record-ALSA.cpp.
References m_rate.
|
private |
scan all ALSA devices, re-creates m_device_list
Definition at line 974 of file Record-ALSA.cpp.
References _, DBG, DEFAULT_DEVICE, m_device_list, name, and Kwave::toInt().
Referenced by alsaDeviceName(), and supportedDevices().
|
virtual |
Set the resolution in bits per sample
new_bits | resolution [bits/sample] |
Implements Kwave::RecordDevice.
Definition at line 891 of file Record-ALSA.cpp.
References m_bits_per_sample, and m_initialized.
|
virtual |
Try to set a new compression type.
new_compression | the identifier of the new compression |
Implements Kwave::RecordDevice.
Definition at line 850 of file Record-ALSA.cpp.
References m_compression, and m_initialized.
|
virtual |
Try to set a new sample format (signed/unsigned)
new_format | the identifier for the new format |
Implements Kwave::RecordDevice.
Definition at line 936 of file Record-ALSA.cpp.
References m_initialized, 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 786 of file Record-ALSA.cpp.
References m_initialized, 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 705 of file Record-ALSA.cpp.
References m_initialized, m_tracks, and tracks().
|
virtual |
Detect a list of supported bits per sample.
Implements Kwave::RecordDevice.
Definition at line 864 of file Record-ALSA.cpp.
References _known_formats, compression_of(), m_compression, and m_supported_formats.
|
virtual |
return a string list with supported device names
Implements Kwave::RecordDevice.
Definition at line 958 of file Record-ALSA.cpp.
References _, DEFAULT_DEVICE, m_device_list, and scanDevices().
|
virtual |
Returns the current number of tracks
Implements Kwave::RecordDevice.
Definition at line 713 of file Record-ALSA.cpp.
References m_tracks.
Referenced by setTracks().
|
private |
resolution [bits per sample]
Definition at line 251 of file Record-ALSA.h.
Referenced by bitsPerSample(), detectSampleFormats(), endianness(), initialize(), and setBitsPerSample().
|
private |
size of the transfer buffer in bytes
Definition at line 274 of file Record-ALSA.h.
Referenced by initialize().
|
private |
Number of bytes per sample, already multiplied with the number of channels (m_channels)
Definition at line 257 of file Record-ALSA.h.
Referenced by initialize(), and read().
|
private |
number of samples per period
Definition at line 277 of file Record-ALSA.h.
Referenced by initialize(), and read().
|
private |
compression mode
Definition at line 248 of file Record-ALSA.h.
Referenced by compression(), detectSampleFormats(), endianness(), initialize(), setCompression(), and supportedBits().
|
staticprivate |
dictionary for translating verbose device names into ALSA hardware device names
initializer for the list of devices
Definition at line 239 of file Record-ALSA.h.
Referenced by alsaDeviceName(), scanDevices(), and supportedDevices().
|
private |
handle of the source device or null if not open
Definition at line 224 of file Record-ALSA.h.
Referenced by close(), detectSampleRates(), detectSupportedFormats(), detectTracks(), initialize(), open(), and read().
|
private |
ALSA hardware parameters
Definition at line 227 of file Record-ALSA.h.
Referenced by detectSampleRates(), detectSupportedFormats(), detectTracks(), initialize(), RecordALSA(), and ~RecordALSA().
|
private |
true if initialize() has been successfully been run
Definition at line 271 of file Record-ALSA.h.
Referenced by close(), initialize(), open(), read(), setBitsPerSample(), setCompression(), setSampleFormat(), setSampleRate(), and setTracks().
|
private |
result of the "open" call, of interest when m_handle == 0
Definition at line 233 of file Record-ALSA.h.
|
private |
sample rate
Definition at line 245 of file Record-ALSA.h.
Referenced by initialize(), read(), sampleRate(), and setSampleRate().
|
private |
sample format (signed int, unsigned int, float, ...
Definition at line 260 of file Record-ALSA.h.
Referenced by endianness(), initialize(), sampleFormat(), and setSampleFormat().
|
private |
list of supported formats of the current device, indices in the global list of known formats. Only valid after a successful call to "open()", otherwise empty
Definition at line 268 of file Record-ALSA.h.
Referenced by close(), detectCompressions(), detectSampleFormats(), detectSupportedFormats(), mode2format(), and supportedBits().
|
private |
ALSA software parameters
Definition at line 230 of file Record-ALSA.h.
Referenced by initialize(), RecordALSA(), and ~RecordALSA().
|
private |
number of tracks [0...N-1]
Definition at line 242 of file Record-ALSA.h.
Referenced by initialize(), setTracks(), and tracks().