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.
This commit is contained in:
nia 2021-09-21 12:15:14 +00:00 committed by GitHub
parent f65e8bc9d1
commit 3ead8d2266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
.Dd November 2, 2014 .Dd September 10, 2021
.Dt SNDFILE-PLAY 1 .Dt SNDFILE-PLAY 1
.Os .Os
.Sh NAME .Sh NAME
@ -19,6 +19,8 @@ ALSA or OSS
sndio sndio
.It FreeBSD .It FreeBSD
/dev/dsp (OSS) /dev/dsp (OSS)
.It NetBSD
/dev/audio
.It Solaris .It Solaris
/dev/audio /dev/audio
.It MacOSX 10.6 .It MacOSX 10.6

View File

@ -64,7 +64,7 @@
#elif HAVE_SNDIO_H #elif HAVE_SNDIO_H
#include <sndio.h> #include <sndio.h>
#elif (defined (sun) && defined (unix)) #elif (defined (sun) && defined (unix)) || defined(__NetBSD__)
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/audioio.h> #include <sys/audioio.h>
@ -729,7 +729,7 @@ sndio_play (int argc, char *argv [])
** Solaris. ** Solaris.
*/ */
#if (defined (sun) && defined (unix)) /* ie Solaris */ #if (defined (sun) && defined (unix)) || defined(__NetBSD__)
static void static void
solaris_play (int argc, char *argv []) 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.channels = sfinfo.channels ;
audio_info.play.precision = 16 ; audio_info.play.precision = 16 ;
audio_info.play.encoding = AUDIO_ENCODING_LINEAR ; 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))) if ((error = ioctl (audio_fd, AUDIO_SETINFO, &audio_info)))
{ perror ("ioctl (AUDIO_SETINFO) failed") ; { perror ("ioctl (AUDIO_SETINFO) failed") ;
@ -809,7 +807,7 @@ solaris_play (int argc, char *argv [])
return ; return ;
} /* solaris_play */ } /* solaris_play */
#endif /* Solaris */ #endif /* Solaris or NetBSD */
/*============================================================================== /*==============================================================================
** Main function. ** Main function.
@ -847,7 +845,7 @@ main (int argc, char *argv [])
opensoundsys_play (argc, argv) ; opensoundsys_play (argc, argv) ;
#elif HAVE_SNDIO_H #elif HAVE_SNDIO_H
sndio_play (argc, argv) ; sndio_play (argc, argv) ;
#elif (defined (sun) && defined (unix)) #elif (defined (sun) && defined (unix)) || defined(__NetBSD__)
solaris_play (argc, argv) ; solaris_play (argc, argv) ;
#elif (OS_IS_WIN32 == 1) #elif (OS_IS_WIN32 == 1)
win32_play (argc, argv) ; win32_play (argc, argv) ;