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
89 lines
2.8 KiB
Diff
89 lines
2.8 KiB
Diff
From 48c2c90f19f07d02082d9fb84fb36ac1fcfa84e1 Mon Sep 17 00:00:00 2001
|
|
From: Takashi Iwai <tiwai@suse.de>
|
|
Date: Fri, 31 Aug 2012 13:53:22 -0700
|
|
Subject: [PATCH 08/30] Add SND_CHMAP_NA and bit flag definitions
|
|
|
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
---
|
|
include/pcm.h | 7 ++++++-
|
|
include/sound/asound.h | 9 +++++++--
|
|
test/chmap.c | 14 ++++++++++----
|
|
3 files changed, 23 insertions(+), 7 deletions(-)
|
|
|
|
--- a/include/pcm.h
|
|
+++ b/include/pcm.h
|
|
@@ -504,9 +504,14 @@ enum snd_pcm_chmap_position {
|
|
SND_CHMAP_FCH, /** front center high */
|
|
SND_CHMAP_FRH, /** front right high */
|
|
SND_CHMAP_TC, /** top center */
|
|
- SND_CHMAP_LAST = SND_CHMAP_TC, /** last entry */
|
|
+ SND_CHMAP_NA, /** N/A, silent */
|
|
+ SND_CHMAP_LAST = SND_CHMAP_NA, /** last entry */
|
|
};
|
|
|
|
+#define SND_CHMAP_POSITION_MASK 0xffff /** bitmask for channel position */
|
|
+#define SND_CHMAP_PHASE_INVERSE (0x01 << 16) /* the channel is phase inverted */
|
|
+#define SND_CHMAP_DRIVER_SPEC (0x02 << 16) /* non-standard channel value */
|
|
+
|
|
int **snd_pcm_query_chmaps(snd_pcm_t *pcm);
|
|
void snd_pcm_free_chmaps(int **maps);
|
|
int *snd_pcm_get_chmap(snd_pcm_t *pcm);
|
|
--- a/include/sound/asound.h
|
|
+++ b/include/sound/asound.h
|
|
@@ -479,7 +479,7 @@ enum {
|
|
|
|
/* channel positions */
|
|
enum {
|
|
- /* this follows the alsa-lib mixer channel value + 1*/
|
|
+ /* this follows the alsa-lib mixer channel value + 1 */
|
|
SNDRV_CHMAP_UNKNOWN = 0,
|
|
SNDRV_CHMAP_FL, /* front left */
|
|
SNDRV_CHMAP_FR, /* front right */
|
|
@@ -501,9 +501,14 @@ enum {
|
|
SNDRV_CHMAP_FCH, /* front center high */
|
|
SNDRV_CHMAP_FRH, /* front right high */
|
|
SNDRV_CHMAP_TC, /* top center */
|
|
- SNDRV_CHMAP_LAST = SNDRV_CHMAP_TC,
|
|
+ SNDRV_CHMAP_NA, /* N/A, silent */
|
|
+ SNDRV_CHMAP_LAST = SNDRV_CHMAP_NA,
|
|
};
|
|
|
|
+#define SNDRV_CHMAP_POSITION_MASK 0xffff
|
|
+#define SNDRV_CHMAP_PHASE_INVERSE (0x01 << 16)
|
|
+#define SNDRV_CHMAP_DRIVER_SPEC (0x02 << 16)
|
|
+
|
|
enum {
|
|
SNDRV_PCM_IOCTL_PVERSION = _IOR('A', 0x00, int),
|
|
SNDRV_PCM_IOCTL_INFO = _IOR('A', 0x01, struct sndrv_pcm_info),
|
|
--- a/test/chmap.c
|
|
+++ b/test/chmap.c
|
|
@@ -25,7 +25,8 @@ static const char * const chname[] = {
|
|
"Unknown",
|
|
"FL", "FR", "RL", "RR", "FC", "LFE", "SL", "SR", "RC",
|
|
"FLC", "FRC", "RLC", "RRC", "FLW", "FRW", "FLH",
|
|
- "FCH", "FCH", "FRH", "TC"
|
|
+ "FCH", "FCH", "FRH", "TC",
|
|
+ "N/A",
|
|
};
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
|
@@ -36,10 +37,15 @@ static void print_channels(int channels,
|
|
printf(" ");
|
|
for (i = 0; i < channels; i++) {
|
|
unsigned int c = *map++;
|
|
- if (c >= ARRAY_SIZE(chname))
|
|
- printf(" Ch%d", c);
|
|
+ unsigned int pos = c & SND_CHMAP_POSITION_MASK;
|
|
+ if (c & SND_CHMAP_DRIVER_SPEC)
|
|
+ printf(" %d", p);
|
|
+ else if (p >= ARRAY_SIZE(chname))
|
|
+ printf(" Ch%d", p);
|
|
else
|
|
- printf(" %s", chname[c]);
|
|
+ printf(" %s", chname[p]);
|
|
+ if (c & SND_CHMAP_PHASE_INVERSE)
|
|
+ printf("[INV]");
|
|
}
|
|
printf("\n");
|
|
}
|