Date: Mon, 08 Dec 2025 17:21:36 +0000 From: Christos Margiolis <christos@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Goran=?utf-8?Q? Meki=C4=87?= <meka@tilda.center> Subject: git: ebe7b241662b - main - sound examples: Check if setting property was successful Message-ID: <69370920.ad32.225d24c8@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=ebe7b241662be3941e462be9f228fcad1b67073a commit ebe7b241662be3941e462be9f228fcad1b67073a Author: Goran Mekić <meka@tilda.center> AuthorDate: 2025-12-08 17:20:34 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2025-12-08 17:21:30 +0000 sound examples: Check if setting property was successful MFC after: 1 week Reviewed by: christos Differential Revision: https://reviews.freebsd.org/D54038 --- share/examples/sound/oss.h | 22 ++++++++++++++++++---- share/examples/sound/simple.c | 4 ++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/share/examples/sound/oss.h b/share/examples/sound/oss.h index e1ba4165810f..cf38b8de2b0c 100644 --- a/share/examples/sound/oss.h +++ b/share/examples/sound/oss.h @@ -112,16 +112,28 @@ oss_init(struct config *config) } /* Set sample format */ - if (ioctl(config->fd, SNDCTL_DSP_SETFMT, &config->format) < 0) + tmp = config->format; + if (ioctl(config->fd, SNDCTL_DSP_SETFMT, &tmp) < 0) err(1, "Unable to set sample format"); + if (tmp != config->format) + warnx("Format: requested=%08x, got=%08x", config->format, tmp); + config->format = tmp; /* Set sample channels */ - if (ioctl(config->fd, SNDCTL_DSP_CHANNELS, &config->audio_info.max_channels) < 0) + tmp = config->audio_info.max_channels; + if (ioctl(config->fd, SNDCTL_DSP_CHANNELS, &tmp) < 0) err(1, "Unable to set channels"); + if (tmp != config->audio_info.max_channels) + warnx("Channels: requested=%d, got=%d", config->audio_info.max_channels, tmp); + config->audio_info.max_channels = tmp; /* Set sample rate */ + tmp = config->sample_rate; if (ioctl(config->fd, SNDCTL_DSP_SPEED, &config->sample_rate) < 0) err(1, "Unable to set sample rate"); + if (tmp != config->sample_rate) + warnx("Sample rate: requested=%d, got=%d", config->sample_rate, tmp); + config->sample_rate = tmp; /* Calculate sample size */ switch (config->format) { @@ -197,10 +209,12 @@ oss_init(struct config *config) config->chsamples = config->sample_count / config->audio_info.max_channels; printf("bytes: %d, fragments: %d, fragsize: %d, fragstotal: %d, " - "samples: %d\n", + "samples: %d, channels: %d, sample size: %d, sample rate: %d, " + "format: %08x\n", config->buffer_info.bytes, config->buffer_info.fragments, config->buffer_info.fragsize, config->buffer_info.fragstotal, - config->sample_count); + 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) { diff --git a/share/examples/sound/simple.c b/share/examples/sound/simple.c index e458841f596a..78f9d848bcec 100644 --- a/share/examples/sound/simple.c +++ b/share/examples/sound/simple.c @@ -29,6 +29,7 @@ * SUCH DAMAGE. */ +#include <sys/soundcard.h> #include "oss.h" /* @@ -115,6 +116,9 @@ main(int argc, char *argv[]) int rc, bytes; oss_init(&config); + if (config.format != AFMT_S32_NE) + errx(1, "Device doesn't support signed 32bit samples. " + "Check with 'sndctl' if it can be configured for 's32le' format."); bytes = config.buffer_info.bytes; channels = malloc(bytes);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69370920.ad32.225d24c8>
