virtual_oss(8): Make sndstat FD global
There is no reason to have per-profile copies, plus this way we open /dev/sndstat multiple times if more than 1 profile is created. Also close the FD on exit to avoid leaking. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: jrm Pull-Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/41
This commit is contained in:
@@ -144,7 +144,6 @@ struct virtual_profile {
|
|||||||
double rx_compressor_gain[VMAX_CHAN];
|
double rx_compressor_gain[VMAX_CHAN];
|
||||||
uint8_t synchronized;
|
uint8_t synchronized;
|
||||||
uint32_t rec_delay;
|
uint32_t rec_delay;
|
||||||
int fd_sta;
|
|
||||||
struct {
|
struct {
|
||||||
const char * host;
|
const char * host;
|
||||||
const char * port;
|
const char * port;
|
||||||
|
|||||||
@@ -1640,6 +1640,7 @@ struct voss_backend *voss_tx_backend;
|
|||||||
static int voss_dups;
|
static int voss_dups;
|
||||||
static int voss_ntds;
|
static int voss_ntds;
|
||||||
static pthread_t *voss_tds;
|
static pthread_t *voss_tds;
|
||||||
|
static int voss_fd_sta = -1;
|
||||||
|
|
||||||
/* XXX I do not like the prefix argument... */
|
/* XXX I do not like the prefix argument... */
|
||||||
static struct voss_backend *
|
static struct voss_backend *
|
||||||
@@ -1845,7 +1846,7 @@ init_sndstat(vprofile_t *ptr)
|
|||||||
warn("Failed to pack nvlist");
|
warn("Failed to pack nvlist");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
err = ioctl(ptr->fd_sta, SNDSTIOC_ADD_USER_DEVS, &arg);
|
err = ioctl(voss_fd_sta, SNDSTIOC_ADD_USER_DEVS, &arg);
|
||||||
free(arg.buf);
|
free(arg.buf);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
warn("Failed to issue ioctl(SNDSTIOC_ADD_USER_DEVS)");
|
warn("Failed to issue ioctl(SNDSTIOC_ADD_USER_DEVS)");
|
||||||
@@ -1912,7 +1913,6 @@ dup_profile(vprofile_t *pvp, int *pamp, int pol, int rx_mute,
|
|||||||
memcpy(ptr, pvp, sizeof(*ptr));
|
memcpy(ptr, pvp, sizeof(*ptr));
|
||||||
|
|
||||||
ptr->synchronized = synchronized;
|
ptr->synchronized = synchronized;
|
||||||
ptr->fd_sta = -1;
|
|
||||||
TAILQ_INIT(&ptr->head);
|
TAILQ_INIT(&ptr->head);
|
||||||
|
|
||||||
for (x = 0; x != ptr->channels; x++) {
|
for (x = 0; x != ptr->channels; x++) {
|
||||||
@@ -1953,12 +1953,13 @@ dup_profile(vprofile_t *pvp, int *pamp, int pol, int rx_mute,
|
|||||||
ptr->oss_dev = pdev;
|
ptr->oss_dev = pdev;
|
||||||
|
|
||||||
/* register to sndstat */
|
/* register to sndstat */
|
||||||
ptr->fd_sta = open("/dev/sndstat", O_WRONLY);
|
if (voss_fd_sta < 0) {
|
||||||
if (ptr->fd_sta < 0) {
|
if ((voss_fd_sta = open("/dev/sndstat", O_WRONLY)) < 0) {
|
||||||
warn("Could not open /dev/sndstat");
|
errstr = "Could not open /dev/sndstat";
|
||||||
} else {
|
goto err;
|
||||||
init_sndstat(ptr);
|
}
|
||||||
}
|
}
|
||||||
|
init_sndstat(ptr);
|
||||||
}
|
}
|
||||||
/* create WAV device */
|
/* create WAV device */
|
||||||
if (ptr->wav_name[0] != 0) {
|
if (ptr->wav_name[0] != 0) {
|
||||||
@@ -2678,6 +2679,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cuse_uninit();
|
cuse_uninit();
|
||||||
|
close(voss_fd_sta);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user