fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] FluidSynth and glib


From: Ryan Gonzalez
Subject: Re: [fluid-dev] FluidSynth and glib
Date: Wed, 13 Jan 2016 14:28:22 -0600

This is a list of all the glib functions/macros Fluidsynth uses:

g_assert
g_atomic_int_add
g_atomic_int_compare_and_exchange
g_atomic_int_dec_and_test
g_atomic_int_exchange_and_add
g_atomic_int_get
g_atomic_int_inc
g_atomic_int_set
g_atomic_pointer_compare_and_exchange
g_atomic_pointer_get
g_atomic_pointer_set
G_BIG_ENDIAN
G_BYTE_ORDER
g_clear_error
g_cond_broadcast
g_cond_clear
g_cond_free
g_cond_init
g_cond_new
g_cond_signal
g_cond_wait
g_free
g_get_current_time
g_mutex_clear
g_mutex_free
g_mutex_init
g_mutex_lock
g_mutex_new
g_mutex_unlock
g_new
g_newa
g_private_get
g_private_set
g_rec_mutex_clear
g_rec_mutex_init
g_rec_mutex_lock
g_rec_mutex_unlock
g_return_if_fail
g_return_val_if_fail
g_setenv
g_shell_parse_argv
g_snprintf
g_static_mutex_free
g_static_mutex_init
G_STATIC_MUTEX_INIT
g_static_mutex_lock
g_static_mutex_unlock
g_static_private_free
g_static_private_get
g_static_private_init
g_static_private_set
g_static_rec_mutex_free
g_static_rec_mutex_init
g_static_rec_mutex_lock
g_static_rec_mutex_unlock
G_STMT_END
G_STMT_START
g_strerror
g_strfreev
g_thread_create
g_thread_init
g_thread_join
g_thread_self
g_thread_supported
g_thread_try_new
g_thread_unref
g_usleep

Out of these:

- G_STMT_START and G_STMT_END are basically more portable do-while blocks in macros. Not sure how needed that is....
- g_strerror is a wrapper over strerror that always returns UTF-8 and makes sure the resulting strings are valid over the process's lifetime. However, the only two places this is used print it instantly.
- g_thread*, g_mutex*, g_rec_mutex*, g_private*, g_atomic*, and g_cond* are pretty self-explanatory. C11's threading support isn't very portable ATM.
- g_static* is deprecated.
- g_strfreev is easily re-implemented.
- g_usleep is a portable usleep.

Similar things for the rest of them. This doesn't seem TOO bad...

On Wed, Jan 13, 2016 at 1:38 PM, Johannes Schickel <address@hidden> wrote:
Hi Element,

don't worry, I see the point of using glib from your side. :-)

You seem to be right about the hash table code. It looks like it only mentions "g_hashtable" in some comments, I appareantly missed that when giving this a quick grep run earlier. Ooops :-).

I was looking a bit into the (obvious) glib dependencies. And yeah, it looks most is threading related.
It looks like the synthesizer code has support for multi-threaded rendering. I.e. there seems to be referrences to "fluid_rvoice_mixer_set_threads", which uses "new_fluid_thread". I guess one could strip that out though.
Then there is this very odd timer use (which uses a thread internally) in src/synth/fluid_synth.c:3182, which seems to start a new timer to unload a sound font in case unloading failed. I am not sure how you would work around that.
The only non-thread related glib reference I can find right now is FLUID_DECLARE_VLA, which falls back to glib's g_newa in case no VLAs are supported by the compiler.

One sad thing is: multi-threaded rendering might be interesting for some platforms we support. A lot of smartphones etc. nowadays feature multiple cores, so taking advantage might be something to look into.

I initially hoped the synthesizer in FluidSynth would be easily working without glib as dependency. But it looks like that is not the case :-/. And I really don't want to make use of a patched up FluidSynth. So unless there is hope any such work could get back upstream, it is not an option.

Thank you for your insights.

Best regards,
Johannes

On 01/13/2016 06:36 PM, Element Green wrote:
Hello Johannes,

Seeing as I'm the one responsible for converting FluidSynth over to glib in the first place, I thought it is only right that I respond ;-)

Prior to FluidSynth depending on glib, there was a bit of platform support code.  This code was error prone, somewhat hard to maintain, and often limited supported platforms. Leveraging off of glib meant that all of this code could be removed and FluidSynth would automatically be available on any platform glib supports.  So this was primarily a convenience for developers.

However, there are cases where it would be nice to not have this dependency.  Embedded and mobile systems use is one example in addition to the Windows use case you describe. However, from what I have gathered, there are versions of glib that do support Win9x which also meet the minimum required version for FluidSynth.  FluidSynth currently depends on glib 2.6.5+.  This email thread (http://gtk.10911.n7.nabble.com/Last-supported-version-of-GTK-for-Win9x-ME-td57072.html) suggests that glib supported win9x with versions as late as 2.6.10 at least (though it is actually talking about GTK in this case - which glib is a dependency of).

Having said all that, it would be nice to have the ability to build a possibly stripped down version of FluidSynth which would utilize a user defined compatibility layer.  I did a quick glance at the current source code.  From what I an tell, the hash table code is native to FluidSynth and was lifted from glib sources.  The majority of the glib subsystem use is related to thread creation/management, thread locking primitives, thread signaling, thread private data, and atomic data operations.  For the single thread use case, a lot of this code is not needed.  Internally the FluidSynth source code still has it's own compatibility layer and from what I can see does not reference glib directly.  The majority of this interface is defined in utils/fluid_sys.c and utils/fluid_sys.h.  Defining platform specific versions of these files would provide what I think you are seeking.  A lot of those primitives are fairly simple really, and could probably be easily lifted from glib sources for use on a specific platform.

At any rate, seems like a good idea.  It would take a little work though.

Best regards,

Element



On Wed, Jan 13, 2016 at 6:52 AM, Johannes Schickel <address@hidden <mailto:address@hidden>> wrote:

    Hello,

    first of all thank you for your awesome project!

    I am a member of ScummVM (http://www.scummvm.org) and I am
    currently looking into getting our FluidSynth support a bit more
    up to speed (i.e. get it into more of our ports, updating to the
    latest version, etc). It looks like there are some obstacles for
    this though. The biggest one is the glib dependency. For example,
    modern glib versions do not support Win9x anymore (2.6.9 is the
    last one to support this AFAICT from:
    http://gtk-win.sourceforge.net/home/index.php/Main/Downloads),
    which is some target we still support.

    >From a quick look at FluidSynth I have the feeling libfluidsynth
    includes a lot of code we are not interested in for ScummVM. We
    are only really interested in the actual synthesizer part. I hoped
    this part would not depend on glib, however I found references to
    glib's hash table and thread code. Is there any chance for the
    future that FluidSynth's core synthesizer could be built
    standalone and without glib dependency? This would allow us to
    switch to a version more up to date than FluidSynth 1.0.9.

    Thanks,
    Johannes

    _______________________________________________
    fluid-dev mailing list
    address@hidden <mailto:address@hidden>
    https://lists.nongnu.org/mailman/listinfo/fluid-dev




_______________________________________________
fluid-dev mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fluid-dev


_______________________________________________
fluid-dev mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fluid-dev



--
Ryan
[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]