pkgsrc - initial commit
[pkgsrc.git] / audio / fluidsynth / patches / patch-aa
1 $NetBSD: patch-aa,v 1.2 2007/12/16 15:18:29 adam Exp $
2
3 --- src/fluid_oss.c.orig        2007-09-19 08:10:57.000000000 +0200
4 +++ src/fluid_oss.c
5 @@ -43,6 +43,12 @@
6  #include <errno.h>
7  #include <sys/poll.h>
8  
9 +#ifdef __NetBSD__
10 +#define DEVOSSMIDI "/dev/rmidi0"
11 +#else
12 +#define DEVOSSMIDI "/dev/midi"
13 +#endif
14 +
15  #define BUFFER_LENGTH 512
16  
17  /* SCHED_FIFO priorities for OSS threads (see pthread_attr_setschedparam) */
18 @@ -103,7 +109,7 @@ static void* fluid_oss_midi_run(void* d)
19  void
20  fluid_oss_audio_driver_settings(fluid_settings_t* settings)
21  {
22 -  fluid_settings_register_str(settings, "audio.oss.device", "/dev/dsp", 0, NULL, NULL);
23 +  fluid_settings_register_str(settings, "audio.oss.device", DEVOSSAUDIO, 0, NULL, NULL);
24  }
25  
26  /*
27 @@ -122,8 +128,10 @@ new_fluid_oss_audio_driver(fluid_setting
28    int format;
29    pthread_attr_t attr;
30    int err;
31 +#if !defined(__NetBSD__)
32    int sched = SCHED_FIFO;
33    struct sched_param priority;
34 +#endif
35  
36    dev = FLUID_NEW(fluid_oss_audio_driver_t);
37    if (dev == NULL) {
38 @@ -168,7 +176,7 @@ new_fluid_oss_audio_driver(fluid_setting
39    }
40  
41    if (!fluid_settings_getstr(settings, "audio.oss.device", &devname)) {
42 -    devname = "/dev/dsp";
43 +    devname = DEVOSSAUDIO;
44    }
45  
46    if (stat(devname, &devstat) == -1) {
47 @@ -229,6 +237,13 @@ new_fluid_oss_audio_driver(fluid_setting
48      goto error_recovery;
49    }
50  
51 +#ifdef __NetBSD__
52 +  err = pthread_create(&dev->thread, &attr, fluid_oss_audio_run, (void*) dev);
53 +  if (err) {
54 +    FLUID_LOG(FLUID_ERR, "Couldn't create audio thread");
55 +    goto error_recovery;
56 +  }
57 +#else
58    /* the pthread_create man page explains that
59       pthread_attr_setschedpolicy returns an error if the user is not
60       permitted the set SCHED_FIFO. it seems however that no error is
61 @@ -264,6 +279,7 @@ new_fluid_oss_audio_driver(fluid_setting
62      }
63      break;
64    }
65 +#endif /* __NetBSD__ */
66  
67    return (fluid_audio_driver_t*) dev;
68  
69 @@ -285,8 +301,10 @@ new_fluid_oss_audio_driver2(fluid_settin
70    int format;
71    pthread_attr_t attr;
72    int err;
73 +#if !defined(__NetBSD__)
74    int sched = SCHED_FIFO;
75    struct sched_param priority;
76 +#endif
77  
78    dev = FLUID_NEW(fluid_oss_audio_driver_t);
79    if (dev == NULL) {
80 @@ -311,7 +329,7 @@ new_fluid_oss_audio_driver2(fluid_settin
81  
82  
83    if (!fluid_settings_getstr(settings, "audio.oss.device", &devname)) {
84 -    devname = "/dev/dsp";
85 +    devname = DEVOSSAUDIO;
86    }
87    if (stat(devname, &devstat) == -1) {
88      FLUID_LOG(FLUID_ERR, "Device <%s> does not exists", devname);
89 @@ -380,6 +398,13 @@ new_fluid_oss_audio_driver2(fluid_settin
90      goto error_recovery;
91    }
92  
93 +#ifdef __NetBSD__
94 +  err = pthread_create(&dev->thread, &attr, fluid_oss_audio_run2, (void*) dev);
95 +  if (err) {
96 +    FLUID_LOG(FLUID_ERR, "Couldn't create audio2 thread");
97 +    goto error_recovery;
98 +  }
99 +#else
100    /* the pthread_create man page explains that
101       pthread_attr_setschedpolicy returns an error if the user is not
102       permitted the set SCHED_FIFO. it seems however that no error is
103 @@ -415,6 +440,7 @@ new_fluid_oss_audio_driver2(fluid_settin
104      }
105      break;
106    }
107 +#endif /* __NetBSD__ */
108  
109    return (fluid_audio_driver_t*) dev;
110  
111 @@ -642,7 +668,7 @@ fluid_oss_audio_run2(void* d)
112  
113  void fluid_oss_midi_driver_settings(fluid_settings_t* settings)
114  {
115 -  fluid_settings_register_str(settings, "midi.oss.device", "/dev/midi", 0, NULL, NULL);
116 +  fluid_settings_register_str(settings, "midi.oss.device", DEVOSSMIDI, 0, NULL, NULL);
117  }
118  
119  /*
120 @@ -655,8 +681,10 @@ new_fluid_oss_midi_driver(fluid_settings
121    int err;
122    fluid_oss_midi_driver_t* dev;
123    pthread_attr_t attr;
124 +#if !defined __NetBSD__
125    int sched = SCHED_FIFO;
126    struct sched_param priority;
127 +#endif
128    char* device;
129  
130    /* not much use doing anything */
131 @@ -687,7 +715,7 @@ new_fluid_oss_midi_driver(fluid_settings
132    /* get the device name. if none is specified, use the default device. */
133    fluid_settings_getstr(settings, "midi.oss.device", &device);
134    if (device == NULL) {
135 -    device = "/dev/midi";
136 +    device = DEVOSSMIDI;
137    }
138  
139    /* open the default hardware device. only use midi in. */
140 @@ -704,6 +732,14 @@ new_fluid_oss_midi_driver(fluid_settings
141      FLUID_LOG(FLUID_ERR, "Couldn't initialize midi thread attributes");
142      goto error_recovery;
143    }
144 +
145 +#ifdef __NetBSD__
146 +  err = pthread_create(&dev->thread, &attr, fluid_oss_midi_run, (void*) dev);
147 +  if (err) {
148 +    FLUID_LOG(FLUID_ERR, "Couldn't create midi thread");
149 +    goto error_recovery;
150 +  }
151 +#else
152    /* use fifo scheduling. if it fails, use default scheduling. */
153    while (1) {
154      err = pthread_attr_setschedpolicy(&attr, sched);
155 @@ -735,6 +771,7 @@ new_fluid_oss_midi_driver(fluid_settings
156      }
157      break;
158    }
159 +#endif /* __NetBSD__ */
160    return (fluid_midi_driver_t*) dev;
161  
162   error_recovery: