Chapter 1. The application context

Table of Contents

Implementations and their interfaces
The main loop property
The config property
The file property
The application mutex
Program start and termination
Abstract data connection
Common interfaces

Making Advanced Gtk+ Sequencer objects reachable from different contices was mandatory as introducing AgsApplicationContext. Imagine you are within a GUI callback and want to lookup a soundcard or sequencer the application context shall provide this functioanlity and provide access to its objects through a well defined interface. As doing it with interfaces you are not limited to one specific implementation rather having the option to choose the appropriate one implementing the interfaces.

There are different contices available e.g. AgsThreadApplicationContext providing its functionality by AgsConcurrencyProvider, AgsAudioApplicationContext giving you the wished objects by implementing AgsConcurrencyProvider and AgsSoundProvider. For example the code below should each giving you the same meaning object but using different contices.

Implementations and their interfaces

Creating a AgsThreadApplicationContext and then get the task launcher by calling AgsThread* ags_concurrency_provider_get_task_launcher(AgsConcurrencyProvider*). Since the AgsConcurrency interface is implemented by the context, we retrieve the task launcher. The AgsTaskLauncher gives you a thread safe signal. It is used to launch AgsTask objects to do thread safe operations but later on this.

Example 1.1. Thread application context

#include <glib.h>
#include <glib-object.h>

#include <ags/libags.h>

AgsApplicationContext *application_context;
AgsTaskLauncher *task_launcher;

application_context = (AgsApplicationContext *) ags_thread_application_context_new();

task_launcher = ags_concurrency_provider_get_task_launcher(AGS_CONCURRENCY_PROVIDER(application_context));

      

The AgsAudioApplicationContext inherites from AgsApplicationContext and implements the AgsConcurrency interface, too. So you can retrieve the task launcher the same way. But the context implements one more, the AgsSoundProvider interface. Giving you objects related to threading and audio processing.

Example 1.2. Audio application context

#include <glib.h>
#include <glib-object.h>

#include <ags/libags.h>
#include <ags/libags-audio.h>

AgsApplicationContext *application_context;
AgsTaskLauncher *task_launcher;

application_context = (AgsApplicationContext *) ags_audio_application_context_new();
task_launcher = ags_concurrency_provider_get_task_launcher(AGS_CONCURRENCY_PROVIDER(application_context));