summaryrefslogtreecommitdiff
path: root/audio/fluidsynth/patches/patch-aa
blob: fff40b6c3fd6cc6b0fc7eaca80a77f9e8f5235bf (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
$NetBSD: patch-aa,v 1.1.1.1 2005/04/25 13:53:37 adam Exp $

--- src/fluid_oss.c.orig	Wed Mar  3 03:02:28 2004
+++ src/fluid_oss.c
@@ -43,6 +43,12 @@
 #include <errno.h>
 #include <sys/poll.h>
 
+#ifdef __NetBSD__
+#define DEVOSSMIDI "/dev/rmidi0"
+#else
+#define DEVOSSMIDI "/dev/midi"
+#endif
+
 #define BUFFER_LENGTH 512
 
 /* SCHED_FIFO priorities for OSS threads (see pthread_attr_setschedparam) */
@@ -103,7 +109,7 @@ static void* fluid_oss_midi_run(void* d)
 void
 fluid_oss_audio_driver_settings(fluid_settings_t* settings)
 {
-  fluid_settings_register_str(settings, "audio.oss.device", "/dev/dsp", 0, NULL, NULL);
+  fluid_settings_register_str(settings, "audio.oss.device", DEVOSSAUDIO, 0, NULL, NULL);
 }
 
 /*
@@ -122,8 +128,10 @@ new_fluid_oss_audio_driver(fluid_setting
   int format;
   pthread_attr_t attr;
   int err;
+#if !defined(__NetBSD__)
   int sched = SCHED_FIFO;
   struct sched_param priority;
+#endif
 
   dev = FLUID_NEW(fluid_oss_audio_driver_t);
   if (dev == NULL) {
@@ -168,7 +176,7 @@ new_fluid_oss_audio_driver(fluid_setting
   }
 
   if (!fluid_settings_getstr(settings, "audio.oss.device", &devname)) {
-    devname = "/dev/dsp";
+    devname = DEVOSSAUDIO;
   }
 
   if (stat(devname, &devstat) == -1) {
@@ -229,6 +237,13 @@ new_fluid_oss_audio_driver(fluid_setting
     goto error_recovery;
   }
 
+#ifdef __NetBSD__
+  err = pthread_create(&dev->thread, &attr, fluid_oss_audio_run, (void*) dev);
+  if (err) {
+    FLUID_LOG(FLUID_ERR, "Couldn't create audio thread");
+    goto error_recovery;
+  }
+#else
   /* the pthread_create man page explains that
      pthread_attr_setschedpolicy returns an error if the user is not
      permitted the set SCHED_FIFO. it seems however that no error is
@@ -264,6 +279,7 @@ new_fluid_oss_audio_driver(fluid_setting
     }
     break;
   }
+#endif /* __NetBSD__ */
 
   return (fluid_audio_driver_t*) dev;
 
@@ -285,8 +301,10 @@ new_fluid_oss_audio_driver2(fluid_settin
   int format;
   pthread_attr_t attr;
   int err;
+#if !defined(__NetBSD__)
   int sched = SCHED_FIFO;
   struct sched_param priority;
+#endif
 
   dev = FLUID_NEW(fluid_oss_audio_driver_t);
   if (dev == NULL) {
@@ -311,7 +329,7 @@ new_fluid_oss_audio_driver2(fluid_settin
 
 
   if (!fluid_settings_getstr(settings, "audio.oss.device", &devname)) {
-    devname = "/dev/dsp";
+    devname = DEVOSSAUDIO;
   }
   if (stat(devname, &devstat) == -1) {
     FLUID_LOG(FLUID_ERR, "Device <%s> does not exists", devname);    
@@ -380,6 +398,13 @@ new_fluid_oss_audio_driver2(fluid_settin
     goto error_recovery;
   }
 
+#ifdef __NetBSD__
+  err = pthread_create(&dev->thread, &attr, fluid_oss_audio_run2, (void*) dev);
+  if (err) {
+    FLUID_LOG(FLUID_ERR, "Couldn't create audio2 thread");
+    goto error_recovery;
+  }
+#else
   /* the pthread_create man page explains that
      pthread_attr_setschedpolicy returns an error if the user is not
      permitted the set SCHED_FIFO. it seems however that no error is
@@ -415,6 +440,7 @@ new_fluid_oss_audio_driver2(fluid_settin
     }
     break;
   }
+#endif /* __NetBSD__ */
 
   return (fluid_audio_driver_t*) dev;
 
@@ -644,7 +670,7 @@ fluid_oss_audio_run2(void* d)
 
 void fluid_oss_midi_driver_settings(fluid_settings_t* settings)
 {
-  fluid_settings_register_str(settings, "midi.oss.device", "/dev/midi", 0, NULL, NULL);
+  fluid_settings_register_str(settings, "midi.oss.device", DEVOSSMIDI, 0, NULL, NULL);
 }
 
 /*
@@ -657,8 +683,10 @@ new_fluid_oss_midi_driver(fluid_settings
   int err;
   fluid_oss_midi_driver_t* dev;
   pthread_attr_t attr;
+#if !defined __NetBSD__
   int sched = SCHED_FIFO;
   struct sched_param priority;
+#endif
   char* device;
   
   /* not much use doing anything */
@@ -689,7 +717,7 @@ new_fluid_oss_midi_driver(fluid_settings
   /* get the device name. if none is specified, use the default device. */
   fluid_settings_getstr(settings, "midi.oss.device", &device);
   if (device == NULL) {
-    device = "/dev/midi";
+    device = DEVOSSMIDI;
   }
 
   /* open the default hardware device. only use midi in. */
@@ -706,6 +734,14 @@ new_fluid_oss_midi_driver(fluid_settings
     FLUID_LOG(FLUID_ERR, "Couldn't initialize midi thread attributes");
     goto error_recovery;
   }
+
+#ifdef __NetBSD__
+  err = pthread_create(&dev->thread, &attr, fluid_oss_midi_run, (void*) dev);
+  if (err) {
+    FLUID_LOG(FLUID_ERR, "Couldn't create midi thread");
+    goto error_recovery;
+  }
+#else
   /* use fifo scheduling. if it fails, use default scheduling. */
   while (1) {
     err = pthread_attr_setschedpolicy(&attr, sched);
@@ -737,6 +773,7 @@ new_fluid_oss_midi_driver(fluid_settings
     }
     break;
   }  
+#endif /* __NetBSD__ */
   return (fluid_midi_driver_t*) dev;
 
  error_recovery: