]> git.alsa-project.org Git - alsa-lib.git/commitdiff
allow changing of device directory path
authorClemens Ladisch <clemens@ladisch.de>
Mon, 27 Feb 2006 10:03:19 +0000 (10:03 +0000)
committerClemens Ladisch <clemens@ladisch.de>
Mon, 27 Feb 2006 10:03:19 +0000 (10:03 +0000)
Add configuration options to change the default device path from the
default /dev/snd.  This is useful for embedded systems that do not want
subdirectories in /dev.

configure.in
src/control/cards.c
src/control/control_hw.c
src/hwdep/hwdep_hw.c
src/pcm/pcm_hw.c
src/rawmidi/rawmidi_hw.c
src/seq/seq_hw.c
src/timer/timer_hw.c
src/timer/timer_query_hw.c

index bf11e899dbb1ff1eb1ec5818d5cf539072d36748..c4a2b3f406f00f51913559e0bca1a8bd4b71d48d 100644 (file)
@@ -196,6 +196,30 @@ if test "$aload" = "yes"; then
   AC_DEFINE(SUPPORT_ALOAD, "1", [Support /dev/aload* access for auto-loading])
 fi
 
+dnl Check for non-standard /dev directory
+AC_MSG_CHECKING([for ALSA device file directory])
+AC_ARG_WITH(alsa-devdir,
+  [  --with-alsa-devdir=dir  directory with ALSA device files (default /dev/snd)],
+  [alsa_dev_dir="$withval"],
+  [alsa_dev_dir="/dev/snd"])
+dnl make sure it has a trailing slash
+if echo "$alsa_dev_dir" | grep -v '/$' > /dev/null; then
+  alsa_dev_dir="$alsa_dev_dir/"
+fi
+AC_DEFINE_UNQUOTED(ALSA_DEVICE_DIRECTORY, "$alsa_dev_dir", [Directory with ALSA device files])
+AC_MSG_RESULT([$alsa_dev_dir])
+
+AC_MSG_CHECKING([for aload* device file directory])
+AC_ARG_WITH(aload-devdir,
+  [  --with-aload-devdir=dir directory with aload* device files (default /dev)],
+  [aload_dev_dir="$withval"],
+  [aload_dev_dir="/dev"])
+if echo "$aload_dev_dir" | grep -v '/$' > /dev/null; then
+  aload_dev_dir="$aload_dev_dir/"
+fi
+AC_DEFINE_UNQUOTED(ALOAD_DEVICE_DIRECTORY, "$aload_dev_dir", [Directory with aload* device files])
+AC_MSG_RESULT([$aload_dev_dir])
+
 dnl Build conditions
 AC_ARG_ENABLE(mixer,
   [  --disable-mixer     Disable the mixer component],
index 2e313693d3d1f814bba09dde7842df742cadc723..c0b05b628499a8ce81edb9ca8f48f056f3039ac1 100644 (file)
@@ -35,8 +35,8 @@
 #include "control_local.h"
 
 #ifndef DOC_HIDDEN
-#define SND_FILE_CONTROL       "/dev/snd/controlC%i"
-#define SND_FILE_LOAD          "/dev/aloadC%i"
+#define SND_FILE_CONTROL       ALSA_DEVICE_DIRECTORY "controlC%i"
+#define SND_FILE_LOAD          ALOAD_DEVICE_DIRECTORY "aloadC%i"
 #endif
 
 /**
 int snd_card_load(int card)
 {
        int open_dev;
-       char control[32];
+       char control[sizeof(SND_FILE_CONTROL) + 10];
 
        sprintf(control, SND_FILE_CONTROL, card);
 
        open_dev = snd_open_device(control, O_RDONLY);
 #ifdef SUPPORT_ALOAD
        if (open_dev < 0) {
-               char aload[32];
+               char aload[sizeof(SND_FILE_LOAD) + 10];
                sprintf(aload, SND_FILE_LOAD, card);
                open_dev = snd_open_device(aload, O_RDONLY);
        }
index 9e4e13e37c300a2fcca72b1b057965eefdcb2428..ac1f231cc41c0dd9137251b142144a1cf6b718b8 100644 (file)
@@ -39,7 +39,7 @@ const char *_snd_module_control_hw = "";
 #endif
 
 #ifndef DOC_HIDDEN
-#define SNDRV_FILE_CONTROL     "/dev/snd/controlC%i"
+#define SNDRV_FILE_CONTROL     ALSA_DEVICE_DIRECTORY "controlC%i"
 #define SNDRV_CTL_VERSION_MAX  SNDRV_PROTOCOL_VERSION(2, 0, 3)
 
 typedef struct {
@@ -321,7 +321,7 @@ snd_ctl_ops_t snd_ctl_hw_ops = {
 int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
 {
        int fd, ver;
-       char filename[32];
+       char filename[sizeof(SNDRV_FILE_CONTROL) + 10];
        int fmode;
        snd_ctl_t *ctl;
        snd_ctl_hw_t *hw;
index 73a3637c322b2b922c349433455fd0a0c7777792..1adaf6ffca6243b32ad71bcec1a3e04cdb6e9e73 100644 (file)
@@ -32,7 +32,7 @@
 const char *_snd_module_hwdep_hw = "";
 #endif
 
-#define SNDRV_FILE_HWDEP       "/dev/snd/hwC%iD%i"
+#define SNDRV_FILE_HWDEP       ALSA_DEVICE_DIRECTORY "hwC%iD%i"
 #define SNDRV_HWDEP_VERSION_MAX        SNDRV_PROTOCOL_VERSION(1, 0, 1)
 
 static int snd_hwdep_hw_close(snd_hwdep_t *hwdep)
@@ -106,7 +106,7 @@ static snd_hwdep_ops_t snd_hwdep_hw_ops = {
 int snd_hwdep_hw_open(snd_hwdep_t **handle, const char *name, int card, int device, int mode)
 {
        int fd, ver, ret;
-       char filename[32];
+       char filename[sizeof(SNDRV_FILE_HWDEP) + 20];
        snd_hwdep_t *hwdep;
        assert(handle);
 
index ef725d26169f0f8f3f8bf1168efefed83180979a..4c7c0fbfb63c1e2e3b44499ca5cebeb9669fdcc0 100644 (file)
@@ -99,8 +99,8 @@ typedef struct {
        snd_pcm_uframes_t appl_ptr;
 } snd_pcm_hw_t;
 
-#define SNDRV_FILE_PCM_STREAM_PLAYBACK         "/dev/snd/pcmC%iD%ip"
-#define SNDRV_FILE_PCM_STREAM_CAPTURE          "/dev/snd/pcmC%iD%ic"
+#define SNDRV_FILE_PCM_STREAM_PLAYBACK         ALSA_DEVICE_DIRECTORY "pcmC%iD%ip"
+#define SNDRV_FILE_PCM_STREAM_CAPTURE          ALSA_DEVICE_DIRECTORY "pcmC%iD%ic"
 #define SNDRV_PCM_VERSION_MAX                  SNDRV_PROTOCOL_VERSION(2, 0, 5)
 
 /* update appl_ptr with driver */
@@ -1167,7 +1167,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
                    snd_pcm_stream_t stream, int mode,
                    int mmap_emulation, int sync_ptr_ioctl)
 {
-       char filename[32];
+       char filename[sizeof(SNDRV_FILE_PCM_STREAM_PLAYBACK) + 20];
        const char *filefmt;
        int ret = 0, fd = -1;
        int attempt = 0;
index d33bbbe31802df945ddb30bdc47b503a221bff7f..2f7d9a294f805a0f171e9017e48a7fd86cd5e31e 100644 (file)
@@ -34,7 +34,7 @@
 const char *_snd_module_rawmidi_hw = "";
 #endif
 
-#define SNDRV_FILE_RAWMIDI             "/dev/snd/midiC%iD%i"
+#define SNDRV_FILE_RAWMIDI             ALSA_DEVICE_DIRECTORY "midiC%iD%i"
 #define SNDRV_RAWMIDI_VERSION_MAX      SNDRV_PROTOCOL_VERSION(2, 0, 0)
 
 #ifndef DOC_HIDDEN
@@ -175,7 +175,7 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
 {
        int fd, ver, ret;
        int attempt = 0;
-       char filename[32];
+       char filename[sizeof(SNDRV_FILE_RAWMIDI) + 20];
        snd_ctl_t *ctl;
        snd_rawmidi_t *rmidi;
        snd_rawmidi_hw_t *hw = NULL;
index 56d87a11c602340ed6b3bf622fa8c9a869818b5c..8876e60dff8c2c73369cd76270ac5241c189b297 100644 (file)
@@ -30,8 +30,8 @@ const char *_snd_module_seq_hw = "";
 #endif
 
 #ifndef DOC_HIDDEN
-#define SNDRV_FILE_SEQ         "/dev/snd/seq"
-#define SNDRV_FILE_ALOADSEQ    "/dev/aloadSEQ"
+#define SNDRV_FILE_SEQ         ALSA_DEVICE_DIRECTORY "seq"
+#define SNDRV_FILE_ALOADSEQ    ALOAD_DEVICE_DIRECTORY "aloadSEQ"
 #define SNDRV_SEQ_VERSION_MAX  SNDRV_PROTOCOL_VERSION(1, 0, 1)
 
 typedef struct {
index 2fc576c558c25b0fb08eb84ac8601bc5508a97db..1a03c2cab46885a065fea9a80ed94b2d7ccf7384 100644 (file)
@@ -33,7 +33,7 @@
 const char *_snd_module_timer_hw = "";
 #endif
 
-#define SNDRV_FILE_TIMER               "/dev/snd/timer"
+#define SNDRV_FILE_TIMER               ALSA_DEVICE_DIRECTORY "timer"
 #define SNDRV_TIMER_VERSION_MAX        SNDRV_PROTOCOL_VERSION(2, 0, 5)
 
 #define SNDRV_TIMER_IOCTL_STATUS_OLD   _IOW('T', 0x14, struct sndrv_timer_status)
index 29c86fff51920f778ac30f6b2fecc8dbb5370469..85a87317e66e80a629fe5110b17458355aaac0e4 100644 (file)
@@ -32,7 +32,7 @@
 const char *_snd_module_timer_query_hw = "";
 #endif
 
-#define SNDRV_FILE_TIMER               "/dev/snd/timer"
+#define SNDRV_FILE_TIMER               ALSA_DEVICE_DIRECTORY "timer"
 #define SNDRV_TIMER_VERSION_MAX        SNDRV_PROTOCOL_VERSION(2, 0, 0)
 
 static int snd_timer_query_hw_close(snd_timer_query_t *handle)