newsAdvanced Gtk+ Sequencer - News: GCC builtin vector functions and a lock free soundcard buffer

 
 
Latest News
Advanced Gtk+ Sequencer version 6.8.x posted by jkraehemann, Wed 17 Apr 2024 01:40:23 PM UTC
Advanced Gtk+ Sequencer version 6.5.x posted by jkraehemann, Sun 11 Feb 2024 05:06:15 PM UTC
Advanced Gtk+ Sequencer version 6.3.5 posted by jkraehemann, Fri 19 Jan 2024 11:53:24 AM UTC
Advanced Gtk+ Sequencer v6.1.0 released posted by jkraehemann, Thu 28 Sep 2023 04:55:19 AM UTC
Advanced Gtk+ Sequencer v6.0.0 released posted by jkraehemann, Mon 21 Aug 2023 11:48:52 AM UTC

GCC builtin vector functions and a lock free soundcard buffer

Item posted by Joël Krähemann <jkraehemann> on Mon 29 Jul 2019 03:36:31 PM UTC.

Yay, this was real fun!

The Advanced Gtk+ Sequencer libraries have got vector optimization.

Just checkout: ags_audio_buffer_util.h

There you find the defined vectors for common types:


typedef gint8 v8s8 __attribute__ ((vector_size(8 * sizeof(gint8))));
typedef gint16 v8s16 __attribute__ ((vector_size(8 * sizeof(gint16))));
typedef gint32 v8s32 __attribute__ ((vector_size(8 * sizeof(gint32))));
typedef gint64 v8s64 __attribute__ ((vector_size(8 * sizeof(gint64))));
typedef gfloat v8float __attribute__ ((vector_size(8 * sizeof(gfloat))));
typedef gdouble v8double __attribute__ ((vector_size(8 * sizeof(gdouble))));


You can now compute your buffers using vector mathematics. These vectors allow to process multiple integer or floats using SSE2 registers or floating point unit.

And the lock free soundcard buffer using pthread_mutex_trylock().

Checkout: ags_soundcard.h

The interface prototype is as following:


guint ags_soundcard_get_sub_block_count(AgsSoundcard *soundcard);

gboolean ags_soundcard_trylock_sub_block(AgsSoundcard *soundcard,
                                         void *buffer, guint sub_block);
void ags_soundcard_unlock_sub_block(AgsSoundcard *soundcard,
                                    void *buffer, guint sub_block);


Currently, only output soundcard implements above:

  • AgsDevout
  • AgsJackDevout
  • AgsPulseDevout
  • AgsCoreAudioDevout


It is used during final mixing using vectors, doing a lock free buffer during ags-play recall.

See here: ags_audio_signal.c



by Joël

 

Back to the top

Powered by Savane 3.13-4448.
Corresponding source code