kwave
18.07.70
|
#include <PlayBack-ALSA.h>
Public Member Functions | |
PlayBackALSA () | |
virtual | ~PlayBackALSA () Q_DECL_OVERRIDE |
virtual QString | open (const QString &device, double rate, unsigned int channels, unsigned int bits, unsigned int bufbase) Q_DECL_OVERRIDE |
virtual int | write (const Kwave::SampleArray &samples) Q_DECL_OVERRIDE |
virtual int | close () Q_DECL_OVERRIDE |
virtual QStringList | supportedDevices () Q_DECL_OVERRIDE |
virtual QString | fileFilter () Q_DECL_OVERRIDE |
virtual QList< unsigned int > | supportedBits (const QString &device) Q_DECL_OVERRIDE |
virtual int | detectChannels (const QString &device, unsigned int &min, unsigned int &max) Q_DECL_OVERRIDE |
![]() | |
virtual | ~PlayBackDevice () |
Protected Member Functions | |
snd_pcm_t * | openDevice (const QString &device) |
int | openDevice (const QString &device, unsigned int rate, unsigned int channels, unsigned int bits) |
int | setFormat (snd_pcm_hw_params_t *hw_params, unsigned int bits) |
int | flush () |
void | scanDevices () |
QString | alsaDeviceName (const QString &name) |
Private Member Functions | |
QList< int > | detectSupportedFormats (const QString &device) |
int | mode2format (int bits) |
Private Attributes | |
QString | m_device_name |
snd_pcm_t * | m_handle |
double | m_rate |
unsigned int | m_channels |
unsigned int | m_bits |
unsigned int | m_bytes_per_sample |
unsigned int | m_bufbase |
QByteArray | m_buffer |
unsigned int | m_buffer_size |
unsigned int | m_buffer_used |
snd_pcm_format_t | m_format |
snd_pcm_uframes_t | m_chunk_size |
QList< int > | m_supported_formats |
Kwave::SampleEncoder * | m_encoder |
Static Private Attributes | |
static QMap< QString, QString > | m_device_list |
Definition at line 45 of file PlayBack-ALSA.h.
Kwave::PlayBackALSA::PlayBackALSA | ( | ) |
Default constructor
Definition at line 191 of file PlayBack-ALSA.cpp.
|
virtual |
Destructor
Definition at line 211 of file PlayBack-ALSA.cpp.
References close().
|
protected |
Translate a verbose device name into a ALSA hardware device name.
name | verbose name of the device |
Definition at line 862 of file PlayBack-ALSA.cpp.
References _, DBG, m_device_list, name, and scanDevices().
Referenced by openDevice().
|
virtual |
Closes the output device.
Implements Kwave::PlayBackDevice.
Definition at line 720 of file PlayBack-ALSA.cpp.
References flush(), m_encoder, m_handle, and m_supported_formats.
Referenced by ~PlayBackALSA().
|
virtual |
Detect the minimum and maximum number of channels. If the detection fails, minimum and maximum are set to zero.
device | filename of the device |
min | receives the lowest supported number of channels |
max | receives the highest supported number of channels |
Reimplemented from Kwave::PlayBackDevice.
Definition at line 965 of file PlayBack-ALSA.cpp.
References ALSA_MALLOC_WRAPPER, m_handle, and openDevice().
|
private |
Walk through the list of all known formats and collect the ones that are supported into "m_supported_formats".
Definition at line 283 of file PlayBack-ALSA.cpp.
References _known_formats, ALSA_MALLOC_WRAPPER, m_handle, m_supported_formats, and openDevice().
Referenced by open(), and supportedBits().
|
virtual |
return a string suitable for a "File Open..." dialog
Reimplemented from Kwave::PlayBackDevice.
Definition at line 903 of file PlayBack-ALSA.cpp.
References _.
|
protected |
Writes the output buffer to the device
Definition at line 641 of file PlayBack-ALSA.cpp.
References m_buffer, m_buffer_size, m_buffer_used, m_bytes_per_sample, m_channels, m_chunk_size, m_format, m_handle, m_rate, Kwave::toInt(), and Kwave::toUint().
Referenced by close(), and write().
|
private |
create a ALSA device format (enum) from parameters.
bits | the number of bits per sample, related to the decoded stream |
Definition at line 261 of file PlayBack-ALSA.cpp.
References _known_formats, and m_supported_formats.
Referenced by setFormat().
|
virtual |
Opens the device for playback.
Implements Kwave::PlayBackDevice.
Definition at line 540 of file PlayBack-ALSA.cpp.
References DBG, detectSupportedFormats(), m_bits, m_bufbase, m_buffer, m_buffer_size, m_buffer_used, m_bytes_per_sample, m_channels, m_chunk_size, m_device_name, m_encoder, m_handle, m_rate, m_supported_formats, openDevice(), and Kwave::toUint().
|
protected |
Opens a physical device and returns its file descriptor (short version, used for probing / detecting)
device | filename of the device |
Definition at line 909 of file PlayBack-ALSA.cpp.
References _, alsaDeviceName(), DBG, and m_handle.
Referenced by detectChannels(), detectSupportedFormats(), and open().
|
protected |
Open the device and set all internal member variables that need to be initialized for playback.
device | name of the ALSA device |
rate | sample rate, rounded as unsigned int |
channels | number of tracks/channels to use |
bits | number of bits per sample |
Definition at line 343 of file PlayBack-ALSA.cpp.
References _, ALSA_MALLOC_WRAPPER, alsaDeviceName(), DBG, m_channels, m_chunk_size, m_handle, m_rate, and setFormat().
|
protected |
scan all ALSA devices, re-creates m_device_list
Definition at line 739 of file PlayBack-ALSA.cpp.
References _, ALSA_MALLOC_WRAPPER, DBG, DEFAULT_DEVICE, m_device_list, name, NULL_DEVICE, and Kwave::toInt().
Referenced by alsaDeviceName(), and supportedDevices().
|
protected |
Used in "openDevice()" to set the member variables m_format, m_bytes_per_sample and m_bits according the given resolution in bits per sample. The number of bits per sample will be rounded up to the next multiple of 8. m_handle must already be an opened device.
hw_params | valid ALSA hardware parameters |
bits | number of bits per sample [1...32] |
Definition at line 217 of file PlayBack-ALSA.cpp.
References _known_formats, endian_of(), m_bits, m_bytes_per_sample, m_channels, m_encoder, m_format, m_handle, mode2format(), and sample_format_of().
Referenced by openDevice().
|
virtual |
returns a list of supported bits per sample resolutions of a given device.
device | filename of the device |
Implements Kwave::PlayBackDevice.
Definition at line 940 of file PlayBack-ALSA.cpp.
References _known_formats, and detectSupportedFormats().
|
virtual |
return a string list with supported device names
Reimplemented from Kwave::PlayBackDevice.
Definition at line 884 of file PlayBack-ALSA.cpp.
References _, DEFAULT_DEVICE, m_device_list, NULL_DEVICE, and scanDevices().
|
virtual |
Writes an array of samples to the output device.
Implements Kwave::PlayBackDevice.
Definition at line 615 of file PlayBack-ALSA.cpp.
References Kwave::SampleEncoder::encode(), flush(), m_buffer, m_buffer_size, m_buffer_used, m_bytes_per_sample, m_channels, m_encoder, and MEMCPY.
|
private |
Resolution in bits per sample
Definition at line 190 of file PlayBack-ALSA.h.
Referenced by open(), and setFormat().
|
private |
|
private |
buffer with raw device data
Definition at line 202 of file PlayBack-ALSA.h.
|
private |
Buffer size on bytes
Definition at line 205 of file PlayBack-ALSA.h.
|
private |
number of bytes in the buffer
Definition at line 208 of file PlayBack-ALSA.h.
|
private |
Number of bytes per sample, already multiplied with the number of channels (m_channels)
Definition at line 196 of file PlayBack-ALSA.h.
Referenced by flush(), open(), setFormat(), and write().
|
private |
Number of channels
Definition at line 187 of file PlayBack-ALSA.h.
Referenced by flush(), open(), openDevice(), setFormat(), and write().
|
private |
number of samples per period
Definition at line 214 of file PlayBack-ALSA.h.
Referenced by flush(), open(), and openDevice().
|
staticprivate |
dictionary for translating verbose device names into ALSA hardware device names (key = verbose name, data = ALSA hardware device name)
Definition at line 221 of file PlayBack-ALSA.h.
Referenced by alsaDeviceName(), scanDevices(), and supportedDevices().
|
private |
|
private |
encoder for conversion from samples to raw
Definition at line 232 of file PlayBack-ALSA.h.
Referenced by close(), open(), setFormat(), and write().
|
private |
sample format, used for ALSA
Definition at line 211 of file PlayBack-ALSA.h.
Referenced by flush(), and setFormat().
|
private |
Handle of the output device
Definition at line 181 of file PlayBack-ALSA.h.
Referenced by close(), detectChannels(), detectSupportedFormats(), flush(), open(), openDevice(), and setFormat().
|
private |
Playback rate [samples/second]
Definition at line 184 of file PlayBack-ALSA.h.
Referenced by flush(), open(), and openDevice().
|
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 229 of file PlayBack-ALSA.h.
Referenced by close(), detectSupportedFormats(), mode2format(), and open().