~noskcaj/unity-settings-daemon/gnome-desktop-3.10

« back to all changes in this revision

Viewing changes to plugins/media-keys/gsd-media-keys-manager.c

  • Committer: CI bot
  • Author(s): Lars Uebernickel
  • Date: 2014-02-25 09:33:28 UTC
  • mfrom: (4019.1.4 unity-settings-daemon)
  • Revision ID: ps-jenkins@lists.canonical.com-20140225093328-psm6b9vn80gzd24p
media-keys: add support for allow-amplified-volume

When that key is set, the maximum volume is PA_VOLUME_UI_MAX instead of PA_VOLUME_NORM. This makes it consistent with the sound indicator and system settings. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
#define HIGH_CONTRAST "HighContrast"
116
116
 
117
117
#define VOLUME_STEP 6           /* percents for one volume button press */
118
 
#define MAX_VOLUME 65536.0
119
118
 
120
119
#define GNOME_DESKTOP_INPUT_SOURCES_DIR "org.gnome.desktop.input-sources"
121
120
#define KEY_CURRENT_INPUT_SOURCE "current"
166
165
        GSettings       *settings;
167
166
        GSettings       *input_settings;
168
167
        GHashTable      *custom_settings;
 
168
        GSettings       *sound_settings;
169
169
 
170
170
        GPtrArray       *keys;
171
171
 
1487
1487
        gboolean old_muted, new_muted;
1488
1488
        guint old_vol, new_vol, norm_vol_step, osd_vol;
1489
1489
        gboolean sound_changed;
 
1490
        pa_volume_t max_volume;
1490
1491
 
1491
1492
        /* Find the stream that corresponds to the device, if any */
1492
1493
        stream = NULL;
1504
1505
        if (stream == NULL)
1505
1506
                return;
1506
1507
 
 
1508
        if (g_settings_get_boolean (manager->priv->sound_settings, "allow-amplified-volume"))
 
1509
                max_volume = PA_VOLUME_UI_MAX;
 
1510
        else
 
1511
                max_volume = PA_VOLUME_NORM;
 
1512
 
1507
1513
        norm_vol_step = PA_VOLUME_NORM * VOLUME_STEP / 100;
1508
1514
 
1509
1515
        /* FIXME: this is racy */
1527
1533
                new_muted = FALSE;
1528
1534
                /* When coming out of mute only increase the volume if it was 0 */
1529
1535
                if (!old_muted || old_vol == 0)
1530
 
                        new_vol = MIN (old_vol + norm_vol_step, MAX_VOLUME);
 
1536
                        new_vol = MIN (old_vol + norm_vol_step, max_volume);
1531
1537
                break;
1532
1538
        }
1533
1539
 
1545
1551
 
1546
1552
        if (type == VOLUME_DOWN_KEY && old_vol == 0 && old_muted)
1547
1553
                osd_vol = -1;
1548
 
        else if (type == VOLUME_UP_KEY && old_vol == PA_VOLUME_NORM && !old_muted)
 
1554
        else if (type == VOLUME_UP_KEY && old_vol == max_volume && !old_muted)
1549
1555
                osd_vol = 101;
1550
1556
        else if (!new_muted)
1551
 
                osd_vol = (int) (100 * (double) new_vol / PA_VOLUME_NORM);
 
1557
                osd_vol = (int) (100 * (double) new_vol / max_volume);
1552
1558
        else
1553
1559
                osd_vol = 0;
1554
1560
 
2958
2964
          g_hash_table_new_full (g_str_hash, g_str_equal,
2959
2965
                                 g_free, g_object_unref);
2960
2966
 
 
2967
        manager->priv->sound_settings = g_settings_new ("com.ubuntu.sound");
 
2968
 
2961
2969
        /* Sound events */
2962
2970
        ca_context_create (&manager->priv->ca);
2963
2971
        ca_context_set_driver (manager->priv->ca, "pulse");
3089
3097
        g_clear_object (&priv->power_proxy);
3090
3098
        g_clear_object (&priv->power_screen_proxy);
3091
3099
        g_clear_object (&priv->power_keyboard_proxy);
 
3100
        g_clear_object (&priv->sound_settings);
3092
3101
 
3093
3102
        if (manager->priv->name_owner_id) {
3094
3103
                g_bus_unwatch_name (manager->priv->name_owner_id);