2000-09-24 09:57:26 +00:00
|
|
|
/*
|
|
|
|
|
* PCM - Common plugin code
|
|
|
|
|
* Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2001-02-27 18:21:31 +00:00
|
|
|
#include "atomic.h"
|
|
|
|
|
|
2001-02-27 13:42:12 +00:00
|
|
|
typedef snd_pcm_uframes_t (*snd_pcm_slave_xfer_areas_func_t)
|
|
|
|
|
(snd_pcm_t *pcm,
|
|
|
|
|
const snd_pcm_channel_area_t *areas,
|
|
|
|
|
snd_pcm_uframes_t offset,
|
|
|
|
|
snd_pcm_uframes_t size,
|
|
|
|
|
const snd_pcm_channel_area_t *slave_areas,
|
|
|
|
|
snd_pcm_uframes_t slave_offset,
|
|
|
|
|
snd_pcm_uframes_t *slave_sizep);
|
|
|
|
|
|
2000-09-24 09:57:26 +00:00
|
|
|
typedef struct {
|
|
|
|
|
snd_pcm_t *slave;
|
|
|
|
|
int close_slave;
|
2001-02-27 13:42:12 +00:00
|
|
|
snd_pcm_slave_xfer_areas_func_t read;
|
|
|
|
|
snd_pcm_slave_xfer_areas_func_t write;
|
2001-01-15 11:06:53 +00:00
|
|
|
snd_pcm_sframes_t (*client_frames)(snd_pcm_t *pcm, snd_pcm_sframes_t frames);
|
|
|
|
|
snd_pcm_sframes_t (*slave_frames)(snd_pcm_t *pcm, snd_pcm_sframes_t frames);
|
2000-09-24 09:57:26 +00:00
|
|
|
int (*init)(snd_pcm_t *pcm);
|
2000-11-20 20:10:46 +00:00
|
|
|
int shmid;
|
2001-01-15 11:06:53 +00:00
|
|
|
snd_pcm_uframes_t appl_ptr, hw_ptr;
|
2001-02-27 18:21:31 +00:00
|
|
|
snd_atomic_write_t watom;
|
2000-09-24 09:57:26 +00:00
|
|
|
} snd_pcm_plugin_t;
|
|
|
|
|
|
|
|
|
|
int snd_pcm_plugin_close(snd_pcm_t *pcm);
|
2000-12-22 14:03:01 +00:00
|
|
|
int snd_pcm_plugin_card(snd_pcm_t *pcm);
|
2000-09-24 09:57:26 +00:00
|
|
|
int snd_pcm_plugin_nonblock(snd_pcm_t *pcm, int nonblock);
|
2000-10-11 12:37:27 +00:00
|
|
|
int snd_pcm_plugin_async(snd_pcm_t *pcm, int sig, pid_t pid);
|
2000-09-24 09:57:26 +00:00
|
|
|
int snd_pcm_plugin_info(snd_pcm_t *pcm, snd_pcm_info_t * info);
|
2001-01-19 13:10:50 +00:00
|
|
|
int snd_pcm_plugin_hw_free(snd_pcm_t *pcm);
|
2000-12-29 15:00:53 +00:00
|
|
|
int snd_pcm_plugin_sw_refine(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
|
2000-11-20 20:10:46 +00:00
|
|
|
int snd_pcm_plugin_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
|
2000-09-24 09:57:26 +00:00
|
|
|
int snd_pcm_plugin_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info);
|
|
|
|
|
int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status);
|
2001-02-04 17:03:17 +00:00
|
|
|
snd_pcm_state_t snd_pcm_plugin_state(snd_pcm_t *pcm);
|
2001-01-15 11:06:53 +00:00
|
|
|
int snd_pcm_plugin_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
|
2000-09-24 09:57:26 +00:00
|
|
|
int snd_pcm_plugin_prepare(snd_pcm_t *pcm);
|
|
|
|
|
int snd_pcm_plugin_start(snd_pcm_t *pcm);
|
2000-10-02 06:59:59 +00:00
|
|
|
int snd_pcm_plugin_drop(snd_pcm_t *pcm);
|
2000-09-29 20:49:18 +00:00
|
|
|
int snd_pcm_plugin_drain(snd_pcm_t *pcm);
|
2000-09-24 09:57:26 +00:00
|
|
|
int snd_pcm_plugin_pause(snd_pcm_t *pcm, int enable);
|
2001-01-15 11:06:53 +00:00
|
|
|
snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
|
|
|
|
|
snd_pcm_sframes_t snd_pcm_plugin_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
|
|
|
|
|
snd_pcm_sframes_t snd_pcm_plugin_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
|
|
|
|
|
snd_pcm_sframes_t snd_pcm_plugin_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
|
|
|
|
|
snd_pcm_sframes_t snd_pcm_plugin_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
|
|
|
|
|
snd_pcm_sframes_t snd_pcm_plugin_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t size);
|
|
|
|
|
snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm);
|
2000-09-24 09:57:26 +00:00
|
|
|
int snd_pcm_plugin_mmap_status(snd_pcm_t *pcm);
|
|
|
|
|
int snd_pcm_plugin_mmap_control(snd_pcm_t *pcm);
|
2000-10-14 10:31:34 +00:00
|
|
|
int snd_pcm_plugin_mmap(snd_pcm_t *pcm);
|
2000-09-24 09:57:26 +00:00
|
|
|
int snd_pcm_plugin_munmap_status(snd_pcm_t *pcm);
|
|
|
|
|
int snd_pcm_plugin_munmap_control(snd_pcm_t *pcm);
|
2000-10-14 10:31:34 +00:00
|
|
|
int snd_pcm_plugin_munmap(snd_pcm_t *pcm);
|
2001-02-12 23:51:49 +00:00
|
|
|
int snd_pcm_plugin_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
|
2001-01-18 18:20:31 +00:00
|
|
|
int snd_pcm_plugin_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
|
|
|
|
int snd_pcm_plugin_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
2000-09-24 09:57:26 +00:00
|
|
|
|
2000-10-14 10:31:34 +00:00
|
|
|
extern snd_pcm_fast_ops_t snd_pcm_plugin_fast_ops;
|
2000-09-24 09:57:26 +00:00
|
|
|
|
2000-11-29 08:32:36 +00:00
|
|
|
#define RATE_MIN 4000
|
|
|
|
|
#define RATE_MAX 192000
|
|
|
|
|
|
2001-02-04 17:03:17 +00:00
|
|
|
int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format);
|
|
|
|
|
int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format);
|
|
|
|
|
int snd_pcm_linear_convert_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format);
|
2001-02-11 15:45:35 +00:00
|
|
|
int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int close_slave);
|
|
|
|
|
int snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
|
|
|
|
|
int snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
|
|
|
|
|
int snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
|
|
|
|
|
int snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
|
2001-01-26 09:56:30 +00:00
|
|
|
int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *ttable,
|
2000-09-24 09:57:26 +00:00
|
|
|
unsigned int tt_csize, unsigned int tt_ssize,
|
|
|
|
|
unsigned int *tt_cused, unsigned int *tt_sused,
|
|
|
|
|
int schannels);
|
2001-02-11 15:45:35 +00:00
|
|
|
int snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
|
2001-03-29 17:50:28 +00:00
|
|
|
snd_pcm_format_t sformat, int schannels,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_route_ttable_entry_t *ttable,
|
2000-09-24 09:57:26 +00:00
|
|
|
unsigned int tt_ssize,
|
|
|
|
|
unsigned int tt_cused, unsigned int tt_sused,
|
|
|
|
|
snd_pcm_t *slave, int close_slave);
|
2001-03-29 17:50:28 +00:00
|
|
|
int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, unsigned int srate, snd_pcm_t *slave, int close_slave);
|
2000-09-24 09:57:26 +00:00
|
|
|
|
2000-12-21 20:44:10 +00:00
|
|
|
|
2001-01-31 17:26:56 +00:00
|
|
|
void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset,
|
|
|
|
|
const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset,
|
2001-03-29 17:50:28 +00:00
|
|
|
unsigned int channels, snd_pcm_uframes_t frames,
|
|
|
|
|
unsigned int convidx);
|
2001-01-31 17:26:56 +00:00
|
|
|
void snd_pcm_alaw_decode(const snd_pcm_channel_area_t *dst_areas,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_uframes_t dst_offset,
|
2001-01-31 17:26:56 +00:00
|
|
|
const snd_pcm_channel_area_t *src_areas,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_uframes_t src_offset,
|
2001-03-29 17:50:28 +00:00
|
|
|
unsigned int channels, snd_pcm_uframes_t frames,
|
|
|
|
|
unsigned int putidx);
|
2001-01-31 17:26:56 +00:00
|
|
|
void snd_pcm_alaw_encode(const snd_pcm_channel_area_t *dst_areas,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_uframes_t dst_offset,
|
2001-01-31 17:26:56 +00:00
|
|
|
const snd_pcm_channel_area_t *src_areas,
|
|
|
|
|
snd_pcm_uframes_t src_offset,
|
2001-03-29 17:50:28 +00:00
|
|
|
unsigned int channels, snd_pcm_uframes_t frames,
|
|
|
|
|
unsigned int getidx);
|
2001-01-31 17:26:56 +00:00
|
|
|
void snd_pcm_mulaw_decode(const snd_pcm_channel_area_t *dst_areas,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_uframes_t dst_offset,
|
2001-01-31 17:26:56 +00:00
|
|
|
const snd_pcm_channel_area_t *src_areas,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_uframes_t src_offset,
|
2001-03-29 17:50:28 +00:00
|
|
|
unsigned int channels, snd_pcm_uframes_t frames,
|
|
|
|
|
unsigned int putidx);
|
2001-01-31 17:26:56 +00:00
|
|
|
void snd_pcm_mulaw_encode(const snd_pcm_channel_area_t *dst_areas,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_uframes_t dst_offset,
|
2001-01-31 17:26:56 +00:00
|
|
|
const snd_pcm_channel_area_t *src_areas,
|
|
|
|
|
snd_pcm_uframes_t src_offset,
|
2001-03-29 17:50:28 +00:00
|
|
|
unsigned int channels, snd_pcm_uframes_t frames,
|
|
|
|
|
unsigned int getidx);
|
2001-01-26 09:56:30 +00:00
|
|
|
|
|
|
|
|
typedef struct _snd_pcm_adpcm_state {
|
|
|
|
|
int pred_val; /* Calculated predicted value */
|
|
|
|
|
int step_idx; /* Previous StepSize lookup index */
|
|
|
|
|
} snd_pcm_adpcm_state_t;
|
|
|
|
|
|
2001-01-31 17:26:56 +00:00
|
|
|
void snd_pcm_adpcm_decode(const snd_pcm_channel_area_t *dst_areas,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_uframes_t dst_offset,
|
2001-01-31 17:26:56 +00:00
|
|
|
const snd_pcm_channel_area_t *src_areas,
|
|
|
|
|
snd_pcm_uframes_t src_offset,
|
2001-03-29 17:50:28 +00:00
|
|
|
unsigned int channels, snd_pcm_uframes_t frames,
|
|
|
|
|
unsigned int putidx,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_adpcm_state_t *states);
|
2001-01-31 17:26:56 +00:00
|
|
|
void snd_pcm_adpcm_encode(const snd_pcm_channel_area_t *dst_areas,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_uframes_t dst_offset,
|
2001-01-31 17:26:56 +00:00
|
|
|
const snd_pcm_channel_area_t *src_areas,
|
|
|
|
|
snd_pcm_uframes_t src_offset,
|
2001-03-29 17:50:28 +00:00
|
|
|
unsigned int channels, snd_pcm_uframes_t frames,
|
|
|
|
|
unsigned int getidx,
|
2001-01-26 09:56:30 +00:00
|
|
|
snd_pcm_adpcm_state_t *states);
|