47
47
private GreeterListInterface _greeter_proxy;
48
48
private Cancellable _mute_cancellable;
49
49
private Cancellable _volume_cancellable;
50
private uint _local_volume_timer = 0;
51
private uint _accountservice_volume_timer = 0;
52
private bool _send_next_local_volume = false;
53
private double _account_service_volume = 0.0;
51
55
public signal void volume_changed (double v);
52
56
public signal void mic_volume_changed (double v);
335
341
public void set_volume (double volume)
337
343
if (set_volume_internal (volume))
338
sync_volume_to_accountsservice.begin (volume);
344
start_local_volume_timer();
341
347
void set_mic_volume_success_cb (Context c, int success)
377
383
Variant volume_variant = changed_properties.lookup_value ("Volume", new VariantType ("d"));
378
384
if (volume_variant != null) {
379
385
var volume = volume_variant.get_double ();
381
set_volume_internal (volume);
387
_account_service_volume = volume;
388
// we need to wait for this to settle.
389
start_account_service_volume_timer();
384
393
Variant mute_variant = changed_properties.lookup_value ("Muted", new VariantType ("b"));
487
496
warning ("unable to sync volume to AccountsService: %s", e.message);
500
private void start_local_volume_timer()
502
// perform a slow sync with the accounts service. max at 1 per second.
504
// stop the AS update timer, as since we're going to be setting the volume.
505
stop_account_service_volume_timer();
507
if (_local_volume_timer == 0) {
508
sync_volume_to_accountsservice.begin (_volume);
509
_local_volume_timer = Timeout.add_seconds (1, local_volume_changed_timeout);
511
_send_next_local_volume = true;
515
private void stop_local_volume_timer()
517
if (_local_volume_timer != 0) {
518
Source.remove (_local_volume_timer);
519
_local_volume_timer = 0;
523
bool local_volume_changed_timeout()
525
_local_volume_timer = 0;
526
if (_send_next_local_volume) {
527
_send_next_local_volume = false;
528
start_local_volume_timer ();
530
return false; // G_SOURCE_REMOVE
533
private void start_account_service_volume_timer()
535
if (_accountservice_volume_timer == 0) {
536
// If we haven't been messing with local volume recently, apply immediately.
537
if (_local_volume_timer == 0 && !set_volume_internal (_account_service_volume)) {
540
// Else check again in another second if needed.
541
// (if AS is throwing us lots of notifications, we update at most once a second)
542
_accountservice_volume_timer = Timeout.add_seconds (1, accountservice_volume_changed_timeout);
546
private void stop_account_service_volume_timer()
548
if (_accountservice_volume_timer != 0) {
549
Source.remove (_accountservice_volume_timer);
550
_accountservice_volume_timer = 0;
554
bool accountservice_volume_changed_timeout ()
556
_accountservice_volume_timer = 0;
557
start_account_service_volume_timer ();
558
return false; // G_SOURCE_REMOVE