mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-17 08:56:45 -05:00
Removed old sync support. Introduced linked streams
This commit is contained in:
parent
bd532fd398
commit
59c6c40f5c
4 changed files with 65 additions and 47 deletions
|
|
@ -100,6 +100,7 @@ typedef struct snd_pcm_loopback snd_pcm_loopback_t;
|
||||||
|
|
||||||
typedef enum { SND_PCM_TYPE_HW, SND_PCM_TYPE_PLUG, SND_PCM_TYPE_MULTI } snd_pcm_type_t;
|
typedef enum { SND_PCM_TYPE_HW, SND_PCM_TYPE_PLUG, SND_PCM_TYPE_MULTI } snd_pcm_type_t;
|
||||||
|
|
||||||
|
#if 0
|
||||||
typedef struct {
|
typedef struct {
|
||||||
snd_pcm_t *handle;
|
snd_pcm_t *handle;
|
||||||
snd_timestamp_t tstamp;
|
snd_timestamp_t tstamp;
|
||||||
|
|
@ -115,6 +116,10 @@ typedef enum { SND_PCM_SYNCHRO_GO } snd_pcm_synchro_cmd_t;
|
||||||
#define SND_PCM_SYNCHRO_MODE_NORMAL SND_PCM_SYNC_MODE_NORMAL
|
#define SND_PCM_SYNCHRO_MODE_NORMAL SND_PCM_SYNC_MODE_NORMAL
|
||||||
#define SND_PCM_SYNCHRO_MODE_HARDWARE SND_PCM_SYNC_MODE_HARDWARE
|
#define SND_PCM_SYNCHRO_MODE_HARDWARE SND_PCM_SYNC_MODE_HARDWARE
|
||||||
#define SND_PCM_SYNCHRO_MODE_RELAXED SND_PCM_SYNC_MODE_RELAXED
|
#define SND_PCM_SYNCHRO_MODE_RELAXED SND_PCM_SYNC_MODE_RELAXED
|
||||||
|
int snd_pcm_synchro(snd_pcm_synchro_cmd_t cmd,
|
||||||
|
unsigned int reqs_count, snd_pcm_synchro_request_t *reqs,
|
||||||
|
snd_pcm_synchro_mode_t mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int snd_pcm_hw_open_subdevice(snd_pcm_t **handle, int card, int device, int subdevice, int stream, int mode);
|
int snd_pcm_hw_open_subdevice(snd_pcm_t **handle, int card, int device, int subdevice, int stream, int mode);
|
||||||
|
|
@ -132,9 +137,6 @@ int snd_pcm_channel_setup(snd_pcm_t *handle, snd_pcm_channel_setup_t *setup);
|
||||||
int snd_pcm_status(snd_pcm_t *handle, snd_pcm_status_t *status);
|
int snd_pcm_status(snd_pcm_t *handle, snd_pcm_status_t *status);
|
||||||
int snd_pcm_prepare(snd_pcm_t *handle);
|
int snd_pcm_prepare(snd_pcm_t *handle);
|
||||||
int snd_pcm_go(snd_pcm_t *handle);
|
int snd_pcm_go(snd_pcm_t *handle);
|
||||||
int snd_pcm_synchro(snd_pcm_synchro_cmd_t cmd,
|
|
||||||
unsigned int reqs_count, snd_pcm_synchro_request_t *reqs,
|
|
||||||
snd_pcm_synchro_mode_t mode);
|
|
||||||
int snd_pcm_drain(snd_pcm_t *handle);
|
int snd_pcm_drain(snd_pcm_t *handle);
|
||||||
int snd_pcm_flush(snd_pcm_t *handle);
|
int snd_pcm_flush(snd_pcm_t *handle);
|
||||||
int snd_pcm_pause(snd_pcm_t *handle, int enable);
|
int snd_pcm_pause(snd_pcm_t *handle, int enable);
|
||||||
|
|
@ -147,6 +149,8 @@ ssize_t snd_pcm_writev(snd_pcm_t *handle, const struct iovec *vector, unsigned l
|
||||||
ssize_t snd_pcm_readv(snd_pcm_t *handle, const struct iovec *vector, unsigned long count);
|
ssize_t snd_pcm_readv(snd_pcm_t *handle, const struct iovec *vector, unsigned long count);
|
||||||
int snd_pcm_dump_setup(snd_pcm_t *handle, FILE *fp);
|
int snd_pcm_dump_setup(snd_pcm_t *handle, FILE *fp);
|
||||||
int snd_pcm_dump(snd_pcm_t *handle, FILE *fp);
|
int snd_pcm_dump(snd_pcm_t *handle, FILE *fp);
|
||||||
|
int snd_pcm_link(snd_pcm_t *handle1, snd_pcm_t *handle2);
|
||||||
|
int snd_pcm_unlink(snd_pcm_t *handle);
|
||||||
|
|
||||||
int snd_pcm_channels_mask(snd_pcm_t *handle, bitset_t *client_vmask);
|
int snd_pcm_channels_mask(snd_pcm_t *handle, bitset_t *client_vmask);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,7 @@ int snd_pcm_go(snd_pcm_t *handle)
|
||||||
return handle->fast_ops->go(handle->fast_op_arg);
|
return handle->fast_ops->go(handle->fast_op_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int snd_pcm_synchro(snd_pcm_synchro_cmd_t cmd,
|
int snd_pcm_synchro(snd_pcm_synchro_cmd_t cmd,
|
||||||
unsigned int reqs_count, snd_pcm_synchro_request_t *reqs,
|
unsigned int reqs_count, snd_pcm_synchro_request_t *reqs,
|
||||||
snd_pcm_synchro_mode_t mode)
|
snd_pcm_synchro_mode_t mode)
|
||||||
|
|
@ -203,7 +204,7 @@ int snd_pcm_synchro(snd_pcm_synchro_cmd_t cmd,
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int snd_pcm_drain(snd_pcm_t *handle)
|
int snd_pcm_drain(snd_pcm_t *handle)
|
||||||
{
|
{
|
||||||
|
|
@ -271,6 +272,52 @@ ssize_t snd_pcm_readv(snd_pcm_t *handle, const struct iovec *vector, unsigned lo
|
||||||
return handle->fast_ops->readv(handle->fast_op_arg, 0, vector, count);
|
return handle->fast_ops->readv(handle->fast_op_arg, 0, vector, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int snd_pcm_link(snd_pcm_t *handle1, snd_pcm_t *handle2)
|
||||||
|
{
|
||||||
|
int fd1, fd2;
|
||||||
|
switch (handle1->type) {
|
||||||
|
case SND_PCM_TYPE_HW:
|
||||||
|
case SND_PCM_TYPE_PLUG:
|
||||||
|
case SND_PCM_TYPE_MULTI:
|
||||||
|
fd1 = snd_pcm_file_descriptor(handle1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
switch (handle2->type) {
|
||||||
|
case SND_PCM_TYPE_HW:
|
||||||
|
case SND_PCM_TYPE_PLUG:
|
||||||
|
case SND_PCM_TYPE_MULTI:
|
||||||
|
fd2 = snd_pcm_file_descriptor(handle2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ioctl(fd1, SND_PCM_IOCTL_LINK, fd2) < 0)
|
||||||
|
return -errno;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int snd_pcm_unlink(snd_pcm_t *handle)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
switch (handle->type) {
|
||||||
|
case SND_PCM_TYPE_HW:
|
||||||
|
case SND_PCM_TYPE_PLUG:
|
||||||
|
case SND_PCM_TYPE_MULTI:
|
||||||
|
fd = snd_pcm_file_descriptor(handle);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ioctl(fd, SND_PCM_IOCTL_UNLINK) < 0)
|
||||||
|
return -errno;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int snd_pcm_file_descriptor(snd_pcm_t *handle)
|
int snd_pcm_file_descriptor(snd_pcm_t *handle)
|
||||||
{
|
{
|
||||||
assert(handle);
|
assert(handle);
|
||||||
|
|
@ -381,7 +428,6 @@ int snd_pcm_dump_setup(snd_pcm_t *handle, FILE *fp)
|
||||||
fprintf(fp, "xrun_mode: %s\n", assoc(setup->xrun_mode, xruns));
|
fprintf(fp, "xrun_mode: %s\n", assoc(setup->xrun_mode, xruns));
|
||||||
fprintf(fp, "time: %s\n", assoc(setup->time, onoff));
|
fprintf(fp, "time: %s\n", assoc(setup->time, onoff));
|
||||||
// ust_time
|
// ust_time
|
||||||
// sync
|
|
||||||
fprintf(fp, "buffer_size: %d\n", setup->buffer_size);
|
fprintf(fp, "buffer_size: %d\n", setup->buffer_size);
|
||||||
fprintf(fp, "frag_size: %d\n", setup->frag_size);
|
fprintf(fp, "frag_size: %d\n", setup->frag_size);
|
||||||
fprintf(fp, "frags: %d\n", setup->frags);
|
fprintf(fp, "frags: %d\n", setup->frags);
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ static int snd_pcm_hw_pause(void *private, int enable)
|
||||||
{
|
{
|
||||||
snd_pcm_hw_t *hw = (snd_pcm_hw_t*) private;
|
snd_pcm_hw_t *hw = (snd_pcm_hw_t*) private;
|
||||||
int fd = hw->fd;
|
int fd = hw->fd;
|
||||||
if (ioctl(fd, SND_PCM_IOCTL_PAUSE, &enable) < 0)
|
if (ioctl(fd, SND_PCM_IOCTL_PAUSE, enable) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,8 @@ static int snd_pcm_multi_close(void *private)
|
||||||
err = snd_pcm_close(slave->handle);
|
err = snd_pcm_close(slave->handle);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
ret = err;
|
ret = err;
|
||||||
}
|
} else
|
||||||
|
snd_pcm_unlink(slave->handle);
|
||||||
if (slave->buf) {
|
if (slave->buf) {
|
||||||
free(slave->buf);
|
free(slave->buf);
|
||||||
free(slave->areas);
|
free(slave->areas);
|
||||||
|
|
@ -285,66 +286,31 @@ static ssize_t snd_pcm_multi_frame_io(void *private, int update)
|
||||||
static int snd_pcm_multi_prepare(void *private)
|
static int snd_pcm_multi_prepare(void *private)
|
||||||
{
|
{
|
||||||
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
||||||
unsigned int i;
|
return snd_pcm_prepare(multi->slaves[0].handle);
|
||||||
for (i = 0; i < multi->slaves_count; ++i) {
|
|
||||||
snd_pcm_t *handle = multi->slaves[i].handle;
|
|
||||||
int err = snd_pcm_prepare(handle);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_multi_go(void *private)
|
static int snd_pcm_multi_go(void *private)
|
||||||
{
|
{
|
||||||
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
||||||
unsigned int i;
|
return snd_pcm_go(multi->slaves[0].handle);
|
||||||
for (i = 0; i < multi->slaves_count; ++i) {
|
|
||||||
snd_pcm_t *handle = multi->slaves[i].handle;
|
|
||||||
int err = snd_pcm_go(handle);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_multi_drain(void *private)
|
static int snd_pcm_multi_drain(void *private)
|
||||||
{
|
{
|
||||||
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
||||||
unsigned int i;
|
return snd_pcm_drain(multi->slaves[0].handle);
|
||||||
for (i = 0; i < multi->slaves_count; ++i) {
|
|
||||||
snd_pcm_t *handle = multi->slaves[i].handle;
|
|
||||||
int err = snd_pcm_drain(handle);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_multi_flush(void *private)
|
static int snd_pcm_multi_flush(void *private)
|
||||||
{
|
{
|
||||||
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
||||||
unsigned int i;
|
return snd_pcm_flush(multi->slaves[0].handle);
|
||||||
for (i = 0; i < multi->slaves_count; ++i) {
|
|
||||||
snd_pcm_t *handle = multi->slaves[i].handle;
|
|
||||||
int err = snd_pcm_flush(handle);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_multi_pause(void *private, int enable)
|
static int snd_pcm_multi_pause(void *private, int enable)
|
||||||
{
|
{
|
||||||
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
|
||||||
unsigned int i;
|
return snd_pcm_pause(multi->slaves[0].handle, enable);
|
||||||
for (i = 0; i < multi->slaves_count; ++i) {
|
|
||||||
snd_pcm_t *handle = multi->slaves[i].handle;
|
|
||||||
int err = snd_pcm_pause(handle, enable);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_multi_channel_setup(void *private, snd_pcm_channel_setup_t *setup)
|
static int snd_pcm_multi_channel_setup(void *private, snd_pcm_channel_setup_t *setup)
|
||||||
|
|
@ -796,6 +762,8 @@ int snd_pcm_multi_create(snd_pcm_t **handlep, size_t slaves_count,
|
||||||
slave->handle = slaves_handle[i];
|
slave->handle = slaves_handle[i];
|
||||||
slave->channels_total = slaves_channels_count[i];
|
slave->channels_total = slaves_channels_count[i];
|
||||||
slave->close_slave = close_slaves;
|
slave->close_slave = close_slaves;
|
||||||
|
if (i != 0)
|
||||||
|
snd_pcm_link(slaves_handle[i-1], slaves_handle[i]);
|
||||||
}
|
}
|
||||||
for (i = 0; i < binds_count; ++i) {
|
for (i = 0; i < binds_count; ++i) {
|
||||||
snd_pcm_multi_bind_t *bind = &multi->binds[i];
|
snd_pcm_multi_bind_t *bind = &multi->binds[i];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue