mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-08 13:30:03 -05:00
Check control API protocol version for TLV control
Check control API protocol version to avoid unnecessary ioctl access for TLV stuff on the older drivers.
This commit is contained in:
parent
f70de1b1cc
commit
a7bc1dd80c
1 changed files with 7 additions and 1 deletions
|
|
@ -40,11 +40,12 @@ const char *_snd_module_control_hw = "";
|
|||
|
||||
#ifndef DOC_HIDDEN
|
||||
#define SNDRV_FILE_CONTROL ALSA_DEVICE_DIRECTORY "controlC%i"
|
||||
#define SNDRV_CTL_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 3)
|
||||
#define SNDRV_CTL_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 4)
|
||||
|
||||
typedef struct {
|
||||
int card;
|
||||
int fd;
|
||||
unsigned int protocol;
|
||||
} snd_ctl_hw_t;
|
||||
#endif /* DOC_HIDDEN */
|
||||
|
||||
|
|
@ -208,6 +209,10 @@ static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag,
|
|||
snd_ctl_hw_t *hw = handle->private_data;
|
||||
struct sndrv_ctl_tlv *xtlv;
|
||||
|
||||
/* we don't support TLV on protocol ver 2.0.3 or earlier */
|
||||
if (hw->protocol < SNDRV_PROTOCOL_VERSION(2, 0, 4))
|
||||
return -ENXIO;
|
||||
|
||||
switch (op_flag) {
|
||||
case -1: inum = SNDRV_CTL_IOCTL_TLV_COMMAND; break;
|
||||
case 0: inum = SNDRV_CTL_IOCTL_TLV_READ; break;
|
||||
|
|
@ -407,6 +412,7 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
|
|||
}
|
||||
hw->card = card;
|
||||
hw->fd = fd;
|
||||
hw->protocol = ver;
|
||||
|
||||
err = snd_ctl_new(&ctl, SND_CTL_TYPE_HW, name);
|
||||
if (err < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue