Advanced Gtk+ Sequencer - News
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
Powered by Savane 3.14-8aba.
Corresponding source code