alsa-plugins  1.2.5
About: ALSA (Advanced Linux Sound Architecture) - Additional plugins for various audio libraries and sound servers.
  Fossies Dox: alsa-plugins-1.2.5.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pcm_usb_stream.c File Reference
#include <byteswap.h>
#include <sys/mman.h>
#include <sys/shm.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <pthread.h>
#include <alsa/asoundlib.h>
#include <alsa/pcm_external.h>
#include <alsa/hwdep.h>
#include "usb_stream.h"
Include dependency graph for pcm_usb_stream.c:

Go to the source code of this file.

Data Structures

struct  user_usb_stream
 
struct  snd_pcm_us_t
 

Macros

#define _GNU_SOURCE
 
#define DEBUG
 
#define DBG(f, ...)    fprintf(stderr, "%s:%i %i "f"\n", __FUNCTION__, __LINE__, getpid(), ## __VA_ARGS__);
 
#define VDBG(f, ...)
 
#define FRAME_SIZE   6
 
#define ARRAY_SIZE(ary)   (sizeof(ary)/sizeof(ary[0]))
 

Functions

static struct user_usb_streamget_uus (int card)
 
static void uus_free (snd_pcm_us_t *us)
 
static void us_free (snd_pcm_us_t *us)
 
static int snd_pcm_us_close (snd_pcm_ioplug_t *io)
 
static snd_pcm_sframes_t snd_pcm_us_pointer (snd_pcm_ioplug_t *io)
 
static int snd_pcm_us_prepare (snd_pcm_ioplug_t *io)
 
static int snd_pcm_us_start (snd_pcm_ioplug_t *io)
 
static int snd_pcm_us_stop (snd_pcm_ioplug_t *io)
 
static snd_pcm_sframes_t snd_pcm_us_write (snd_pcm_ioplug_t *io, const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset, snd_pcm_uframes_t size)
 
static int usb_stream_read (struct user_usb_stream *uus, void *to)
 
static snd_pcm_sframes_t snd_pcm_us_read (snd_pcm_ioplug_t *io, const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset, snd_pcm_uframes_t size)
 
static int us_set_hw_constraint (snd_pcm_us_t *us)
 
static int snd_pcm_us_open (snd_pcm_t **pcmp, const char *name, int card, snd_pcm_stream_t stream, int mode, snd_pcm_uframes_t period_size, unsigned int rate)
 
 SND_PCM_PLUGIN_DEFINE_FUNC (usb_stream)
 
 SND_PCM_PLUGIN_SYMBOL (usb_stream)
 

Variables

static struct user_usb_streamuus
 
static pthread_mutex_t uus_mutex = PTHREAD_MUTEX_INITIALIZER
 
static snd_pcm_ioplug_callback_t us_playback_callback
 
static snd_pcm_ioplug_callback_t us_capture_callback
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 21 of file pcm_usb_stream.c.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   ary)    (sizeof(ary)/sizeof(ary[0]))

Definition at line 366 of file pcm_usb_stream.c.

◆ DBG

#define DBG (   f,
  ... 
)     fprintf(stderr, "%s:%i %i "f"\n", __FUNCTION__, __LINE__, getpid(), ## __VA_ARGS__);

Definition at line 38 of file pcm_usb_stream.c.

◆ DEBUG

#define DEBUG

Definition at line 36 of file pcm_usb_stream.c.

◆ FRAME_SIZE

#define FRAME_SIZE   6

Definition at line 51 of file pcm_usb_stream.c.

◆ VDBG

#define VDBG (   f,
  ... 
)

Definition at line 48 of file pcm_usb_stream.c.

Function Documentation

◆ get_uus()

static struct user_usb_stream* get_uus ( int  card)
static

◆ SND_PCM_PLUGIN_DEFINE_FUNC()

SND_PCM_PLUGIN_DEFINE_FUNC ( usb_stream  )

Definition at line 465 of file pcm_usb_stream.c.

References name, usb_stream::period_size, and snd_pcm_us_open().

◆ SND_PCM_PLUGIN_SYMBOL()

SND_PCM_PLUGIN_SYMBOL ( usb_stream  )

◆ snd_pcm_us_close()

static int snd_pcm_us_close ( snd_pcm_ioplug_t *  io)
static

Definition at line 137 of file pcm_usb_stream.c.

References snd_pcm_us_t::hwdep, and us_free().

◆ snd_pcm_us_open()

static int snd_pcm_us_open ( snd_pcm_t **  pcmp,
const char *  name,
int  card,
snd_pcm_stream_t  stream,
int  mode,
snd_pcm_uframes_t  period_size,
unsigned int  rate 
)
static

◆ snd_pcm_us_pointer()

static snd_pcm_sframes_t snd_pcm_us_pointer ( snd_pcm_ioplug_t *  io)
static

◆ snd_pcm_us_prepare()

◆ snd_pcm_us_read()

static snd_pcm_sframes_t snd_pcm_us_read ( snd_pcm_ioplug_t *  io,
const snd_pcm_channel_area_t *  areas,
snd_pcm_uframes_t  offset,
snd_pcm_uframes_t  size 
)
static

◆ snd_pcm_us_start()

static int snd_pcm_us_start ( snd_pcm_ioplug_t *  io)
static

◆ snd_pcm_us_stop()

static int snd_pcm_us_stop ( snd_pcm_ioplug_t *  io)
static

◆ snd_pcm_us_write()

static snd_pcm_sframes_t snd_pcm_us_write ( snd_pcm_ioplug_t *  io,
const snd_pcm_channel_area_t *  areas,
snd_pcm_uframes_t  offset,
snd_pcm_uframes_t  size 
)
static

◆ us_free()

static void us_free ( snd_pcm_us_t us)
static

Definition at line 131 of file pcm_usb_stream.c.

References uus_free().

Referenced by snd_pcm_us_close(), and snd_pcm_us_open().

◆ us_set_hw_constraint()

static int us_set_hw_constraint ( snd_pcm_us_t us)
static

◆ usb_stream_read()

◆ uus_free()

Variable Documentation

◆ us_capture_callback

snd_pcm_ioplug_callback_t us_capture_callback
static
Initial value:
= {
.close = snd_pcm_us_close,
.start = snd_pcm_us_start,
.stop = snd_pcm_us_stop,
.transfer = snd_pcm_us_read,
.pointer = snd_pcm_us_pointer,
.prepare = snd_pcm_us_prepare,
}
static int snd_pcm_us_prepare(snd_pcm_ioplug_t *io)
static snd_pcm_sframes_t snd_pcm_us_pointer(snd_pcm_ioplug_t *io)
static int snd_pcm_us_close(snd_pcm_ioplug_t *io)
static int snd_pcm_us_start(snd_pcm_ioplug_t *io)
static snd_pcm_sframes_t snd_pcm_us_read(snd_pcm_ioplug_t *io, const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset, snd_pcm_uframes_t size)
static int snd_pcm_us_stop(snd_pcm_ioplug_t *io)

Definition at line 357 of file pcm_usb_stream.c.

Referenced by snd_pcm_us_open().

◆ us_playback_callback

snd_pcm_ioplug_callback_t us_playback_callback
static
Initial value:
= {
.close = snd_pcm_us_close,
.start = snd_pcm_us_start,
.stop = snd_pcm_us_stop,
.transfer = snd_pcm_us_write,
.pointer = snd_pcm_us_pointer,
.prepare = snd_pcm_us_prepare,
}
static snd_pcm_sframes_t snd_pcm_us_write(snd_pcm_ioplug_t *io, const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset, snd_pcm_uframes_t size)

Definition at line 349 of file pcm_usb_stream.c.

Referenced by snd_pcm_us_open().

◆ uus

struct user_usb_stream* uus
static

◆ uus_mutex

pthread_mutex_t uus_mutex = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 79 of file pcm_usb_stream.c.

Referenced by get_uus(), and uus_free().