summaryrefslogtreecommitdiff
path: root/devel/godot/files/patch-thirdparty_rtaudio_RtAudio.cpp
blob: 02dd71439c984a4765fe6e417df268135f8e2a73 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--- thirdparty/rtaudio/RtAudio.cpp.orig	2016-08-09 07:52:15 UTC
+++ thirdparty/rtaudio/RtAudio.cpp
@@ -8589,6 +8589,12 @@ bool RtApiPulse::probeDeviceOpen( unsign
 #include <errno.h>
 #include <math.h>
 
+#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
@@ -8615,9 +8621,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;
   }
@@ -8639,9 +8647,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;
   }
@@ -8697,8 +8707,10 @@ RtAudio::DeviceInfo RtApiOss :: getDevic
     info.nativeFormats |= RTAUDIO_SINT8;
   if ( mask & AFMT_S32_LE || mask & AFMT_S32_BE )
     info.nativeFormats |= RTAUDIO_SINT32;
+#if defined(AFMT_FLOAT)
   if ( mask & AFMT_FLOAT )
     info.nativeFormats |= RTAUDIO_FLOAT32;
+#endif
   if ( mask & AFMT_S24_LE || mask & AFMT_S24_BE )
     info.nativeFormats |= RTAUDIO_SINT24;
 
@@ -8757,9 +8769,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;
   }
 
@@ -8787,7 +8801,11 @@ bool RtApiOss :: probeDeviceOpen( unsign
   }
 
   oss_audioinfo ainfo;
+#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 ) {
@@ -9025,7 +9043,7 @@ bool RtApiOss :: probeDeviceOpen( unsign
   }
 
   // Verify the sample rate setup worked.
-  if ( abs( srate - sampleRate ) > 100 ) {
+  if ( abs( srate - (int)sampleRate ) > 100 ) {
     close( fd );
     errorStream_ << "RtApiOss::probeDeviceOpen: device (" << ainfo.name << ") does not support sample rate (" << sampleRate << ").";
     errorText_ = errorStream_.str();