Takashi Iwai
8a90d87ca6
- backport from upstream tree: * lots of patches to support the new chmap API * fix segfault in rate plugin error path * add a couple of test programs * fix inifinte loop in htimestamp of dmix & co OBS-URL: https://build.opensuse.org/request/show/138456 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=113
180 lines
5.4 KiB
Diff
180 lines
5.4 KiB
Diff
From 662f79d4ec6b52bbaab28d5a9b60cc8bcdf042f9 Mon Sep 17 00:00:00 2001
|
|
From: Takashi Iwai <tiwai@suse.de>
|
|
Date: Wed, 25 Jul 2012 15:54:45 +0200
|
|
Subject: [PATCH 03/30] Implement get_chmap/set_chmap for PCM extplug/ioplug
|
|
plugins
|
|
|
|
Added the new ops for both external plugins, so the protocol numbers
|
|
are incremented.
|
|
|
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
---
|
|
include/pcm_extplug.h | 14 +++++++++++++-
|
|
include/pcm_ioplug.h | 16 ++++++++++++++--
|
|
src/pcm/pcm_extplug.c | 33 +++++++++++++++++++++++++++++++++
|
|
src/pcm/pcm_ioplug.c | 33 +++++++++++++++++++++++++++++++++
|
|
4 files changed, 93 insertions(+), 3 deletions(-)
|
|
|
|
--- a/include/pcm_extplug.h
|
|
+++ b/include/pcm_extplug.h
|
|
@@ -55,7 +55,7 @@ typedef struct snd_pcm_extplug_callback
|
|
*/
|
|
#define SND_PCM_EXTPLUG_VERSION_MAJOR 1 /**< Protocol major version */
|
|
#define SND_PCM_EXTPLUG_VERSION_MINOR 0 /**< Protocol minor version */
|
|
-#define SND_PCM_EXTPLUG_VERSION_TINY 1 /**< Protocol tiny version */
|
|
+#define SND_PCM_EXTPLUG_VERSION_TINY 2 /**< Protocol tiny version */
|
|
/**
|
|
* Filter-plugin protocol version
|
|
*/
|
|
@@ -151,6 +151,18 @@ struct snd_pcm_extplug_callback {
|
|
* init; optional initialization called at prepare or reset
|
|
*/
|
|
int (*init)(snd_pcm_extplug_t *ext);
|
|
+ /**
|
|
+ * query the channel maps; optional; since v1.0.2
|
|
+ */
|
|
+ int **(*query_chmaps)(snd_pcm_extplug_t *ext);
|
|
+ /**
|
|
+ * get the channel map; optional; since v1.0.2
|
|
+ */
|
|
+ int *(*get_chmap)(snd_pcm_extplug_t *ext);
|
|
+ /**
|
|
+ * set the channel map; optional; since v1.0.2
|
|
+ */
|
|
+ int (*set_chmap)(snd_pcm_extplug_t *ext, const int *map);
|
|
};
|
|
|
|
|
|
--- a/include/pcm_ioplug.h
|
|
+++ b/include/pcm_ioplug.h
|
|
@@ -66,7 +66,7 @@ typedef struct snd_pcm_ioplug_callback s
|
|
*/
|
|
#define SND_PCM_IOPLUG_VERSION_MAJOR 1 /**< Protocol major version */
|
|
#define SND_PCM_IOPLUG_VERSION_MINOR 0 /**< Protocol minor version */
|
|
-#define SND_PCM_IOPLUG_VERSION_TINY 1 /**< Protocol tiny version */
|
|
+#define SND_PCM_IOPLUG_VERSION_TINY 2 /**< Protocol tiny version */
|
|
/**
|
|
* IO-plugin protocol version
|
|
*/
|
|
@@ -186,9 +186,21 @@ struct snd_pcm_ioplug_callback {
|
|
*/
|
|
void (*dump)(snd_pcm_ioplug_t *io, snd_output_t *out);
|
|
/**
|
|
- * get the delay for the running PCM; optional
|
|
+ * get the delay for the running PCM; optional; since v1.0.1
|
|
*/
|
|
int (*delay)(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp);
|
|
+ /**
|
|
+ * query the channel maps; optional; since v1.0.2
|
|
+ */
|
|
+ int **(*query_chmaps)(snd_pcm_ioplug_t *io);
|
|
+ /**
|
|
+ * get the channel map; optional; since v1.0.2
|
|
+ */
|
|
+ int *(*get_chmap)(snd_pcm_ioplug_t *io);
|
|
+ /**
|
|
+ * set the channel map; optional; since v1.0.2
|
|
+ */
|
|
+ int (*set_chmap)(snd_pcm_ioplug_t *io, const int *map);
|
|
};
|
|
|
|
|
|
--- a/src/pcm/pcm_extplug.c
|
|
+++ b/src/pcm/pcm_extplug.c
|
|
@@ -425,6 +425,36 @@ static int snd_pcm_extplug_close(snd_pcm
|
|
return 0;
|
|
}
|
|
|
|
+static int **snd_pcm_extplug_query_chmaps(snd_pcm_t *pcm)
|
|
+{
|
|
+ extplug_priv_t *ext = pcm->private_data;
|
|
+
|
|
+ if (ext->data->version >= 0x010002 &&
|
|
+ ext->data->callback->query_chmaps)
|
|
+ return ext->data->callback->query_chmaps(ext->data);
|
|
+ return snd_pcm_generic_query_chmaps(pcm);
|
|
+}
|
|
+
|
|
+static int *snd_pcm_extplug_get_chmap(snd_pcm_t *pcm)
|
|
+{
|
|
+ extplug_priv_t *ext = pcm->private_data;
|
|
+
|
|
+ if (ext->data->version >= 0x010002 &&
|
|
+ ext->data->callback->get_chmap)
|
|
+ return ext->data->callback->get_chmap(ext->data);
|
|
+ return snd_pcm_generic_get_chmap(pcm);
|
|
+}
|
|
+
|
|
+static int snd_pcm_extplug_set_chmap(snd_pcm_t *pcm, const int *map)
|
|
+{
|
|
+ extplug_priv_t *ext = pcm->private_data;
|
|
+
|
|
+ if (ext->data->version >= 0x010002 &&
|
|
+ ext->data->callback->set_chmap)
|
|
+ return ext->data->callback->set_chmap(ext->data, map);
|
|
+ return snd_pcm_generic_set_chmap(pcm, map);
|
|
+}
|
|
+
|
|
static const snd_pcm_ops_t snd_pcm_extplug_ops = {
|
|
.close = snd_pcm_extplug_close,
|
|
.info = snd_pcm_generic_info,
|
|
@@ -438,6 +468,9 @@ static const snd_pcm_ops_t snd_pcm_extpl
|
|
.async = snd_pcm_generic_async,
|
|
.mmap = snd_pcm_generic_mmap,
|
|
.munmap = snd_pcm_generic_munmap,
|
|
+ .query_chmaps = snd_pcm_extplug_query_chmaps,
|
|
+ .get_chmap = snd_pcm_extplug_get_chmap,
|
|
+ .set_chmap = snd_pcm_extplug_set_chmap,
|
|
};
|
|
|
|
#endif /* !DOC_HIDDEN */
|
|
--- a/src/pcm/pcm_ioplug.c
|
|
+++ b/src/pcm/pcm_ioplug.c
|
|
@@ -710,6 +710,36 @@ static int snd_pcm_ioplug_munmap(snd_pcm
|
|
return 0;
|
|
}
|
|
|
|
+static int **snd_pcm_ioplug_query_chmaps(snd_pcm_t *pcm)
|
|
+{
|
|
+ ioplug_priv_t *io = pcm->private_data;
|
|
+
|
|
+ if (io->data->version >= 0x010002 &&
|
|
+ io->data->callback->query_chmaps)
|
|
+ return io->data->callback->query_chmaps(io->data);
|
|
+ return NULL;
|
|
+}
|
|
+
|
|
+static int *snd_pcm_ioplug_get_chmap(snd_pcm_t *pcm)
|
|
+{
|
|
+ ioplug_priv_t *io = pcm->private_data;
|
|
+
|
|
+ if (io->data->version >= 0x010002 &&
|
|
+ io->data->callback->get_chmap)
|
|
+ return io->data->callback->get_chmap(io->data);
|
|
+ return NULL;
|
|
+}
|
|
+
|
|
+static int snd_pcm_ioplug_set_chmap(snd_pcm_t *pcm, const int *map)
|
|
+{
|
|
+ ioplug_priv_t *io = pcm->private_data;
|
|
+
|
|
+ if (io->data->version >= 0x010002 &&
|
|
+ io->data->callback->set_chmap)
|
|
+ return io->data->callback->set_chmap(io->data, map);
|
|
+ return -ENXIO;
|
|
+}
|
|
+
|
|
static void snd_pcm_ioplug_dump(snd_pcm_t *pcm, snd_output_t *out)
|
|
{
|
|
ioplug_priv_t *io = pcm->private_data;
|
|
@@ -760,6 +790,9 @@ static const snd_pcm_ops_t snd_pcm_ioplu
|
|
.dump = snd_pcm_ioplug_dump,
|
|
.mmap = snd_pcm_ioplug_mmap,
|
|
.munmap = snd_pcm_ioplug_munmap,
|
|
+ .query_chmaps = snd_pcm_ioplug_query_chmaps,
|
|
+ .get_chmap = snd_pcm_ioplug_get_chmap,
|
|
+ .set_chmap = snd_pcm_ioplug_set_chmap,
|
|
};
|
|
|
|
static const snd_pcm_fast_ops_t snd_pcm_ioplug_fast_ops = {
|