Merge branch 'master' of git@git.alsa-project.org:alsa-lib

This commit is contained in:
Jaroslav Kysela 2008-10-23 09:58:10 +02:00
commit 8feae77e13
4 changed files with 65 additions and 20 deletions

View file

@ -725,7 +725,7 @@ struct sndrv_timer_tread {
* *
****************************************************************************/
#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 5)
#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6)
struct sndrv_ctl_card_info {
int card; /* card number */
@ -736,8 +736,7 @@ struct sndrv_ctl_card_info {
unsigned char longname[80]; /* name + info text about soundcard */
unsigned char reserved_[16]; /* reserved for future (was ID of mixer) */
unsigned char mixername[80]; /* visual mixer identification */
unsigned char components[80]; /* card components / fine identification, delimited with one space (AC97 etc..) */
unsigned char reserved[48]; /* reserved for future */
unsigned char components[128]; /* card components / fine identification, delimited with one space (AC97 etc..) */
};
enum sndrv_ctl_elem_type {

View file

@ -44,3 +44,42 @@ PS3.pcm.default {
}
}
}
<confdir:pcm/iec958.conf>
PS3.pcm.iec958.0 {
@args [ CARD AES0 AES1 AES2 AES3 ]
@args.CARD {
type string
}
@args.AES0 {
type integer
}
@args.AES1 {
type integer
}
@args.AES2 {
type integer
}
@args.AES3 {
type integer
}
type hooks
slave.pcm {
type hw
card $CARD
}
hooks.0 {
type ctl_elems
hook_args [
{
interface PCM
name "IEC958 Playback Default"
lock true
preserve true
optional true
value [ $AES0 $AES1 $AES2 $AES3 ]
}
]
}
}

View file

@ -116,7 +116,7 @@ static int snd_ctl_hw_subscribe_events(snd_ctl_t *handle, int subscribe)
SYSERR("SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS failed");
return -errno;
}
return subscribe;
return 0;
}
static int snd_ctl_hw_card_info(snd_ctl_t *handle, snd_ctl_card_info_t *info)
@ -324,7 +324,11 @@ static int snd_ctl_hw_read(snd_ctl_t *handle, snd_ctl_event_t *event)
ssize_t res = read(hw->fd, event, sizeof(*event));
if (res <= 0)
return -errno;
assert(res == sizeof(*event));
if (CHECK_SANITY(res != sizeof(*event))) {
SNDMSG("snd_ctl_hw_read: read size error (req:%d, got:%d)\n",
sizeof(*event), res);
return -EINVAL;
}
return 1;
}
@ -368,7 +372,10 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
*handle = NULL;
assert(card >= 0 && card < 32);
if (CHECK_SANITY(card < 0 || card >= 32)) {
SNDMSG("Invalid card index %d", card);
return -EINVAL;
}
sprintf(filename, SNDRV_FILE_CONTROL, card);
if (mode & SND_CTL_READONLY)
fmode = O_RDONLY;

View file

@ -84,10 +84,11 @@ static void zero_handler(const char *file ATTRIBUTE_UNUSED,
{
}
static int get_dev_name1(struct hint_list *list, char **res)
static int get_dev_name1(struct hint_list *list, char **res, int device,
int stream)
{
*res = NULL;
if (list->device < 0)
if (device < 0)
return 0;
switch (list->iface) {
#ifdef BUILD_HWDEP
@ -95,7 +96,7 @@ static int get_dev_name1(struct hint_list *list, char **res)
{
snd_hwdep_info_t *info;
snd_hwdep_info_alloca(&info);
snd_hwdep_info_set_device(info, list->device);
snd_hwdep_info_set_device(info, device);
if (snd_ctl_hwdep_info(list->ctl, info) < 0)
return 0;
*res = strdup(snd_hwdep_info_get_name(info));
@ -107,8 +108,8 @@ static int get_dev_name1(struct hint_list *list, char **res)
{
snd_pcm_info_t *info;
snd_pcm_info_alloca(&info);
snd_pcm_info_set_device(info, list->device);
snd_pcm_info_set_stream(info, list->stream ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK);
snd_pcm_info_set_device(info, device);
snd_pcm_info_set_stream(info, stream ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK);
if (snd_ctl_pcm_info(list->ctl, info) < 0)
return 0;
switch (snd_pcm_info_get_class(info)) {
@ -127,8 +128,8 @@ static int get_dev_name1(struct hint_list *list, char **res)
{
snd_rawmidi_info_t *info;
snd_rawmidi_info_alloca(&info);
snd_rawmidi_info_set_device(info, list->device);
snd_rawmidi_info_set_stream(info, list->stream ? SND_RAWMIDI_STREAM_INPUT : SND_RAWMIDI_STREAM_OUTPUT);
snd_rawmidi_info_set_device(info, device);
snd_rawmidi_info_set_stream(info, stream ? SND_RAWMIDI_STREAM_INPUT : SND_RAWMIDI_STREAM_OUTPUT);
if (snd_ctl_rawmidi_info(list->ctl, info) < 0)
return 0;
*res = strdup(snd_rawmidi_info_get_name(info));
@ -143,14 +144,13 @@ static int get_dev_name1(struct hint_list *list, char **res)
static char *get_dev_name(struct hint_list *list)
{
char *str1, *str2, *res;
int device;
list->device = list->device_input >= 0 ? list->device_input : list->device;
list->stream = 1;
if (get_dev_name1(list, &str1) < 0)
device = list->device_input >= 0 ? list->device_input : list->device;
if (get_dev_name1(list, &str1, device, 1) < 0)
return NULL;
list->device = list->device_output >= 0 ? list->device_input : list->device;
list->stream = 0;
if (get_dev_name1(list, &str2) < 0) {
device = list->device_output >= 0 ? list->device_output : list->device;
if (get_dev_name1(list, &str2, device, 0) < 0) {
if (str1)
free(str1);
return NULL;
@ -199,7 +199,7 @@ static char *get_dev_name(struct hint_list *list)
}
}
/* if the specified device doesn't exist, skip this entry */
if (list->device_input >= 0 || list->device_output >= 0)
if (list->device >= 0 || list->device_input >= 0 || list->device_output >= 0)
return NULL;
return strdup(list->cardname);
}