kwave  18.07.70
PlayBack-ALSA.cpp File Reference
#include "config.h"
#include <errno.h>
#include <math.h>
#include <stdlib.h>
#include <unistd.h>
#include <QLatin1Char>
#include <QString>
#include <QtGlobal>
#include <KLocalizedString>
#include "libkwave/Compression.h"
#include "libkwave/SampleEncoderLinear.h"
#include "libkwave/SampleFormat.h"
#include "libkwave/String.h"
#include "libkwave/Utils.h"
#include "libkwave/memcpy.h"
#include "PlayBack-ALSA.h"
Include dependency graph for PlayBack-ALSA.cpp:

Go to the source code of this file.

Classes

class  AlsaMallocWrapper< T,, >
 

Macros

#define DEFAULT_DEVICE   (i18n("Default device") + _("|sound_note"))
 
#define NULL_DEVICE   (i18n("Null device") + _("|sound_note"))
 
#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
 
#define ALSA_MALLOC_WRAPPER(__t__)   AlsaMallocWrapper<__t__##_t, __t__##_malloc, __t__##_free>
 

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)
 

Variables

static const snd_pcm_format_t _known_formats []
 

Macro Definition Documentation

◆ ALSA_MALLOC_WRAPPER

#define ALSA_MALLOC_WRAPPER (   __t__)    AlsaMallocWrapper<__t__##_t, __t__##_malloc, __t__##_free>

◆ DEFAULT_DEVICE

#define DEFAULT_DEVICE   (i18n("Default device") + _("|sound_note"))

gui name of the default device

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

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

◆ NULL_DEVICE

#define NULL_DEVICE   (i18n("Null device") + _("|sound_note"))

gui name of the null device

Definition at line 53 of file PlayBack-ALSA.cpp.

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

◆ SND_PCM_FORMAT_S18_3

#define SND_PCM_FORMAT_S18_3   SND_PCM_FORMAT_S18_3BE

Definition at line 60 of file PlayBack-ALSA.cpp.

◆ SND_PCM_FORMAT_S20_3

#define SND_PCM_FORMAT_S20_3   SND_PCM_FORMAT_S20_3BE

Definition at line 63 of file PlayBack-ALSA.cpp.

◆ SND_PCM_FORMAT_S24_3

#define SND_PCM_FORMAT_S24_3   SND_PCM_FORMAT_S24_3BE

Definition at line 65 of file PlayBack-ALSA.cpp.

◆ SND_PCM_FORMAT_U18_3

#define SND_PCM_FORMAT_U18_3   SND_PCM_FORMAT_U18_3BE

Definition at line 61 of file PlayBack-ALSA.cpp.

◆ SND_PCM_FORMAT_U20_3

#define SND_PCM_FORMAT_U20_3   SND_PCM_FORMAT_U20_3BE

Definition at line 62 of file PlayBack-ALSA.cpp.

◆ SND_PCM_FORMAT_U24_3

#define SND_PCM_FORMAT_U24_3   SND_PCM_FORMAT_U24_3BE

Definition at line 64 of file PlayBack-ALSA.cpp.

Function Documentation

◆ 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 144 of file PlayBack-ALSA.cpp.

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

Referenced by Kwave::PlayBackALSA::setFormat().

145 {
146  if (snd_pcm_format_little_endian(fmt) == 1)
147  return Kwave::LittleEndian;
148  if (snd_pcm_format_big_endian(fmt) == 1)
149  return Kwave::BigEndian;
150  return Kwave::CpuEndian;
151 }
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 125 of file PlayBack-ALSA.cpp.

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

Referenced by Kwave::PlayBackALSA::setFormat().

126 {
127  if (snd_pcm_format_float(fmt)) {
128  if (snd_pcm_format_width(fmt) == 32)
130  if (snd_pcm_format_width(fmt) == 64)
132  } else if (snd_pcm_format_linear(fmt)) {
133  if (snd_pcm_format_signed(fmt) == 1)
135  else if (snd_pcm_format_unsigned(fmt) == 1)
137  }
138 
140 }
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 91 of file PlayBack-ALSA.cpp.

Referenced by Kwave::PlayBackALSA::detectSupportedFormats(), Kwave::PlayBackALSA::mode2format(), Kwave::PlayBackALSA::setFormat(), and Kwave::PlayBackALSA::supportedBits().