|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* \file include/pcm_ioplug.h
|
|
Packit Service |
db8eaa |
* \brief External I/O-Plugin SDK
|
|
Packit Service |
db8eaa |
* \author Takashi Iwai <tiwai@suse.de>
|
|
Packit Service |
db8eaa |
* \date 2005
|
|
Packit Service |
db8eaa |
*
|
|
Packit Service |
db8eaa |
* External I/O-Plugin SDK
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/*
|
|
Packit Service |
db8eaa |
* ALSA external PCM plugin SDK
|
|
Packit Service |
db8eaa |
*
|
|
Packit Service |
db8eaa |
* Copyright (c) 2005 Takashi Iwai <tiwai@suse.de>
|
|
Packit Service |
db8eaa |
*
|
|
Packit Service |
db8eaa |
* This library is free software; you can redistribute it and/or modify
|
|
Packit Service |
db8eaa |
* it under the terms of the GNU Lesser General Public License as
|
|
Packit Service |
db8eaa |
* published by the Free Software Foundation; either version 2.1 of
|
|
Packit Service |
db8eaa |
* the License, or (at your option) any later version.
|
|
Packit Service |
db8eaa |
*
|
|
Packit Service |
db8eaa |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
db8eaa |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
db8eaa |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
db8eaa |
* GNU Lesser General Public License for more details.
|
|
Packit Service |
db8eaa |
*
|
|
Packit Service |
db8eaa |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
db8eaa |
* License along with this library; if not, write to the Free Software
|
|
Packit Service |
db8eaa |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit Service |
db8eaa |
*
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
#ifndef __ALSA_PCM_IOPLUG_H
|
|
Packit Service |
db8eaa |
#define __ALSA_PCM_IOPLUG_H
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* \defgroup PCM_IOPlug External I/O plugin SDK
|
|
Packit Service |
db8eaa |
* \ingroup Plugin_SDK
|
|
Packit Service |
db8eaa |
* See the \ref pcm page for more details.
|
|
Packit Service |
db8eaa |
* \{
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/** hw constraints for ioplug */
|
|
Packit Service |
db8eaa |
enum {
|
|
Packit Service |
db8eaa |
SND_PCM_IOPLUG_HW_ACCESS = 0, /**< access type */
|
|
Packit Service |
db8eaa |
SND_PCM_IOPLUG_HW_FORMAT, /**< format */
|
|
Packit Service |
db8eaa |
SND_PCM_IOPLUG_HW_CHANNELS, /**< channels */
|
|
Packit Service |
db8eaa |
SND_PCM_IOPLUG_HW_RATE, /**< rate */
|
|
Packit Service |
db8eaa |
SND_PCM_IOPLUG_HW_PERIOD_BYTES, /**< period bytes */
|
|
Packit Service |
db8eaa |
SND_PCM_IOPLUG_HW_BUFFER_BYTES, /**< buffer bytes */
|
|
Packit Service |
db8eaa |
SND_PCM_IOPLUG_HW_PERIODS, /**< number of periods */
|
|
Packit Service |
db8eaa |
SND_PCM_IOPLUG_HW_PARAMS /**< max number of hw constraints */
|
|
Packit Service |
db8eaa |
};
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/** I/O plugin handle */
|
|
Packit Service |
db8eaa |
typedef struct snd_pcm_ioplug snd_pcm_ioplug_t;
|
|
Packit Service |
db8eaa |
/** Callback table of ioplug */
|
|
Packit Service |
db8eaa |
typedef struct snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;
|
|
Packit Service |
db8eaa |
#ifdef DOC_HIDDEN
|
|
Packit Service |
db8eaa |
/* redefine typedefs for stupid doxygen */
|
|
Packit Service |
db8eaa |
typedef snd_pcm_ioplug snd_pcm_ioplug_t;
|
|
Packit Service |
db8eaa |
typedef snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;
|
|
Packit Service |
db8eaa |
#endif
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/*
|
|
Packit Service |
db8eaa |
* bit flags for additional conditions
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
#define SND_PCM_IOPLUG_FLAG_LISTED (1<<0) /**< list up this PCM */
|
|
Packit Service |
db8eaa |
#define SND_PCM_IOPLUG_FLAG_MONOTONIC (1<<1) /**< monotonic timestamps */
|
|
Packit Service |
db8eaa |
/** hw pointer wrap around at boundary instead of buffer_size */
|
|
Packit Service |
db8eaa |
#define SND_PCM_IOPLUG_FLAG_BOUNDARY_WA (1<<2)
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/*
|
|
Packit Service |
db8eaa |
* Protocol version
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
#define SND_PCM_IOPLUG_VERSION_MAJOR 1 /**< Protocol major version */
|
|
Packit Service |
db8eaa |
#define SND_PCM_IOPLUG_VERSION_MINOR 0 /**< Protocol minor version */
|
|
Packit Service |
db8eaa |
#define SND_PCM_IOPLUG_VERSION_TINY 2 /**< Protocol tiny version */
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* IO-plugin protocol version
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
#define SND_PCM_IOPLUG_VERSION ((SND_PCM_IOPLUG_VERSION_MAJOR<<16) |\
|
|
Packit Service |
db8eaa |
(SND_PCM_IOPLUG_VERSION_MINOR<<8) |\
|
|
Packit Service |
db8eaa |
(SND_PCM_IOPLUG_VERSION_TINY))
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/** Handle of ioplug */
|
|
Packit Service |
db8eaa |
struct snd_pcm_ioplug {
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* protocol version; #SND_PCM_IOPLUG_VERSION must be filled here
|
|
Packit Service |
db8eaa |
* before calling #snd_pcm_ioplug_create()
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
unsigned int version;
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* name of this plugin; must be filled before calling #snd_pcm_ioplug_create()
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
const char *name;
|
|
Packit Service |
db8eaa |
unsigned int flags; /**< SND_PCM_IOPLUG_FLAG_XXX */
|
|
Packit Service |
db8eaa |
int poll_fd; /**< poll file descriptor */
|
|
Packit Service |
db8eaa |
unsigned int poll_events; /**< poll events */
|
|
Packit Service |
db8eaa |
unsigned int mmap_rw; /**< pseudo mmap mode */
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* callbacks of this plugin; must be filled before calling #snd_pcm_ioplug_create()
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
const snd_pcm_ioplug_callback_t *callback;
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* private data, which can be used freely in the driver callbacks
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
void *private_data;
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* PCM handle filled by #snd_pcm_ioplug_create()
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
snd_pcm_t *pcm;
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
snd_pcm_stream_t stream; /**< stream direcion; read-only */
|
|
Packit Service |
db8eaa |
snd_pcm_state_t state; /**< current PCM state; read-only */
|
|
Packit Service |
db8eaa |
volatile snd_pcm_uframes_t appl_ptr; /**< application pointer; read-only */
|
|
Packit Service |
db8eaa |
volatile snd_pcm_uframes_t hw_ptr; /**< hw pointer; read-only */
|
|
Packit Service |
db8eaa |
int nonblock; /**< non-block mode; read-only */
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
snd_pcm_access_t access; /**< access type; filled after hw_params is called */
|
|
Packit Service |
db8eaa |
snd_pcm_format_t format; /**< PCM format; filled after hw_params is called */
|
|
Packit Service |
db8eaa |
unsigned int channels; /**< number of channels; filled after hw_params is called */
|
|
Packit Service |
db8eaa |
unsigned int rate; /**< rate; filled after hw_params is called */
|
|
Packit Service |
db8eaa |
snd_pcm_uframes_t period_size; /**< period size; filled after hw_params is called */
|
|
Packit Service |
db8eaa |
snd_pcm_uframes_t buffer_size; /**< buffer size; filled after hw_params is called */
|
|
Packit Service |
db8eaa |
};
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/** Callback table of ioplug */
|
|
Packit Service |
db8eaa |
struct snd_pcm_ioplug_callback {
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* start the PCM; required, called inside mutex lock
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*start)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* stop the PCM; required, called inside mutex lock
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*stop)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* get the current DMA position; required, called inside mutex lock
|
|
Packit Service |
db8eaa |
* \return buffer position up to buffer_size or
|
|
Packit Service |
db8eaa |
* when #SND_PCM_IOPLUG_FLAG_BOUNDARY_WA flag is set up to boundary or
|
|
Packit Service |
db8eaa |
* a negative error code for Xrun
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
snd_pcm_sframes_t (*pointer)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* transfer the data; optional, called inside mutex lock
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
snd_pcm_sframes_t (*transfer)(snd_pcm_ioplug_t *io,
|
|
Packit Service |
db8eaa |
const snd_pcm_channel_area_t *areas,
|
|
Packit Service |
db8eaa |
snd_pcm_uframes_t offset,
|
|
Packit Service |
db8eaa |
snd_pcm_uframes_t size);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* close the PCM; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*close)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* hw_params; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*hw_params)(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* hw_free; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*hw_free)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* sw_params; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*sw_params)(snd_pcm_ioplug_t *io, snd_pcm_sw_params_t *params);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* prepare; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*prepare)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* drain; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*drain)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* toggle pause; optional, called inside mutex lock
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*pause)(snd_pcm_ioplug_t *io, int enable);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* resume; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*resume)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* poll descriptors count; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*poll_descriptors_count)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* poll descriptors; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*poll_descriptors)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int space);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* mangle poll events; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*poll_revents)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int nfds, unsigned short *revents);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* dump; optional
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
void (*dump)(snd_pcm_ioplug_t *io, snd_output_t *out);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* get the delay for the running PCM; optional; since v1.0.1
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*delay)(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* query the channel maps; optional; since v1.0.2
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
snd_pcm_chmap_query_t **(*query_chmaps)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* get the channel map; optional; since v1.0.2
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
snd_pcm_chmap_t *(*get_chmap)(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
/**
|
|
Packit Service |
db8eaa |
* set the channel map; optional; since v1.0.2
|
|
Packit Service |
db8eaa |
*/
|
|
Packit Service |
db8eaa |
int (*set_chmap)(snd_pcm_ioplug_t *io, const snd_pcm_chmap_t *map);
|
|
Packit Service |
db8eaa |
};
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
int snd_pcm_ioplug_create(snd_pcm_ioplug_t *io, const char *name,
|
|
Packit Service |
db8eaa |
snd_pcm_stream_t stream, int mode);
|
|
Packit Service |
db8eaa |
int snd_pcm_ioplug_delete(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/* update poll_fd and mmap_rw */
|
|
Packit Service |
db8eaa |
int snd_pcm_ioplug_reinit_status(snd_pcm_ioplug_t *ioplug);
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/* get a mmap area (for mmap_rw only) */
|
|
Packit Service |
db8eaa |
const snd_pcm_channel_area_t *snd_pcm_ioplug_mmap_areas(snd_pcm_ioplug_t *ioplug);
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/* clear hw_parameter setting */
|
|
Packit Service |
db8eaa |
void snd_pcm_ioplug_params_reset(snd_pcm_ioplug_t *io);
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/* hw_parameter setting */
|
|
Packit Service |
db8eaa |
int snd_pcm_ioplug_set_param_minmax(snd_pcm_ioplug_t *io, int type, unsigned int min, unsigned int max);
|
|
Packit Service |
db8eaa |
int snd_pcm_ioplug_set_param_list(snd_pcm_ioplug_t *io, int type, unsigned int num_list, const unsigned int *list);
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/* change PCM status */
|
|
Packit Service |
db8eaa |
int snd_pcm_ioplug_set_state(snd_pcm_ioplug_t *ioplug, snd_pcm_state_t state);
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/* calucalte the available frames */
|
|
Packit Service |
db8eaa |
snd_pcm_uframes_t snd_pcm_ioplug_avail(const snd_pcm_ioplug_t * const ioplug,
|
|
Packit Service |
db8eaa |
const snd_pcm_uframes_t hw_ptr,
|
|
Packit Service |
db8eaa |
const snd_pcm_uframes_t appl_ptr);
|
|
Packit Service |
db8eaa |
snd_pcm_uframes_t snd_pcm_ioplug_hw_avail(const snd_pcm_ioplug_t * const ioplug,
|
|
Packit Service |
db8eaa |
const snd_pcm_uframes_t hw_ptr,
|
|
Packit Service |
db8eaa |
const snd_pcm_uframes_t appl_ptr);
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
/** \} */
|
|
Packit Service |
db8eaa |
|
|
Packit Service |
db8eaa |
#endif /* __ALSA_PCM_IOPLUG_H */
|