$NetBSD: patch-ac,v 1.3 2007/05/23 12:00:04 rillig Exp $ --- oss.c.orig 2001-05-14 23:35:52.000000000 +0200 +++ oss.c 2007-05-23 13:57:16.000000000 +0200 @@ -42,9 +42,10 @@ # include #elif defined(HAVE_MACHINE_SOUNDCARD_H) # include +#elif defined(HAVE_SOUNDCARD_H) +# include #endif - /* output plugin callback prototypes */ static void oss_get_volume (int *l, int *r); static void oss_set_volume (int l, int r); @@ -91,6 +92,8 @@ static gint dsp_buffer_size = 0; static gint dsp_fragment_size = 0; static gboolean dsp_select_works = FALSE; +/* let's assume that this is really meant to be a local variable. */ +#define buffer_mutex oss_c_local_variable_buffer_mutex static pthread_mutex_t buffer_mutex; static pthread_t buffer_thread; @@ -305,9 +308,9 @@ oss_open_audio(AFormat fmt, int rate, in if(config->oss_use_alt_audio_device && (config->oss_alt_audio_device != NULL)) device_name = g_strdup(config->oss_alt_audio_device); else if(config->oss_audio_device > 0) - device_name = g_strdup_printf("/dev/dsp%d", config->oss_audio_device); + device_name = g_strdup_printf(DEFAULT_OSS_ALT_AUDIO_DEVICE "%d", config->oss_audio_device); else - device_name = g_strdup("/dev/dsp"); + device_name = g_strdup(DEFAULT_OSS_ALT_AUDIO_DEVICE); /* HACK: Test if the device is not locked by another process. This is * just a crude workaround to avoid complete lockup of XMMS. It is @@ -499,13 +502,26 @@ buffer_thread_f(void *arg) while(dsp_fd != -1) { /* wait for device */ if(dsp_select_works) { - tv.tv_sec = 0; + pthread_mutex_unlock(&buffer_mutex); +#ifdef _PTH_PTHREAD_H_ + { int i; + + for (i=0; i<16; i++) { + tv.tv_usec = OSS_FRAGMENT_UTIME/16; +#else tv.tv_usec = OSS_FRAGMENT_UTIME; +#endif + tv.tv_sec = 0; FD_ZERO(&set); FD_SET(dsp_fd, &set); - pthread_mutex_unlock(&buffer_mutex); sel = select(dsp_fd+1, NULL, &set, NULL, &tv); +#ifdef _PTH_PTHREAD_H_ + if (sel) break; + + sched_yield(); + }} +#endif pthread_mutex_lock(&buffer_mutex); if(sel == -1) {