mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
Enhanced code (use_fd)
This commit is contained in:
parent
290c2ed8fc
commit
22c689135e
1 changed files with 21 additions and 2 deletions
|
|
@ -53,6 +53,8 @@ struct _snd_pcm_surround {
|
||||||
unsigned int channels; /* count of channels (4 or 6) */
|
unsigned int channels; /* count of channels (4 or 6) */
|
||||||
int pcms; /* count of PCM channels */
|
int pcms; /* count of PCM channels */
|
||||||
int use_fd; /* use this FD for the direct access */
|
int use_fd; /* use this FD for the direct access */
|
||||||
|
int use_fd_four;
|
||||||
|
int use_fd_six;
|
||||||
snd_pcm_t *pcm[3]; /* up to three PCM stereo streams */
|
snd_pcm_t *pcm[3]; /* up to three PCM stereo streams */
|
||||||
int use_route: 1; /* route is used */
|
int use_route: 1; /* route is used */
|
||||||
int route[6]; /* channel route */
|
int route[6]; /* channel route */
|
||||||
|
|
@ -652,13 +654,25 @@ int load_surround_config(snd_ctl_t *ctl, snd_pcm_surround_t *surr,
|
||||||
} else if (isdigit(*str) && atoi(str) != 0)
|
} else if (isdigit(*str) && atoi(str) != 0)
|
||||||
surr->caps |= SURR_CAP_6CH;
|
surr->caps |= SURR_CAP_6CH;
|
||||||
}
|
}
|
||||||
if (snd_config_search(n, "use_fd", &n1) >= 0) {
|
if (snd_config_search(n, "use_fd_four", &n1) >= 0) {
|
||||||
|
unsigned long i;
|
||||||
|
if ((err = snd_config_get_integer(n1, &i)) < 0) {
|
||||||
|
SNDERR("Invalid type for %s", id);
|
||||||
|
goto __error;
|
||||||
|
} else if (i <= 1)
|
||||||
|
surr->use_fd_four = i;
|
||||||
|
else {
|
||||||
|
SNDERR("Invalid range for use_fd (0-2): %li", i);
|
||||||
|
goto __error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (snd_config_search(n, "use_fd_six", &n1) >= 0) {
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
if ((err = snd_config_get_integer(n1, &i)) < 0) {
|
if ((err = snd_config_get_integer(n1, &i)) < 0) {
|
||||||
SNDERR("Invalid type for %s", id);
|
SNDERR("Invalid type for %s", id);
|
||||||
goto __error;
|
goto __error;
|
||||||
} else if (i <= 2)
|
} else if (i <= 2)
|
||||||
surr->use_fd = i;
|
surr->use_fd_six = i;
|
||||||
else {
|
else {
|
||||||
SNDERR("Invalid range for use_fd (0-2): %li", i);
|
SNDERR("Invalid range for use_fd (0-2): %li", i);
|
||||||
goto __error;
|
goto __error;
|
||||||
|
|
@ -725,6 +739,7 @@ int load_surround_config(snd_ctl_t *ctl, snd_pcm_surround_t *surr,
|
||||||
if (snd_config_search(n, "open_single", &n1) >= 0) {
|
if (snd_config_search(n, "open_single", &n1) >= 0) {
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
int device = 0, subdevice = -1;
|
int device = 0, subdevice = -1;
|
||||||
|
surr->use_fd = 0;
|
||||||
if (snd_config_get_type(n1) != SND_CONFIG_TYPE_COMPOUND) {
|
if (snd_config_get_type(n1) != SND_CONFIG_TYPE_COMPOUND) {
|
||||||
SNDERR("compound type expected");
|
SNDERR("compound type expected");
|
||||||
goto __error;
|
goto __error;
|
||||||
|
|
@ -818,12 +833,14 @@ int load_surround_config(snd_ctl_t *ctl, snd_pcm_surround_t *surr,
|
||||||
}
|
}
|
||||||
switch (stype) {
|
switch (stype) {
|
||||||
case SND_PCM_SURROUND_40:
|
case SND_PCM_SURROUND_40:
|
||||||
|
surr->use_fd = surr->use_fd_four;
|
||||||
if (!(surr->caps & SURR_CAP_4CH)) {
|
if (!(surr->caps & SURR_CAP_4CH)) {
|
||||||
err = -ENODEV;
|
err = -ENODEV;
|
||||||
goto __error;
|
goto __error;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SND_PCM_SURROUND_51:
|
case SND_PCM_SURROUND_51:
|
||||||
|
surr->use_fd = surr->use_fd_six;
|
||||||
if (!(surr->caps & SURR_CAP_6CH)) {
|
if (!(surr->caps & SURR_CAP_6CH)) {
|
||||||
err = -ENODEV;
|
err = -ENODEV;
|
||||||
goto __error;
|
goto __error;
|
||||||
|
|
@ -834,6 +851,8 @@ int load_surround_config(snd_ctl_t *ctl, snd_pcm_surround_t *surr,
|
||||||
SNDERR("surround single stream open error %i,%i,%i,%i,%i,%i,%i: %s", surr->card, device[0], subdevice[0], device[1], subdevice[1], device[2], subdevice[2], snd_strerror(err));
|
SNDERR("surround single stream open error %i,%i,%i,%i,%i,%i,%i: %s", surr->card, device[0], subdevice[0], device[1], subdevice[1], device[2], subdevice[2], snd_strerror(err));
|
||||||
goto __error;
|
goto __error;
|
||||||
}
|
}
|
||||||
|
if (surr->pcm[surr->use_fd] == NULL)
|
||||||
|
surr->use_fd = 0;
|
||||||
opened = 1;
|
opened = 1;
|
||||||
}
|
}
|
||||||
if (opened == 0) {
|
if (opened == 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue