mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Fix resmgr support
Call normal open() before trying with res_open_device(). snd_open_device() is defined to do this procedure.
This commit is contained in:
parent
237d46cfb6
commit
f9b9015245
9 changed files with 30 additions and 94 deletions
|
|
@ -34,6 +34,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#ifdef SUPPORT_RESMGR
|
||||||
|
#include <resmgr.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _snd_config_iterator list_head
|
#define _snd_config_iterator list_head
|
||||||
#define _snd_interval sndrv_interval
|
#define _snd_interval sndrv_interval
|
||||||
|
|
@ -216,4 +219,17 @@ extern snd_lib_error_handler_t snd_err_msg;
|
||||||
# define link_warning(symbol, msg)
|
# define link_warning(symbol, msg)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* open with resmgr */
|
||||||
|
#ifdef SUPPORT_RESMGR
|
||||||
|
static inline int snd_open_device(const char *filename, int fmode)
|
||||||
|
{
|
||||||
|
int fd = open(filename, fmode);
|
||||||
|
if (fd >= 0)
|
||||||
|
return fd;
|
||||||
|
return rsm_open_device(filename, fmode);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define snd_open_device(filename, fmode) open(filename, fmode);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "control_local.h"
|
#include "control_local.h"
|
||||||
#ifdef SUPPORT_RESMGR
|
|
||||||
#include <resmgr.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DOC_HIDDEN
|
#ifndef DOC_HIDDEN
|
||||||
#define SND_FILE_CONTROL "/dev/snd/controlC%i"
|
#define SND_FILE_CONTROL "/dev/snd/controlC%i"
|
||||||
|
|
@ -54,19 +51,11 @@ int snd_card_load(int card)
|
||||||
|
|
||||||
sprintf(control, SND_FILE_CONTROL, card);
|
sprintf(control, SND_FILE_CONTROL, card);
|
||||||
|
|
||||||
#ifdef SUPPORT_RESMGR
|
open_dev = snd_open_device(control, O_RDONLY);
|
||||||
open_dev = rsm_open_device(control, O_RDONLY);
|
|
||||||
#else
|
|
||||||
open_dev = open(control, O_RDONLY);
|
|
||||||
#endif
|
|
||||||
if (open_dev < 0) {
|
if (open_dev < 0) {
|
||||||
char aload[32];
|
char aload[32];
|
||||||
sprintf(aload, SND_FILE_LOAD, card);
|
sprintf(aload, SND_FILE_LOAD, card);
|
||||||
#ifdef SUPPORT_RESMGR
|
open_dev = snd_open_device(aload, O_RDONLY);
|
||||||
open_dev = rsm_open_device(aload, O_RDONLY);
|
|
||||||
#else
|
|
||||||
open_dev = open(aload, O_RDONLY);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (open_dev >= 0) {
|
if (open_dev >= 0) {
|
||||||
close (open_dev);
|
close (open_dev);
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "control_local.h"
|
#include "control_local.h"
|
||||||
#ifdef SUPPORT_RESMGR
|
|
||||||
#include <resmgr.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PIC
|
#ifndef PIC
|
||||||
/* entry for static linking */
|
/* entry for static linking */
|
||||||
|
|
@ -340,18 +337,10 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
|
||||||
fmode |= O_NONBLOCK;
|
fmode |= O_NONBLOCK;
|
||||||
if (mode & SND_CTL_ASYNC)
|
if (mode & SND_CTL_ASYNC)
|
||||||
fmode |= O_ASYNC;
|
fmode |= O_ASYNC;
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(filename, fmode);
|
||||||
fd = rsm_open_device(filename, fmode);
|
|
||||||
#else
|
|
||||||
fd = open(filename, fmode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
snd_card_load(card);
|
snd_card_load(card);
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(filename, fmode);
|
||||||
fd = rsm_open_device(filename, fmode);
|
|
||||||
#else
|
|
||||||
fd = open(filename, fmode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "hwdep_local.h"
|
#include "hwdep_local.h"
|
||||||
#ifdef SUPPORT_RESMGR
|
|
||||||
#include <resmgr.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PIC
|
#ifndef PIC
|
||||||
/* entry for static linking */
|
/* entry for static linking */
|
||||||
|
|
@ -118,18 +115,10 @@ int snd_hwdep_hw_open(snd_hwdep_t **handle, const char *name, int card, int devi
|
||||||
if (card < 0 || card >= 32)
|
if (card < 0 || card >= 32)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
sprintf(filename, SNDRV_FILE_HWDEP, card, device);
|
sprintf(filename, SNDRV_FILE_HWDEP, card, device);
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(filename, mode);
|
||||||
fd = rsm_open_device(filename, mode);
|
|
||||||
#else
|
|
||||||
fd = open(filename, mode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
snd_card_load(card);
|
snd_card_load(card);
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(filename, mode);
|
||||||
fd = rsm_open_device(filename, mode);
|
|
||||||
#else
|
|
||||||
fd = open(filename, mode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,6 @@
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include "pcm_local.h"
|
#include "pcm_local.h"
|
||||||
#include "../control/control_local.h"
|
#include "../control/control_local.h"
|
||||||
#ifdef SUPPORT_RESMGR
|
|
||||||
#include <resmgr.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define DEBUG_RW /* use to debug readi/writei/readn/writen */
|
//#define DEBUG_RW /* use to debug readi/writei/readn/writen */
|
||||||
//#define DEBUG_MMAP /* debug mmap_commit */
|
//#define DEBUG_MMAP /* debug mmap_commit */
|
||||||
|
|
@ -1206,11 +1203,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
|
||||||
fmode |= O_NONBLOCK;
|
fmode |= O_NONBLOCK;
|
||||||
if (mode & SND_PCM_ASYNC)
|
if (mode & SND_PCM_ASYNC)
|
||||||
fmode |= O_ASYNC;
|
fmode |= O_ASYNC;
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(filename, fmode);
|
||||||
fd = rsm_open_device(filename, fmode);
|
|
||||||
#else
|
|
||||||
fd = open(filename, fmode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
SYSMSG("open %s failed", filename);
|
SYSMSG("open %s failed", filename);
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "../control/control_local.h"
|
#include "../control/control_local.h"
|
||||||
#include "rawmidi_local.h"
|
#include "rawmidi_local.h"
|
||||||
#ifdef SUPPORT_RESMGR
|
|
||||||
#include <resmgr.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PIC
|
#ifndef PIC
|
||||||
/* entry for static linking */
|
/* entry for static linking */
|
||||||
|
|
@ -223,18 +220,10 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
|
||||||
|
|
||||||
assert(!(mode & ~(SND_RAWMIDI_APPEND|SND_RAWMIDI_NONBLOCK|SND_RAWMIDI_SYNC)));
|
assert(!(mode & ~(SND_RAWMIDI_APPEND|SND_RAWMIDI_NONBLOCK|SND_RAWMIDI_SYNC)));
|
||||||
|
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(filename, fmode);
|
||||||
fd = rsm_open_device(filename, fmode);
|
|
||||||
#else
|
|
||||||
fd = open(filename, fmode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
snd_card_load(card);
|
snd_card_load(card);
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(filename, fmode);
|
||||||
fd = rsm_open_device(filename, fmode);
|
|
||||||
#else
|
|
||||||
fd = open(filename, fmode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
snd_ctl_close(ctl);
|
snd_ctl_close(ctl);
|
||||||
SYSERR("open %s failed", filename);
|
SYSERR("open %s failed", filename);
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "seq_local.h"
|
#include "seq_local.h"
|
||||||
#ifdef SUPPORT_RESMGR
|
|
||||||
#include <resmgr.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PIC
|
#ifndef PIC
|
||||||
/* entry for static linking */
|
/* entry for static linking */
|
||||||
|
|
@ -443,24 +440,12 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode)
|
||||||
fmode |= O_NONBLOCK;
|
fmode |= O_NONBLOCK;
|
||||||
|
|
||||||
filename = SNDRV_FILE_SEQ;
|
filename = SNDRV_FILE_SEQ;
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(filename, fmode);
|
||||||
fd = rsm_open_device(filename, fmode);
|
|
||||||
#else
|
|
||||||
fd = open(filename, fmode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(SNDRV_FILE_ALOADSEQ, fmode);
|
||||||
fd = open(SNDRV_FILE_ALOADSEQ, O_RDWR);
|
|
||||||
#else
|
|
||||||
fd = open(SNDRV_FILE_ALOADSEQ, fmode);
|
|
||||||
#endif
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(filename, fmode);
|
||||||
fd = rsm_open_device(filename, fmode);
|
|
||||||
#else
|
|
||||||
fd = open(filename, fmode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
SYSERR("open %s failed", filename);
|
SYSERR("open %s failed", filename);
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "timer_local.h"
|
#include "timer_local.h"
|
||||||
#ifdef SUPPORT_RESMGR
|
|
||||||
#include <resmgr.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PIC
|
#ifndef PIC
|
||||||
/* entry for static linking */
|
/* entry for static linking */
|
||||||
|
|
@ -214,11 +211,7 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int
|
||||||
tmode = O_RDONLY;
|
tmode = O_RDONLY;
|
||||||
if (mode & SND_TIMER_OPEN_NONBLOCK)
|
if (mode & SND_TIMER_OPEN_NONBLOCK)
|
||||||
tmode |= O_NONBLOCK;
|
tmode |= O_NONBLOCK;
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(SNDRV_FILE_TIMER, tmode);
|
||||||
fd = rsm_open_device(SNDRV_FILE_TIMER, tmode);
|
|
||||||
#else
|
|
||||||
fd = open(SNDRV_FILE_TIMER, tmode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "timer_local.h"
|
#include "timer_local.h"
|
||||||
#ifdef SUPPORT_RESMGR
|
|
||||||
#include <resmgr.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PIC
|
#ifndef PIC
|
||||||
/* entry for static linking */
|
/* entry for static linking */
|
||||||
|
|
@ -102,11 +99,7 @@ int snd_timer_query_hw_open(snd_timer_query_t **handle, const char *name, int mo
|
||||||
tmode = O_RDONLY;
|
tmode = O_RDONLY;
|
||||||
if (mode & SND_TIMER_OPEN_NONBLOCK)
|
if (mode & SND_TIMER_OPEN_NONBLOCK)
|
||||||
tmode |= O_NONBLOCK;
|
tmode |= O_NONBLOCK;
|
||||||
#ifdef SUPPORT_RESMGR
|
fd = snd_open_device(SNDRV_FILE_TIMER, tmode);
|
||||||
fd = rsm_open_device(SNDRV_FILE_TIMER, tmode);
|
|
||||||
#else
|
|
||||||
fd = open(SNDRV_FILE_TIMER, tmode);
|
|
||||||
#endif
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
if (ioctl(fd, SNDRV_TIMER_IOCTL_PVERSION, &ver) < 0) {
|
if (ioctl(fd, SNDRV_TIMER_IOCTL_PVERSION, &ver) < 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue