summaryrefslogtreecommitdiff
path: root/plugins/media-keys/cut-n-paste/gvc-channel-map.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-12-07 06:06:41 -0800
committerStefano Karapetsas <[email protected]>2012-12-07 06:06:41 -0800
commit12dcf19aa5f51901053c273cd7f5c17ce85e909d (patch)
tree5b71387df7bf817dd5d0dff60ecc09d8291dba0d /plugins/media-keys/cut-n-paste/gvc-channel-map.c
parenta279b02b4d563d2300ccb588e5969c7dfac8108e (diff)
parent6e61d207a2088479f5bb12ce4edb1d2886c40b53 (diff)
downloadmate-settings-daemon-12dcf19aa5f51901053c273cd7f5c17ce85e909d.tar.bz2
mate-settings-daemon-12dcf19aa5f51901053c273cd7f5c17ce85e909d.tar.xz
Merge pull request #29 from jasmineaura/develop
Fix #23, and some cleanups
Diffstat (limited to 'plugins/media-keys/cut-n-paste/gvc-channel-map.c')
-rw-r--r--plugins/media-keys/cut-n-paste/gvc-channel-map.c67
1 files changed, 10 insertions, 57 deletions
diff --git a/plugins/media-keys/cut-n-paste/gvc-channel-map.c b/plugins/media-keys/cut-n-paste/gvc-channel-map.c
index 6748d57..e35e793 100644
--- a/plugins/media-keys/cut-n-paste/gvc-channel-map.c
+++ b/plugins/media-keys/cut-n-paste/gvc-channel-map.c
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <glib.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <pulse/pulseaudio.h>
@@ -33,14 +33,6 @@
#define GVC_CHANNEL_MAP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_CHANNEL_MAP, GvcChannelMapPrivate))
-#ifndef PA_CHECK_VERSION
-#define PA_CHECK_VERSION(major,minor,micro) \
- ((PA_MAJOR > (major)) || \
- (PA_MAJOR == (major) && PA_MINOR > (minor)) || \
- (PA_MAJOR == (major) && PA_MINOR == (minor) && PA_MICRO >= (micro)))
-#endif
-
-
struct GvcChannelMapPrivate
{
pa_channel_map pa_map;
@@ -49,7 +41,6 @@ struct GvcChannelMapPrivate
gdouble extern_volume[NUM_TYPES]; /* volume, balance, fade, lfe */
gboolean can_balance;
gboolean can_fade;
- gboolean has_lfe;
};
enum {
@@ -65,46 +56,8 @@ static void gvc_channel_map_finalize (GObject *object);
G_DEFINE_TYPE (GvcChannelMap, gvc_channel_map, G_TYPE_OBJECT)
-/* FIXME remove when we depend on a newer PA */
-static int
-gvc_pa_channel_map_has_position (const pa_channel_map *map, pa_channel_position_t p) {
- unsigned c;
-
- g_return_val_if_fail(pa_channel_map_valid(map), 0);
- g_return_val_if_fail(p < PA_CHANNEL_POSITION_MAX, 0);
-
- for (c = 0; c < map->channels; c++)
- if (map->map[c] == p)
- return 1;
-
- return 0;
-}
-
-#if !PA_CHECK_VERSION(0,9,16)
-/* The PulseAudio master increase version only when tagged, so let's avoid clashing with pa_ namespace */
-#define pa_cvolume_get_position gvc_cvolume_get_position
-static pa_volume_t
-gvc_cvolume_get_position (pa_cvolume *cv, const pa_channel_map *map, pa_channel_position_t t) {
- unsigned c;
- pa_volume_t v = PA_VOLUME_MUTED;
-
- g_assert(cv);
- g_assert(map);
-
- g_return_val_if_fail(pa_cvolume_compatible_with_channel_map(cv, map), PA_VOLUME_MUTED);
- g_return_val_if_fail(t < PA_CHANNEL_POSITION_MAX, PA_VOLUME_MUTED);
-
- for (c = 0; c < map->channels; c++)
- if (map->map[c] == t)
- if (cv->values[c] > v)
- v = cv->values[c];
-
- return v;
-}
-#endif
-
guint
-gvc_channel_map_get_num_channels (GvcChannelMap *map)
+gvc_channel_map_get_num_channels (const GvcChannelMap *map)
{
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), 0);
@@ -140,7 +93,7 @@ gvc_channel_map_get_volume (GvcChannelMap *map)
}
gboolean
-gvc_channel_map_can_balance (GvcChannelMap *map)
+gvc_channel_map_can_balance (const GvcChannelMap *map)
{
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), FALSE);
@@ -148,7 +101,7 @@ gvc_channel_map_can_balance (GvcChannelMap *map)
}
gboolean
-gvc_channel_map_can_fade (GvcChannelMap *map)
+gvc_channel_map_can_fade (const GvcChannelMap *map)
{
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), FALSE);
@@ -156,7 +109,7 @@ gvc_channel_map_can_fade (GvcChannelMap *map)
}
const char *
-gvc_channel_map_get_mapping (GvcChannelMap *map)
+gvc_channel_map_get_mapping (const GvcChannelMap *map)
{
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL);
@@ -167,15 +120,16 @@ gvc_channel_map_get_mapping (GvcChannelMap *map)
}
gboolean
-gvc_channel_map_has_lfe (GvcChannelMap *map)
+gvc_channel_map_has_position (const GvcChannelMap *map,
+ pa_channel_position_t position)
{
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), FALSE);
- return map->priv->has_lfe;
+ return pa_channel_map_has_position (&(map->priv->pa_map), position);
}
const pa_channel_map *
-gvc_channel_map_get_pa_channel_map (GvcChannelMap *map)
+gvc_channel_map_get_pa_channel_map (const GvcChannelMap *map)
{
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL);
@@ -186,7 +140,7 @@ gvc_channel_map_get_pa_channel_map (GvcChannelMap *map)
}
const pa_cvolume *
-gvc_channel_map_get_cvolume (GvcChannelMap *map)
+gvc_channel_map_get_cvolume (const GvcChannelMap *map)
{
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL);
@@ -274,7 +228,6 @@ set_from_pa_map (GvcChannelMap *map,
map->priv->can_balance = pa_channel_map_can_balance (pa_map);
map->priv->can_fade = pa_channel_map_can_fade (pa_map);
- map->priv->has_lfe = gvc_pa_channel_map_has_position (pa_map, PA_CHANNEL_POSITION_LFE);
map->priv->pa_map = *pa_map;
pa_cvolume_set(&map->priv->pa_volume, pa_map->channels, PA_VOLUME_NORM);