9mGH1JfzKEhm/AqhBKmEYPbi3CYZOy28kb o1tk+kQQ20AwyNrnBBAc09OVtosnhhA+kzAWcwCScU4UCilNWa9pjyO5rv2iI8CBkd0PIE 8QPncGMqKxM/kiphKYyqw5/0R/V/F+f/tDA0wzZu6zF1LZtVXGrAUr9HPxGUaHMq3LjdKw RRmAi3BePPWLE5PGSRAEtc3fZW2jLKp24EMsNwodqEzus7qDRrErzYyoiQ6BqdlyjBBMVv tMkY1SNqYGfm7Bj/CaKqm7P6nv1YUP5XosT+zmph4mIBT6vpNbTpJ6z/39xpAQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dVLXS6lMqz5l1 for ; Mon, 15 Dec 2025 13:30:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 32081 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 15 Dec 2025 13:30:16 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Goran=?utf-8?Q? Meki=C4=87?= From: Christos Margiolis Subject: git: 164d03e30812 - stable/15 - sound examples: Check if setting property was successful List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 164d03e30812b623b06cb3b82436386ae1f52db7 Auto-Submitted: auto-generated Date: Mon, 15 Dec 2025 13:30:16 +0000 Message-Id: <69400d68.32081.4b5f0abc@gitrepo.freebsd.org> The branch stable/15 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=164d03e30812b623b06cb3b82436386ae1f52db7 commit 164d03e30812b623b06cb3b82436386ae1f52db7 Author: Goran Mekić AuthorDate: 2025-12-08 17:20:34 +0000 Commit: Christos Margiolis CommitDate: 2025-12-15 13:29:56 +0000 sound examples: Check if setting property was successful MFC after: 1 week Reviewed by: christos Differential Revision: https://reviews.freebsd.org/D54038 (cherry picked from commit ebe7b241662be3941e462be9f228fcad1b67073a) --- 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 #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);