summaryrefslogtreecommitdiff
path: root/aplay
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-09-11 12:20:55 +0200
committerTakashi Iwai <tiwai@suse.de>2012-09-17 12:23:33 +0200
commita9add2252f44fae3eb0ce5470cb842f220fb0454 (patch)
tree9fc9ad78b6a12e5c418665866fbfffc2b38582d8 /aplay
parent951cb2c2974293db6e12ef067ae7001074887932 (diff)
downloadalsa-utils-a9add2252f44fae3eb0ce5470cb842f220fb0454.tar.gz
aplay: Add support for channel mapping
With -m option, user can specify the order of channel map. As of this commit, it just tries to override the channel map, thus it works only on devices that support the channel map override like HDMI. Adjusting the channel order in aplay itself will be added later. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'aplay')
-rw-r--r--aplay/aplay.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/aplay/aplay.c b/aplay/aplay.c
index 17fa913..a4e5846 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -54,6 +54,10 @@
#include "formats.h"
#include "version.h"
+#ifdef SND_CHMAP_API_VERSION
+#define CONFIG_SUPPORT_CHMAP 1
+#endif
+
#ifndef LLONG_MAX
#define LLONG_MAX 9223372036854775807LL
#endif
@@ -140,6 +144,10 @@ static char *pidfile_name = NULL;
FILE *pidf = NULL;
static int pidfile_written = 0;
+#ifdef CONFIG_SUPPORT_CHMAP
+static snd_pcm_chmap_t *channel_map = NULL;
+#endif
+
/* needed prototypes */
static void done_stdin(void);
@@ -227,7 +235,9 @@ _("Usage: %s [OPTION]... [FILE]...\n"
" --process-id-file write the process ID here\n"
" --use-strftime apply the strftime facility to the output file name\n"
" --dump-hw-params dump hw_params of the device\n"
-" --fatal-errors treat all errors as fatal\n")
+" --fatal-errors treat all errors as fatal\n"
+"-m, --chmap=ch1,ch2,.. Give the channel map to override\n"
+ )
, command);
printf(_("Recognized sample formats are:"));
for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
@@ -428,7 +438,11 @@ enum {
int main(int argc, char *argv[])
{
int option_index;
- static const char short_options[] = "hnlLD:qt:c:f:r:d:MNF:A:R:T:B:vV:IPCi";
+ static const char short_options[] = "hnlLD:qt:c:f:r:d:MNF:A:R:T:B:vV:IPCi"
+#ifdef CONFIG_SUPPORT_CHMAP
+ "m:"
+#endif
+ ;
static const struct option long_options[] = {
{"help", 0, 0, 'h'},
{"version", 0, 0, OPT_VERSION},
@@ -469,6 +483,9 @@ int main(int argc, char *argv[])
{"interactive", 0, 0, 'i'},
{"dump-hw-params", 0, 0, OPT_DUMP_HWPARAMS},
{"fatal-errors", 0, 0, OPT_FATAL_ERRORS},
+#ifdef CONFIG_SUPPORT_CHMAP
+ {"chmap", 1, 0, 'm'},
+#endif
{0, 0, 0, 0}
};
char *pcm_name = "default";
@@ -676,6 +693,15 @@ int main(int argc, char *argv[])
case OPT_FATAL_ERRORS:
fatal_errors = 1;
break;
+#ifdef CONFIG_SUPPORT_CHMAP
+ case 'm':
+ channel_map = snd_pcm_chmap_parse_string(optarg);
+ if (!channel_map) {
+ fprintf(stderr, _("Unable to parse channel map string: %s\n"), optarg);
+ return 1;
+ }
+ break;
+#endif
default:
fprintf(stderr, _("Try `%s --help' for more information.\n"), command);
return 1;
@@ -1206,6 +1232,16 @@ static void set_params(void)
prg_exit(EXIT_FAILURE);
}
+#ifdef CONFIG_SUPPORT_CHMAP
+ if (channel_map) {
+ err = snd_pcm_set_chmap(handle, channel_map);
+ if (err < 0) {
+ error(_("Unable to set channel map"));
+ prg_exit(EXIT_FAILURE);
+ }
+ }
+#endif
+
if (verbose)
snd_pcm_dump(handle, log);