1999-11-06 23:47:07 +00:00
|
|
|
/*
|
|
|
|
|
* PCM Interface - local header file
|
|
|
|
|
* Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2000-04-17 17:31:41 +00:00
|
|
|
#include <pthread.h>
|
1999-11-06 23:47:07 +00:00
|
|
|
#include "asoundlib.h"
|
|
|
|
|
|
2000-05-08 18:53:38 +00:00
|
|
|
|
|
|
|
|
struct snd_pcm_ops {
|
|
|
|
|
int (*channel_close)(snd_pcm_t *pcm, int channel);
|
|
|
|
|
int (*channel_nonblock)(snd_pcm_t *pcm, int channel, int nonblock);
|
|
|
|
|
int (*info)(snd_pcm_t *pcm, snd_pcm_info_t *info);
|
|
|
|
|
int (*channel_info)(snd_pcm_t *pcm, snd_pcm_channel_info_t *info);
|
|
|
|
|
int (*channel_params)(snd_pcm_t *pcm, snd_pcm_channel_params_t *params);
|
|
|
|
|
int (*channel_setup)(snd_pcm_t *pcm, snd_pcm_channel_setup_t *setup);
|
|
|
|
|
int (*voice_setup)(snd_pcm_t *pcm, int channel, snd_pcm_voice_setup_t *setup);
|
|
|
|
|
int (*channel_status)(snd_pcm_t *pcm, snd_pcm_channel_status_t *status);
|
|
|
|
|
int (*channel_prepare)(snd_pcm_t *pcm, int channel);
|
2000-05-09 10:46:43 +00:00
|
|
|
int (*channel_update)(snd_pcm_t *pcm, int channel);
|
2000-05-08 18:53:38 +00:00
|
|
|
int (*channel_go)(snd_pcm_t *pcm, int channel);
|
|
|
|
|
int (*sync_go)(snd_pcm_t *pcm, snd_pcm_sync_t *sync);
|
|
|
|
|
int (*channel_drain)(snd_pcm_t *pcm, int channel);
|
|
|
|
|
int (*channel_flush)(snd_pcm_t *pcm, int channel);
|
|
|
|
|
int (*channel_pause)(snd_pcm_t *pcm, int channel, int enable);
|
|
|
|
|
ssize_t (*write)(snd_pcm_t *pcm, const void *buffer, size_t size);
|
|
|
|
|
ssize_t (*writev)(snd_pcm_t *pcm, const struct iovec *vector, unsigned long count);
|
|
|
|
|
ssize_t (*read)(snd_pcm_t *pcm, void *buffer, size_t size);
|
|
|
|
|
ssize_t (*readv)(snd_pcm_t *pcm, const struct iovec *vector, unsigned long count);
|
|
|
|
|
int (*mmap_control)(snd_pcm_t *pcm, int channel, snd_pcm_mmap_control_t **control, size_t csize);
|
|
|
|
|
int (*mmap_data)(snd_pcm_t *pcm, int channel, void **buffer, size_t bsize);
|
|
|
|
|
int (*munmap_control)(snd_pcm_t *pcm, int channel, snd_pcm_mmap_control_t *control, size_t csize);
|
|
|
|
|
int (*munmap_data)(snd_pcm_t *pcm, int channel, void *buffer, size_t bsize);
|
|
|
|
|
int (*file_descriptor)(snd_pcm_t* pcm, int channel);
|
|
|
|
|
int (*voices_mask)(snd_pcm_t *pcm, int channel, bitset_t *client_vmask);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct snd_pcm_plug_chan {
|
2000-04-17 17:31:41 +00:00
|
|
|
snd_pcm_plugin_t *first;
|
|
|
|
|
snd_pcm_plugin_t *last;
|
|
|
|
|
void *alloc_ptr[2];
|
2000-05-08 18:53:38 +00:00
|
|
|
size_t alloc_size[2];
|
2000-04-17 17:31:41 +00:00
|
|
|
int alloc_lock[2];
|
|
|
|
|
};
|
|
|
|
|
|
2000-05-08 18:53:38 +00:00
|
|
|
typedef struct snd_pcm_plug {
|
|
|
|
|
int close_slave;
|
|
|
|
|
snd_pcm_t *slave;
|
|
|
|
|
struct snd_pcm_plug_chan chan[2];
|
|
|
|
|
} snd_pcm_plug_t;
|
|
|
|
|
|
|
|
|
|
struct snd_pcm_hw_chan {
|
2000-04-17 17:31:41 +00:00
|
|
|
int fd;
|
2000-05-08 18:53:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct snd_pcm_hw {
|
|
|
|
|
int card;
|
|
|
|
|
int device;
|
|
|
|
|
int ver;
|
|
|
|
|
struct snd_pcm_hw_chan chan[2];
|
|
|
|
|
} snd_pcm_hw_t;
|
|
|
|
|
|
|
|
|
|
struct snd_pcm_chan {
|
|
|
|
|
int open;
|
|
|
|
|
int mode;
|
|
|
|
|
int valid_setup;
|
2000-04-17 17:31:41 +00:00
|
|
|
snd_pcm_channel_setup_t setup;
|
2000-05-16 15:20:34 +00:00
|
|
|
snd_pcm_voice_area_t *voices;
|
|
|
|
|
size_t sample_width;
|
|
|
|
|
size_t bits_per_sample;
|
|
|
|
|
size_t samples_per_frag;
|
2000-04-17 17:31:41 +00:00
|
|
|
snd_pcm_mmap_control_t *mmap_control;
|
2000-05-08 18:53:38 +00:00
|
|
|
size_t mmap_control_size;
|
|
|
|
|
int mmap_control_emulation;
|
2000-04-17 17:31:41 +00:00
|
|
|
char *mmap_data;
|
2000-05-08 18:53:38 +00:00
|
|
|
size_t mmap_data_size;
|
|
|
|
|
int mmap_data_emulation;
|
|
|
|
|
pthread_t mmap_thread;
|
|
|
|
|
int mmap_thread_stop;
|
|
|
|
|
pthread_mutex_t mutex;
|
|
|
|
|
pthread_cond_t status_cond;
|
|
|
|
|
pthread_cond_t ready_cond;
|
2000-04-17 17:31:41 +00:00
|
|
|
};
|
|
|
|
|
|
1999-11-06 23:47:07 +00:00
|
|
|
struct snd_pcm {
|
2000-05-08 18:53:38 +00:00
|
|
|
snd_pcm_type_t type;
|
1999-11-06 23:47:07 +00:00
|
|
|
int mode;
|
2000-05-08 18:53:38 +00:00
|
|
|
struct snd_pcm_ops *ops;
|
2000-04-17 17:31:41 +00:00
|
|
|
struct snd_pcm_chan chan[2];
|
2000-05-08 18:53:38 +00:00
|
|
|
int private[0];
|
1999-11-06 23:47:07 +00:00
|
|
|
};
|
1999-12-11 11:46:05 +00:00
|
|
|
|
2000-05-08 18:53:38 +00:00
|
|
|
void snd_pcm_mmap_status_change(snd_pcm_t *pcm, int channel, int newstatus);
|
|
|
|
|
|
|
|
|
|
int snd_pcm_abstract_open(snd_pcm_t **handle, int mode, snd_pcm_type_t type, size_t extra);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int snd_pcm_plug_formats(unsigned int formats);
|
|
|
|
|
int snd_pcm_plug_slave_params(snd_pcm_channel_params_t *params,
|
|
|
|
|
snd_pcm_channel_info_t *slave_info,
|
|
|
|
|
snd_pcm_channel_params_t *slave_params);
|
|
|
|
|
int snd_pcm_plug_format(snd_pcm_plugin_handle_t *pcm,
|
|
|
|
|
snd_pcm_channel_params_t *params,
|
|
|
|
|
snd_pcm_channel_params_t *slave_params);
|
|
|
|
|
|
|
|
|
|
ssize_t snd_pcm_plug_write_transfer(snd_pcm_plugin_handle_t *handle, snd_pcm_plugin_voice_t *src_voices, size_t size);
|
|
|
|
|
ssize_t snd_pcm_plug_read_transfer(snd_pcm_plugin_handle_t *handle, snd_pcm_plugin_voice_t *dst_voices_final, size_t size);
|
|
|
|
|
ssize_t snd_pcm_plug_client_voices_iovec(snd_pcm_plugin_handle_t *handle, int channel,
|
|
|
|
|
const struct iovec *vector, unsigned long count,
|
|
|
|
|
snd_pcm_plugin_voice_t **voices);
|
|
|
|
|
ssize_t snd_pcm_plug_client_voices_buf(snd_pcm_plugin_handle_t *handle, int channel,
|
|
|
|
|
char *buf, size_t count,
|
|
|
|
|
snd_pcm_plugin_voice_t **voices);
|
|
|
|
|
|
|
|
|
|
int snd_pcm_plug_playback_voices_mask(snd_pcm_plugin_handle_t *handle,
|
|
|
|
|
bitset_t *client_vmask);
|
|
|
|
|
int snd_pcm_plug_capture_voices_mask(snd_pcm_plugin_handle_t *handle,
|
|
|
|
|
bitset_t *client_vmask);
|
|
|
|
|
int snd_pcm_plugin_client_voices(snd_pcm_plugin_t *plugin,
|
|
|
|
|
size_t samples,
|
|
|
|
|
snd_pcm_plugin_voice_t **voices);
|
|
|
|
|
|
|
|
|
|
void *snd_pcm_plug_buf_alloc(snd_pcm_t *pcm, int channel, size_t size);
|
|
|
|
|
void snd_pcm_plug_buf_unlock(snd_pcm_t *pcm, int channel, void *ptr);
|
1999-12-11 11:46:05 +00:00
|
|
|
|
2000-04-12 20:41:16 +00:00
|
|
|
#define ROUTE_PLUGIN_RESOLUTION 16
|
|
|
|
|
|
|
|
|
|
int getput_index(int format);
|
2000-05-08 18:53:38 +00:00
|
|
|
int conv_index(int src_format, int dst_format);
|
2000-04-12 20:41:16 +00:00
|
|
|
|
|
|
|
|
#ifdef PLUGIN_DEBUG
|
2000-05-08 18:53:38 +00:00
|
|
|
#define pdprintf( args... ) fprintf(stderr, "plugin: " ##args)
|
1999-12-11 11:46:05 +00:00
|
|
|
#else
|
|
|
|
|
#define pdprintf( args... ) { ; }
|
|
|
|
|
#endif
|