git: d3aa926bffd2 - main - sound examples: trigger dsp devices via syncgroup
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 19 Oct 2026 09:01:13 UTC
The branch main has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=d3aa926bffd20e4ef0e12e3ee9af1707ad234cda
commit d3aa926bffd20e4ef0e12e3ee9af1707ad234cda
Author: Goran Mekić <meka@tilda.center>
AuthorDate: 2026-10-19 08:59:36 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-10-19 08:59:36 +0000
sound examples: trigger dsp devices via syncgroup
Triggering is only needed if device is in mmap mode, and in mmap example
the device is triggered as part of syncgroup. For non-mmap mode,
triggering is not needed at all. Triggering mmap'ed device too early
would start the IPTR/OPTR counters and that would cause those pointers
to be out of sync, so let syncgroup do the triggering once the device is
fully configured and ready for capture and playback.
MFC after: 1 week
Reviewed by: christos
Differential Revision: https://reviews.freebsd.org/D60839
---
share/examples/sound/oss.h | 41 +++++++++++++++--------------------------
1 file changed, 15 insertions(+), 26 deletions(-)
diff --git a/share/examples/sound/oss.h b/share/examples/sound/oss.h
index cf38b8de2b0c..77a022646509 100644
--- a/share/examples/sound/oss.h
+++ b/share/examples/sound/oss.h
@@ -98,10 +98,6 @@ oss_init(struct config *config)
if (ioctl(config->fd, SNDCTL_DSP_GETCAPS, &config->audio_info.caps) < 0)
err(1, "Unable to get capabilities");
- /* Check if device supports triggering */
- if (!(config->audio_info.caps & PCM_CAP_TRIGGER))
- errx(1, "Device doesn't support triggering!\n");
-
/* Handle memory mapped mode */
if (config->mmap) {
if (!(config->audio_info.caps & PCM_CAP_MMAP))
@@ -216,27 +212,24 @@ oss_init(struct config *config)
config->sample_count, config->audio_info.max_channels,
config->sample_size, config->sample_rate, config->format);
- /* Set trigger direction and mmap protection */
- switch (config->mode & O_ACCMODE) {
- case O_RDONLY:
- tmp = PCM_ENABLE_INPUT;
- prot = PROT_READ;
- break;
- case O_WRONLY:
- tmp = PCM_ENABLE_OUTPUT;
- prot = PROT_WRITE;
- break;
- case O_RDWR:
- tmp = PCM_ENABLE_INPUT | PCM_ENABLE_OUTPUT;
- prot = PROT_READ | PROT_WRITE;
- break;
- default:
- errx(1, "Invalid mode %d", config->mode);
- break;
- }
/* Map or allocate the buffer */
if (config->mmap) {
+ /* Set mmap protection */
+ switch (config->mode & O_ACCMODE) {
+ case O_RDONLY:
+ prot = PROT_READ;
+ break;
+ case O_WRONLY:
+ prot = PROT_WRITE;
+ break;
+ case O_RDWR:
+ prot = PROT_READ | PROT_WRITE;
+ break;
+ default:
+ errx(1, "Invalid mode %d", config->mode);
+ break;
+ }
config->buf = mmap(NULL, config->buffer_info.bytes, prot, MAP_SHARED, config->fd, 0);
if (config->buf == MAP_FAILED)
err(1, "Memory map failed");
@@ -244,8 +237,4 @@ oss_init(struct config *config)
if ((config->buf = malloc(config->buffer_info.bytes)) == NULL)
err(1, "Allocating buffer failed");
}
-
- /* Set the trigger */
- if (ioctl(config->fd, SNDCTL_DSP_SETTRIGGER, &tmp) < 0)
- err(1, "Failed to set trigger");
}