newsAdvanced Gtk+ Sequencer - News: Revising AgsThread and AgsMainLoop

 
 
Latest News
GSequencer gets triple-sync and additional dialogs posted by jkraehemann, Fri 13 Oct 2017 04:28:05 PM UTC - 0 replies
GSequencer first major release 1.0.0 posted by jkraehemann, Sun 01 Oct 2017 05:41:43 AM UTC - 0 replies
Reduced latency of JACK posted by jkraehemann, Fri 22 Sep 2017 12:37:27 PM UTC - 0 replies
Advanced Gtk+ Sequencer v1.0.0-beta posted by jkraehemann, Thu 31 Aug 2017 06:14:22 PM UTC - 0 replies
Inaccurate attack calculation of bpm posted by jkraehemann, Sat 19 Aug 2017 11:56:06 PM UTC - 0 replies
[Submit News]
[40 news in archive]

Revising AgsThread and AgsMainLoop

Item posted by Joël Krähemann <jkraehemann> on Wed 17 Aug 2016 05:59:48 PM UTC.

I just have added some prototypes to have grained control over program flow. Since GMainContext might have undetermined amount of time wasting on poll(). Advanced Gtk+ Sequencer suffers throughput problems.

Audio output gets delayed and distorted because of that. The way to try to solve it is by suspend AgsGuiThread. AgsGuiThread does something like following and polls in place:

main_context = g_main_context_default();

...

g_main_context_push_thread_default(main_context);

Now, following functions and signals has been added:

  • ags_main_loop_interrupt()
  • ags_main_loop_monitor()
  • ags_thread_interrupted()

AgsThread::suspend and AgsThread::resume exists for quite a long time but have been forgotten. They get improved, yet. Thus AGS_THREAD_INTERRUPTED and AGS_THREAD_MONITORING sync flags has been introduced. In order to get most out of nanosleep() ags_main_loop_monitor() might alter time_spent. After callbacked by ags_thread_interrupted() from ags_thread_resume().

So this is what basically happens within AgsGuiThread.

/* avoid exceeding time_cycle */
ags_thread_run();

/* soundcard has to start new playback */
ags_main_loop_interrupt();
ags_thread_suspend();

/* AgsGuiThread gets notified about next tic and is allowed to recover as */
/* AGS_THREAD_RECOVER_INTERRUPTED. If AGS_THREAD_RESUME_INTERRUPTED is set */
/* thread resumes just at the next cycle. */
ags_thread_resume();
ags_thread_interrupted();

cheers,
Joël

Comments:

No messages in Revising AgsThread and AgsMainLoop

 

Back to the top


Powered by Savane 3.1-cleanup1