From 3ead8d226694cd765cf1aaa7ba6e02b698f0eaba Mon Sep 17 00:00:00 2001 From: nia <29542929+alarixnia@users.noreply.github.com> Date: Tue, 21 Sep 2021 12:15:14 +0000 Subject: [PATCH] sndfile-play: Add NetBSD support (#776) * sndfile-play: Use Sun-compatible audio device on NetBSD Keep the gain unchanged. Avoids distortion from playing sounds too loudly and preserves the user's existing volume settings. --- man/sndfile-play.1 | 4 +++- programs/sndfile-play.c | 10 ++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/man/sndfile-play.1 b/man/sndfile-play.1 index f36d1315..4d570eaf 100644 --- a/man/sndfile-play.1 +++ b/man/sndfile-play.1 @@ -1,4 +1,4 @@ -.Dd November 2, 2014 +.Dd September 10, 2021 .Dt SNDFILE-PLAY 1 .Os .Sh NAME @@ -19,6 +19,8 @@ ALSA or OSS sndio .It FreeBSD /dev/dsp (OSS) +.It NetBSD +/dev/audio .It Solaris /dev/audio .It MacOSX 10.6 diff --git a/programs/sndfile-play.c b/programs/sndfile-play.c index c2818476..16aaf4d2 100644 --- a/programs/sndfile-play.c +++ b/programs/sndfile-play.c @@ -64,7 +64,7 @@ #elif HAVE_SNDIO_H #include -#elif (defined (sun) && defined (unix)) +#elif (defined (sun) && defined (unix)) || defined(__NetBSD__) #include #include #include @@ -729,7 +729,7 @@ sndio_play (int argc, char *argv []) ** Solaris. */ -#if (defined (sun) && defined (unix)) /* ie Solaris */ +#if (defined (sun) && defined (unix)) || defined(__NetBSD__) static void solaris_play (int argc, char *argv []) @@ -766,8 +766,6 @@ solaris_play (int argc, char *argv []) audio_info.play.channels = sfinfo.channels ; audio_info.play.precision = 16 ; audio_info.play.encoding = AUDIO_ENCODING_LINEAR ; - audio_info.play.gain = AUDIO_MAX_GAIN ; - audio_info.play.balance = AUDIO_MID_BALANCE ; if ((error = ioctl (audio_fd, AUDIO_SETINFO, &audio_info))) { perror ("ioctl (AUDIO_SETINFO) failed") ; @@ -809,7 +807,7 @@ solaris_play (int argc, char *argv []) return ; } /* solaris_play */ -#endif /* Solaris */ +#endif /* Solaris or NetBSD */ /*============================================================================== ** Main function. @@ -847,7 +845,7 @@ main (int argc, char *argv []) opensoundsys_play (argc, argv) ; #elif HAVE_SNDIO_H sndio_play (argc, argv) ; -#elif (defined (sun) && defined (unix)) +#elif (defined (sun) && defined (unix)) || defined(__NetBSD__) solaris_play (argc, argv) ; #elif (OS_IS_WIN32 == 1) win32_play (argc, argv) ;