r3869 - in branches/beast-mingw: . birnet bse
- From: stw svn gnome org
- To: svn-commits-list gnome org
- Subject: r3869 - in branches/beast-mingw: . birnet bse
- Date: Sat, 26 Aug 2006 17:51:29 -0400 (EDT)
Author: stw
Date: 2006-08-26 17:50:32 -0400 (Sat, 26 Aug 2006)
New Revision: 3869
Added:
branches/beast-mingw/bse/bsewin32.cc
branches/beast-mingw/bse/bsewin32.h
Modified:
branches/beast-mingw/ChangeLog.win32
branches/beast-mingw/birnet/birnetcore.h
branches/beast-mingw/bse/Makefile.am
branches/beast-mingw/bse/bseblockutils.hh
branches/beast-mingw/bse/bseengine.c
branches/beast-mingw/bse/bseenginemaster.c
branches/beast-mingw/bse/bseenginemaster.h
branches/beast-mingw/bse/bsemididevice-oss.c
branches/beast-mingw/bse/bsepcmdevice-oss.c
branches/beast-mingw/bse/bseplugin.c
branches/beast-mingw/bse/bsesequencer.cc
branches/beast-mingw/bse/bseserver.c
branches/beast-mingw/bse/gslcommon.c
branches/beast-mingw/bse/gsldatahandle-mad.c
branches/beast-mingw/bse/gslfilehash.c
branches/beast-mingw/bse/mkcproc.pl
Log:
Sat Aug 26 23:48:45 2006 Stefan Westerfeld <stefan space twc de>
* birnet/birnetcore.h: Provide fake definition for ETXTBSY errno.
* bse/Makefile.am:
* bse/bsewin32.h:
* bse/bsewin32.cc: Implement semaphore based thread notification; using
pipe()s under windows just doesn't work, as they need an extra thread
(because they are not really poll()able). But using an extra thread
would be bad for realtime performace.
* bse/bseengine.c:
* bse/bseenginemaster.[hc]:
* bse/bsesequencer.cc: Use semaphore based thread wakeup instead of
pipe based thread wakeup.
* bse/bseplugin.c: Fix plugin search pattern for plugins:
For windows, we need to use "*.dll", for unix, we need to keep using
"*.so" as before.
* bse/Makefile.am: Under windows, it is not possible to use the .o
files of birnet and sfi, to copy their contents into the bse dll, so
we simply link against libbirnet.la and libsfi.la, as usual.
* bse/bseserver.c: Disabled priority code via #if 0..., since this
needs to be done differently on windows.
* bse/bseenginemaster.c: Use g_get_current_time() instead of
gettimeofday().
* bse/bsepcmdevice-oss.c: Never compile this, since we don't need it
for win32 (hack).
* bse/gsldatahandle-mad.c: There is no <sys/mman.h> under windows. #if
0.
* bse/bseblockutils.hh: sizeof (wchar_t) == 2 under windows, so we
can't use wmemset (and so forth).
* bse/gslfilehash.c: Hack to get it to compile. There is no O_NOCTTY
on windows.
* bse/mkcproc.pl: Don't hardcode that perl is in /usr/bin/perl.
* bse/gslcommon.c: Hacks: remove unexistant includes.
Modified: branches/beast-mingw/ChangeLog.win32
===================================================================
--- branches/beast-mingw/ChangeLog.win32 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/ChangeLog.win32 2006-08-26 21:50:32 UTC (rev 3869)
@@ -1,3 +1,49 @@
+Sat Aug 26 23:48:45 2006 Stefan Westerfeld <stefan space twc de>
+
+ * birnet/birnetcore.h: Provide fake definition for ETXTBSY errno.
+
+ * bse/Makefile.am:
+ * bse/bsewin32.h:
+ * bse/bsewin32.cc: Implement semaphore based thread notification; using
+ pipe()s under windows just doesn't work, as they need an extra thread
+ (because they are not really poll()able). But using an extra thread
+ would be bad for realtime performace.
+
+ * bse/bseengine.c:
+ * bse/bseenginemaster.[hc]:
+ * bse/bsesequencer.cc: Use semaphore based thread wakeup instead of
+ pipe based thread wakeup.
+
+ * bse/bseplugin.c: Fix plugin search pattern for plugins:
+ For windows, we need to use "*.dll", for unix, we need to keep using
+ "*.so" as before.
+
+ * bse/Makefile.am: Under windows, it is not possible to use the .o
+ files of birnet and sfi, to copy their contents into the bse dll, so
+ we simply link against libbirnet.la and libsfi.la, as usual.
+
+ * bse/bseserver.c: Disabled priority code via #if 0..., since this
+ needs to be done differently on windows.
+
+ * bse/bseenginemaster.c: Use g_get_current_time() instead of
+ gettimeofday().
+
+ * bse/bsepcmdevice-oss.c: Never compile this, since we don't need it
+ for win32 (hack).
+
+ * bse/gsldatahandle-mad.c: There is no <sys/mman.h> under windows. #if
+ 0.
+
+ * bse/bseblockutils.hh: sizeof (wchar_t) == 2 under windows, so we
+ can't use wmemset (and so forth).
+
+ * bse/gslfilehash.c: Hack to get it to compile. There is no O_NOCTTY
+ on windows.
+
+ * bse/mkcproc.pl: Don't hardcode that perl is in /usr/bin/perl.
+
+ * bse/gslcommon.c: Hacks: remove unexistant includes.
+
Thu Aug 24 20:24:17 2006 Stefan Westerfeld <stefan space twc de>
* sfi/sficomport.c:
Modified: branches/beast-mingw/birnet/birnetcore.h
===================================================================
--- branches/beast-mingw/birnet/birnetcore.h 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/birnet/birnetcore.h 2006-08-26 21:50:32 UTC (rev 3869)
@@ -30,6 +30,7 @@
them internally, to indicate internal error types */
#define ELOOP 1000
#define ENODATA 1001
+#define ETXTBSY 1002
#endif
BIRNET_EXTERN_C_BEGIN();
Modified: branches/beast-mingw/bse/Makefile.am
===================================================================
--- branches/beast-mingw/bse/Makefile.am 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/Makefile.am 2006-08-26 21:50:32 UTC (rev 3869)
@@ -54,7 +54,7 @@
bsecompat.h bseundostack.h bsemidiinput.h bsemididecoder.h \
bsenote.h bsemidifile.h bseblockutils.hh \
bsecxxvalue.hh bsecxxutils.hh bsecxxbase.hh bsecxxclosure.hh \
- bsecxxarg.hh bsecxxmodule.hh bsecxxplugin.hh bseloader.h \
+ bsecxxarg.hh bsecxxmodule.hh bsecxxplugin.hh bseloader.h bsewin32.h \
)
# BSE C sources
bse_c_sources = $(strip \
@@ -87,7 +87,7 @@
bsecxxvalue.cc bsecxxutils.cc bsecxxbase.cc bsecxxclosure.cc \
bsecxxarg.cc bsecxxmodule.cc bsecxxplugin.cc bseloader.c \
bseloader-aiff.c bseloader-guspatch.cc bseloader-oggvorbis.c bseloader-bsewave.c \
- bseloader-mad.c bseloader-wav.c \
+ bseloader-mad.c bseloader-wav.c bsewin32.cc \
)
# BSE C++ sources
bse_cc_sources = $(strip \
@@ -138,7 +138,7 @@
libbseinclude_HEADERS = $(bse_public_h_sources) bse.idl $(bse_idl_sources) bsehack.idl $(idl_dummy_files)
nodist_libbseinclude_HEADERS = bsecore.genidl.hh
libbse_la_SOURCES = $(bse_c_sources) $(bse_proc_gen_sources) $(bse_cc_sources)
-libbse_la_LIBADD = $(top_builddir)/birnet/libbirnet.o $(top_builddir)/sfi/libsfi.o $(BSE_LIBS) $(SFI_LIBS)
+libbse_la_LIBADD = $(top_builddir)/birnet/libbirnet.la $(top_builddir)/sfi/libsfi.la $(BSE_LIBS) $(SFI_LIBS)
libbse_la_LDFLAGS = $(strip \
-Wl,--version-script=$(srcdir)/ldscript.map \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
Modified: branches/beast-mingw/bse/bseblockutils.hh
===================================================================
--- branches/beast-mingw/bse/bseblockutils.hh 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bseblockutils.hh 2006-08-26 21:50:32 UTC (rev 3869)
@@ -124,7 +124,7 @@
const float *ivalues,
float& min_value,
float& max_value) { return singleton->range_and_square_sum (n_values, ivalues, min_value, max_value); }
-
+
class Impl {
protected:
virtual ~Impl ();
@@ -174,10 +174,15 @@
float *values,
float value)
{
+#ifdef WIN32
+ while (n_values--)
+ *values++ = value;
+#else
BIRNET_STATIC_ASSERT (sizeof (float) == 4);
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
const union { float f; guint32 vuint32; } u = { value };
wmemset ((wchar_t*) values, u.vuint32, n_values);
+#endif
}
inline void
@@ -185,8 +190,13 @@
guint32 *values,
guint32 value)
{
+#ifdef WIN32
+ while (n_values--)
+ *values++ = value;
+#else
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) values, value, n_values);
+#endif
}
inline void
@@ -194,8 +204,12 @@
guint32 *values,
const guint32 *ivalues)
{
+#ifdef WIN32
+ memcpy (values, ivalues, n_values * sizeof (guint32));
+#else
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
+#endif
}
inline void
@@ -203,9 +217,14 @@
gfloat *values,
const gfloat *ivalues)
{
+#ifdef WIN32
+ while (n_values--)
+ *values++ = *ivalues++;
+#else
BIRNET_STATIC_ASSERT (sizeof (float) == 4);
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
+#endif
}
} // Bse
@@ -219,8 +238,13 @@
guint32 *values,
guint32 vuint32)
{
+#ifdef WIN32
+ while (n_values--)
+ *values++ = vuint32;
+#else
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) values, vuint32, n_values);
+#endif
}
static inline void
@@ -228,10 +252,15 @@
float *values,
const float value)
{
+#ifdef WIN32
+ while (n_values--)
+ *values++ = value;
+#else
BIRNET_STATIC_ASSERT (sizeof (float) == 4);
const union { float f; guint32 vuint32; } u = { value };
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) values, u.vuint32, n_values);
+#endif
}
static inline void
@@ -239,8 +268,13 @@
guint32 *values,
const guint32 *ivalues)
{
+#if WIN32
+ while (n_values--)
+ *values++ = *ivalues++;
+#else
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
+#endif
}
static inline void
@@ -248,9 +282,14 @@
gfloat *values,
const gfloat *ivalues)
{
+#if WIN32
+ while (n_values--)
+ *values++ = *ivalues++;
+#else
BIRNET_STATIC_ASSERT (sizeof (float) == 4);
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
+#endif
}
G_END_DECLS
Modified: branches/beast-mingw/bse/bseengine.c
===================================================================
--- branches/beast-mingw/bse/bseengine.c 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bseengine.c 2006-08-26 21:50:32 UTC (rev 3869)
@@ -1325,6 +1325,8 @@
*control_raster_p = control_raster;
}
+static BIRNET_MUTEX_DECLARE_INITIALIZED (sync_mutex);
+
/**
* @param latency_ms calculation latency in milli seconds
* @param sample_freq mixing frequency
@@ -1340,7 +1342,6 @@
guint sample_freq,
guint control_freq)
{
- static BirnetMutex sync_mutex = { 0, };
static BirnetCond sync_cond = { 0, };
static gboolean sync_lock = FALSE;
guint block_size, control_raster, success = FALSE;
@@ -1443,8 +1444,11 @@
if (bse_engine_threaded)
{
+ master_data.user_thread = birnet_thread_self ();
+#ifdef WIN32
+ master_data.win32_waiter = bse_win32_waiter_new();
+#else
gint err = pipe (master_data.wakeup_pipe);
- master_data.user_thread = birnet_thread_self ();
if (!err)
{
glong d_long = fcntl (master_data.wakeup_pipe[0], F_GETFL, 0);
@@ -1461,6 +1465,7 @@
}
if (err)
g_error ("failed to create wakeup pipe: %s", g_strerror (errno));
+#endif
master_thread = birnet_thread_run ("DSP #1", (BirnetThreadFunc) bse_engine_master_thread, &master_data);
if (!master_thread)
g_error ("failed to create master thread");
@@ -1474,11 +1479,15 @@
{
if (master_thread)
{
+#ifdef WIN32
+ bse_win32_waiter_wakeup (master_data.win32_waiter);
+#else
guint8 data = 'W';
gint l;
do
l = write (master_data.wakeup_pipe[1], &data, 1);
while (l < 0 && (errno == EINTR || errno == ERESTART));
+#endif
}
}
Modified: branches/beast-mingw/bse/bseenginemaster.c
===================================================================
--- branches/beast-mingw/bse/bseenginemaster.c 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bseenginemaster.c 2006-08-26 21:50:32 UTC (rev 3869)
@@ -25,7 +25,6 @@
#include "bseieee754.h"
#include <string.h>
#include <unistd.h>
-#include <sys/poll.h>
#include <sys/time.h>
#include <errno.h>
@@ -38,10 +37,10 @@
/* --- time stamping (debugging) --- */
-#define ToyprofStamp struct timeval
+#define ToyprofStamp GTimeVal
#define toyprof_clock_name() ("Glibc gettimeofday(2)")
#define toyprof_stampinit() /* nothing */
-#define toyprof_stamp(st) gettimeofday (&(st), 0)
+#define toyprof_stamp(st) g_get_current_time (&(st))
#define toyprof_stamp_ticks() (1000000)
static inline guint64
toyprof_elapsed (ToyprofStamp fstamp,
@@ -1134,6 +1133,7 @@
{
birnet_msg_set_thread_handler (bse_msg_handler);
+#if 0
/* assert pollfd equality, since we're simply casting structures */
g_static_assert (sizeof (struct pollfd) == sizeof (GPollFD));
g_static_assert (G_STRUCT_OFFSET (GPollFD, fd) == G_STRUCT_OFFSET (struct pollfd, fd));
@@ -1150,6 +1150,7 @@
master_pollfds[0].events = G_IO_IN;
master_n_pollfds = 1;
master_pollfds_changed = TRUE;
+#endif
toyprof_stampinit ();
@@ -1162,11 +1163,15 @@
if (!need_dispatch)
{
+#ifdef WIN32
+ loop.revents_filled = bse_win32_waiter_wait (mdata->win32_waiter, loop.timeout) > 0;
+#else
gint err = poll ((struct pollfd*) loop.fds, loop.n_fds, loop.timeout);
if (err >= 0)
loop.revents_filled = TRUE;
else if (errno != EINTR)
g_printerr ("%s: poll() error: %s\n", G_STRFUNC, g_strerror (errno));
+#endif
if (loop.revents_filled)
need_dispatch = _engine_master_check (&loop);
@@ -1174,7 +1179,8 @@
if (need_dispatch)
_engine_master_dispatch ();
-
+
+#ifndef WIN32
/* clear wakeup pipe */
{
guint8 data[64];
@@ -1183,6 +1189,7 @@
l = read (mdata->wakeup_pipe[0], data, sizeof (data));
while ((l < 0 && errno == EINTR) || l == sizeof (data));
}
+#endif
/* wakeup user thread if necessary */
if (bse_engine_has_garbage ())
Modified: branches/beast-mingw/bse/bseenginemaster.h
===================================================================
--- branches/beast-mingw/bse/bseenginemaster.h 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bseenginemaster.h 2006-08-26 21:50:32 UTC (rev 3869)
@@ -19,6 +19,7 @@
#define __BSE_ENGINE_MASTER_H__
#include <bse/bseengine.h>
+#include <bse/bsewin32.h>
G_BEGIN_DECLS
@@ -28,8 +29,12 @@
void _engine_master_dispatch_jobs (void);
void _engine_master_dispatch (void);
typedef struct {
- BirnetThread *user_thread;
- gint wakeup_pipe[2]; /* read(wakeup_pipe[0]), write(wakeup_pipe[1]) */
+ BirnetThread *user_thread;
+#ifdef WIN32
+ BseWin32Waiter *win32_waiter;
+#else
+ gint wakeup_pipe[2]; /* read(wakeup_pipe[0]), write(wakeup_pipe[1]) */
+#endif
} EngineMasterData;
void bse_engine_master_thread (EngineMasterData *mdata);
Modified: branches/beast-mingw/bse/bsemididevice-oss.c
===================================================================
--- branches/beast-mingw/bse/bsemididevice-oss.c 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bsemididevice-oss.c 2006-08-26 21:50:32 UTC (rev 3869)
@@ -22,7 +22,7 @@
#include "bsesequencer.h"
#include "topconfig.h"
-#ifndef BSE_MIDI_DEVICE_CONF_OSS
+#if 1 /* ndef BSE_MIDI_DEVICE_CONF_OSS <- hack! */
BSE_DUMMY_TYPE (BseMidiDeviceOSS);
#else /* BSE_MIDI_DEVICE_CONF_OSS */
Modified: branches/beast-mingw/bse/bsepcmdevice-oss.c
===================================================================
--- branches/beast-mingw/bse/bsepcmdevice-oss.c 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bsepcmdevice-oss.c 2006-08-26 21:50:32 UTC (rev 3869)
@@ -22,7 +22,7 @@
#include "gsldatautils.h"
#include "gslcommon.h" // FIXME: remove
-#ifndef BSE_PCM_DEVICE_CONF_OSS
+#if 1 /* ndef BSE_PCM_DEVICE_CONF_OSS <- hack */
BSE_DUMMY_TYPE (BsePcmDeviceOSS);
#else /* BSE_PCM_DEVICE_CONF_OSS */
Modified: branches/beast-mingw/bse/bseplugin.c
===================================================================
--- branches/beast-mingw/bse/bseplugin.c 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bseplugin.c 2006-08-26 21:50:32 UTC (rev 3869)
@@ -657,6 +657,12 @@
return false;
}
+#ifdef WIN32
+#define PLUGIN_EXTENSION ".dll"
+#else
+#define PLUGIN_EXTENSION ".so"
+#endif
+
SfiRing*
bse_plugin_path_list_files (gboolean include_drivers,
gboolean include_plugins)
@@ -672,21 +678,21 @@
{
if (include_drivers)
{
- files = sfi_file_crawler_list_files (BSE_PATH_DRIVERS, "*.so", G_FILE_TEST_IS_REGULAR);
+ files = sfi_file_crawler_list_files (BSE_PATH_DRIVERS, "*" PLUGIN_EXTENSION, G_FILE_TEST_IS_REGULAR);
ring = sfi_ring_concat (ring, sfi_ring_sort (files, (SfiCompareFunc) strcmp, NULL));
files = sfi_file_crawler_list_files (BSE_PATH_DRIVERS, "*.o", G_FILE_TEST_IS_REGULAR);
ring = sfi_ring_concat (ring, sfi_ring_sort (files, (SfiCompareFunc) strcmp, NULL));
}
if (include_plugins)
{
- files = sfi_file_crawler_list_files (BSE_PATH_PLUGINS, "*.so", G_FILE_TEST_IS_REGULAR);
+ files = sfi_file_crawler_list_files (BSE_PATH_PLUGINS, "*" PLUGIN_EXTENSION, G_FILE_TEST_IS_REGULAR);
ring = sfi_ring_concat (ring, sfi_ring_sort (files, (SfiCompareFunc) strcmp, NULL));
files = sfi_file_crawler_list_files (BSE_PATH_PLUGINS, "*.o", G_FILE_TEST_IS_REGULAR);
ring = sfi_ring_concat (ring, sfi_ring_sort (files, (SfiCompareFunc) strcmp, NULL));
}
if (include_plugins && BSE_GCONFIG (plugin_path) && BSE_GCONFIG (plugin_path)[0])
{
- files = sfi_file_crawler_list_files (BSE_GCONFIG (plugin_path), "*.so", G_FILE_TEST_IS_REGULAR);
+ files = sfi_file_crawler_list_files (BSE_GCONFIG (plugin_path), "*" PLUGIN_EXTENSION, G_FILE_TEST_IS_REGULAR);
ring = sfi_ring_concat (ring, sfi_ring_sort (files, (SfiCompareFunc) strcmp, NULL));
files = sfi_file_crawler_list_files (BSE_GCONFIG (plugin_path), "*.o", G_FILE_TEST_IS_REGULAR);
ring = sfi_ring_concat (ring, sfi_ring_sort (files, (SfiCompareFunc) strcmp, NULL));
@@ -698,12 +704,12 @@
if (true)
{
const BirnetCPUInfo *cpu_info = birnet_cpu_info();
- const char *exts[] = { ".FPU.so", ".FPU.la", ".so", ".la", };
+ const char *exts[] = { ".FPU" PLUGIN_EXTENSION, ".FPU.la", PLUGIN_EXTENSION, ".la", };
if (BSE_WITH_SSE_FLAGS && !bse_main_args->force_fpu &&
cpu_info->x86_mmx && cpu_info->x86_sse && cpu_info->x86_ssesys)
{
- exts[0] = ".SSE.so"; /* !".FPU.so" */
- exts[1] = ".SSE.la"; /* !".FPU.la" */
+ exts[0] = ".SSE" PLUGIN_EXTENSION; /* !".FPU.so" / ".FPU.dll" */
+ exts[1] = ".SSE.la"; /* !".FPU.la" */
}
SfiRing *fname;
files = ring;
Modified: branches/beast-mingw/bse/bsesequencer.cc
===================================================================
--- branches/beast-mingw/bse/bsesequencer.cc 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bsesequencer.cc 2006-08-26 21:50:32 UTC (rev 3869)
@@ -25,7 +25,7 @@
#include "bsemidireceiver.h"
#include "bsemain.h"
#include "bseieee754.h"
-#include <sys/poll.h>
+#include "bsewin32.h"
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
@@ -53,7 +53,11 @@
/* --- variables --- */
static BseSequencer *global_sequencer = NULL;
static BirnetCond current_watch_cond = { 0, };
+#ifdef WIN32
+static BseWin32Waiter *sequencer_win32_waiter;
+#else
static gint sequencer_wake_up_pipe[2] = { -1, -1 };
+#endif
/* --- functions --- */
extern "C" void
@@ -63,12 +67,16 @@
birnet_cond_init (¤t_watch_cond);
+#ifdef WIN32
+ sequencer_win32_waiter = bse_win32_waiter_new();
+#else
if (pipe (sequencer_wake_up_pipe) < 0)
g_error ("failed to create sequencer wake-up pipe: %s", strerror (errno));
glong flags = fcntl (sequencer_wake_up_pipe[0], F_GETFL, 0);
fcntl (sequencer_wake_up_pipe[0], F_SETFL, O_NONBLOCK | flags);
flags = fcntl (sequencer_wake_up_pipe[1], F_GETFL, 0);
fcntl (sequencer_wake_up_pipe[1], F_SETFL, O_NONBLOCK | flags);
+#endif
/* initialize BseSequencer */
static BseSequencer sseq = { 0, };
@@ -84,11 +92,15 @@
static void
sequencer_wake_up (gpointer wake_up_data)
{
+#ifdef WIN32
+ bse_win32_waiter_wakeup (sequencer_win32_waiter);
+#else
guint8 wake_up_message = 'W';
gint err;
do
err = write (sequencer_wake_up_pipe[1], &wake_up_message, 1);
while (err < 0 && errno == EINTR);
+#endif
}
namespace { // Anon
@@ -185,7 +197,8 @@
watches.erase (watches.begin() + i);
return true;
}
-
+
+#if 0
BIRNET_STATIC_ASSERT (sizeof (GPollFD) == sizeof (struct pollfd));
BIRNET_STATIC_ASSERT (offsetof (GPollFD, fd) == offsetof (struct pollfd, fd));
BIRNET_STATIC_ASSERT (sizeof (((GPollFD*) 0)->fd) == sizeof (((struct pollfd*) 0)->fd));
@@ -193,6 +206,7 @@
BIRNET_STATIC_ASSERT (sizeof (((GPollFD*) 0)->events) == sizeof (((struct pollfd*) 0)->events));
BIRNET_STATIC_ASSERT (offsetof (GPollFD, revents) == offsetof (struct pollfd, revents));
BIRNET_STATIC_ASSERT (sizeof (((GPollFD*) 0)->revents) == sizeof (((struct pollfd*) 0)->revents));
+#endif
};
} // Anon
@@ -267,21 +281,30 @@
{
guint n_pfds = sequencer_poll_pool.get_n_pfds() + 1; /* one for the wake-up pipe */
GPollFD *pfds = g_newa (GPollFD, n_pfds);
+#ifndef WIN32
pfds[0].fd = sequencer_wake_up_pipe[0];
+#endif
pfds[0].events = G_IO_IN;
pfds[0].revents = 0;
sequencer_poll_pool.fill_pfds (n_pfds - 1, pfds + 1); /* rest used for io watch array */
BSE_SEQUENCER_UNLOCK ();
+#ifdef WIN32
+ gint result = bse_win32_waiter_wait (sequencer_win32_waiter, timeout_ms);
+ pfds[0].revents = G_IO_IN;
+#else
gint result = poll ((struct pollfd*) pfds, n_pfds, timeout_ms);
+#endif
if (result < 0 && errno != EINTR)
g_printerr ("%s: poll() error: %s\n", G_STRFUNC, g_strerror (errno));
BSE_SEQUENCER_LOCK ();
+#ifndef WIN32
if (result > 0 && pfds[0].revents)
{
guint8 buffer[256];
read (sequencer_wake_up_pipe[0], buffer, 256); /* eat wake up message */
result -= 1;
}
+#endif
if (result > 0)
{
/* dispatch io watches */
Modified: branches/beast-mingw/bse/bseserver.c
===================================================================
--- branches/beast-mingw/bse/bseserver.c 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bseserver.c 2006-08-26 21:50:32 UTC (rev 3869)
@@ -27,7 +27,6 @@
#include "bsemididevice-null.h"
#include "bsejanitor.h"
#include <sys/time.h>
-#include <sys/resource.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
@@ -1150,9 +1149,11 @@
engine_is_initialized = TRUE;
bse_engine_init (TRUE);
/* lower priorities compared to engine if our priority range permits */
+#if 0
current_priority = getpriority (PRIO_PROCESS, mypid);
if (current_priority <= -2 && mypid)
setpriority (PRIO_PROCESS, mypid, current_priority + 1);
+#endif
}
bse_engine_configure (BSE_GCONFIG (synth_latency), mix_freq, BSE_GCONFIG (synth_control_freq));
Added: branches/beast-mingw/bse/bsewin32.cc
===================================================================
--- branches/beast-mingw/bse/bsewin32.cc 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bsewin32.cc 2006-08-26 21:50:32 UTC (rev 3869)
@@ -0,0 +1,74 @@
+/* BSE - Bedevilled Sound Engine
+ * Copyright (C) 2006 Stefan Westerfeld
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+/*
+ * The notification stuff was adapted from glib's gmain.c (also LGPL,
+ * see glib's AUTHORS file for individual authors).
+ */
+#include "bsewin32.h"
+#include <windows.h>
+
+struct _BseWin32Waiter
+{
+ HANDLE wake_up_semaphore;
+};
+
+extern "C" BseWin32Waiter *
+bse_win32_waiter_new ()
+{
+ BseWin32Waiter *waiter = g_new0 (BseWin32Waiter, 1);
+
+ waiter->wake_up_semaphore = CreateSemaphore (NULL, 0, 100, NULL);
+ if (waiter->wake_up_semaphore == NULL)
+ g_error ("Cannot create wake-up semaphore: %s",
+ g_win32_error_message (GetLastError ()));
+
+ return waiter;
+}
+
+extern "C" void
+bse_win32_waiter_destroy (BseWin32Waiter *waiter)
+{
+ CloseHandle (waiter->wake_up_semaphore);
+}
+
+extern "C" void
+bse_win32_waiter_wakeup (BseWin32Waiter *waiter)
+{
+ ReleaseSemaphore (waiter->wake_up_semaphore, 1, NULL);
+}
+
+extern "C" int
+bse_win32_waiter_wait (BseWin32Waiter *waiter,
+ int timeout)
+{
+ HANDLE handles[1] = { waiter->wake_up_semaphore };
+
+ guint ready = WaitForMultipleObjects (1, handles, FALSE, timeout < 0 ? INFINITE : timeout);
+ if (ready == WAIT_FAILED)
+ {
+ gchar *emsg = g_win32_error_message (GetLastError ());
+ g_warning (G_STRLOC ": WaitForMultipleObjects() failed: %s", emsg);
+ g_free (emsg);
+
+ return -1;
+ }
+ if (ready == WAIT_TIMEOUT)
+ return 0;
+ return 1;
+}
Added: branches/beast-mingw/bse/bsewin32.h
===================================================================
--- branches/beast-mingw/bse/bsewin32.h 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/bsewin32.h 2006-08-26 21:50:32 UTC (rev 3869)
@@ -0,0 +1,35 @@
+/* BSE - Bedevilled Sound Engine
+ * Copyright (C) 2006 Stefan Westerfeld
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __BSE_WIN32_H__
+#define __BSE_WIN32_H__
+
+#include <bse/bsedefs.h>
+
+G_BEGIN_DECLS
+
+typedef struct _BseWin32Waiter BseWin32Waiter;
+
+BseWin32Waiter *bse_win32_waiter_new ();
+void bse_win32_waiter_destroy (BseWin32Waiter *waiter);
+void bse_win32_waiter_wakeup (BseWin32Waiter *waiter);
+int bse_win32_waiter_wait (BseWin32Waiter *waiter, int timeout);
+
+G_END_DECLS
+
+#endif /* __BSE_BLOCK_UTILS_H__ */
Modified: branches/beast-mingw/bse/gslcommon.c
===================================================================
--- branches/beast-mingw/bse/gslcommon.c 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/gslcommon.c 2006-08-26 21:50:32 UTC (rev 3869)
@@ -20,13 +20,10 @@
#include "gsldatacache.h"
#include <unistd.h>
-#include <sys/utsname.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
-#include <sched.h>
#include <errno.h>
-#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/time.h>
Modified: branches/beast-mingw/bse/gsldatahandle-mad.c
===================================================================
--- branches/beast-mingw/bse/gsldatahandle-mad.c 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/gsldatahandle-mad.c 2006-08-26 21:50:32 UTC (rev 3869)
@@ -23,7 +23,9 @@
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
+#ifndef WIN32
#include <sys/mman.h>
+#endif
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
Modified: branches/beast-mingw/bse/gslfilehash.c
===================================================================
--- branches/beast-mingw/bse/gslfilehash.c 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/gslfilehash.c 2006-08-26 21:50:32 UTC (rev 3869)
@@ -128,7 +128,7 @@
{
gint fd;
- fd = open (file_name, O_RDONLY | O_NOCTTY, 0);
+ fd = open (file_name, O_RDONLY, 0);
if (fd >= 0)
{
hfile = sfi_new_struct0 (GslHFile, 1);
Modified: branches/beast-mingw/bse/mkcproc.pl
===================================================================
--- branches/beast-mingw/bse/mkcproc.pl 2006-08-24 20:29:00 UTC (rev 3868)
+++ branches/beast-mingw/bse/mkcproc.pl 2006-08-26 21:50:32 UTC (rev 3869)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!perl -w
use Cwd 'abs_path';
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]