mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	Base mainloop on pa_rtclock_now()
Move the mainloop to monotonic based time events.
Introduces 4 helper functions:
pa_{context,core}_rttime_{new,restart}(), that fill correctly a
timeval with the rtclock flag set if the mainloop supports it.
Both mainloop-test and mainloop-test-glib works with rt and timeval
based time events. PulseAudio and clients should be fully functional.
This patch has received several iterations, and this one as been
largely untested.
Signed-off-by: Marc-André Lureau <marca-andre.lureau@nokia.com>
			
			
This commit is contained in:
		
							parent
							
								
									125c528896
								
							
						
					
					
						commit
						0955e3d45b
					
				
					 42 changed files with 311 additions and 233 deletions
				
			
		| 
						 | 
				
			
			@ -35,6 +35,7 @@
 | 
			
		|||
#include <pulse/volume.h>
 | 
			
		||||
#include <pulse/timeval.h>
 | 
			
		||||
#include <pulse/util.h>
 | 
			
		||||
#include <pulse/rtclock.h>
 | 
			
		||||
 | 
			
		||||
#include <pulsecore/core-error.h>
 | 
			
		||||
#include <pulsecore/module.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +62,7 @@ PA_MODULE_USAGE(
 | 
			
		|||
        "restore_volume=<Save/restore volumes?> "
 | 
			
		||||
        "restore_muted=<Save/restore muted states?>");
 | 
			
		||||
 | 
			
		||||
#define SAVE_INTERVAL 10
 | 
			
		||||
#define SAVE_INTERVAL (10 * PA_USEC_PER_SEC)
 | 
			
		||||
#define IDENTIFICATION_PROPERTY "module-stream-restore.id"
 | 
			
		||||
 | 
			
		||||
static const char* const valid_modargs[] = {
 | 
			
		||||
| 
						 | 
				
			
			@ -111,12 +112,11 @@ enum {
 | 
			
		|||
    SUBCOMMAND_EVENT
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata) {
 | 
			
		||||
static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *t, void *userdata) {
 | 
			
		||||
    struct userdata *u = userdata;
 | 
			
		||||
 | 
			
		||||
    pa_assert(a);
 | 
			
		||||
    pa_assert(e);
 | 
			
		||||
    pa_assert(tv);
 | 
			
		||||
    pa_assert(u);
 | 
			
		||||
 | 
			
		||||
    pa_assert(e == u->save_time_event);
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +210,6 @@ fail:
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void trigger_save(struct userdata *u) {
 | 
			
		||||
    struct timeval tv;
 | 
			
		||||
    pa_native_connection *c;
 | 
			
		||||
    uint32_t idx;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -230,9 +229,7 @@ static void trigger_save(struct userdata *u) {
 | 
			
		|||
    if (u->save_time_event)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    pa_gettimeofday(&tv);
 | 
			
		||||
    tv.tv_sec += SAVE_INTERVAL;
 | 
			
		||||
    u->save_time_event = u->core->mainloop->time_new(u->core->mainloop, &tv, save_time_callback, u);
 | 
			
		||||
    u->save_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + SAVE_INTERVAL, save_time_callback, u);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static pa_bool_t entries_equal(const struct entry *a, const struct entry *b) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue