Path: blob/master/thirdparty/linuxbsd_headers/alsa/pcm_ioplug.h
9898 views
/**1* \file include/pcm_ioplug.h2* \brief External I/O-Plugin SDK3* \author Takashi Iwai <[email protected]>4* \date 20055*6* External I/O-Plugin SDK7*/89/*10* ALSA external PCM plugin SDK11*12* Copyright (c) 2005 Takashi Iwai <[email protected]>13*14* This library is free software; you can redistribute it and/or modify15* it under the terms of the GNU Lesser General Public License as16* published by the Free Software Foundation; either version 2.1 of17* the License, or (at your option) any later version.18*19* This program is distributed in the hope that it will be useful,20* but WITHOUT ANY WARRANTY; without even the implied warranty of21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the22* GNU Lesser General Public License for more details.23*24* You should have received a copy of the GNU Lesser General Public25* License along with this library; if not, write to the Free Software26* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA27*28*/2930#ifndef __ALSA_PCM_IOPLUG_H31#define __ALSA_PCM_IOPLUG_H3233/**34* \defgroup PCM_IOPlug External I/O plugin SDK35* \ingroup Plugin_SDK36* See the \ref pcm page for more details.37* \{38*/3940/** hw constraints for ioplug */41enum {42SND_PCM_IOPLUG_HW_ACCESS = 0, /**< access type */43SND_PCM_IOPLUG_HW_FORMAT, /**< format */44SND_PCM_IOPLUG_HW_CHANNELS, /**< channels */45SND_PCM_IOPLUG_HW_RATE, /**< rate */46SND_PCM_IOPLUG_HW_PERIOD_BYTES, /**< period bytes */47SND_PCM_IOPLUG_HW_BUFFER_BYTES, /**< buffer bytes */48SND_PCM_IOPLUG_HW_PERIODS, /**< number of periods */49SND_PCM_IOPLUG_HW_PARAMS /**< max number of hw constraints */50};5152/** I/O plugin handle */53typedef struct snd_pcm_ioplug snd_pcm_ioplug_t;54/** Callback table of ioplug */55typedef struct snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;56#ifdef DOC_HIDDEN57/* redefine typedefs for stupid doxygen */58typedef snd_pcm_ioplug snd_pcm_ioplug_t;59typedef snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;60#endif6162/*63* bit flags for additional conditions64*/65#define SND_PCM_IOPLUG_FLAG_LISTED (1<<0) /**< list up this PCM */66#define SND_PCM_IOPLUG_FLAG_MONOTONIC (1<<1) /**< monotonic timestamps */6768/*69* Protocol version70*/71#define SND_PCM_IOPLUG_VERSION_MAJOR 1 /**< Protocol major version */72#define SND_PCM_IOPLUG_VERSION_MINOR 0 /**< Protocol minor version */73#define SND_PCM_IOPLUG_VERSION_TINY 2 /**< Protocol tiny version */74/**75* IO-plugin protocol version76*/77#define SND_PCM_IOPLUG_VERSION ((SND_PCM_IOPLUG_VERSION_MAJOR<<16) |\78(SND_PCM_IOPLUG_VERSION_MINOR<<8) |\79(SND_PCM_IOPLUG_VERSION_TINY))8081/** Handle of ioplug */82struct snd_pcm_ioplug {83/**84* protocol version; #SND_PCM_IOPLUG_VERSION must be filled here85* before calling #snd_pcm_ioplug_create()86*/87unsigned int version;88/**89* name of this plugin; must be filled before calling #snd_pcm_ioplug_create()90*/91const char *name;92unsigned int flags; /**< SND_PCM_IOPLUG_FLAG_XXX */93int poll_fd; /**< poll file descriptor */94unsigned int poll_events; /**< poll events */95unsigned int mmap_rw; /**< pseudo mmap mode */96/**97* callbacks of this plugin; must be filled before calling #snd_pcm_ioplug_create()98*/99const snd_pcm_ioplug_callback_t *callback;100/**101* private data, which can be used freely in the driver callbacks102*/103void *private_data;104/**105* PCM handle filled by #snd_pcm_extplug_create()106*/107snd_pcm_t *pcm;108109snd_pcm_stream_t stream; /**< stream direcion; read-only */110snd_pcm_state_t state; /**< current PCM state; read-only */111volatile snd_pcm_uframes_t appl_ptr; /**< application pointer; read-only */112volatile snd_pcm_uframes_t hw_ptr; /**< hw pointer; read-only */113int nonblock; /**< non-block mode; read-only */114115snd_pcm_access_t access; /**< access type; filled after hw_params is called */116snd_pcm_format_t format; /**< PCM format; filled after hw_params is called */117unsigned int channels; /**< number of channels; filled after hw_params is called */118unsigned int rate; /**< rate; filled after hw_params is called */119snd_pcm_uframes_t period_size; /**< period size; filled after hw_params is called */120snd_pcm_uframes_t buffer_size; /**< buffer size; filled after hw_params is called */121};122123/** Callback table of ioplug */124struct snd_pcm_ioplug_callback {125/**126* start the PCM; required, called inside mutex lock127*/128int (*start)(snd_pcm_ioplug_t *io);129/**130* stop the PCM; required, called inside mutex lock131*/132int (*stop)(snd_pcm_ioplug_t *io);133/**134* get the current DMA position; required, called inside mutex lock135*/136snd_pcm_sframes_t (*pointer)(snd_pcm_ioplug_t *io);137/**138* transfer the data; optional, called inside mutex lock139*/140snd_pcm_sframes_t (*transfer)(snd_pcm_ioplug_t *io,141const snd_pcm_channel_area_t *areas,142snd_pcm_uframes_t offset,143snd_pcm_uframes_t size);144/**145* close the PCM; optional146*/147int (*close)(snd_pcm_ioplug_t *io);148/**149* hw_params; optional150*/151int (*hw_params)(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params);152/**153* hw_free; optional154*/155int (*hw_free)(snd_pcm_ioplug_t *io);156/**157* sw_params; optional158*/159int (*sw_params)(snd_pcm_ioplug_t *io, snd_pcm_sw_params_t *params);160/**161* prepare; optional162*/163int (*prepare)(snd_pcm_ioplug_t *io);164/**165* drain; optional166*/167int (*drain)(snd_pcm_ioplug_t *io);168/**169* toggle pause; optional, called inside mutex lock170*/171int (*pause)(snd_pcm_ioplug_t *io, int enable);172/**173* resume; optional174*/175int (*resume)(snd_pcm_ioplug_t *io);176/**177* poll descriptors count; optional178*/179int (*poll_descriptors_count)(snd_pcm_ioplug_t *io);180/**181* poll descriptors; optional182*/183int (*poll_descriptors)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int space);184/**185* mangle poll events; optional186*/187int (*poll_revents)(snd_pcm_ioplug_t *io, struct pollfd *pfd, unsigned int nfds, unsigned short *revents);188/**189* dump; optional190*/191void (*dump)(snd_pcm_ioplug_t *io, snd_output_t *out);192/**193* get the delay for the running PCM; optional; since v1.0.1194*/195int (*delay)(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp);196/**197* query the channel maps; optional; since v1.0.2198*/199snd_pcm_chmap_query_t **(*query_chmaps)(snd_pcm_ioplug_t *io);200/**201* get the channel map; optional; since v1.0.2202*/203snd_pcm_chmap_t *(*get_chmap)(snd_pcm_ioplug_t *io);204/**205* set the channel map; optional; since v1.0.2206*/207int (*set_chmap)(snd_pcm_ioplug_t *io, const snd_pcm_chmap_t *map);208};209210211int snd_pcm_ioplug_create(snd_pcm_ioplug_t *io, const char *name,212snd_pcm_stream_t stream, int mode);213int snd_pcm_ioplug_delete(snd_pcm_ioplug_t *io);214215/* update poll_fd and mmap_rw */216int snd_pcm_ioplug_reinit_status(snd_pcm_ioplug_t *ioplug);217218/* get a mmap area (for mmap_rw only) */219const snd_pcm_channel_area_t *snd_pcm_ioplug_mmap_areas(snd_pcm_ioplug_t *ioplug);220221/* clear hw_parameter setting */222void snd_pcm_ioplug_params_reset(snd_pcm_ioplug_t *io);223224/* hw_parameter setting */225int snd_pcm_ioplug_set_param_minmax(snd_pcm_ioplug_t *io, int type, unsigned int min, unsigned int max);226int snd_pcm_ioplug_set_param_list(snd_pcm_ioplug_t *io, int type, unsigned int num_list, const unsigned int *list);227228/* change PCM status */229int snd_pcm_ioplug_set_state(snd_pcm_ioplug_t *ioplug, snd_pcm_state_t state);230231/** \} */232233#endif /* __ALSA_PCM_IOPLUG_H */234235236