]> git.alsa-project.org Git - alsa-lib.git/commitdiff
more name hint interace updates
authorJaroslav Kysela <perex@perex.cz>
Thu, 12 Oct 2006 12:34:23 +0000 (14:34 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 12 Oct 2006 12:34:23 +0000 (14:34 +0200)
- add long card name to device description
- create empty PCM plugin to allow right hint description parsing
- reorder devices in alsa.conf
- make namehint more configurable (using default.namehint.showall switch)
- add two levels basic and exteded for hints to default configuration files
- do not show direct device aliases
- removed all known memory leaks

20 files changed:
configure.in
src/conf/alsa.conf
src/conf/cards/HDA-Intel.conf
src/conf/pcm/center_lfe.conf
src/conf/pcm/dmix.conf
src/conf/pcm/dsnoop.conf
src/conf/pcm/front.conf
src/conf/pcm/iec958.conf
src/conf/pcm/modem.conf
src/conf/pcm/rear.conf
src/conf/pcm/side.conf
src/conf/pcm/surround40.conf
src/conf/pcm/surround41.conf
src/conf/pcm/surround50.conf
src/conf/pcm/surround51.conf
src/conf/pcm/surround71.conf
src/confmisc.c
src/control/namehint.c
src/pcm/Makefile.am
src/pcm/pcm.c

index 3cad3322f28864db6393895f2630b5142d3c4584..8c39586cee63412bc20e32c695a5a5ce02091254 100644 (file)
@@ -292,7 +292,7 @@ else
 pcm_plugins=""
 fi
 
-PCM_PLUGIN_LIST="copy linear route mulaw alaw adpcm rate plug multi shm file null share meter hooks lfloat ladspa dmix dshare dsnoop asym iec958 softvol extplug ioplug"
+PCM_PLUGIN_LIST="copy linear route mulaw alaw adpcm rate plug multi shm file null empty share meter hooks lfloat ladspa dmix dshare dsnoop asym iec958 softvol extplug ioplug"
 
 build_pcm_plugin="no"
 for t in $PCM_PLUGIN_LIST; do
@@ -332,6 +332,7 @@ AM_CONDITIONAL(BUILD_PCM_PLUGIN_MULTI, test x$build_pcm_multi = xyes)
 AM_CONDITIONAL(BUILD_PCM_PLUGIN_SHM, test x$build_pcm_shm = xyes)
 AM_CONDITIONAL(BUILD_PCM_PLUGIN_FILE, test x$build_pcm_file = xyes)
 AM_CONDITIONAL(BUILD_PCM_PLUGIN_NULL, test x$build_pcm_null = xyes)
+AM_CONDITIONAL(BUILD_PCM_PLUGIN_EMPTY, test x$build_pcm_empty = xyes)
 AM_CONDITIONAL(BUILD_PCM_PLUGIN_SHARE, test x$build_pcm_share = xyes)
 AM_CONDITIONAL(BUILD_PCM_PLUGIN_METER, test x$build_pcm_meter = xyes)
 AM_CONDITIONAL(BUILD_PCM_PLUGIN_HOOKS, test x$build_pcm_hooks = xyes)
index 77a40ea2b4db4bbff7b03d7814ab415c2a62535c..a0716f963b7f1b9e23ab135f5fb321a7565141e7 100644 (file)
@@ -47,8 +47,17 @@ cards.@hooks [
        }
 ]
 
+#
 # defaults
+#
 
+# show all name hints also for definitions without hint {} section
+defaults.namehint.showall off
+# show just basic name hints
+defaults.namehint.basic on
+# show extended name hints
+defaults.namehint.extended off
+#
 defaults.ctl.card 0
 defaults.pcm.card 0
 defaults.pcm.device 0
@@ -101,6 +110,26 @@ defaults.timer.subdevice 0
 #  PCM interface
 #
 
+# redirect to load-on-demand extended pcm definitions
+pcm.cards cards.pcm
+
+pcm.default cards.pcm.default
+pcm.front cards.pcm.front
+pcm.rear cards.pcm.rear
+pcm.center_lfe cards.pcm.center_lfe
+pcm.side cards.pcm.side
+pcm.surround40 cards.pcm.surround40
+pcm.surround41 cards.pcm.surround41
+pcm.surround50 cards.pcm.surround50
+pcm.surround51 cards.pcm.surround51
+pcm.surround71 cards.pcm.surround71
+pcm.iec958 cards.pcm.iec958
+pcm.spdif iec958
+pcm.dmix cards.pcm.dmix
+pcm.dsnoop cards.pcm.dsnoop
+pcm.modem cards.pcm.modem
+pcm.phoneline cards.pcm.phoneline
+
 pcm.hw {
        @args [ CARD DEV SUBDEV ]
        @args.CARD {
@@ -141,7 +170,13 @@ pcm.hw {
        card $CARD
        device $DEV
        subdevice $SUBDEV
-       hint 0
+       hint {
+               show {
+                       @func refer
+                       name defaults.namehint.extended
+               }
+               description "Direct hardware device without any conversions"
+       }
 }
 
 pcm.plughw {
@@ -187,7 +222,13 @@ pcm.plughw {
                device $DEV
                subdevice $SUBDEV
        }
-       hint 0
+       hint {
+               show {
+                       @func refer
+                       name defaults.namehint.extended
+               }
+               description "Hardware device with all software conversions"
+       }
 }
 
 pcm.plug {
@@ -246,35 +287,35 @@ pcm.file {
 }
 
 pcm.null {
-       hint.description "Discard all samples (playback) or generate zero samples (capture)"
        type null
+       hint {
+               show {
+                       @func refer
+                       name defaults.namehint.basic
+               }
+               description "Discard all samples (playback) or generate zero samples (capture)"
+       }
 }
 
-# redirect to load-on-demand extended pcm definitions
-pcm.cards cards.pcm
-# some links for easy use
-pcm.front cards.pcm.front
-pcm.rear cards.pcm.rear
-pcm.center_lfe cards.pcm.center_lfe
-pcm.side cards.pcm.side
-pcm.surround40 cards.pcm.surround40
-pcm.surround41 cards.pcm.surround41
-pcm.surround50 cards.pcm.surround50
-pcm.surround51 cards.pcm.surround51
-pcm.surround71 cards.pcm.surround71
-pcm.iec958 cards.pcm.iec958
-pcm.spdif cards.pcm.iec958
-pcm.modem cards.pcm.modem
-pcm.phoneline cards.pcm.phoneline
-
-pcm.default cards.pcm.default
-pcm.dmix cards.pcm.dmix
-pcm.dsnoop cards.pcm.dsnoop
-
 #
 #  Control interface
 #
        
+ctl.default {
+       type hw
+       card {
+               @func getenv
+               vars [
+                       ALSA_CTL_CARD
+                       ALSA_CARD
+               ]
+               default {
+                       @func refer
+                       name defaults.ctl.card
+               }
+       }
+}
+
 ctl.hw {
        @args[ CARD ]
        @args.CARD {
@@ -308,25 +349,35 @@ ctl.shm {
        ctl $CTL
 }
 
-ctl.default {
+#
+#  RawMidi interface
+#
+
+rawmidi.default {
        type hw
        card {
                @func getenv
                vars [
-                       ALSA_CTL_CARD
+                       ALSA_RAWMIDI_CARD
                        ALSA_CARD
                ]
                default {
                        @func refer
-                       name defaults.ctl.card
+                       name defaults.rawmidi.card
+               }
+       }
+       device {
+               @func igetenv
+               vars [
+                       ALSA_RAWMIDI_DEVICE
+               ]
+               default {
+                       @func refer
+                       name defaults.rawmidi.device
                }
        }
 }
 
-#
-#  RawMidi interface
-#
-
 rawmidi.hw {
        @args [ CARD DEV SUBDEV ]
        @args.CARD {
@@ -370,31 +421,6 @@ rawmidi.hw {
        }
 }
 
-rawmidi.default {
-       type hw
-       card {
-               @func getenv
-               vars [
-                       ALSA_RAWMIDI_CARD
-                       ALSA_CARD
-               ]
-               default {
-                       @func refer
-                       name defaults.rawmidi.card
-               }
-       }
-       device {
-               @func igetenv
-               vars [
-                       ALSA_RAWMIDI_DEVICE
-               ]
-               default {
-                       @func refer
-                       name defaults.rawmidi.device
-               }
-       }
-}
-
 rawmidi.virtual {
        @args [ MERGE ]
        @args.MERGE {
@@ -421,6 +447,31 @@ seq.hw {
 #  HwDep interface
 #
 
+hwdep.default {
+       type hw
+       card {
+               @func getenv
+               vars [
+                       ALSA_HWDEP_CARD
+                       ALSA_CARD
+               ]
+               default {
+                       @func refer
+                       name defaults.hwdep.card
+               }
+       }
+       device {
+               @func igetenv
+               vars [
+                       ALSA_HWDEP_DEVICE
+               ]
+               default {
+                       @func refer
+                       name defaults.hwdep.device
+               }
+       }
+}
+
 hwdep.hw {
        @args [ CARD DEV ]
        @args.CARD {
@@ -455,41 +506,41 @@ hwdep.hw {
        device $DEV
 }
 
-hwdep.default {
-       type hw
-       card {
-               @func getenv
-               vars [
-                       ALSA_HWDEP_CARD
-                       ALSA_CARD
-               ]
-               default {
-                       @func refer
-                       name defaults.hwdep.card
-               }
-       }
-       device {
-               @func igetenv
-               vars [
-                       ALSA_HWDEP_DEVICE
-               ]
-               default {
-                       @func refer
-                       name defaults.hwdep.device
-               }
-       }
-}
-
 #
 #  Timer interface
 #
 
+timer_query.default {
+       type hw
+}
+
 timer_query.hw {
        type hw
 }
 
-timer_query.default {
+timer.default {
        type hw
+       class {
+               @func refer
+               name defaults.timer.class
+       }
+       sclass {
+               @func refer
+               name defaults.timer.sclass
+       }
+       card {
+               @func refer
+               name defaults.timer.card
+       }
+       device {
+               @func refer
+               name defaults.timer.device
+       }
+       subdevice {
+               @func refer
+               name defaults.timer.subdevice
+       }
+       hint.description "Default direct hardware timer device"
 }
 
 timer.hw {
@@ -536,28 +587,3 @@ timer.hw {
        device $DEV
        subdevice $SUBDEV
 }
-
-timer.default {
-       type hw
-       class {
-               @func refer
-               name defaults.timer.class
-       }
-       sclass {
-               @func refer
-               name defaults.timer.sclass
-       }
-       card {
-               @func refer
-               name defaults.timer.card
-       }
-       device {
-               @func refer
-               name defaults.timer.device
-       }
-       subdevice {
-               @func refer
-               name defaults.timer.subdevice
-       }
-       hint.description "Default direct hardware timer device"
-}
index f1a6d8a209e70773efc582bd1aadf00119b64225..a5fafdf362420417850480db64b49ef8b642aee9 100644 (file)
@@ -19,10 +19,7 @@ HDA-Intel.pcm.front.0 {
                name "PCM Playback Volume"
                card $CARD
        }
-       hint {
-               description "Front speakers and multichannel output"
-               device 0
-       }
+       hint.device 0
 }      
 
 # default with dmix+softvol & dsnoop
@@ -54,7 +51,6 @@ HDA-Intel.pcm.default {
                }
        }
        hint {
-               description "Default dmix+softvol + dsnoop device"
                device_output {
                        @func refer
                        name defaults.pcm.dmix.device
@@ -140,10 +136,7 @@ HDA-Intel.pcm.iec958.0 {
                        ]
                }
        }
-       hint {
-               description "IEC958 (S/PDIF) Output"
-               device 1
-       }
+       hint.device 1
 }
 
 <confdir:pcm/modem.conf>
@@ -156,5 +149,5 @@ HDA-Intel.pcm.modem.0 {
        type hw
        card $CARD
        device 6
-       hint 0
+       hint.show off
 }
index 423f6cb4196b8e4bf2c75ee7c5d436af6a1976d9..228c619503c42931239b2018d48869533f5e3e1c 100644 (file)
@@ -32,16 +32,26 @@ pcm.!center_lfe {
                        }
                }
        }
-       @func refer
-       name {
-               @func concat
-               strings [
-                       "cards."
-                       {
-                               @func card_driver
-                               card $CARD
-                       }
-                       ".pcm.center_lfe." $DEV ":CARD=" $CARD
-               ]
+       type empty
+       slave.pcm {
+               @func refer
+               name {
+                       @func concat
+                       strings [
+                               "cards."
+                               {
+                                       @func card_driver
+                                       card $CARD
+                               }
+                               ".pcm.center_lfe." $DEV ":CARD=" $CARD
+                       ]
+               }
+       }
+       hint {
+               show {
+                       @func refer
+                       name defaults.namehint.basic
+               }
+               description "Center and Subwoofer speakers"
        }
 }
index 530174e8c24a24b020c9e80eaee650363112572d..f5de5b56fa01a948f420898d4ad668a15afb9f28 100644 (file)
@@ -12,14 +12,14 @@ pcm.!dmix {
                }
        }
        @args.DEV {
-               type string
+               type integer
                default {
                        @func refer
                        name defaults.pcm.dmix.device
                }
        }
        @args.SUBDEV {
-               type string
+               type integer
                default -1
        }
        @args.FORMAT {
@@ -120,6 +120,10 @@ pcm.!dmix {
                }
        }
        hint {
+               show {
+                       @func refer
+                       name defaults.namehint.extended
+               }
                description "Direct sample mixing device"
                device $DEV
        }
index dc2aa3e2136b2cc84e5360f55d554062536cca1c..14a47d7039e3a896f6f8e810a9283701d81ff528 100644 (file)
@@ -12,14 +12,14 @@ pcm.!dsnoop {
                }
        }
        @args.DEV {
-               type string
+               type integer
                default {
                        @func refer
                        name defaults.pcm.dsnoop.device
                }
        }
        @args.SUBDEV {
-               type string
+               type integer
                default -1
        }
        @args.FORMAT {
@@ -120,6 +120,10 @@ pcm.!dsnoop {
                }
        }
        hint {
+               show {
+                       @func refer
+                       name defaults.namehint.extended
+               }
                description "Direct sample snooping device"
                device $DEV
        }
index 74ba7f2e72c82e455577d20774952c6ee051b9ae..ba92848148a93a39136a6b073a103ab5b4a0378c 100644 (file)
@@ -32,16 +32,26 @@ pcm.!front {
                        }
                }
        }
-       @func refer
-       name {
-               @func concat
-               strings [
-                       "cards."
-                       {
-                               @func card_driver
-                               card $CARD
-                       }
-                       ".pcm.front." $DEV ":CARD=" $CARD
-               ]
+       type empty
+       slave.pcm {
+               @func refer
+               name {
+                       @func concat
+                       strings [
+                               "cards."
+                               {
+                                       @func card_driver
+                                       card $CARD
+                               }
+                               ".pcm.front." $DEV ":CARD=" $CARD
+                       ]
+               }
+       }
+       hint {
+               show {
+                       @func refer
+                       name defaults.namehint.basic
+               }
+               description "Front speakers"
        }
 }
index 555c58d51cbad8c9cb7530af2594166825ee8569..9be622e964e18c9043625f5073733a169c7c94af 100644 (file)
@@ -52,21 +52,31 @@ pcm.!iec958 {
                # fs=48000Hz, clock accuracy=1000ppm
                default 0x02
        }
-       @func refer
-       name {
-               @func concat
-               strings [
-                       "cards."
-                       {
-                               @func card_driver
-                               card $CARD
-                       }
-                       ".pcm.iec958." $DEV ":"
-                       "CARD=" $CARD ","
-                       "AES0=" $AES0 ","
-                       "AES1=" $AES1 ","
-                       "AES2=" $AES2 ","
-                       "AES3=" $AES3
-               ]
+       type empty
+       slave.pcm {
+               @func refer
+               name {
+                       @func concat
+                       strings [
+                               "cards."
+                               {
+                                       @func card_driver
+                                       card $CARD
+                               }
+                               ".pcm.iec958." $DEV ":"
+                               "CARD=" $CARD ","
+                               "AES0=" $AES0 ","
+                               "AES1=" $AES1 ","
+                               "AES2=" $AES2 ","
+                               "AES3=" $AES3
+                       ]
+               }
+       }
+       hint {
+               show {
+                       @func refer
+                       name defaults.namehint.basic
+               }
+               description "IEC958 (S/PDIF) Digital Audio Output"
        }
 }
index 2837c60cb667eceea98825c14bf19252da9c216d..0af0e72c568a0ecacde72549e81fc2f7e21d2adb 100644 (file)
@@ -44,7 +44,7 @@ pcm.!phoneline {
                        ".pcm.modem." $DEV ":CARD=" $CARD
                ]
        }
-       hint 0
+       hint.show off
 }
 
 #
@@ -102,5 +102,5 @@ pcm.!modem {
                }
                ]
        }
-       hint 0
+       hint.show off
 }
index 33b4b90fe0b583c4bfcc2ce8ba5a9316b1374211..952a1d65a06ac8335c43ac415376201090945d9b 100644 (file)
@@ -32,16 +32,26 @@ pcm.!rear {
                        }
                }
        }
-       @func refer
-       name {
-               @func concat
-               strings [
-                       "cards."
-                       {
-                               @func card_driver
-                               card $CARD
-                       }
-                       ".pcm.rear." $DEV ":CARD=" $CARD
-               ]
+       type empty
+       slave.pcm {
+               @func refer
+               name {
+                       @func concat
+                       strings [
+                               "cards."
+                               {
+                                       @func card_driver
+                                       card $CARD
+                               }
+                               ".pcm.rear." $DEV ":CARD=" $CARD
+                       ]
+               }
+       }
+       hint {
+               show {
+                       @func refer
+                       name defaults.namehint.basic
+               }
+               description "Rear speakers"
        }
 }
index b7e644b4720a1beffab0ce91bcdfefaa16a1a356..2d86c7fe283bf35637d4317d65b21082c6635646 100644 (file)
@@ -32,16 +32,26 @@ pcm.!side {
                        }
                }
        }
-       @func refer
-       name {
-               @func concat
-               strings [
-                       "cards."
-                       {
-                               @func card_driver
-                               card $CARD
-                       }
-                       ".pcm.side." $DEV ":CARD=" $CARD
-               ]
+       type empty
+       slave.pcm {
+               @func refer
+               name {
+                       @func concat
+                       strings [
+                               "cards."
+                               {
+                                       @func card_driver
+                                       card $CARD
+                               }
+                               ".pcm.side." $DEV ":CARD=" $CARD
+                       ]
+               }
+       }
+       hint {
+               show {
+                       @func refer
+                       name defaults.namehint.basic
+               }
+               description "Side speakers"
        }
 }
index a3b577aad7d3613adf54e6dc26679b837575ba41..8733f8f73746fe2d6bd3325a23734f1c91329dc2 100644 (file)
@@ -37,16 +37,20 @@ pcm.!surround40 {
                        }
                }
        }
-       @func refer
-       name {
-               @func concat
-               strings [
-                       "cards."
-                       {
-                               @func card_driver
-                               card $CARD
-                       }
-                       ".pcm.surround40." $DEV ":CARD=" $CARD
-               ]
+       type empty
+       slave.pcm {
+               @func refer
+               name {
+                       @func concat
+                       strings [
+                               "cards."
+                               {
+                                       @func card_driver
+                                       card $CARD
+                               }
+                               ".pcm.surround40." $DEV ":CARD=" $CARD
+                       ]
+               }
        }
+       hint.description "4.0 Surround output to Front and Rear speakers"
 }
index 9e504fecb7442d339cca66ce33f2f9a3537ed2fb..69facf102b5eefc0e97c8e6c4a1e5dfbfb82358c 100644 (file)
@@ -59,4 +59,5 @@ pcm.!surround41 {
        ttable.2.2 1
        ttable.3.3 1
        ttable.4.5 1
+       hint.description "4.1 Surround output to Front, Rear and Subwoofer speakers"
 }
index 7e658ec66cd2cf50f35146acc6b6673e1c9555ee..c033fe355c0c5e4b2d356228a825cd2d3eaa8ab5 100644 (file)
@@ -59,4 +59,5 @@ pcm.!surround50 {
        ttable.2.2 1
        ttable.3.3 1
        ttable.4.4 1
+       hint.description "5.0 Surround output to Front, Center and Rear speakers"
 }
index 1347033f96470e82f2167261673f37346f651901..3cd079094b1814ebb31748189c140f88f94058cb 100644 (file)
@@ -39,16 +39,20 @@ pcm.!surround51 {
                        }
                }
        }
-       @func refer
-       name {
-               @func concat
-               strings [
-                       "cards."
-                       {
-                               @func card_driver
-                               card $CARD
-                       }
-                       ".pcm.surround51." $DEV ":CARD=" $CARD
-               ]
+       type empty
+       slave.pcm {
+               @func refer
+               name {
+                       @func concat
+                       strings [
+                               "cards."
+                               {
+                                       @func card_driver
+                                       card $CARD
+                               }
+                               ".pcm.surround51." $DEV ":CARD=" $CARD
+                       ]
+               }
        }
+       hint.description "5.1 Surround output to Front, Center, Rear and Subwoofer speakers"
 }
index 6e6e1cf07d8696de3433b4e571fb2bfc4b09fcec..41a636540b461eafdec43720804f39a1ffd9b715 100644 (file)
@@ -41,16 +41,20 @@ pcm.!surround71 {
                        }
                }
        }
-       @func refer
-       name {
-               @func concat
-               strings [
-                       "cards."
-                       {
-                               @func card_driver
-                               card $CARD
-                       }
-                       ".pcm.surround71." $DEV ":CARD=" $CARD
-               ]
+       type empty
+       slave.pcm {
+               @func refer
+               name {
+                       @func concat
+                       strings [
+                               "cards."
+                               {
+                                       @func card_driver
+                                       card $CARD
+                               }
+                               ".pcm.surround71." $DEV ":CARD=" $CARD
+                       ]
+               }
        }
+       hint.description "7.1 Surround output to Front, Center, Side, Rear and Woofer speakers"
 }
index a77bd893452dd07ce1f9fa1040c23160e52b8daf..81445835ada42f6c75bab67815697c06f12b31d6 100644 (file)
@@ -493,16 +493,6 @@ static int snd_func_iops(snd_config_t **dst,
                        }
                        if (i == idx) {
                                idx++;
-#if 1
-       {
-                        snd_output_t *out;
-                        fprintf(stderr, "********* ID '%s':\n", id);
-                        snd_output_stdio_attach(&out, stderr, 0);
-                        snd_config_save(n, out);
-                        snd_output_close(out);
-                        printf("\n");
-       }
-#endif
                                err = snd_config_get_integer(n, &val);
                                if (err < 0) {
                                        SNDERR("invalid integer for id %s", id);
index 4e5b0b01c03d14d990f12b0ae14addf9eb8f2bee..23ae7396aecfa69f2f56c8b3d6c253e3a374b494 100644 (file)
@@ -40,6 +40,8 @@ struct hint_list {
        long device_input;
        long device_output;
        int stream;
+       int show_all;
+       char *longname;
 };
 #endif
 
@@ -80,10 +82,11 @@ static void zero_handler(const char *file ATTRIBUTE_UNUSED,
 {
 }
 
-static char *get_dev_name1(struct hint_list *list)
+static int get_dev_name1(struct hint_list *list, char **res)
 {
+       *res = NULL;
        if (list->device < 0)
-               return NULL;
+               return 0;
        switch (list->iface) {
        case SND_CTL_ELEM_IFACE_HWDEP:
                {
@@ -91,8 +94,9 @@ static char *get_dev_name1(struct hint_list *list)
                        snd_hwdep_info_alloca(&info);
                        snd_hwdep_info_set_device(info, list->device);
                        if (snd_ctl_hwdep_info(list->ctl, info) < 0)
-                               return NULL;
-                       return strdup(snd_hwdep_info_get_name(info));
+                               return 0;
+                       *res = strdup(snd_hwdep_info_get_name(info));
+                       return 0;
                }
        case SND_CTL_ELEM_IFACE_PCM:
                {
@@ -101,15 +105,16 @@ static char *get_dev_name1(struct hint_list *list)
                        snd_pcm_info_set_device(info, list->device);
                        snd_pcm_info_set_stream(info, list->stream ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK);
                        if (snd_ctl_pcm_info(list->ctl, info) < 0)
-                               return NULL;
+                               return 0;
                        switch (snd_pcm_info_get_class(info)) {
                        case SND_PCM_CLASS_MODEM:
                        case SND_PCM_CLASS_DIGITIZER:
-                               return NULL;
+                               return -ENODEV;
                        default:
                                break;
                        }
-                       return strdup(snd_pcm_info_get_name(info));
+                       *res = strdup(snd_pcm_info_get_name(info));
+                       return 0;
                }
        case SND_CTL_ELEM_IFACE_RAWMIDI:
                {
@@ -118,11 +123,12 @@ static char *get_dev_name1(struct hint_list *list)
                        snd_rawmidi_info_set_device(info, list->device);
                        snd_rawmidi_info_set_stream(info, list->stream ? SND_RAWMIDI_STREAM_INPUT : SND_RAWMIDI_STREAM_OUTPUT);
                        if (snd_ctl_rawmidi_info(list->ctl, info) < 0)
-                               return NULL;
-                       return strdup(snd_rawmidi_info_get_name(info));
+                               return 0;
+                       *res = strdup(snd_rawmidi_info_get_name(info));
+                       return 0;
                }
        default:
-               return NULL;
+               return 0;
        }
 }
 
@@ -132,49 +138,60 @@ static char *get_dev_name(struct hint_list *list)
        
        list->device = list->device_input >= 0 ? list->device_input : list->device;
        list->stream = 1;
-       str1 = get_dev_name1(list);
+       if (get_dev_name1(list, &str1) < 0)
+               return NULL;
        list->device = list->device_output >= 0 ? list->device_input : list->device;
        list->stream = 0;
-       str2 = get_dev_name1(list);
+       if (get_dev_name1(list, &str2) < 0) {
+               if (str1)
+                       free(str1);
+               return NULL;
+       }
        if (str1 != NULL || str2 != NULL) {
                if (str1 != NULL && str2 != NULL) {
                        if (strcmp(str1, str2) == 0) {
-                               free(str1);
-                               return str2;
-                       }
-                       res = realloc(str2, strlen(str2) + strlen(str1) + 4);
-                       if (res != NULL) {
-                               strcat(res, " / ");
-                               strcat(res, str1);
-                               free(str1);
-                               return res;
+                               res = malloc(strlen(list->longname) + strlen(str2) + 3);
+                               if (res != NULL) {
+                                       strcpy(res, list->longname);
+                                       strcat(res, ", ");
+                                       strcat(res, str2);
+                               }
                        } else {
-                               free(str2);
-                               free(str1);
+                               res = malloc(strlen(list->longname) + strlen(str2) + strlen(str1) + 6);
+                               if (res != NULL) {
+                                       strcpy(res, list->longname);
+                                       strcat(res, ", ");
+                                       strcat(res, str2);
+                                       strcat(res, " / ");
+                                       strcat(res, str1);
+                               }
                        }
+                       free(str2);
+                       free(str1);
+                       return res;
                } else {
                        if (str1 != NULL) {
-                               res = realloc(str1, strlen(str1) + 16);
-                               if (res == NULL) {
-                                       free(str1);
-                                       return NULL;
-                               }
-                               strcat(res, " {");
-                               strcat(res, list->iface == SND_CTL_ELEM_IFACE_PCM ? "Capture" : "Input");
-                               strcat(res, "}");
-                               return res;
+                               str2 = list->iface == SND_CTL_ELEM_IFACE_PCM ? "Capture" : "Input";
                        } else {
-                               res = realloc(str2, strlen(str2) + 16);
-                               if (res == NULL) {
-                                       free(str2);
-                                       return NULL;
-                               }
-                               strcat(res, " {");
-                               strcat(res, list->iface == SND_CTL_ELEM_IFACE_PCM ? "Playback" : "Output");
-                               strcat(res, "}");
-                               return res;
+                               str1 = str2;
+                               str2 = list->iface == SND_CTL_ELEM_IFACE_PCM ? "Playback" : "Output";
                        }
+                       res = malloc(strlen(list->longname) + strlen(str1) + 19);
+                       if (res == NULL) {
+                               free(str1);
+                               return NULL;
+                       }
+                       strcpy(res, list->longname);
+                       strcat(res, ", ");
+                       strcat(res, str1);
+                       strcat(res, " {");
+                       strcat(res, list->iface == SND_CTL_ELEM_IFACE_PCM ? "Capture" : "Input");
+                       strcat(res, "}");
+                       free(str1);
+                       return res;
                }
+       } else {
+               return strdup(list->longname);
        }
        return NULL;
 }
@@ -188,11 +205,11 @@ static int try_config(struct hint_list *list,
                      const char *name)
 {
        snd_lib_error_handler_t eh;
-       snd_config_t *res, *cfg, *n;
+       snd_config_t *res = NULL, *cfg, *n;
        snd_config_iterator_t i, next;
        char *buf, *buf1 = NULL, *buf2;
        const char *str;
-       int err;
+       int err = 0, level;
        long dev = list->device;
 
        list->device_input = -1;
@@ -200,6 +217,13 @@ static int try_config(struct hint_list *list,
        buf = malloc(BUF_SIZE);
        if (buf == NULL)
                return -ENOMEM;
+       sprintf(buf, "%s.%s", base, name);
+       /* look for redirection */
+       if (snd_config_search(snd_config, buf, &cfg) >= 0 &&
+           snd_config_get_string(cfg, &str) >= 0 &&
+           ((strncmp(base, str, strlen(base)) == 0 &&
+            str[strlen(base)] == '.') || strchr(str, '.') == NULL))
+               goto __skip_add;
        if (list->card >= 0 && list->device >= 0)
                sprintf(buf, "%s:CARD=%s,DEV=%i", name, snd_ctl_card_info_get_id(list->info), list->device);
        else if (list->card >= 0)
@@ -211,62 +235,76 @@ static int try_config(struct hint_list *list,
        err = snd_config_search_definition(snd_config, base, buf, &res);
        snd_lib_error_set_handler(eh);
        if (err < 0)
-               return err;
+               goto __skip_add;
        err = -EINVAL;
        if (snd_config_get_type(res) != SND_CONFIG_TYPE_COMPOUND)
                goto __cleanup;
        if (snd_config_search(res, "type", NULL) < 0)
                goto __cleanup;
+
+#if 0  /* for debug purposes */
+               {
+                       snd_output_t *out;
+                       fprintf(stderr, "********* PCM '%s':\n", buf);
+                       snd_output_stdio_attach(&out, stderr, 0);
+                       snd_config_save(res, out);
+                       snd_output_close(out);
+                       fprintf(stderr, "\n");
+               }
+#endif
+
        cfg = res;
+       level = 0;
       __hint:
+       level++;
        if (snd_config_search(cfg, "hint", &cfg) >= 0) {
-               if (snd_config_get_type(cfg) == SND_CONFIG_TYPE_COMPOUND) {
-                       if (snd_config_search(cfg, "description", &n) >= 0 &&
-                           snd_config_get_string(n, &str) >= 0) {
-                               buf1 = strdup(str);
-                               if (buf1 == NULL) {
-                                       err = -ENOMEM;
-                                       goto __cleanup;
-                               }
+               if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
+                       SNDERR("hint (%s) must be a compound", buf);
+                       err = -EINVAL;
+                       goto __cleanup;
+               }
+               if (level == 1 &&
+                   snd_config_search(cfg, "show", &n) >= 0 &&
+                   snd_config_get_bool(n) <= 0)
+                       goto __skip_add;
+               if (buf1 == NULL &&
+                   snd_config_search(cfg, "description", &n) >= 0 &&
+                   snd_config_get_string(n, &str) >= 0) {
+                       buf1 = strdup(str);
+                       if (buf1 == NULL) {
+                               err = -ENOMEM;
+                               goto __cleanup;
                        }
-                       if (snd_config_search(cfg, "device", &n) >= 0) {
-                               if (snd_config_get_integer(n, &dev) < 0) {
-                                       err = -EINVAL;
-                                       goto __cleanup;
-                               }
+               }
+               if (snd_config_search(cfg, "device", &n) >= 0) {
+                       if (snd_config_get_integer(n, &dev) < 0) {
+                               SNDERR("(%s) device must be an integer", buf);
+                               err = -EINVAL;
+                               goto __cleanup;
                        }
-                       if (snd_config_search(cfg, "device_input", &n) >= 0) {
-                               if (snd_config_get_integer(n, &list->device_input) < 0) {
-                                       err = -EINVAL;
-                                       goto __cleanup;
-                               }
+                       list->device_input = -1;
+                       list->device_output = -1;
+               }
+               if (snd_config_search(cfg, "device_input", &n) >= 0) {
+                       if (snd_config_get_integer(n, &list->device_input) < 0) {
+                               SNDERR("(%s) device_input must be an integer", buf);
+                               err = -EINVAL;
+                               goto __cleanup;
                        }
-                       if (snd_config_search(cfg, "device_output", &n) >= 0) {
-                               if (snd_config_get_integer(n, &list->device_output) < 0) {
-                                       err = -EINVAL;
-                                       goto __cleanup;
-                               }
+                       list->device_output = -1;
+               }
+               if (snd_config_search(cfg, "device_output", &n) >= 0) {
+                       if (snd_config_get_integer(n, &list->device_output) < 0) {
+                               SNDERR("(%s) device_output must be an integer", buf);
+                               err = -EINVAL;
+                               goto __cleanup;
                        }
-               } else if (snd_config_get_bool(cfg) == 0) {
-                       err = -EXDEV;
-                       goto __cleanup;
                }
-               goto __hint_ok;
-       }
+       } else if (level == 1 && !list->show_all)
+               goto __skip_add;
        if (snd_config_search(cfg, "slave", &cfg) >= 0 &&
            snd_config_search(cfg, base, &cfg) >= 0)
                goto __hint;
-      __hint_ok:
-#if 0  /* for debug purposes */
-               {
-                       snd_output_t *out;
-                       fprintf(stderr, "********* PCM '%s':\n", buf);
-                       snd_output_stdio_attach(&out, stderr, 0);
-                       snd_config_save(res, out);
-                       snd_output_close(out);
-                       printf("\n");
-               }
-#endif
        snd_config_delete(res);
        res = NULL;
        if (strchr(buf, ':') != NULL)
@@ -291,16 +329,14 @@ static int try_config(struct hint_list *list,
       __ok:
        err = 0;
       __cleanup:
-       if (res)
-               snd_config_delete(res);
        if (err >= 0) {
                list->device = dev;
-               str = get_dev_name(list);
+               str = list->card >= 0 ? get_dev_name(list) : NULL;
                if (str != NULL) {
-                       buf2 = realloc((char *)str, (buf1 == NULL ? 0 : strlen(buf1)) + 2 + strlen(str) + 1);
+                       buf2 = realloc((char *)str, (buf1 == NULL ? 0 : strlen(buf1)) + 1 + strlen(str) + 1);
                        if (buf2 != NULL) {
                                if (buf1 != NULL) {
-                                       strcat(buf2, "");
+                                       strcat(buf2, "\n");
                                        strcat(buf2, buf1);
                                        free(buf1);
                                }
@@ -313,6 +349,8 @@ static int try_config(struct hint_list *list,
                err = hint_list_add(list, buf, buf1);
        }
       __skip_add:
+       if (res)
+               snd_config_delete(res);
        if (buf1)
                free(buf1);
        free(buf);
@@ -348,8 +386,6 @@ static int add_card(struct hint_list *list, int card, snd_ctl_elem_iface_t iface
        list->info = info;
        if (iface > SND_CTL_ELEM_IFACE_LAST)
                return -EINVAL;
-       if (snd_card_get_name(card, (char **)&str) < 0)
-               return 0;
        base = snd_ctl_iface_conf_name(iface);
        err = snd_config_search(snd_config, base, &conf);
        if (err < 0)
@@ -399,8 +435,7 @@ static int add_card(struct hint_list *list, int card, snd_ctl_elem_iface_t iface
        }
        err = 0;
       __error:
-       if (err < 0)
-               snd_ctl_close(list->ctl);
+       snd_ctl_close(list->ctl);
        return err;
 }
 
@@ -421,6 +456,9 @@ static int add_card(struct hint_list *list, int card, snd_ctl_elem_iface_t iface
  *   myplug "plug:front:Do all conversions for front speakers"<br>
  * }
  * </code>
+ *
+ * Special variables: defaults.namehint.showall specifies if all device
+ * definitions are accepted (boolean type).
  */
 int snd_device_name_hint(int card, snd_ctl_elem_iface_t iface, char ***hints)
 {
@@ -439,6 +477,10 @@ int snd_device_name_hint(int card, snd_ctl_elem_iface_t iface, char ***hints)
        list.list = NULL;
        list.count = list.allocated = 0;
        list.iface = iface;
+       list.show_all = 0;
+       list.longname = NULL;
+       if (snd_config_search(snd_config, "defaults.namehint.showall", &conf) >= 0)
+               list.show_all = snd_config_get_bool(conf) > 0;
        if (card >= 0) {
                err = add_card(&list, card, iface);
        } else {
@@ -446,6 +488,9 @@ int snd_device_name_hint(int card, snd_ctl_elem_iface_t iface, char ***hints)
                if (err < 0)
                        goto __error;
                while (card >= 0) {
+                       err = snd_card_get_longname(card, &list.longname);
+                       if (err < 0)
+                               goto __error;
                        err = add_card(&list, card, iface);
                        if (err < 0)
                                goto __error;
@@ -470,12 +515,16 @@ int snd_device_name_hint(int card, snd_ctl_elem_iface_t iface, char ***hints)
       __error:
        if (err < 0) {
                snd_device_name_free_hint(list.list);
+               if (list.longname)
+                       free(list.longname);
                return err;
        } else {
                err = hint_list_add(&list, NULL, NULL);
                if (err < 0)
                        goto __error;
                *hints = list.list;
+               if (list.longname)
+                       free(list.longname);
        }
        return 0;
 }
index 990ad330db70e2d43d4a6a1746cf8649095e7861..95e7ad048459715f32fdb1fa6b3a75a4ed5fe002 100644 (file)
@@ -46,6 +46,9 @@ endif
 if BUILD_PCM_PLUGIN_NULL
 libpcm_la_SOURCES += pcm_null.c
 endif
+if BUILD_PCM_PLUGIN_EMPTY
+libpcm_la_SOURCES += pcm_empty.c
+endif
 if BUILD_PCM_PLUGIN_SHARE
 libpcm_la_SOURCES += pcm_share.c
 endif
index bba665d90cba24b3e1a6c71c4889fc18153d51b3..6c520425db22101284f1f23f20d63a0a406583f7 100644 (file)
@@ -1983,7 +1983,7 @@ snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler)
 
 static char *build_in_pcms[] = {
        "adpcm", "alaw", "copy", "dmix", "file", "hooks", "hw", "ladspa", "lfloat",
-       "linear", "meter", "mulaw", "multi", "null", "plug", "rate", "route", "share",
+       "linear", "meter", "mulaw", "multi", "null", "empty", "plug", "rate", "route", "share",
        "shm", "dsnoop", "dshare", "asym", "iec958", "softvol", NULL
 };