Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Apr 2025 00:28:29 GMT
From:      Christos Margiolis <christos@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1890f0b0df24 - stable/14 - beep(1): Use AFMT_FLOAT
Message-ID:  <202504060028.5360ST0Q065739@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=1890f0b0df244fd36c511303e2068d5c6f3aa174

commit 1890f0b0df244fd36c511303e2068d5c6f3aa174
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-03-30 17:45:48 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-04-06 00:28:14 +0000

    beep(1): Use AFMT_FLOAT
    
    AFMT_FLOAT is supported by sound(4) as of FILLME, so use it here, since
    the whole program works with floats already.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D47639
    
    (cherry picked from commit 1166cfd96f3403edb082387fbc3a4d4aa249bce8)
---
 usr.bin/beep/beep.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/usr.bin/beep/beep.c b/usr.bin/beep/beep.c
index 2696bacfacf4..0bdfe2cf97a7 100644
--- a/usr.bin/beep/beep.c
+++ b/usr.bin/beep/beep.c
@@ -152,7 +152,7 @@ usage(void)
 int
 main(int argc, char **argv)
 {
-	int32_t *buffer;
+	float *buffer;
 	size_t slope;
 	size_t size;
 	size_t off;
@@ -208,9 +208,9 @@ main(int argc, char **argv)
 	if (ioctl(f, SOUND_PCM_WRITE_CHANNELS, &c) != 0)
 		errx(1, "ioctl SOUND_PCM_WRITE_CHANNELS(1) failed");
 
-	c = AFMT_S32_NE;
+	c = AFMT_FLOAT;
 	if (ioctl(f, SNDCTL_DSP_SETFMT, &c) != 0)
-		errx(1, "ioctl SNDCTL_DSP_SETFMT(AFMT_S32_NE) failed");
+		errx(1, "ioctl SNDCTL_DSP_SETFMT(AFMT_FLOAT) failed");
 
 	if (ioctl(f, SNDCTL_DSP_SPEED, &sample_rate) != 0)
 		errx(1, "ioctl SNDCTL_DSP_SPEED(%d) failed", sample_rate);
@@ -251,7 +251,7 @@ main(int argc, char **argv)
 		else if (off > (size - slope))
 			sample = sample * (size - off - 1) / (float)slope;
 
-		buffer[off] = sample * 0x7fffff00;
+		buffer[off] = sample;
 	}
 
 	if (write(f, buffer, size * sizeof(buffer[0])) !=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202504060028.5360ST0Q065739>