--- RtAudio.cpp 2017-08-31 07:00:36 UTC +++ RtAudio.cpp @@ -8685,6 +8685,12 @@ bool RtApiPulse::probeDeviceOpen( unsign #include #include +#if defined(__FreeBSD__) +#define SND_DEVICE "/dev/dsp" +#else +#define SND_DEVICE "/dev/mixer" +#endif + static void *ossCallbackHandler(void * ptr); // A structure to hold various information related to the OSS API @@ -8711,9 +8717,11 @@ RtApiOss :: ~RtApiOss() unsigned int RtApiOss :: getDeviceCount( void ) { - int mixerfd = open( "/dev/mixer", O_RDWR, 0 ); + int mixerfd = open( SND_DEVICE, O_RDWR, 0 ); if ( mixerfd == -1 ) { - errorText_ = "RtApiOss::getDeviceCount: error opening '/dev/mixer'."; + errorText_ = "RtApiOss::getDeviceCount: error opening "; + errorText_ += SND_DEVICE; + errorText_ += "'."; error( RtAudioError::WARNING ); return 0; } @@ -8735,9 +8743,11 @@ RtAudio::DeviceInfo RtApiOss :: getDevic RtAudio::DeviceInfo info; info.probed = false; - int mixerfd = open( "/dev/mixer", O_RDWR, 0 ); + int mixerfd = open( SND_DEVICE, O_RDWR, 0 ); if ( mixerfd == -1 ) { - errorText_ = "RtApiOss::getDeviceInfo: error opening '/dev/mixer'."; + errorText_ = "RtApiOss::getDeviceInfo: error opening "; + errorText_ += SND_DEVICE; + errorText_ += "'."; error( RtAudioError::WARNING ); return info; } @@ -8785,19 +8795,23 @@ RtAudio::DeviceInfo RtApiOss :: getDevic info.duplexChannels = (info.outputChannels > info.inputChannels) ? info.inputChannels : info.outputChannels; } - // Probe data formats ... do for input - unsigned long mask = ainfo.iformats; - if ( mask & AFMT_S16_LE || mask & AFMT_S16_BE ) + // Probe data formats ... merge input and output into one list + unsigned long imask = ainfo.iformats; + unsigned long omask = ainfo.oformats; + if (( imask & AFMT_S16_LE || imask & AFMT_S16_BE ) || + ( omask & AFMT_S16_LE || omask & AFMT_S16_BE )) info.nativeFormats |= RTAUDIO_SINT16; - if ( mask & AFMT_S8 ) + if (( imask & AFMT_S8 ) || ( omask & AFMT_S8 )) info.nativeFormats |= RTAUDIO_SINT8; - if ( mask & AFMT_S32_LE || mask & AFMT_S32_BE ) + if (( imask & AFMT_S32_LE || imask & AFMT_S32_BE ) || + ( omask & AFMT_S32_LE || omask & AFMT_S32_BE )) info.nativeFormats |= RTAUDIO_SINT32; #ifdef AFMT_FLOAT - if ( mask & AFMT_FLOAT ) + if (( imask & AFMT_FLOAT ) || ( omask & AFMT_FLOAT )) info.nativeFormats |= RTAUDIO_FLOAT32; #endif - if ( mask & AFMT_S24_LE || mask & AFMT_S24_BE ) + if (( imask & AFMT_S24_LE || imask & AFMT_S24_BE ) || + ( omask & AFMT_S24_LE || omask & AFMT_S24_BE )) info.nativeFormats |= RTAUDIO_SINT24; // Check that we have at least one supported format @@ -8855,9 +8869,11 @@ bool RtApiOss :: probeDeviceOpen( unsign RtAudioFormat format, unsigned int *bufferSize, RtAudio::StreamOptions *options ) { - int mixerfd = open( "/dev/mixer", O_RDWR, 0 ); + int mixerfd = open( SND_DEVICE, O_RDWR, 0 ); if ( mixerfd == -1 ) { - errorText_ = "RtApiOss::probeDeviceOpen: error opening '/dev/mixer'."; + errorText_ = "RtApiOss::probeDeviceOpen: error opening "; + errorText_ += SND_DEVICE; + errorText_ += "'."; return FAILURE; } @@ -8885,7 +8901,11 @@ bool RtApiOss :: probeDeviceOpen( unsign } oss_audioinfo ainfo; - ainfo.dev = device; +#if defined(__FreeBSD__) + ainfo.dev = -1; // specify -1 to get default device +#else + ainfo.dev = device; +#endif result = ioctl( mixerfd, SNDCTL_AUDIOINFO, &ainfo ); close( mixerfd ); if ( result == -1 ) {