Lines Matching +full:0 +full:m

48 	if (ioctl(dev->parent_mixer->fd, MIXER_READ(dev->devno), &v) < 0)  in _mixer_readvol()
50 dev->vol.left = MIX_VOLNORM(v & 0x00ff); in _mixer_readvol()
51 dev->vol.right = MIX_VOLNORM((v >> 8) & 0x00ff); in _mixer_readvol()
53 return (0); in _mixer_readvol()
67 struct mixer *m = NULL; in mixer_open() local
72 if ((m = calloc(1, sizeof(struct mixer))) == NULL) in mixer_open()
77 if (strncmp(name, BASEPATH, strlen(BASEPATH)) != 0) { in mixer_open()
78 m->unit = -1; in mixer_open()
81 if (strncmp(name, BASEPATH, strlen(name)) == 0) in mixer_open()
83 m->unit = strtol(name + strlen(BASEPATH), NULL, 10); in mixer_open()
85 (void)strlcpy(m->name, name, sizeof(m->name)); in mixer_open()
88 if ((m->unit = mixer_get_dunit()) < 0) in mixer_open()
90 (void)snprintf(m->name, sizeof(m->name), BASEPATH "%d", m->unit); in mixer_open()
93 if ((m->fd = open(m->name, O_RDWR)) < 0) in mixer_open()
96 m->devmask = m->recmask = m->recsrc = 0; in mixer_open()
97 m->f_default = m->unit == mixer_get_dunit(); in mixer_open()
98 m->mode = mixer_get_mode(m->unit); in mixer_open()
100 m->mi.dev = m->unit; in mixer_open()
101 m->ci.card = m->unit; in mixer_open()
102 if (ioctl(m->fd, SNDCTL_MIXERINFO, &m->mi) < 0) { in mixer_open()
103 memset(&m->mi, 0, sizeof(m->mi)); in mixer_open()
104 strlcpy(m->mi.name, m->name, sizeof(m->mi.name)); in mixer_open()
106 if (ioctl(m->fd, SNDCTL_CARDINFO, &m->ci) < 0) in mixer_open()
107 memset(&m->ci, 0, sizeof(m->ci)); in mixer_open()
108 if (ioctl(m->fd, SOUND_MIXER_READ_DEVMASK, &m->devmask) < 0 || in mixer_open()
109 ioctl(m->fd, SOUND_MIXER_READ_MUTE, &m->mutemask) < 0 || in mixer_open()
110 ioctl(m->fd, SOUND_MIXER_READ_RECMASK, &m->recmask) < 0 || in mixer_open()
111 ioctl(m->fd, SOUND_MIXER_READ_RECSRC, &m->recsrc) < 0) in mixer_open()
114 TAILQ_INIT(&m->devs); in mixer_open()
115 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) { in mixer_open()
116 if (!MIX_ISDEV(m, i)) in mixer_open()
120 dp->parent_mixer = m; in mixer_open()
122 dp->nctl = 0; in mixer_open()
123 if (_mixer_readvol(dp) < 0) in mixer_open()
127 TAILQ_INSERT_TAIL(&m->devs, dp, devs); in mixer_open()
128 m->ndev++; in mixer_open()
132 m->dev = TAILQ_FIRST(&m->devs); in mixer_open()
134 return (m); in mixer_open()
136 if (m != NULL) in mixer_open()
137 (void)mixer_close(m); in mixer_open()
146 mixer_close(struct mixer *m) in mixer_close() argument
151 r = close(m->fd); in mixer_close()
152 while (!TAILQ_EMPTY(&m->devs)) { in mixer_close()
153 dp = TAILQ_FIRST(&m->devs); in mixer_close()
154 TAILQ_REMOVE(&m->devs, dp, devs); in mixer_close()
159 free(m); in mixer_close()
170 * The caller must manually assign the return value to `m->dev`.
173 mixer_get_dev(struct mixer *m, int dev) in mixer_get_dev() argument
177 if (dev < 0 || dev >= m->ndev) { in mixer_get_dev()
181 TAILQ_FOREACH(dp, &m->devs, devs) { in mixer_get_dev()
196 mixer_get_dev_byname(struct mixer *m, const char *name) in mixer_get_dev_byname() argument
200 TAILQ_FOREACH(dp, &m->devs, devs) { in mixer_get_dev_byname()
244 return (0); in mixer_add_ctl()
278 return (0); in mixer_remove_ctl()
318 * an integer value between 0 and 100 stored as `lvol | rvol << 8` -- for
325 mixer_set_vol(struct mixer *m, mix_volume_t vol) in mixer_set_vol() argument
335 if (ioctl(m->fd, MIXER_WRITE(m->dev->devno), &v) < 0) in mixer_set_vol()
337 if (_mixer_readvol(m->dev) < 0) in mixer_set_vol()
340 return (0); in mixer_set_vol()
351 mixer_set_mute(struct mixer *m, int opt) in mixer_set_mute() argument
355 m->mutemask |= (1 << m->dev->devno); in mixer_set_mute()
358 m->mutemask &= ~(1 << m->dev->devno); in mixer_set_mute()
361 m->mutemask ^= (1 << m->dev->devno); in mixer_set_mute()
367 if (ioctl(m->fd, SOUND_MIXER_WRITE_MUTE, &m->mutemask) < 0) in mixer_set_mute()
369 if (ioctl(m->fd, SOUND_MIXER_READ_MUTE, &m->mutemask) < 0) in mixer_set_mute()
372 return 0; in mixer_set_mute()
385 mixer_mod_recsrc(struct mixer *m, int opt) in mixer_mod_recsrc() argument
387 if (!m->recmask || !MIX_ISREC(m, m->dev->devno)) { in mixer_mod_recsrc()
393 m->recsrc |= (1 << m->dev->devno); in mixer_mod_recsrc()
396 m->recsrc &= ~(1 << m->dev->devno); in mixer_mod_recsrc()
399 m->recsrc = (1 << m->dev->devno); in mixer_mod_recsrc()
402 m->recsrc ^= (1 << m->dev->devno); in mixer_mod_recsrc()
408 if (ioctl(m->fd, SOUND_MIXER_WRITE_RECSRC, &m->recsrc) < 0) in mixer_mod_recsrc()
410 if (ioctl(m->fd, SOUND_MIXER_READ_RECSRC, &m->recsrc) < 0) in mixer_mod_recsrc()
413 return (0); in mixer_mod_recsrc()
427 if (sysctlbyname("hw.snd.default_unit", &unit, &size, NULL, 0) < 0) in mixer_get_dunit()
441 mixer_set_dunit(struct mixer *m, int unit) in mixer_set_dunit() argument
446 if (sysctlbyname("hw.snd.default_unit", NULL, 0, &unit, size) < 0) in mixer_set_dunit()
449 m->f_default = m->unit == unit; in mixer_set_dunit()
451 return (0); in mixer_set_dunit()
467 if (sysctlbyname(buf, &mode, &size, NULL, 0) < 0) in mixer_get_mode()
468 return (0); in mixer_get_mode()
479 struct mixer *m; in mixer_get_nmixers() local
486 if ((m = mixer_open(NULL)) == NULL) in mixer_get_nmixers()
488 if (ioctl(m->fd, OSS_SYSINFO, &si) < 0) { in mixer_get_nmixers()
489 (void)mixer_close(m); in mixer_get_nmixers()
492 (void)mixer_close(m); in mixer_get_nmixers()
505 if (!(unit == -1 || (unit >= 0 && unit < mixer_get_nmixers()))) { in mixer_get_path()
519 return (0); in mixer_get_path()