kwave  18.07.70
Record-ALSA.cpp File Reference
#include "config.h"
#include <errno.h>
#include <math.h>
#include <QtGlobal>
#include "libkwave/Compression.h"
#include "libkwave/String.h"
#include "libkwave/Utils.h"
#include "Record-ALSA.h"
Include dependency graph for Record-ALSA.cpp:

Go to the source code of this file.

Macros

#define DEFAULT_DEVICE   (i18n("DSNOOP plugin") + _("|sound_note"))
 
#define ELEMENTS_OF(__array__)   (sizeof(__array__) / sizeof(__array__[0]))
 
#define SND_PCM_FORMAT_S18_3   SND_PCM_FORMAT_S18_3BE
 
#define SND_PCM_FORMAT_U18_3   SND_PCM_FORMAT_U18_3BE
 
#define SND_PCM_FORMAT_U20_3   SND_PCM_FORMAT_U20_3BE
 
#define SND_PCM_FORMAT_S20_3   SND_PCM_FORMAT_S20_3BE
 
#define SND_PCM_FORMAT_U24_3   SND_PCM_FORMAT_U24_3BE
 
#define SND_PCM_FORMAT_S24_3   SND_PCM_FORMAT_S24_3BE
 

Functions

static Kwave::SampleFormat::Format sample_format_of (snd_pcm_format_t fmt)
 
static Kwave::byte_order_t endian_of (snd_pcm_format_t fmt)
 
static Kwave::Compression::Type compression_of (snd_pcm_format_t fmt)
 

Variables

static const snd_pcm_format_t _known_formats []
 

Macro Definition Documentation

◆ DEFAULT_DEVICE

#define DEFAULT_DEVICE   (i18n("DSNOOP plugin") + _("|sound_note"))

gui name of the default device

Definition at line 36 of file Record-ALSA.cpp.

Referenced by Kwave::RecordALSA::scanDevices(), and Kwave::RecordALSA::supportedDevices().

◆ ELEMENTS_OF

#define ELEMENTS_OF (   __array__)    (sizeof(__array__) / sizeof(__array__[0]))

helper macro: returns the number of elements in an array

Definition at line 39 of file Record-ALSA.cpp.

Referenced by Kwave::RecordALSA::detectSampleRates().

◆ SND_PCM_FORMAT_S18_3

#define SND_PCM_FORMAT_S18_3   SND_PCM_FORMAT_S18_3BE

Definition at line 46 of file Record-ALSA.cpp.

◆ SND_PCM_FORMAT_S20_3

#define SND_PCM_FORMAT_S20_3   SND_PCM_FORMAT_S20_3BE

Definition at line 49 of file Record-ALSA.cpp.

◆ SND_PCM_FORMAT_S24_3

#define SND_PCM_FORMAT_S24_3   SND_PCM_FORMAT_S24_3BE

Definition at line 51 of file Record-ALSA.cpp.

◆ SND_PCM_FORMAT_U18_3

#define SND_PCM_FORMAT_U18_3   SND_PCM_FORMAT_U18_3BE

Definition at line 47 of file Record-ALSA.cpp.

◆ SND_PCM_FORMAT_U20_3

#define SND_PCM_FORMAT_U20_3   SND_PCM_FORMAT_U20_3BE

Definition at line 48 of file Record-ALSA.cpp.

◆ SND_PCM_FORMAT_U24_3

#define SND_PCM_FORMAT_U24_3   SND_PCM_FORMAT_U24_3BE

Definition at line 50 of file Record-ALSA.cpp.

Function Documentation

◆ compression_of()

static Kwave::Compression::Type compression_of ( snd_pcm_format_t  fmt)
static

Definition at line 177 of file Record-ALSA.cpp.

References Kwave::Compression::G711_ALAW, Kwave::Compression::G711_ULAW, Kwave::Compression::GSM, Kwave::Compression::MPEG_LAYER_I, Kwave::Compression::MS_ADPCM, and Kwave::Compression::NONE.

Referenced by Kwave::RecordALSA::detectCompressions(), Kwave::RecordALSA::detectSampleFormats(), Kwave::RecordALSA::mode2format(), and Kwave::RecordALSA::supportedBits().

178 {
180  switch (fmt) {
181  case SND_PCM_FORMAT_MU_LAW:
183  case SND_PCM_FORMAT_A_LAW:
185  case SND_PCM_FORMAT_IMA_ADPCM:
186  c = Kwave::Compression::MS_ADPCM; break;
187  case SND_PCM_FORMAT_MPEG:
189  case SND_PCM_FORMAT_GSM:
190  c = Kwave::Compression::GSM; break;
191  default:
192  break;
193  }
194  return c;
195 }
Here is the caller graph for this function:

◆ endian_of()

static Kwave::byte_order_t endian_of ( snd_pcm_format_t  fmt)
static

find out the endianness of an ALSA format

Definition at line 167 of file Record-ALSA.cpp.

References Kwave::BigEndian, Kwave::CpuEndian, and Kwave::LittleEndian.

Referenced by Kwave::RecordALSA::endianness().

168 {
169  if (snd_pcm_format_little_endian(fmt) == 1)
170  return Kwave::LittleEndian;
171  if (snd_pcm_format_big_endian(fmt) == 1)
172  return Kwave::BigEndian;
173  return Kwave::CpuEndian;
174 }
Here is the caller graph for this function:

◆ sample_format_of()

static Kwave::SampleFormat::Format sample_format_of ( snd_pcm_format_t  fmt)
static

find out the SampleFormat of an ALSA format

Definition at line 148 of file Record-ALSA.cpp.

References Kwave::SampleFormat::Double, Kwave::SampleFormat::Float, Kwave::SampleFormat::Signed, Kwave::SampleFormat::Unknown, and Kwave::SampleFormat::Unsigned.

Referenced by Kwave::RecordALSA::detectSampleFormats(), and Kwave::RecordALSA::mode2format().

149 {
150  if (snd_pcm_format_float(fmt)) {
151  if (snd_pcm_format_width(fmt) == 32)
153  if (snd_pcm_format_width(fmt) == 64)
155  } else if (snd_pcm_format_linear(fmt)) {
156  if (snd_pcm_format_signed(fmt) == 1)
158  else if (snd_pcm_format_unsigned(fmt) == 1)
160  }
161 
163 }
Here is the caller graph for this function:

Variable Documentation

◆ _known_formats

const snd_pcm_format_t _known_formats[]
static

Global list of all known sample formats.

Note
this list should be sorted so that the most preferable formats come first in the list. When searching for a format that matches a given set of parameters, the first entry is taken.

The sort order should be:

  • compression: none -> ulaw -> alaw -> adpcm -> mpeg ...
  • bits per sample: ascending
  • sample format: signed -> unsigned -> float -> double ...
  • endianness: cpu -> little -> big
  • bytes per sample: ascending

Definition at line 77 of file Record-ALSA.cpp.

Referenced by Kwave::RecordALSA::detectCompressions(), Kwave::RecordALSA::detectSampleFormats(), Kwave::RecordALSA::detectSupportedFormats(), Kwave::RecordALSA::endianness(), Kwave::RecordALSA::initialize(), Kwave::RecordALSA::mode2format(), and Kwave::RecordALSA::supportedBits().