kwave  18.07.70
PlayBack-OSS.cpp File Reference
#include "config.h"
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <QDir>
#include <QFile>
#include <QLatin1Char>
#include <KLocalizedString>
#include "libkwave/ByteOrder.h"
#include "libkwave/Compression.h"
#include "libkwave/SampleEncoderLinear.h"
#include "libkwave/String.h"
#include "libkwave/Utils.h"
#include "libkwave/memcpy.h"
#include "PlayBack-OSS.h"
Include dependency graph for PlayBack-OSS.cpp:

Go to the source code of this file.

Macros

#define MIN_PLAYBACK_BUFFER   8
 
#define MAX_PLAYBACK_BUFFER   16
 
#define MAX_CHANNELS   7
 
#define AFMT_S24_LE   0x00008000
 
#define AFMT_S24_BE   0x00010000
 
#define AFMT_S32_LE   0x00001000
 
#define AFMT_S32_BE   0x00002000
 
#define SNDCTL_DSP_SPEED   SOUND_PCM_WRITE_RATE
 
#define SNDCTL_DSP_CHANNELS   SOUND_PCM_WRITE_CHANNELS
 
#define SOUND_PCM_SETFMT   SOUND_PCM_WRITE_BITS
 
#define SNDCTL_DSP_SETFMT   SOUND_PCM_SETFMT
 

Functions

static bool addIfExists (QStringList &list, const QString &name)
 
static void scanFiles (QStringList &list, const QString &dirname, const QString &mask)
 
static void scanDirectory (QStringList &list, const QString &dir)
 

Macro Definition Documentation

◆ AFMT_S24_BE

#define AFMT_S24_BE   0x00010000

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

Referenced by Kwave::PlayBackOSS::format2mode().

◆ AFMT_S24_LE

#define AFMT_S24_LE   0x00008000

Definition at line 58 of file PlayBack-OSS.cpp.

Referenced by Kwave::PlayBackOSS::format2mode(), and Kwave::PlayBackOSS::open().

◆ AFMT_S32_BE

#define AFMT_S32_BE   0x00002000

Definition at line 67 of file PlayBack-OSS.cpp.

Referenced by Kwave::PlayBackOSS::format2mode().

◆ AFMT_S32_LE

#define AFMT_S32_LE   0x00001000

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

Referenced by Kwave::PlayBackOSS::format2mode(), and Kwave::PlayBackOSS::open().

◆ MAX_CHANNELS

#define MAX_CHANNELS   7

highest available number of channels

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

Referenced by Kwave::PlayBackOSS::detectChannels().

◆ MAX_PLAYBACK_BUFFER

#define MAX_PLAYBACK_BUFFER   16

use at most 2^16 = 65536 bytes for playback buffer !!!

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

Referenced by Kwave::PlayBackOSS::open().

◆ MIN_PLAYBACK_BUFFER

#define MIN_PLAYBACK_BUFFER   8

use at least 2^8 = 256 bytes for playback buffer !!!

Definition at line 47 of file PlayBack-OSS.cpp.

Referenced by Kwave::PlayBackOSS::open().

◆ SNDCTL_DSP_CHANNELS

#define SNDCTL_DSP_CHANNELS   SOUND_PCM_WRITE_CHANNELS

◆ SNDCTL_DSP_SETFMT

#define SNDCTL_DSP_SETFMT   SOUND_PCM_SETFMT

Definition at line 83 of file PlayBack-OSS.cpp.

Referenced by Kwave::PlayBackOSS::open().

◆ SNDCTL_DSP_SPEED

#define SNDCTL_DSP_SPEED   SOUND_PCM_WRITE_RATE

Definition at line 71 of file PlayBack-OSS.cpp.

Referenced by Kwave::PlayBackOSS::open().

◆ SOUND_PCM_SETFMT

#define SOUND_PCM_SETFMT   SOUND_PCM_WRITE_BITS

Definition at line 79 of file PlayBack-OSS.cpp.

Function Documentation

◆ addIfExists()

static bool addIfExists ( QStringList &  list,
const QString &  name 
)
static

Definition at line 325 of file PlayBack-OSS.cpp.

References _.

Referenced by scanFiles().

326 {
327  QFile file;
328 
329  if (name.contains(_("%1"))) {
330  // test for the name without suffix first
331  addIfExists(list, name.arg(_("")));
332 
333  // loop over the list and try until a suffix does not exist
334  for (unsigned int index=0; index < 64; index++)
335  addIfExists(list, name.arg(index));
336  } else {
337  // check a single name
338  file.setFileName(name);
339  if (!file.exists())
340  return false;
341 
342  if (!list.contains(name))
343  list.append(name);
344  }
345 
346  return true;
347 }
const char name[16]
Definition: memcpy.c:510
#define _(m)
Definition: memcpy.c:66
static bool addIfExists(QStringList &list, const QString &name)
Here is the caller graph for this function:

◆ scanDirectory()

static void scanDirectory ( QStringList &  list,
const QString &  dir 
)
static

Definition at line 369 of file PlayBack-OSS.cpp.

References _, and scanFiles().

Referenced by Kwave::PlayBackOSS::supportedDevices().

370 {
371  scanFiles(list, dir, _("dsp*"));
372  scanFiles(list, dir, _("*audio*"));
373  scanFiles(list, dir, _("adsp*"));
374  scanFiles(list, dir, _("dio*"));
375  scanFiles(list, dir, _("pcm*"));
376 }
static void scanFiles(QStringList &list, const QString &dirname, const QString &mask)
#define _(m)
Definition: memcpy.c:66
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scanFiles()

static void scanFiles ( QStringList &  list,
const QString &  dirname,
const QString &  mask 
)
static

Definition at line 350 of file PlayBack-OSS.cpp.

References addIfExists().

Referenced by scanDirectory(), and Kwave::PlayBackOSS::supportedDevices().

352 {
353  QStringList files;
354  QDir dir;
355 
356  dir.setPath(dirname);
357  dir.setNameFilters(mask.split(QLatin1Char(' ')));
358  dir.setFilter(QDir::Files | QDir::Writable | QDir::System);
359  dir.setSorting(QDir::Name);
360  files = dir.entryList();
361 
362  for (QStringList::Iterator it=files.begin(); it != files.end(); ++it) {
363  QString devicename = dirname + QDir::separator() + (*it);
364  addIfExists(list, devicename);
365  }
366 }
static bool addIfExists(QStringList &list, const QString &name)
Here is the call graph for this function:
Here is the caller graph for this function: