$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 #include +#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: