From: Takashi Iwai Date: Wed, 26 Jan 2005 10:50:28 +0000 (+0000) Subject: Add resmgr support X-Git-Tag: v1.0.9rc1~42 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=77c925a71f32297f6504b2bdeb0ca4e721d0e9e9;p=alsa-lib.git Add resmgr support Added the support for resmgr. A new configure option --with-resmgr is added to enable the resmgr support. --- diff --git a/configure.in b/configure.in index abfa12b1..c2bb6e5d 100644 --- a/configure.in +++ b/configure.in @@ -171,6 +171,18 @@ arm*) ;; esac +dnl Check for resmgr support... +AC_MSG_CHECKING(for resmgr support) +AC_ARG_WITH(resmgr, + [ --with-resmgr support resmgr (optional)], + resmgr="$withval", resmgr="no") +AC_MSG_RESULT($resmgr) +if test "$resmgr" = "yes"; then + AC_CHECK_LIB(resmgr, rsm_open_device,, + AC_ERROR([Cannot find libresmgr])) + AC_DEFINE(SUPPORT_RESMGR, "1", [Support resmgr with alsa-lib]) +fi + dnl Make a symlink for inclusion of alsa/xxx.h if test ! -L include/alsa ; then echo "Making a symlink include/alsa" diff --git a/src/control/cards.c b/src/control/cards.c index 994ffbe1..fbadb17c 100644 --- a/src/control/cards.c +++ b/src/control/cards.c @@ -33,6 +33,9 @@ #include #include #include "control_local.h" +#ifdef SUPPORT_RESMGR +#include +#endif #ifndef DOC_HIDDEN #define SND_FILE_CONTROL "/dev/snd/controlC%i" @@ -51,10 +54,19 @@ int snd_card_load(int card) sprintf(control, SND_FILE_CONTROL, card); - if ((open_dev=open(control, O_RDONLY)) < 0) { +#ifdef SUPPORT_RESMGR + open_dev = rsm_open_device(control, O_RDONLY); +#else + open_dev = open(control, O_RDONLY); +#endif + if (open_dev < 0) { char aload[32]; sprintf(aload, SND_FILE_LOAD, card); +#ifdef SUPPORT_RESMGR + open_dev = rsm_open_device(aload, O_RDONLY); +#else open_dev = open(aload, O_RDONLY); +#endif } if (open_dev >= 0) { close (open_dev); diff --git a/src/control/control_hw.c b/src/control/control_hw.c index 4e9dd07f..eb4a594a 100644 --- a/src/control/control_hw.c +++ b/src/control/control_hw.c @@ -28,6 +28,9 @@ #include #include #include "control_local.h" +#ifdef SUPPORT_RESMGR +#include +#endif #ifndef PIC /* entry for static linking */ @@ -337,9 +340,19 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode) fmode |= O_NONBLOCK; if (mode & SND_CTL_ASYNC) fmode |= O_ASYNC; - if ((fd = open(filename, fmode)) < 0) { +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(filename, fmode); +#else + fd = open(filename, fmode); +#endif + if (fd < 0) { snd_card_load(card); - if ((fd = open(filename, O_RDWR)) < 0) +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(filename, fmode); +#else + fd = open(filename, fmode); +#endif + if (fd < 0) return -errno; } #if 0 diff --git a/src/hwdep/hwdep_hw.c b/src/hwdep/hwdep_hw.c index 59ff6d17..22b7da12 100644 --- a/src/hwdep/hwdep_hw.c +++ b/src/hwdep/hwdep_hw.c @@ -26,6 +26,9 @@ #include #include #include "hwdep_local.h" +#ifdef SUPPORT_RESMGR +#include +#endif #ifndef PIC /* entry for static linking */ @@ -115,9 +118,19 @@ int snd_hwdep_hw_open(snd_hwdep_t **handle, const char *name, int card, int devi if (card < 0 || card >= 32) return -EINVAL; sprintf(filename, SNDRV_FILE_HWDEP, card, device); - if ((fd = open(filename, mode)) < 0) { +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(filename, mode); +#else + fd = open(filename, mode); +#endif + if (fd < 0) { snd_card_load(card); - if ((fd = open(filename, mode)) < 0) +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(filename, mode); +#else + fd = open(filename, mode); +#endif + if (fd < 0) return -errno; } #if 0 diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 499bd0cc..91440540 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -39,6 +39,9 @@ #include #include "pcm_local.h" #include "../control/control_local.h" +#ifdef SUPPORT_RESMGR +#include +#endif //#define DEBUG_RW /* use to debug readi/writei/readn/writen */ //#define DEBUG_MMAP /* debug mmap_commit */ @@ -1203,7 +1206,12 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, fmode |= O_NONBLOCK; if (mode & SND_PCM_ASYNC) fmode |= O_ASYNC; - if ((fd = open(filename, fmode)) < 0) { +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(filename, fmode); +#else + fd = open(filename, fmode); +#endif + if (fd < 0) { ret = -errno; SYSMSG("open %s failed", filename); goto _err; diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c index ff4d523f..279e6919 100644 --- a/src/rawmidi/rawmidi_hw.c +++ b/src/rawmidi/rawmidi_hw.c @@ -28,6 +28,9 @@ #include #include "../control/control_local.h" #include "rawmidi_local.h" +#ifdef SUPPORT_RESMGR +#include +#endif #ifndef PIC /* entry for static linking */ @@ -220,9 +223,19 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, assert(!(mode & ~(SND_RAWMIDI_APPEND|SND_RAWMIDI_NONBLOCK|SND_RAWMIDI_SYNC))); - if ((fd = open(filename, fmode)) < 0) { +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(filename, fmode); +#else + fd = open(filename, fmode); +#endif + if (fd < 0) { snd_card_load(card); - if ((fd = open(filename, fmode)) < 0) { +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(filename, fmode); +#else + fd = open(filename, fmode); +#endif + if (fd < 0) { snd_ctl_close(ctl); SYSERR("open %s failed", filename); return -errno; diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c index 6e9b70cb..d1b3a336 100644 --- a/src/seq/seq_hw.c +++ b/src/seq/seq_hw.c @@ -23,6 +23,9 @@ #include #include #include "seq_local.h" +#ifdef SUPPORT_RESMGR +#include +#endif #ifndef PIC /* entry for static linking */ @@ -415,7 +418,7 @@ snd_seq_ops_t snd_seq_hw_ops = { int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode) { int fd, ver, client, fmode, ret; - char filename[32]; + const char *filename; snd_seq_t *seq; snd_seq_hw_t *hw; @@ -439,10 +442,26 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode) if (mode & SND_SEQ_NONBLOCK) fmode |= O_NONBLOCK; - sprintf(filename, SNDRV_FILE_SEQ); - if ((fd = open(filename, fmode)) < 0) { - close(open(SNDRV_FILE_ALOADSEQ, O_RDWR)); - if ((fd = open(filename, fmode)) < 0) { + filename = SNDRV_FILE_SEQ; +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(filename, fmode); +#else + fd = open(filename, fmode); +#endif + if (fd < 0) { +#ifdef SUPPORT_RESMGR + fd = open(SNDRV_FILE_ALOADSEQ, O_RDWR); +#else + fd = open(SNDRV_FILE_ALOADSEQ, fmode); +#endif + if (fd >= 0) + close(fd); +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(filename, fmode); +#else + fd = open(filename, fmode); +#endif + if (fd < 0) { SYSERR("open %s failed", filename); return -errno; } diff --git a/src/timer/timer_hw.c b/src/timer/timer_hw.c index 2ea2aa98..d09c7a8f 100644 --- a/src/timer/timer_hw.c +++ b/src/timer/timer_hw.c @@ -27,6 +27,9 @@ #include #include #include "timer_local.h" +#ifdef SUPPORT_RESMGR +#include +#endif #ifndef PIC /* entry for static linking */ @@ -211,7 +214,12 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int tmode = O_RDONLY; if (mode & SND_TIMER_OPEN_NONBLOCK) tmode |= O_NONBLOCK; - if ((fd = open(SNDRV_FILE_TIMER, tmode)) < 0) +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(SNDRV_FILE_TIMER, tmode); +#else + fd = open(SNDRV_FILE_TIMER, tmode); +#endif + if (fd < 0) return -errno; #if 0 /* diff --git a/src/timer/timer_query_hw.c b/src/timer/timer_query_hw.c index 5f1e5b6a..cb0e03c8 100644 --- a/src/timer/timer_query_hw.c +++ b/src/timer/timer_query_hw.c @@ -26,6 +26,9 @@ #include #include #include "timer_local.h" +#ifdef SUPPORT_RESMGR +#include +#endif #ifndef PIC /* entry for static linking */ @@ -99,7 +102,12 @@ int snd_timer_query_hw_open(snd_timer_query_t **handle, const char *name, int mo tmode = O_RDONLY; if (mode & SND_TIMER_OPEN_NONBLOCK) tmode |= O_NONBLOCK; - if ((fd = open(SNDRV_FILE_TIMER, tmode)) < 0) +#ifdef SUPPORT_RESMGR + fd = rsm_open_device(SNDRV_FILE_TIMER, tmode); +#else + fd = open(SNDRV_FILE_TIMER, tmode); +#endif + if (fd < 0) return -errno; if (ioctl(fd, SNDRV_TIMER_IOCTL_PVERSION, &ver) < 0) { close(fd);