Add private gnome-volume-control library
The library is introspected, and should not require using Pulseaudio directly. With help from Giovanni Campagna <scampa.giovanni@gmail.com> (introspection annotations, build fixes) https://bugzilla.gnome.org/show_bug.cgi?id=629455
This commit is contained in:
parent
a5d4abda00
commit
8064c6c827
@ -90,6 +90,7 @@ PKG_CHECK_MODULES(TIDY, clutter-1.0)
|
|||||||
PKG_CHECK_MODULES(ST, clutter-1.0 gtk+-3.0 libcroco-0.6 gnome-desktop-3.0 >= 2.90.0)
|
PKG_CHECK_MODULES(ST, clutter-1.0 gtk+-3.0 libcroco-0.6 gnome-desktop-3.0 >= 2.90.0)
|
||||||
PKG_CHECK_MODULES(GDMUSER, dbus-glib-1 gtk+-3.0)
|
PKG_CHECK_MODULES(GDMUSER, dbus-glib-1 gtk+-3.0)
|
||||||
PKG_CHECK_MODULES(TRAY, gtk+-3.0)
|
PKG_CHECK_MODULES(TRAY, gtk+-3.0)
|
||||||
|
PKG_CHECK_MODULES(GVC, libpulse libpulse-mainloop-glib gobject-2.0)
|
||||||
|
|
||||||
MUTTER_BIN_DIR=`$PKG_CONFIG --variable=exec_prefix mutter-plugins`/bin
|
MUTTER_BIN_DIR=`$PKG_CONFIG --variable=exec_prefix mutter-plugins`/bin
|
||||||
# FIXME: metacity-plugins.pc should point directly to its .gir file
|
# FIXME: metacity-plugins.pc should point directly to its .gir file
|
||||||
|
69
src/Makefile-gvc.am
Normal file
69
src/Makefile-gvc.am
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
noinst_LTLIBRARIES += libgvc.la
|
||||||
|
|
||||||
|
libgvc_la_CPPFLAGS = \
|
||||||
|
$(WARN_CFLAGS) \
|
||||||
|
$(GVC_CFLAGS) \
|
||||||
|
-I$(srcdir)/gvc/ \
|
||||||
|
-DWITH_INTROSPECTION \
|
||||||
|
-DG_LOG_DOMAIN="\"Gvc\""
|
||||||
|
|
||||||
|
libgvc_la_LIBADD = \
|
||||||
|
$(GVC_LIBS)
|
||||||
|
|
||||||
|
libgvc_la_LDFLAGS = -avoid-version
|
||||||
|
|
||||||
|
libgvc_la_gir_sources = \
|
||||||
|
gvc/gvc-mixer-stream.h \
|
||||||
|
gvc/gvc-mixer-stream.c \
|
||||||
|
gvc/gvc-channel-map.h \
|
||||||
|
gvc/gvc-channel-map.c \
|
||||||
|
gvc/gvc-mixer-card.c \
|
||||||
|
gvc/gvc-mixer-card.h \
|
||||||
|
gvc/gvc-mixer-sink.h \
|
||||||
|
gvc/gvc-mixer-sink.c \
|
||||||
|
gvc/gvc-mixer-source.h \
|
||||||
|
gvc/gvc-mixer-source.c \
|
||||||
|
gvc/gvc-mixer-sink-input.h \
|
||||||
|
gvc/gvc-mixer-sink-input.c \
|
||||||
|
gvc/gvc-mixer-source-output.h \
|
||||||
|
gvc/gvc-mixer-source-output.c \
|
||||||
|
gvc/gvc-mixer-event-role.h \
|
||||||
|
gvc/gvc-mixer-event-role.c \
|
||||||
|
gvc/gvc-mixer-control.h \
|
||||||
|
gvc/gvc-mixer-control.c \
|
||||||
|
gvc/gvc-pulseaudio-fake.h
|
||||||
|
|
||||||
|
libgvc_la_private_sources = \
|
||||||
|
gvc/gvc-mixer-stream-private.h \
|
||||||
|
gvc/gvc-channel-map-private.h \
|
||||||
|
gvc/gvc-mixer-card-private.h \
|
||||||
|
gvc/gvc-mixer-control-private.h \
|
||||||
|
gvc/gvc-pulseaudio-fake.h
|
||||||
|
|
||||||
|
libgvc_la_SOURCES = \
|
||||||
|
$(libgvc_la_gir_sources) \
|
||||||
|
$(libgvc_la_private_sources)
|
||||||
|
|
||||||
|
Gvc-1.0.gir: $(G_IR_SCANNER) libgvc.la Makefile
|
||||||
|
$(AM_V_GEN) $(G_IR_SCANNER) \
|
||||||
|
--namespace=Gvc \
|
||||||
|
--nsversion=1.0 \
|
||||||
|
--warn-all \
|
||||||
|
--quiet \
|
||||||
|
--libtool="$(LIBTOOL)" \
|
||||||
|
--add-include-path=$(builddir) \
|
||||||
|
--include=GObject-2.0 \
|
||||||
|
--library=libgvc.la \
|
||||||
|
--identifier-prefix=Gvc \
|
||||||
|
--symbol-prefix=gvc_ \
|
||||||
|
$(addprefix $(srcdir)/,$(libgvc_la_gir_sources)) \
|
||||||
|
$(INCLUDES) \
|
||||||
|
-I $(srcdir) \
|
||||||
|
-I $(srcdir)/gvc \
|
||||||
|
-DWITH_INTROSPECTION \
|
||||||
|
-o $@
|
||||||
|
CLEANFILES += Gvc-1.0.gir
|
||||||
|
|
||||||
|
Gvc-1.0.typelib: Gvc-1.0.gir
|
||||||
|
$(AM_V_GEN) $(G_IR_COMPILER) $< -o $@
|
||||||
|
CLEANFILES += Gvc-1.0.typelib
|
@ -37,6 +37,7 @@ EXTRA_DIST += gnome-shell-clock-preferences.in
|
|||||||
include Makefile-gdmuser.am
|
include Makefile-gdmuser.am
|
||||||
include Makefile-st.am
|
include Makefile-st.am
|
||||||
include Makefile-tray.am
|
include Makefile-tray.am
|
||||||
|
include Makefile-gvc.am
|
||||||
|
|
||||||
gnome_shell_cflags = \
|
gnome_shell_cflags = \
|
||||||
$(MUTTER_PLUGIN_CFLAGS) \
|
$(MUTTER_PLUGIN_CFLAGS) \
|
||||||
@ -190,11 +191,12 @@ libgnome_shell_la_LIBADD = \
|
|||||||
$(LIBGNOMEUI_LIBS) \
|
$(LIBGNOMEUI_LIBS) \
|
||||||
libst-1.0.la \
|
libst-1.0.la \
|
||||||
libgdmuser-1.0.la \
|
libgdmuser-1.0.la \
|
||||||
libtray.la
|
libtray.la \
|
||||||
|
libgvc.la
|
||||||
libgnome_shell_la_CPPFLAGS = $(gnome_shell_cflags)
|
libgnome_shell_la_CPPFLAGS = $(gnome_shell_cflags)
|
||||||
|
|
||||||
typelibdir = $(pkglibdir)
|
typelibdir = $(pkglibdir)
|
||||||
typelib_DATA = Shell-0.1.typelib St-1.0.typelib Gdm-1.0.typelib
|
typelib_DATA = Shell-0.1.typelib St-1.0.typelib Gdm-1.0.typelib Gvc-1.0.typelib
|
||||||
|
|
||||||
Shell-0.1.gir: $(mutter) $(G_IR_SCANNER) St-1.0.gir libgnome-shell.la Makefile
|
Shell-0.1.gir: $(mutter) $(G_IR_SCANNER) St-1.0.gir libgnome-shell.la Makefile
|
||||||
$(AM_V_GEN) $(G_IR_SCANNER) \
|
$(AM_V_GEN) $(G_IR_SCANNER) \
|
||||||
|
@ -296,6 +296,15 @@ add_statistics (GnomeShellPlugin *shell_plugin)
|
|||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_muted_debug_log_handler (const char *log_domain,
|
||||||
|
GLogLevelFlags log_level,
|
||||||
|
const char *message,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
/* Intentionally empty to discard message */
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gnome_shell_plugin_start (MutterPlugin *plugin)
|
gnome_shell_plugin_start (MutterPlugin *plugin)
|
||||||
{
|
{
|
||||||
@ -355,6 +364,10 @@ gnome_shell_plugin_start (MutterPlugin *plugin)
|
|||||||
shell_plugin->gjs_context = gjs_context_new_with_search_path(search_path);
|
shell_plugin->gjs_context = gjs_context_new_with_search_path(search_path);
|
||||||
g_strfreev(search_path);
|
g_strfreev(search_path);
|
||||||
|
|
||||||
|
/* Disable the gnome-volume-control debug */
|
||||||
|
g_log_set_handler ("Gvc", G_LOG_LEVEL_DEBUG,
|
||||||
|
gvc_muted_debug_log_handler, NULL);
|
||||||
|
|
||||||
/* Initialize the global object here. */
|
/* Initialize the global object here. */
|
||||||
global = shell_global_get ();
|
global = shell_global_get ();
|
||||||
|
|
||||||
|
39
src/gvc/gvc-channel-map-private.h
Normal file
39
src/gvc/gvc-channel-map-private.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_CHANNEL_MAP_PRIVATE_H
|
||||||
|
#define __GVC_CHANNEL_MAP_PRIVATE_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
GvcChannelMap * gvc_channel_map_new_from_pa_channel_map (const pa_channel_map *map);
|
||||||
|
const pa_channel_map * gvc_channel_map_get_pa_channel_map (const GvcChannelMap *map);
|
||||||
|
|
||||||
|
void gvc_channel_map_volume_changed (GvcChannelMap *map,
|
||||||
|
const pa_cvolume *cv,
|
||||||
|
gboolean set);
|
||||||
|
const pa_cvolume * gvc_channel_map_get_cvolume (const GvcChannelMap *map);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_CHANNEL_MAP_PRIVATE_H */
|
254
src/gvc/gvc-channel-map.c
Normal file
254
src/gvc/gvc-channel-map.c
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 William Jon McCann
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
|
#include "gvc-channel-map.h"
|
||||||
|
#include "gvc-channel-map-private.h"
|
||||||
|
|
||||||
|
#define GVC_CHANNEL_MAP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_CHANNEL_MAP, GvcChannelMapPrivate))
|
||||||
|
|
||||||
|
struct GvcChannelMapPrivate
|
||||||
|
{
|
||||||
|
pa_channel_map pa_map;
|
||||||
|
gboolean pa_volume_is_set;
|
||||||
|
pa_cvolume pa_volume;
|
||||||
|
gdouble extern_volume[NUM_TYPES]; /* volume, balance, fade, lfe */
|
||||||
|
gboolean can_balance;
|
||||||
|
gboolean can_fade;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
VOLUME_CHANGED,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint signals [LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
|
static void gvc_channel_map_class_init (GvcChannelMapClass *klass);
|
||||||
|
static void gvc_channel_map_init (GvcChannelMap *channel_map);
|
||||||
|
static void gvc_channel_map_finalize (GObject *object);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GvcChannelMap, gvc_channel_map, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
guint
|
||||||
|
gvc_channel_map_get_num_channels (const GvcChannelMap *map)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), 0);
|
||||||
|
|
||||||
|
if (!pa_channel_map_valid(&map->priv->pa_map))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return map->priv->pa_map.channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gdouble *
|
||||||
|
gvc_channel_map_get_volume (GvcChannelMap *map)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL);
|
||||||
|
|
||||||
|
if (!pa_channel_map_valid(&map->priv->pa_map))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
map->priv->extern_volume[VOLUME] = (gdouble) pa_cvolume_max (&map->priv->pa_volume);
|
||||||
|
if (gvc_channel_map_can_balance (map))
|
||||||
|
map->priv->extern_volume[BALANCE] = (gdouble) pa_cvolume_get_balance (&map->priv->pa_volume, &map->priv->pa_map);
|
||||||
|
else
|
||||||
|
map->priv->extern_volume[BALANCE] = 0;
|
||||||
|
if (gvc_channel_map_can_fade (map))
|
||||||
|
map->priv->extern_volume[FADE] = (gdouble) pa_cvolume_get_fade (&map->priv->pa_volume, &map->priv->pa_map);
|
||||||
|
else
|
||||||
|
map->priv->extern_volume[FADE] = 0;
|
||||||
|
if (gvc_channel_map_has_lfe (map))
|
||||||
|
map->priv->extern_volume[LFE] = (gdouble) pa_cvolume_get_position (&map->priv->pa_volume, &map->priv->pa_map, PA_CHANNEL_POSITION_LFE);
|
||||||
|
else
|
||||||
|
map->priv->extern_volume[LFE] = 0;
|
||||||
|
|
||||||
|
return map->priv->extern_volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_channel_map_can_balance (const GvcChannelMap *map)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), FALSE);
|
||||||
|
|
||||||
|
return map->priv->can_balance;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_channel_map_can_fade (const GvcChannelMap *map)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), FALSE);
|
||||||
|
|
||||||
|
return map->priv->can_fade;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gvc_channel_map_get_mapping (const GvcChannelMap *map)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL);
|
||||||
|
|
||||||
|
if (!pa_channel_map_valid(&map->priv->pa_map))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return pa_channel_map_to_pretty_name (&map->priv->pa_map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_channel_map_has_position: (skip)
|
||||||
|
*
|
||||||
|
* @map:
|
||||||
|
* @position:
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
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 pa_channel_map_has_position (&(map->priv->pa_map), position);
|
||||||
|
}
|
||||||
|
|
||||||
|
const pa_channel_map *
|
||||||
|
gvc_channel_map_get_pa_channel_map (const GvcChannelMap *map)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL);
|
||||||
|
|
||||||
|
if (!pa_channel_map_valid(&map->priv->pa_map))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return &map->priv->pa_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pa_cvolume *
|
||||||
|
gvc_channel_map_get_cvolume (const GvcChannelMap *map)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL);
|
||||||
|
|
||||||
|
if (!pa_channel_map_valid(&map->priv->pa_map))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return &map->priv->pa_volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_channel_map_class_init (GvcChannelMapClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->finalize = gvc_channel_map_finalize;
|
||||||
|
|
||||||
|
signals [VOLUME_CHANGED] =
|
||||||
|
g_signal_new ("volume-changed",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (GvcChannelMapClass, volume_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__BOOLEAN,
|
||||||
|
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GvcChannelMapPrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gvc_channel_map_volume_changed (GvcChannelMap *map,
|
||||||
|
const pa_cvolume *cv,
|
||||||
|
gboolean set)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GVC_IS_CHANNEL_MAP (map));
|
||||||
|
g_return_if_fail (cv != NULL);
|
||||||
|
g_return_if_fail (pa_cvolume_compatible_with_channel_map(cv, &map->priv->pa_map));
|
||||||
|
|
||||||
|
if (pa_cvolume_equal(cv, &map->priv->pa_volume))
|
||||||
|
return;
|
||||||
|
|
||||||
|
map->priv->pa_volume = *cv;
|
||||||
|
|
||||||
|
if (map->priv->pa_volume_is_set == FALSE) {
|
||||||
|
map->priv->pa_volume_is_set = TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_signal_emit (map, signals[VOLUME_CHANGED], 0, set);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_channel_map_init (GvcChannelMap *map)
|
||||||
|
{
|
||||||
|
map->priv = GVC_CHANNEL_MAP_GET_PRIVATE (map);
|
||||||
|
map->priv->pa_volume_is_set = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_channel_map_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GvcChannelMap *channel_map;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_CHANNEL_MAP (object));
|
||||||
|
|
||||||
|
channel_map = GVC_CHANNEL_MAP (object);
|
||||||
|
|
||||||
|
g_return_if_fail (channel_map->priv != NULL);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gvc_channel_map_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
GvcChannelMap *
|
||||||
|
gvc_channel_map_new (void)
|
||||||
|
{
|
||||||
|
GObject *map;
|
||||||
|
map = g_object_new (GVC_TYPE_CHANNEL_MAP, NULL);
|
||||||
|
return GVC_CHANNEL_MAP (map);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_from_pa_map (GvcChannelMap *map,
|
||||||
|
const pa_channel_map *pa_map)
|
||||||
|
{
|
||||||
|
g_assert (pa_channel_map_valid(pa_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->pa_map = *pa_map;
|
||||||
|
pa_cvolume_set(&map->priv->pa_volume, pa_map->channels, PA_VOLUME_NORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
GvcChannelMap *
|
||||||
|
gvc_channel_map_new_from_pa_channel_map (const pa_channel_map *pa_map)
|
||||||
|
{
|
||||||
|
GObject *map;
|
||||||
|
map = g_object_new (GVC_TYPE_CHANNEL_MAP, NULL);
|
||||||
|
|
||||||
|
set_from_pa_map (GVC_CHANNEL_MAP (map), pa_map);
|
||||||
|
|
||||||
|
return GVC_CHANNEL_MAP (map);
|
||||||
|
}
|
73
src/gvc/gvc-channel-map.h
Normal file
73
src/gvc/gvc-channel-map.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_CHANNEL_MAP_H
|
||||||
|
#define __GVC_CHANNEL_MAP_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <gvc-pulseaudio-fake.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GVC_TYPE_CHANNEL_MAP (gvc_channel_map_get_type ())
|
||||||
|
#define GVC_CHANNEL_MAP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_CHANNEL_MAP, GvcChannelMap))
|
||||||
|
#define GVC_CHANNEL_MAP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_CHANNEL_MAP, GvcChannelMapClass))
|
||||||
|
#define GVC_IS_CHANNEL_MAP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_CHANNEL_MAP))
|
||||||
|
#define GVC_IS_CHANNEL_MAP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_CHANNEL_MAP))
|
||||||
|
#define GVC_CHANNEL_MAP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_CHANNEL_MAP, GvcChannelMapClass))
|
||||||
|
|
||||||
|
typedef struct GvcChannelMapPrivate GvcChannelMapPrivate;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GObject parent;
|
||||||
|
GvcChannelMapPrivate *priv;
|
||||||
|
} GvcChannelMap;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GObjectClass parent_class;
|
||||||
|
void (*volume_changed) (GvcChannelMap *channel_map, gboolean set);
|
||||||
|
} GvcChannelMapClass;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
VOLUME,
|
||||||
|
BALANCE,
|
||||||
|
FADE,
|
||||||
|
LFE,
|
||||||
|
NUM_TYPES
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gvc_channel_map_get_type (void);
|
||||||
|
|
||||||
|
GvcChannelMap * gvc_channel_map_new (void);
|
||||||
|
guint gvc_channel_map_get_num_channels (const GvcChannelMap *map);
|
||||||
|
const gdouble * gvc_channel_map_get_volume (GvcChannelMap *map);
|
||||||
|
gboolean gvc_channel_map_can_balance (const GvcChannelMap *map);
|
||||||
|
gboolean gvc_channel_map_can_fade (const GvcChannelMap *map);
|
||||||
|
gboolean gvc_channel_map_has_position (const GvcChannelMap *map,
|
||||||
|
pa_channel_position_t position);
|
||||||
|
#define gvc_channel_map_has_lfe(x) gvc_channel_map_has_position (x, PA_CHANNEL_POSITION_LFE)
|
||||||
|
|
||||||
|
const char * gvc_channel_map_get_mapping (const GvcChannelMap *map);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_CHANNEL_MAP_H */
|
35
src/gvc/gvc-mixer-card-private.h
Normal file
35
src/gvc/gvc-mixer-card-private.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2009 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_CARD_PRIVATE_H
|
||||||
|
#define __GVC_MIXER_CARD_PRIVATE_H
|
||||||
|
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
#include "gvc-mixer-card.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
GvcMixerCard * gvc_mixer_card_new (pa_context *context,
|
||||||
|
guint index);
|
||||||
|
pa_context * gvc_mixer_card_get_pa_context (GvcMixerCard *card);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_CARD_PRIVATE_H */
|
506
src/gvc/gvc-mixer-card.c
Normal file
506
src/gvc/gvc-mixer-card.c
Normal file
@ -0,0 +1,506 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 William Jon McCann
|
||||||
|
* Copyright (C) 2009 Bastien Nocera
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
|
#include "gvc-mixer-card.h"
|
||||||
|
#include "gvc-mixer-card-private.h"
|
||||||
|
|
||||||
|
#define GVC_MIXER_CARD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_CARD, GvcMixerCardPrivate))
|
||||||
|
|
||||||
|
static guint32 card_serial = 1;
|
||||||
|
|
||||||
|
struct GvcMixerCardPrivate
|
||||||
|
{
|
||||||
|
pa_context *pa_context;
|
||||||
|
guint id;
|
||||||
|
guint index;
|
||||||
|
char *name;
|
||||||
|
char *icon_name;
|
||||||
|
char *profile;
|
||||||
|
char *target_profile;
|
||||||
|
char *human_profile;
|
||||||
|
GList *profiles;
|
||||||
|
pa_operation *profile_op;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_ID,
|
||||||
|
PROP_PA_CONTEXT,
|
||||||
|
PROP_INDEX,
|
||||||
|
PROP_NAME,
|
||||||
|
PROP_ICON_NAME,
|
||||||
|
PROP_PROFILE,
|
||||||
|
PROP_HUMAN_PROFILE,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gvc_mixer_card_class_init (GvcMixerCardClass *klass);
|
||||||
|
static void gvc_mixer_card_init (GvcMixerCard *mixer_card);
|
||||||
|
static void gvc_mixer_card_finalize (GObject *object);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GvcMixerCard, gvc_mixer_card, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
static guint32
|
||||||
|
get_next_card_serial (void)
|
||||||
|
{
|
||||||
|
guint32 serial;
|
||||||
|
|
||||||
|
serial = card_serial++;
|
||||||
|
|
||||||
|
if ((gint32)card_serial < 0) {
|
||||||
|
card_serial = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return serial;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_context *
|
||||||
|
gvc_mixer_card_get_pa_context (GvcMixerCard *card)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), 0);
|
||||||
|
return card->priv->pa_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
gvc_mixer_card_get_index (GvcMixerCard *card)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), 0);
|
||||||
|
return card->priv->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
gvc_mixer_card_get_id (GvcMixerCard *card)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), 0);
|
||||||
|
return card->priv->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gvc_mixer_card_get_name (GvcMixerCard *card)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), NULL);
|
||||||
|
return card->priv->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_card_set_name (GvcMixerCard *card,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
|
||||||
|
|
||||||
|
g_free (card->priv->name);
|
||||||
|
card->priv->name = g_strdup (name);
|
||||||
|
g_object_notify (G_OBJECT (card), "name");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gvc_mixer_card_get_icon_name (GvcMixerCard *card)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), NULL);
|
||||||
|
return card->priv->icon_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_card_set_icon_name (GvcMixerCard *card,
|
||||||
|
const char *icon_name)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
|
||||||
|
|
||||||
|
g_free (card->priv->icon_name);
|
||||||
|
card->priv->icon_name = g_strdup (icon_name);
|
||||||
|
g_object_notify (G_OBJECT (card), "icon-name");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_card_get_profile: (skip)
|
||||||
|
*
|
||||||
|
* @card:
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
GvcMixerCardProfile *
|
||||||
|
gvc_mixer_card_get_profile (GvcMixerCard *card)
|
||||||
|
{
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), NULL);
|
||||||
|
g_return_val_if_fail (card->priv->profiles != NULL, FALSE);
|
||||||
|
|
||||||
|
for (l = card->priv->profiles; l != NULL; l = l->next) {
|
||||||
|
GvcMixerCardProfile *p = l->data;
|
||||||
|
if (g_str_equal (card->priv->profile, p->profile)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert_not_reached ();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_card_set_profile (GvcMixerCard *card,
|
||||||
|
const char *profile)
|
||||||
|
{
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
|
||||||
|
g_return_val_if_fail (card->priv->profiles != NULL, FALSE);
|
||||||
|
|
||||||
|
g_free (card->priv->profile);
|
||||||
|
card->priv->profile = g_strdup (profile);
|
||||||
|
|
||||||
|
g_free (card->priv->human_profile);
|
||||||
|
card->priv->human_profile = NULL;
|
||||||
|
|
||||||
|
for (l = card->priv->profiles; l != NULL; l = l->next) {
|
||||||
|
GvcMixerCardProfile *p = l->data;
|
||||||
|
if (g_str_equal (card->priv->profile, p->profile)) {
|
||||||
|
card->priv->human_profile = g_strdup (p->human_profile);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (card), "profile");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_pa_context_set_card_profile_by_index_cb (pa_context *context,
|
||||||
|
int success,
|
||||||
|
void *userdata)
|
||||||
|
{
|
||||||
|
GvcMixerCard *card = GVC_MIXER_CARD (userdata);
|
||||||
|
|
||||||
|
g_assert (card->priv->target_profile);
|
||||||
|
|
||||||
|
if (success > 0) {
|
||||||
|
gvc_mixer_card_set_profile (card, card->priv->target_profile);
|
||||||
|
} else {
|
||||||
|
g_debug ("Failed to switch profile on '%s' from '%s' to '%s'",
|
||||||
|
card->priv->name,
|
||||||
|
card->priv->profile,
|
||||||
|
card->priv->target_profile);
|
||||||
|
}
|
||||||
|
g_free (card->priv->target_profile);
|
||||||
|
card->priv->target_profile = NULL;
|
||||||
|
|
||||||
|
pa_operation_unref (card->priv->profile_op);
|
||||||
|
card->priv->profile_op = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_card_change_profile (GvcMixerCard *card,
|
||||||
|
const char *profile)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
|
||||||
|
g_return_val_if_fail (card->priv->profiles != NULL, FALSE);
|
||||||
|
|
||||||
|
/* Same profile, or already requested? */
|
||||||
|
if (g_strcmp0 (card->priv->profile, profile) == 0)
|
||||||
|
return TRUE;
|
||||||
|
if (g_strcmp0 (profile, card->priv->target_profile) == 0)
|
||||||
|
return TRUE;
|
||||||
|
if (card->priv->profile_op != NULL) {
|
||||||
|
pa_operation_cancel (card->priv->profile_op);
|
||||||
|
pa_operation_unref (card->priv->profile_op);
|
||||||
|
card->priv->profile_op = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (card->priv->profile != NULL) {
|
||||||
|
g_free (card->priv->target_profile);
|
||||||
|
card->priv->target_profile = g_strdup (profile);
|
||||||
|
|
||||||
|
card->priv->profile_op = pa_context_set_card_profile_by_index (card->priv->pa_context,
|
||||||
|
card->priv->index,
|
||||||
|
card->priv->target_profile,
|
||||||
|
_pa_context_set_card_profile_by_index_cb,
|
||||||
|
card);
|
||||||
|
|
||||||
|
if (card->priv->profile_op == NULL) {
|
||||||
|
g_warning ("pa_context_set_card_profile_by_index() failed");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g_assert (card->priv->human_profile == NULL);
|
||||||
|
card->priv->profile = g_strdup (profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GList *
|
||||||
|
gvc_mixer_card_get_profiles (GvcMixerCard *card)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
|
||||||
|
return card->priv->profiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
sort_profiles (GvcMixerCardProfile *a,
|
||||||
|
GvcMixerCardProfile *b)
|
||||||
|
{
|
||||||
|
if (a->priority == b->priority)
|
||||||
|
return 0;
|
||||||
|
if (a->priority > b->priority)
|
||||||
|
return 1;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_card_set_profiles (GvcMixerCard *card,
|
||||||
|
GList *profiles)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
|
||||||
|
g_return_val_if_fail (card->priv->profiles == NULL, FALSE);
|
||||||
|
|
||||||
|
card->priv->profiles = g_list_sort (profiles, (GCompareFunc) sort_profiles);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_card_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GvcMixerCard *self = GVC_MIXER_CARD (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PA_CONTEXT:
|
||||||
|
self->priv->pa_context = g_value_get_pointer (value);
|
||||||
|
break;
|
||||||
|
case PROP_INDEX:
|
||||||
|
self->priv->index = g_value_get_ulong (value);
|
||||||
|
break;
|
||||||
|
case PROP_ID:
|
||||||
|
self->priv->id = g_value_get_ulong (value);
|
||||||
|
break;
|
||||||
|
case PROP_NAME:
|
||||||
|
gvc_mixer_card_set_name (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
case PROP_ICON_NAME:
|
||||||
|
gvc_mixer_card_set_icon_name (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
case PROP_PROFILE:
|
||||||
|
gvc_mixer_card_set_profile (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_card_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GvcMixerCard *self = GVC_MIXER_CARD (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PA_CONTEXT:
|
||||||
|
g_value_set_pointer (value, self->priv->pa_context);
|
||||||
|
break;
|
||||||
|
case PROP_INDEX:
|
||||||
|
g_value_set_ulong (value, self->priv->index);
|
||||||
|
break;
|
||||||
|
case PROP_ID:
|
||||||
|
g_value_set_ulong (value, self->priv->id);
|
||||||
|
break;
|
||||||
|
case PROP_NAME:
|
||||||
|
g_value_set_string (value, self->priv->name);
|
||||||
|
break;
|
||||||
|
case PROP_ICON_NAME:
|
||||||
|
g_value_set_string (value, self->priv->icon_name);
|
||||||
|
break;
|
||||||
|
case PROP_PROFILE:
|
||||||
|
g_value_set_string (value, self->priv->profile);
|
||||||
|
break;
|
||||||
|
case PROP_HUMAN_PROFILE:
|
||||||
|
g_value_set_string (value, self->priv->human_profile);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
gvc_mixer_card_constructor (GType type,
|
||||||
|
guint n_construct_properties,
|
||||||
|
GObjectConstructParam *construct_params)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
GvcMixerCard *self;
|
||||||
|
|
||||||
|
object = G_OBJECT_CLASS (gvc_mixer_card_parent_class)->constructor (type, n_construct_properties, construct_params);
|
||||||
|
|
||||||
|
self = GVC_MIXER_CARD (object);
|
||||||
|
|
||||||
|
self->priv->id = get_next_card_serial ();
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_card_class_init (GvcMixerCardClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->constructor = gvc_mixer_card_constructor;
|
||||||
|
gobject_class->finalize = gvc_mixer_card_finalize;
|
||||||
|
|
||||||
|
gobject_class->set_property = gvc_mixer_card_set_property;
|
||||||
|
gobject_class->get_property = gvc_mixer_card_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_INDEX,
|
||||||
|
g_param_spec_ulong ("index",
|
||||||
|
"Index",
|
||||||
|
"The index for this card",
|
||||||
|
0, G_MAXULONG, 0,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_ID,
|
||||||
|
g_param_spec_ulong ("id",
|
||||||
|
"id",
|
||||||
|
"The id for this card",
|
||||||
|
0, G_MAXULONG, 0,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_PA_CONTEXT,
|
||||||
|
g_param_spec_pointer ("pa-context",
|
||||||
|
"PulseAudio context",
|
||||||
|
"The PulseAudio context for this card",
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_NAME,
|
||||||
|
g_param_spec_string ("name",
|
||||||
|
"Name",
|
||||||
|
"Name to display for this card",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_ICON_NAME,
|
||||||
|
g_param_spec_string ("icon-name",
|
||||||
|
"Icon Name",
|
||||||
|
"Name of icon to display for this card",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_PROFILE,
|
||||||
|
g_param_spec_string ("profile",
|
||||||
|
"Profile",
|
||||||
|
"Name of current profile for this card",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_HUMAN_PROFILE,
|
||||||
|
g_param_spec_string ("human-profile",
|
||||||
|
"Profile (Human readable)",
|
||||||
|
"Name of current profile for this card in human readable form",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GvcMixerCardPrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_card_init (GvcMixerCard *card)
|
||||||
|
{
|
||||||
|
card->priv = GVC_MIXER_CARD_GET_PRIVATE (card);
|
||||||
|
}
|
||||||
|
|
||||||
|
GvcMixerCard *
|
||||||
|
gvc_mixer_card_new (pa_context *context,
|
||||||
|
guint index)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (GVC_TYPE_MIXER_CARD,
|
||||||
|
"index", index,
|
||||||
|
"pa-context", context,
|
||||||
|
NULL);
|
||||||
|
return GVC_MIXER_CARD (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_profile (GvcMixerCardProfile *p)
|
||||||
|
{
|
||||||
|
g_free (p->profile);
|
||||||
|
g_free (p->human_profile);
|
||||||
|
g_free (p->status);
|
||||||
|
g_free (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_card_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerCard *mixer_card;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_CARD (object));
|
||||||
|
|
||||||
|
mixer_card = GVC_MIXER_CARD (object);
|
||||||
|
|
||||||
|
g_return_if_fail (mixer_card->priv != NULL);
|
||||||
|
|
||||||
|
g_free (mixer_card->priv->name);
|
||||||
|
mixer_card->priv->name = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_card->priv->icon_name);
|
||||||
|
mixer_card->priv->icon_name = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_card->priv->target_profile);
|
||||||
|
mixer_card->priv->target_profile = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_card->priv->profile);
|
||||||
|
mixer_card->priv->profile = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_card->priv->human_profile);
|
||||||
|
mixer_card->priv->human_profile = NULL;
|
||||||
|
|
||||||
|
g_list_foreach (mixer_card->priv->profiles, (GFunc) free_profile, NULL);
|
||||||
|
g_list_free (mixer_card->priv->profiles);
|
||||||
|
mixer_card->priv->profiles = NULL;
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_card_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
83
src/gvc/gvc-mixer-card.h
Normal file
83
src/gvc/gvc-mixer-card.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2009 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_CARD_H
|
||||||
|
#define __GVC_MIXER_CARD_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GVC_TYPE_MIXER_CARD (gvc_mixer_card_get_type ())
|
||||||
|
#define GVC_MIXER_CARD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_CARD, GvcMixerCard))
|
||||||
|
#define GVC_MIXER_CARD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_CARD, GvcMixerCardClass))
|
||||||
|
#define GVC_IS_MIXER_CARD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_CARD))
|
||||||
|
#define GVC_IS_MIXER_CARD_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_CARD))
|
||||||
|
#define GVC_MIXER_CARD_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_CARD, GvcMixerCardClass))
|
||||||
|
|
||||||
|
typedef struct GvcMixerCardPrivate GvcMixerCardPrivate;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GObject parent;
|
||||||
|
GvcMixerCardPrivate *priv;
|
||||||
|
} GvcMixerCard;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
/* vtable */
|
||||||
|
} GvcMixerCardClass;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char *profile;
|
||||||
|
char *human_profile;
|
||||||
|
char *status;
|
||||||
|
guint priority;
|
||||||
|
guint n_sinks, n_sources;
|
||||||
|
} GvcMixerCardProfile;
|
||||||
|
|
||||||
|
GType gvc_mixer_card_get_type (void);
|
||||||
|
|
||||||
|
guint gvc_mixer_card_get_id (GvcMixerCard *card);
|
||||||
|
guint gvc_mixer_card_get_index (GvcMixerCard *card);
|
||||||
|
const char * gvc_mixer_card_get_name (GvcMixerCard *card);
|
||||||
|
const char * gvc_mixer_card_get_icon_name (GvcMixerCard *card);
|
||||||
|
GvcMixerCardProfile * gvc_mixer_card_get_profile (GvcMixerCard *card);
|
||||||
|
const GList * gvc_mixer_card_get_profiles (GvcMixerCard *card);
|
||||||
|
|
||||||
|
gboolean gvc_mixer_card_change_profile (GvcMixerCard *card,
|
||||||
|
const char *profile);
|
||||||
|
|
||||||
|
/* private */
|
||||||
|
gboolean gvc_mixer_card_set_name (GvcMixerCard *card,
|
||||||
|
const char *name);
|
||||||
|
gboolean gvc_mixer_card_set_icon_name (GvcMixerCard *card,
|
||||||
|
const char *name);
|
||||||
|
gboolean gvc_mixer_card_set_profile (GvcMixerCard *card,
|
||||||
|
const char *profile);
|
||||||
|
gboolean gvc_mixer_card_set_profiles (GvcMixerCard *card,
|
||||||
|
GList *profiles);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_CARD_H */
|
35
src/gvc/gvc-mixer-control-private.h
Normal file
35
src/gvc/gvc-mixer-control-private.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_CONTROL_PRIVATE_H
|
||||||
|
#define __GVC_MIXER_CONTROL_PRIVATE_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
#include "gvc-mixer-stream.h"
|
||||||
|
#include "gvc-mixer-card.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
pa_context * gvc_mixer_control_get_pa_context (GvcMixerControl *control);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_CONTROL_PRIVATE_H */
|
2232
src/gvc/gvc-mixer-control.c
Normal file
2232
src/gvc/gvc-mixer-control.c
Normal file
File diff suppressed because it is too large
Load Diff
96
src/gvc/gvc-mixer-control.h
Normal file
96
src/gvc/gvc-mixer-control.h
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_CONTROL_H
|
||||||
|
#define __GVC_MIXER_CONTROL_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include "gvc-mixer-stream.h"
|
||||||
|
#include "gvc-mixer-card.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GVC_TYPE_MIXER_CONTROL (gvc_mixer_control_get_type ())
|
||||||
|
#define GVC_MIXER_CONTROL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_CONTROL, GvcMixerControl))
|
||||||
|
#define GVC_MIXER_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_CONTROL, GvcMixerControlClass))
|
||||||
|
#define GVC_IS_MIXER_CONTROL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_CONTROL))
|
||||||
|
#define GVC_IS_MIXER_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_CONTROL))
|
||||||
|
#define GVC_MIXER_CONTROL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_CONTROL, GvcMixerControlClass))
|
||||||
|
|
||||||
|
typedef struct GvcMixerControlPrivate GvcMixerControlPrivate;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GObject parent;
|
||||||
|
GvcMixerControlPrivate *priv;
|
||||||
|
} GvcMixerControl;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
void (*connecting) (GvcMixerControl *control);
|
||||||
|
void (*ready) (GvcMixerControl *control);
|
||||||
|
void (*stream_added) (GvcMixerControl *control,
|
||||||
|
guint id);
|
||||||
|
void (*stream_removed) (GvcMixerControl *control,
|
||||||
|
guint id);
|
||||||
|
void (*card_added) (GvcMixerControl *control,
|
||||||
|
guint id);
|
||||||
|
void (*card_removed) (GvcMixerControl *control,
|
||||||
|
guint id);
|
||||||
|
void (*default_sink_changed) (GvcMixerControl *control,
|
||||||
|
guint id);
|
||||||
|
void (*default_source_changed) (GvcMixerControl *control,
|
||||||
|
guint id);
|
||||||
|
} GvcMixerControlClass;
|
||||||
|
|
||||||
|
GType gvc_mixer_control_get_type (void);
|
||||||
|
|
||||||
|
GvcMixerControl * gvc_mixer_control_new (const char *name);
|
||||||
|
|
||||||
|
gboolean gvc_mixer_control_open (GvcMixerControl *control);
|
||||||
|
gboolean gvc_mixer_control_close (GvcMixerControl *control);
|
||||||
|
gboolean gvc_mixer_control_is_ready (GvcMixerControl *control);
|
||||||
|
|
||||||
|
GSList * gvc_mixer_control_get_cards (GvcMixerControl *control);
|
||||||
|
GSList * gvc_mixer_control_get_streams (GvcMixerControl *control);
|
||||||
|
GSList * gvc_mixer_control_get_sinks (GvcMixerControl *control);
|
||||||
|
GSList * gvc_mixer_control_get_sources (GvcMixerControl *control);
|
||||||
|
GSList * gvc_mixer_control_get_sink_inputs (GvcMixerControl *control);
|
||||||
|
GSList * gvc_mixer_control_get_source_outputs (GvcMixerControl *control);
|
||||||
|
|
||||||
|
GvcMixerStream * gvc_mixer_control_lookup_stream_id (GvcMixerControl *control,
|
||||||
|
guint id);
|
||||||
|
GvcMixerCard * gvc_mixer_control_lookup_card_id (GvcMixerControl *control,
|
||||||
|
guint id);
|
||||||
|
|
||||||
|
GvcMixerStream * gvc_mixer_control_get_default_sink (GvcMixerControl *control);
|
||||||
|
GvcMixerStream * gvc_mixer_control_get_default_source (GvcMixerControl *control);
|
||||||
|
GvcMixerStream * gvc_mixer_control_get_event_sink_input (GvcMixerControl *control);
|
||||||
|
|
||||||
|
gboolean gvc_mixer_control_set_default_sink (GvcMixerControl *control,
|
||||||
|
GvcMixerStream *stream);
|
||||||
|
gboolean gvc_mixer_control_set_default_source (GvcMixerControl *control,
|
||||||
|
GvcMixerStream *stream);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_CONTROL_H */
|
250
src/gvc/gvc-mixer-event-role.c
Normal file
250
src/gvc/gvc-mixer-event-role.c
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 William Jon McCann
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
#include <pulse/ext-stream-restore.h>
|
||||||
|
|
||||||
|
#include "gvc-mixer-event-role.h"
|
||||||
|
#include "gvc-mixer-stream-private.h"
|
||||||
|
#include "gvc-channel-map-private.h"
|
||||||
|
|
||||||
|
#define GVC_MIXER_EVENT_ROLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_EVENT_ROLE, GvcMixerEventRolePrivate))
|
||||||
|
|
||||||
|
struct GvcMixerEventRolePrivate
|
||||||
|
{
|
||||||
|
char *device;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_DEVICE
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gvc_mixer_event_role_class_init (GvcMixerEventRoleClass *klass);
|
||||||
|
static void gvc_mixer_event_role_init (GvcMixerEventRole *mixer_event_role);
|
||||||
|
static void gvc_mixer_event_role_finalize (GObject *object);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GvcMixerEventRole, gvc_mixer_event_role, GVC_TYPE_MIXER_STREAM)
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
update_settings (GvcMixerEventRole *role,
|
||||||
|
gboolean is_muted,
|
||||||
|
gpointer *op)
|
||||||
|
{
|
||||||
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
const GvcChannelMap *map;
|
||||||
|
pa_context *context;
|
||||||
|
pa_ext_stream_restore_info info;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (GVC_MIXER_STREAM (role));
|
||||||
|
|
||||||
|
map = gvc_mixer_stream_get_channel_map (GVC_MIXER_STREAM(role));
|
||||||
|
|
||||||
|
info.volume = *gvc_channel_map_get_cvolume(map);
|
||||||
|
info.name = "sink-input-by-media-role:event";
|
||||||
|
info.channel_map = *gvc_channel_map_get_pa_channel_map(map);
|
||||||
|
info.device = role->priv->device;
|
||||||
|
info.mute = is_muted;
|
||||||
|
|
||||||
|
context = gvc_mixer_stream_get_pa_context (GVC_MIXER_STREAM (role));
|
||||||
|
|
||||||
|
o = pa_ext_stream_restore_write (context,
|
||||||
|
PA_UPDATE_REPLACE,
|
||||||
|
&info,
|
||||||
|
1,
|
||||||
|
TRUE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_ext_stream_restore_write() failed");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (op != NULL)
|
||||||
|
*op = o;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_event_role_push_volume (GvcMixerStream *stream, gpointer *op)
|
||||||
|
{
|
||||||
|
return update_settings (GVC_MIXER_EVENT_ROLE (stream),
|
||||||
|
gvc_mixer_stream_get_is_muted (stream), op);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_event_role_change_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted)
|
||||||
|
{
|
||||||
|
return update_settings (GVC_MIXER_EVENT_ROLE (stream),
|
||||||
|
is_muted, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_event_role_set_device (GvcMixerEventRole *role,
|
||||||
|
const char *device)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_EVENT_ROLE (role), FALSE);
|
||||||
|
|
||||||
|
g_free (role->priv->device);
|
||||||
|
role->priv->device = g_strdup (device);
|
||||||
|
g_object_notify (G_OBJECT (role), "device");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_event_role_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GvcMixerEventRole *self = GVC_MIXER_EVENT_ROLE (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_DEVICE:
|
||||||
|
gvc_mixer_event_role_set_device (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_event_role_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GvcMixerEventRole *self = GVC_MIXER_EVENT_ROLE (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_DEVICE:
|
||||||
|
g_value_set_string (value, self->priv->device);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
gvc_mixer_event_role_constructor (GType type,
|
||||||
|
guint n_construct_properties,
|
||||||
|
GObjectConstructParam *construct_params)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
GvcMixerEventRole *self;
|
||||||
|
|
||||||
|
object = G_OBJECT_CLASS (gvc_mixer_event_role_parent_class)->constructor (type, n_construct_properties, construct_params);
|
||||||
|
|
||||||
|
self = GVC_MIXER_EVENT_ROLE (object);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_event_role_class_init (GvcMixerEventRoleClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructor = gvc_mixer_event_role_constructor;
|
||||||
|
object_class->finalize = gvc_mixer_event_role_finalize;
|
||||||
|
object_class->set_property = gvc_mixer_event_role_set_property;
|
||||||
|
object_class->get_property = gvc_mixer_event_role_get_property;
|
||||||
|
|
||||||
|
stream_class->push_volume = gvc_mixer_event_role_push_volume;
|
||||||
|
stream_class->change_is_muted = gvc_mixer_event_role_change_is_muted;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_DEVICE,
|
||||||
|
g_param_spec_string ("device",
|
||||||
|
"Device",
|
||||||
|
"Device",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GvcMixerEventRolePrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_event_role_init (GvcMixerEventRole *event_role)
|
||||||
|
{
|
||||||
|
event_role->priv = GVC_MIXER_EVENT_ROLE_GET_PRIVATE (event_role);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_event_role_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerEventRole *mixer_event_role;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_EVENT_ROLE (object));
|
||||||
|
|
||||||
|
mixer_event_role = GVC_MIXER_EVENT_ROLE (object);
|
||||||
|
|
||||||
|
g_return_if_fail (mixer_event_role->priv != NULL);
|
||||||
|
|
||||||
|
g_free (mixer_event_role->priv->device);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_event_role_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_event_role_new: (skip)
|
||||||
|
*
|
||||||
|
* @context:
|
||||||
|
* @index:
|
||||||
|
* @channel_map:
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
GvcMixerStream *
|
||||||
|
gvc_mixer_event_role_new (pa_context *context,
|
||||||
|
const char *device,
|
||||||
|
GvcChannelMap *channel_map)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (GVC_TYPE_MIXER_EVENT_ROLE,
|
||||||
|
"pa-context", context,
|
||||||
|
"index", 0,
|
||||||
|
"device", device,
|
||||||
|
"channel-map", channel_map,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return GVC_MIXER_STREAM (object);
|
||||||
|
}
|
57
src/gvc/gvc-mixer-event-role.h
Normal file
57
src/gvc/gvc-mixer-event-role.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_EVENT_ROLE_H
|
||||||
|
#define __GVC_MIXER_EVENT_ROLE_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include "gvc-mixer-stream.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GVC_TYPE_MIXER_EVENT_ROLE (gvc_mixer_event_role_get_type ())
|
||||||
|
#define GVC_MIXER_EVENT_ROLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_EVENT_ROLE, GvcMixerEventRole))
|
||||||
|
#define GVC_MIXER_EVENT_ROLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_EVENT_ROLE, GvcMixerEventRoleClass))
|
||||||
|
#define GVC_IS_MIXER_EVENT_ROLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_EVENT_ROLE))
|
||||||
|
#define GVC_IS_MIXER_EVENT_ROLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_EVENT_ROLE))
|
||||||
|
#define GVC_MIXER_EVENT_ROLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_EVENT_ROLE, GvcMixerEventRoleClass))
|
||||||
|
|
||||||
|
typedef struct GvcMixerEventRolePrivate GvcMixerEventRolePrivate;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStream parent;
|
||||||
|
GvcMixerEventRolePrivate *priv;
|
||||||
|
} GvcMixerEventRole;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStreamClass parent_class;
|
||||||
|
} GvcMixerEventRoleClass;
|
||||||
|
|
||||||
|
GType gvc_mixer_event_role_get_type (void);
|
||||||
|
|
||||||
|
GvcMixerStream * gvc_mixer_event_role_new (pa_context *context,
|
||||||
|
const char *device,
|
||||||
|
GvcChannelMap *channel_map);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_EVENT_ROLE_H */
|
199
src/gvc/gvc-mixer-sink-input.c
Normal file
199
src/gvc/gvc-mixer-sink-input.c
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 William Jon McCann
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
|
#include "gvc-mixer-sink-input.h"
|
||||||
|
#include "gvc-mixer-stream-private.h"
|
||||||
|
#include "gvc-channel-map-private.h"
|
||||||
|
|
||||||
|
#define GVC_MIXER_SINK_INPUT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SINK_INPUT, GvcMixerSinkInputPrivate))
|
||||||
|
|
||||||
|
struct GvcMixerSinkInputPrivate
|
||||||
|
{
|
||||||
|
gpointer dummy;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gvc_mixer_sink_input_class_init (GvcMixerSinkInputClass *klass);
|
||||||
|
static void gvc_mixer_sink_input_init (GvcMixerSinkInput *mixer_sink_input);
|
||||||
|
static void gvc_mixer_sink_input_finalize (GObject *object);
|
||||||
|
static void gvc_mixer_sink_input_dispose (GObject *object);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GvcMixerSinkInput, gvc_mixer_sink_input, GVC_TYPE_MIXER_STREAM)
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_sink_input_push_volume (GvcMixerStream *stream, gpointer *op)
|
||||||
|
{
|
||||||
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
const GvcChannelMap *map;
|
||||||
|
pa_context *context;
|
||||||
|
const pa_cvolume *cv;
|
||||||
|
guint num_channels;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
|
||||||
|
map = gvc_mixer_stream_get_channel_map (stream);
|
||||||
|
num_channels = gvc_channel_map_get_num_channels (map);
|
||||||
|
|
||||||
|
cv = gvc_channel_map_get_cvolume(map);
|
||||||
|
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_sink_input_volume (context,
|
||||||
|
index,
|
||||||
|
cv,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_sink_input_volume() failed");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*op = o;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_sink_input_change_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted)
|
||||||
|
{
|
||||||
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
pa_context *context;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_sink_input_mute (context,
|
||||||
|
index,
|
||||||
|
is_muted,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_sink_input_mute_by_index() failed");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_operation_unref(o);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
gvc_mixer_sink_input_constructor (GType type,
|
||||||
|
guint n_construct_properties,
|
||||||
|
GObjectConstructParam *construct_params)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
GvcMixerSinkInput *self;
|
||||||
|
|
||||||
|
object = G_OBJECT_CLASS (gvc_mixer_sink_input_parent_class)->constructor (type, n_construct_properties, construct_params);
|
||||||
|
|
||||||
|
self = GVC_MIXER_SINK_INPUT (object);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_sink_input_class_init (GvcMixerSinkInputClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructor = gvc_mixer_sink_input_constructor;
|
||||||
|
object_class->dispose = gvc_mixer_sink_input_dispose;
|
||||||
|
object_class->finalize = gvc_mixer_sink_input_finalize;
|
||||||
|
|
||||||
|
stream_class->push_volume = gvc_mixer_sink_input_push_volume;
|
||||||
|
stream_class->change_is_muted = gvc_mixer_sink_input_change_is_muted;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GvcMixerSinkInputPrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_sink_input_init (GvcMixerSinkInput *sink_input)
|
||||||
|
{
|
||||||
|
sink_input->priv = GVC_MIXER_SINK_INPUT_GET_PRIVATE (sink_input);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_sink_input_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerSinkInput *mixer_sink_input;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_SINK_INPUT (object));
|
||||||
|
|
||||||
|
mixer_sink_input = GVC_MIXER_SINK_INPUT (object);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_sink_input_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_sink_input_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerSinkInput *mixer_sink_input;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_SINK_INPUT (object));
|
||||||
|
|
||||||
|
mixer_sink_input = GVC_MIXER_SINK_INPUT (object);
|
||||||
|
|
||||||
|
g_return_if_fail (mixer_sink_input->priv != NULL);
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_sink_input_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_sink_input_new: (skip)
|
||||||
|
*
|
||||||
|
* @context:
|
||||||
|
* @index:
|
||||||
|
* @channel_map:
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
GvcMixerStream *
|
||||||
|
gvc_mixer_sink_input_new (pa_context *context,
|
||||||
|
guint index,
|
||||||
|
GvcChannelMap *channel_map)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (GVC_TYPE_MIXER_SINK_INPUT,
|
||||||
|
"pa-context", context,
|
||||||
|
"index", index,
|
||||||
|
"channel-map", channel_map,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return GVC_MIXER_STREAM (object);
|
||||||
|
}
|
57
src/gvc/gvc-mixer-sink-input.h
Normal file
57
src/gvc/gvc-mixer-sink-input.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_SINK_INPUT_H
|
||||||
|
#define __GVC_MIXER_SINK_INPUT_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include "gvc-mixer-stream.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GVC_TYPE_MIXER_SINK_INPUT (gvc_mixer_sink_input_get_type ())
|
||||||
|
#define GVC_MIXER_SINK_INPUT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_SINK_INPUT, GvcMixerSinkInput))
|
||||||
|
#define GVC_MIXER_SINK_INPUT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_SINK_INPUT, GvcMixerSinkInputClass))
|
||||||
|
#define GVC_IS_MIXER_SINK_INPUT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_SINK_INPUT))
|
||||||
|
#define GVC_IS_MIXER_SINK_INPUT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_SINK_INPUT))
|
||||||
|
#define GVC_MIXER_SINK_INPUT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_SINK_INPUT, GvcMixerSinkInputClass))
|
||||||
|
|
||||||
|
typedef struct GvcMixerSinkInputPrivate GvcMixerSinkInputPrivate;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStream parent;
|
||||||
|
GvcMixerSinkInputPrivate *priv;
|
||||||
|
} GvcMixerSinkInput;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStreamClass parent_class;
|
||||||
|
} GvcMixerSinkInputClass;
|
||||||
|
|
||||||
|
GType gvc_mixer_sink_input_get_type (void);
|
||||||
|
|
||||||
|
GvcMixerStream * gvc_mixer_sink_input_new (pa_context *context,
|
||||||
|
guint index,
|
||||||
|
GvcChannelMap *map);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_SINK_INPUT_H */
|
231
src/gvc/gvc-mixer-sink.c
Normal file
231
src/gvc/gvc-mixer-sink.c
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 William Jon McCann
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
|
#include "gvc-mixer-sink.h"
|
||||||
|
#include "gvc-mixer-stream-private.h"
|
||||||
|
#include "gvc-channel-map-private.h"
|
||||||
|
|
||||||
|
#define GVC_MIXER_SINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SINK, GvcMixerSinkPrivate))
|
||||||
|
|
||||||
|
struct GvcMixerSinkPrivate
|
||||||
|
{
|
||||||
|
gpointer dummy;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gvc_mixer_sink_class_init (GvcMixerSinkClass *klass);
|
||||||
|
static void gvc_mixer_sink_init (GvcMixerSink *mixer_sink);
|
||||||
|
static void gvc_mixer_sink_finalize (GObject *object);
|
||||||
|
static void gvc_mixer_sink_dispose (GObject *object);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GvcMixerSink, gvc_mixer_sink, GVC_TYPE_MIXER_STREAM)
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_sink_push_volume (GvcMixerStream *stream, gpointer *op)
|
||||||
|
{
|
||||||
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
const GvcChannelMap *map;
|
||||||
|
pa_context *context;
|
||||||
|
const pa_cvolume *cv;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
|
||||||
|
map = gvc_mixer_stream_get_channel_map (stream);
|
||||||
|
|
||||||
|
/* set the volume */
|
||||||
|
cv = gvc_channel_map_get_cvolume(map);
|
||||||
|
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_sink_volume_by_index (context,
|
||||||
|
index,
|
||||||
|
cv,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_sink_volume_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*op = o;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_sink_change_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted)
|
||||||
|
{
|
||||||
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
pa_context *context;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_sink_mute_by_index (context,
|
||||||
|
index,
|
||||||
|
is_muted,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_sink_mute_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_operation_unref(o);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_sink_change_port (GvcMixerStream *stream,
|
||||||
|
const char *port)
|
||||||
|
{
|
||||||
|
#if PA_MICRO > 15
|
||||||
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
pa_context *context;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_sink_port_by_index (context,
|
||||||
|
index,
|
||||||
|
port,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_sink_port_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_operation_unref(o);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
#else
|
||||||
|
return FALSE;
|
||||||
|
#endif /* PA_MICRO > 15 */
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
gvc_mixer_sink_constructor (GType type,
|
||||||
|
guint n_construct_properties,
|
||||||
|
GObjectConstructParam *construct_params)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
GvcMixerSink *self;
|
||||||
|
|
||||||
|
object = G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->constructor (type, n_construct_properties, construct_params);
|
||||||
|
|
||||||
|
self = GVC_MIXER_SINK (object);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_sink_class_init (GvcMixerSinkClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructor = gvc_mixer_sink_constructor;
|
||||||
|
object_class->dispose = gvc_mixer_sink_dispose;
|
||||||
|
object_class->finalize = gvc_mixer_sink_finalize;
|
||||||
|
|
||||||
|
stream_class->push_volume = gvc_mixer_sink_push_volume;
|
||||||
|
stream_class->change_port = gvc_mixer_sink_change_port;
|
||||||
|
stream_class->change_is_muted = gvc_mixer_sink_change_is_muted;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GvcMixerSinkPrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_sink_init (GvcMixerSink *sink)
|
||||||
|
{
|
||||||
|
sink->priv = GVC_MIXER_SINK_GET_PRIVATE (sink);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_sink_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerSink *mixer_sink;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_SINK (object));
|
||||||
|
|
||||||
|
mixer_sink = GVC_MIXER_SINK (object);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_sink_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerSink *mixer_sink;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_SINK (object));
|
||||||
|
|
||||||
|
mixer_sink = GVC_MIXER_SINK (object);
|
||||||
|
|
||||||
|
g_return_if_fail (mixer_sink->priv != NULL);
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_sink_new: (skip)
|
||||||
|
*
|
||||||
|
* @context:
|
||||||
|
* @index:
|
||||||
|
* @channel_map:
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
GvcMixerStream *
|
||||||
|
gvc_mixer_sink_new (pa_context *context,
|
||||||
|
guint index,
|
||||||
|
GvcChannelMap *channel_map)
|
||||||
|
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (GVC_TYPE_MIXER_SINK,
|
||||||
|
"pa-context", context,
|
||||||
|
"index", index,
|
||||||
|
"channel-map", channel_map,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return GVC_MIXER_STREAM (object);
|
||||||
|
}
|
57
src/gvc/gvc-mixer-sink.h
Normal file
57
src/gvc/gvc-mixer-sink.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_SINK_H
|
||||||
|
#define __GVC_MIXER_SINK_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include "gvc-mixer-stream.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GVC_TYPE_MIXER_SINK (gvc_mixer_sink_get_type ())
|
||||||
|
#define GVC_MIXER_SINK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_SINK, GvcMixerSink))
|
||||||
|
#define GVC_MIXER_SINK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_SINK, GvcMixerSinkClass))
|
||||||
|
#define GVC_IS_MIXER_SINK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_SINK))
|
||||||
|
#define GVC_IS_MIXER_SINK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_SINK))
|
||||||
|
#define GVC_MIXER_SINK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_SINK, GvcMixerSinkClass))
|
||||||
|
|
||||||
|
typedef struct GvcMixerSinkPrivate GvcMixerSinkPrivate;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStream parent;
|
||||||
|
GvcMixerSinkPrivate *priv;
|
||||||
|
} GvcMixerSink;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStreamClass parent_class;
|
||||||
|
} GvcMixerSinkClass;
|
||||||
|
|
||||||
|
GType gvc_mixer_sink_get_type (void);
|
||||||
|
|
||||||
|
GvcMixerStream * gvc_mixer_sink_new (pa_context *context,
|
||||||
|
guint index,
|
||||||
|
GvcChannelMap *map);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_SINK_H */
|
137
src/gvc/gvc-mixer-source-output.c
Normal file
137
src/gvc/gvc-mixer-source-output.c
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 William Jon McCann
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
|
#include "gvc-mixer-source-output.h"
|
||||||
|
|
||||||
|
#define GVC_MIXER_SOURCE_OUTPUT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutputPrivate))
|
||||||
|
|
||||||
|
struct GvcMixerSourceOutputPrivate
|
||||||
|
{
|
||||||
|
gpointer dummy;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gvc_mixer_source_output_class_init (GvcMixerSourceOutputClass *klass);
|
||||||
|
static void gvc_mixer_source_output_init (GvcMixerSourceOutput *mixer_source_output);
|
||||||
|
static void gvc_mixer_source_output_finalize (GObject *object);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GvcMixerSourceOutput, gvc_mixer_source_output, GVC_TYPE_MIXER_STREAM)
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_source_output_push_volume (GvcMixerStream *stream, gpointer *op)
|
||||||
|
{
|
||||||
|
/* FIXME: */
|
||||||
|
*op = NULL;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_source_output_change_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted)
|
||||||
|
{
|
||||||
|
/* FIXME: */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
gvc_mixer_source_output_constructor (GType type,
|
||||||
|
guint n_construct_properties,
|
||||||
|
GObjectConstructParam *construct_params)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
GvcMixerSourceOutput *self;
|
||||||
|
|
||||||
|
object = G_OBJECT_CLASS (gvc_mixer_source_output_parent_class)->constructor (type, n_construct_properties, construct_params);
|
||||||
|
|
||||||
|
self = GVC_MIXER_SOURCE_OUTPUT (object);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_source_output_class_init (GvcMixerSourceOutputClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructor = gvc_mixer_source_output_constructor;
|
||||||
|
object_class->finalize = gvc_mixer_source_output_finalize;
|
||||||
|
|
||||||
|
stream_class->push_volume = gvc_mixer_source_output_push_volume;
|
||||||
|
stream_class->change_is_muted = gvc_mixer_source_output_change_is_muted;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GvcMixerSourceOutputPrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_source_output_init (GvcMixerSourceOutput *source_output)
|
||||||
|
{
|
||||||
|
source_output->priv = GVC_MIXER_SOURCE_OUTPUT_GET_PRIVATE (source_output);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_source_output_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerSourceOutput *mixer_source_output;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_SOURCE_OUTPUT (object));
|
||||||
|
|
||||||
|
mixer_source_output = GVC_MIXER_SOURCE_OUTPUT (object);
|
||||||
|
|
||||||
|
g_return_if_fail (mixer_source_output->priv != NULL);
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_source_output_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_source_output_new: (skip)
|
||||||
|
*
|
||||||
|
* @context:
|
||||||
|
* @index:
|
||||||
|
* @channel_map:
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
GvcMixerStream *
|
||||||
|
gvc_mixer_source_output_new (pa_context *context,
|
||||||
|
guint index,
|
||||||
|
GvcChannelMap *channel_map)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (GVC_TYPE_MIXER_SOURCE_OUTPUT,
|
||||||
|
"pa-context", context,
|
||||||
|
"index", index,
|
||||||
|
"channel-map", channel_map,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return GVC_MIXER_STREAM (object);
|
||||||
|
}
|
57
src/gvc/gvc-mixer-source-output.h
Normal file
57
src/gvc/gvc-mixer-source-output.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_SOURCE_OUTPUT_H
|
||||||
|
#define __GVC_MIXER_SOURCE_OUTPUT_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include "gvc-mixer-stream.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GVC_TYPE_MIXER_SOURCE_OUTPUT (gvc_mixer_source_output_get_type ())
|
||||||
|
#define GVC_MIXER_SOURCE_OUTPUT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutput))
|
||||||
|
#define GVC_MIXER_SOURCE_OUTPUT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutputClass))
|
||||||
|
#define GVC_IS_MIXER_SOURCE_OUTPUT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT))
|
||||||
|
#define GVC_IS_MIXER_SOURCE_OUTPUT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_SOURCE_OUTPUT))
|
||||||
|
#define GVC_MIXER_SOURCE_OUTPUT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutputClass))
|
||||||
|
|
||||||
|
typedef struct GvcMixerSourceOutputPrivate GvcMixerSourceOutputPrivate;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStream parent;
|
||||||
|
GvcMixerSourceOutputPrivate *priv;
|
||||||
|
} GvcMixerSourceOutput;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStreamClass parent_class;
|
||||||
|
} GvcMixerSourceOutputClass;
|
||||||
|
|
||||||
|
GType gvc_mixer_source_output_get_type (void);
|
||||||
|
|
||||||
|
GvcMixerStream * gvc_mixer_source_output_new (pa_context *context,
|
||||||
|
guint index,
|
||||||
|
GvcChannelMap *map);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_SOURCE_OUTPUT_H */
|
231
src/gvc/gvc-mixer-source.c
Normal file
231
src/gvc/gvc-mixer-source.c
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 William Jon McCann
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
|
#include "gvc-mixer-source.h"
|
||||||
|
#include "gvc-mixer-stream-private.h"
|
||||||
|
#include "gvc-channel-map-private.h"
|
||||||
|
|
||||||
|
#define GVC_MIXER_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SOURCE, GvcMixerSourcePrivate))
|
||||||
|
|
||||||
|
struct GvcMixerSourcePrivate
|
||||||
|
{
|
||||||
|
gpointer dummy;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gvc_mixer_source_class_init (GvcMixerSourceClass *klass);
|
||||||
|
static void gvc_mixer_source_init (GvcMixerSource *mixer_source);
|
||||||
|
static void gvc_mixer_source_finalize (GObject *object);
|
||||||
|
static void gvc_mixer_source_dispose (GObject *object);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GvcMixerSource, gvc_mixer_source, GVC_TYPE_MIXER_STREAM)
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_source_push_volume (GvcMixerStream *stream, gpointer *op)
|
||||||
|
{
|
||||||
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
const GvcChannelMap *map;
|
||||||
|
pa_context *context;
|
||||||
|
const pa_cvolume *cv;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
|
||||||
|
map = gvc_mixer_stream_get_channel_map (stream);
|
||||||
|
|
||||||
|
/* set the volume */
|
||||||
|
cv = gvc_channel_map_get_cvolume (map);
|
||||||
|
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_source_volume_by_index (context,
|
||||||
|
index,
|
||||||
|
cv,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_source_volume_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*op = o;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_source_change_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted)
|
||||||
|
{
|
||||||
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
pa_context *context;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_source_mute_by_index (context,
|
||||||
|
index,
|
||||||
|
is_muted,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_source_mute_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_operation_unref(o);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_source_change_port (GvcMixerStream *stream,
|
||||||
|
const char *port)
|
||||||
|
{
|
||||||
|
#if PA_MICRO > 15
|
||||||
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
pa_context *context;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_source_port_by_index (context,
|
||||||
|
index,
|
||||||
|
port,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_source_port_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_operation_unref(o);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
#else
|
||||||
|
return FALSE;
|
||||||
|
#endif /* PA_MICRO > 15 */
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
gvc_mixer_source_constructor (GType type,
|
||||||
|
guint n_construct_properties,
|
||||||
|
GObjectConstructParam *construct_params)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
GvcMixerSource *self;
|
||||||
|
|
||||||
|
object = G_OBJECT_CLASS (gvc_mixer_source_parent_class)->constructor (type, n_construct_properties, construct_params);
|
||||||
|
|
||||||
|
self = GVC_MIXER_SOURCE (object);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_source_class_init (GvcMixerSourceClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructor = gvc_mixer_source_constructor;
|
||||||
|
object_class->dispose = gvc_mixer_source_dispose;
|
||||||
|
object_class->finalize = gvc_mixer_source_finalize;
|
||||||
|
|
||||||
|
stream_class->push_volume = gvc_mixer_source_push_volume;
|
||||||
|
stream_class->change_is_muted = gvc_mixer_source_change_is_muted;
|
||||||
|
stream_class->change_port = gvc_mixer_source_change_port;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GvcMixerSourcePrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_source_init (GvcMixerSource *source)
|
||||||
|
{
|
||||||
|
source->priv = GVC_MIXER_SOURCE_GET_PRIVATE (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_source_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerSource *mixer_source;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_SOURCE (object));
|
||||||
|
|
||||||
|
mixer_source = GVC_MIXER_SOURCE (object);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_source_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_source_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerSource *mixer_source;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_SOURCE (object));
|
||||||
|
|
||||||
|
mixer_source = GVC_MIXER_SOURCE (object);
|
||||||
|
|
||||||
|
g_return_if_fail (mixer_source->priv != NULL);
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_source_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_source_new: (skip)
|
||||||
|
*
|
||||||
|
* @context:
|
||||||
|
* @index:
|
||||||
|
* @channel_map:
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
GvcMixerStream *
|
||||||
|
gvc_mixer_source_new (pa_context *context,
|
||||||
|
guint index,
|
||||||
|
GvcChannelMap *channel_map)
|
||||||
|
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (GVC_TYPE_MIXER_SOURCE,
|
||||||
|
"pa-context", context,
|
||||||
|
"index", index,
|
||||||
|
"channel-map", channel_map,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return GVC_MIXER_STREAM (object);
|
||||||
|
}
|
57
src/gvc/gvc-mixer-source.h
Normal file
57
src/gvc/gvc-mixer-source.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_SOURCE_H
|
||||||
|
#define __GVC_MIXER_SOURCE_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include "gvc-mixer-stream.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GVC_TYPE_MIXER_SOURCE (gvc_mixer_source_get_type ())
|
||||||
|
#define GVC_MIXER_SOURCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_SOURCE, GvcMixerSource))
|
||||||
|
#define GVC_MIXER_SOURCE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_SOURCE, GvcMixerSourceClass))
|
||||||
|
#define GVC_IS_MIXER_SOURCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_SOURCE))
|
||||||
|
#define GVC_IS_MIXER_SOURCE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_SOURCE))
|
||||||
|
#define GVC_MIXER_SOURCE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_SOURCE, GvcMixerSourceClass))
|
||||||
|
|
||||||
|
typedef struct GvcMixerSourcePrivate GvcMixerSourcePrivate;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStream parent;
|
||||||
|
GvcMixerSourcePrivate *priv;
|
||||||
|
} GvcMixerSource;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GvcMixerStreamClass parent_class;
|
||||||
|
} GvcMixerSourceClass;
|
||||||
|
|
||||||
|
GType gvc_mixer_source_get_type (void);
|
||||||
|
|
||||||
|
GvcMixerStream * gvc_mixer_source_new (pa_context *context,
|
||||||
|
guint index,
|
||||||
|
GvcChannelMap *map);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_SOURCE_H */
|
34
src/gvc/gvc-mixer-stream-private.h
Normal file
34
src/gvc/gvc-mixer-stream-private.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_STREAM_PRIVATE_H
|
||||||
|
#define __GVC_MIXER_STREAM_PRIVATE_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "gvc-channel-map.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
pa_context * gvc_mixer_stream_get_pa_context (GvcMixerStream *stream);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_STREAM_PRIVATE_H */
|
944
src/gvc/gvc-mixer-stream.c
Normal file
944
src/gvc/gvc-mixer-stream.c
Normal file
@ -0,0 +1,944 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 William Jon McCann
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
|
#include "gvc-mixer-stream.h"
|
||||||
|
#include "gvc-mixer-stream-private.h"
|
||||||
|
#include "gvc-channel-map-private.h"
|
||||||
|
|
||||||
|
#define GVC_MIXER_STREAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_STREAM, GvcMixerStreamPrivate))
|
||||||
|
|
||||||
|
static guint32 stream_serial = 1;
|
||||||
|
|
||||||
|
struct GvcMixerStreamPrivate
|
||||||
|
{
|
||||||
|
pa_context *pa_context;
|
||||||
|
guint id;
|
||||||
|
guint index;
|
||||||
|
gint card_index;
|
||||||
|
GvcChannelMap *channel_map;
|
||||||
|
char *name;
|
||||||
|
char *description;
|
||||||
|
char *application_id;
|
||||||
|
char *icon_name;
|
||||||
|
gboolean is_muted;
|
||||||
|
gboolean can_decibel;
|
||||||
|
gboolean is_event_stream;
|
||||||
|
gboolean is_virtual;
|
||||||
|
pa_volume_t base_volume;
|
||||||
|
pa_operation *change_volume_op;
|
||||||
|
char *port;
|
||||||
|
char *human_port;
|
||||||
|
GList *ports;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_ID,
|
||||||
|
PROP_PA_CONTEXT,
|
||||||
|
PROP_CHANNEL_MAP,
|
||||||
|
PROP_INDEX,
|
||||||
|
PROP_NAME,
|
||||||
|
PROP_DESCRIPTION,
|
||||||
|
PROP_APPLICATION_ID,
|
||||||
|
PROP_ICON_NAME,
|
||||||
|
PROP_VOLUME,
|
||||||
|
PROP_DECIBEL,
|
||||||
|
PROP_IS_MUTED,
|
||||||
|
PROP_CAN_DECIBEL,
|
||||||
|
PROP_IS_EVENT_STREAM,
|
||||||
|
PROP_IS_VIRTUAL,
|
||||||
|
PROP_CARD_INDEX,
|
||||||
|
PROP_PORT,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gvc_mixer_stream_class_init (GvcMixerStreamClass *klass);
|
||||||
|
static void gvc_mixer_stream_init (GvcMixerStream *mixer_stream);
|
||||||
|
static void gvc_mixer_stream_finalize (GObject *object);
|
||||||
|
|
||||||
|
G_DEFINE_ABSTRACT_TYPE (GvcMixerStream, gvc_mixer_stream, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
static guint32
|
||||||
|
get_next_stream_serial (void)
|
||||||
|
{
|
||||||
|
guint32 serial;
|
||||||
|
|
||||||
|
serial = stream_serial++;
|
||||||
|
|
||||||
|
if ((gint32)stream_serial < 0) {
|
||||||
|
stream_serial = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return serial;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_context *
|
||||||
|
gvc_mixer_stream_get_pa_context (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), 0);
|
||||||
|
return stream->priv->pa_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
gvc_mixer_stream_get_index (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), 0);
|
||||||
|
return stream->priv->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
gvc_mixer_stream_get_id (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), 0);
|
||||||
|
return stream->priv->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GvcChannelMap *
|
||||||
|
gvc_mixer_stream_get_channel_map (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), NULL);
|
||||||
|
return stream->priv->channel_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_stream_get_volume:
|
||||||
|
*
|
||||||
|
* @stream:
|
||||||
|
*
|
||||||
|
* Returns: (type guint32) (transfer none):
|
||||||
|
*/
|
||||||
|
pa_volume_t
|
||||||
|
gvc_mixer_stream_get_volume (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), 0);
|
||||||
|
|
||||||
|
return (pa_volume_t) gvc_channel_map_get_volume(stream->priv->channel_map)[VOLUME];
|
||||||
|
}
|
||||||
|
|
||||||
|
gdouble
|
||||||
|
gvc_mixer_stream_get_decibel (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), 0);
|
||||||
|
|
||||||
|
return pa_sw_volume_to_dB(
|
||||||
|
(pa_volume_t) gvc_channel_map_get_volume(stream->priv->channel_map)[VOLUME]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_stream_set_volume:
|
||||||
|
*
|
||||||
|
* @stream:
|
||||||
|
* @volume: (type guint32):
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_volume (GvcMixerStream *stream,
|
||||||
|
pa_volume_t volume)
|
||||||
|
{
|
||||||
|
pa_cvolume cv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
cv = *gvc_channel_map_get_cvolume(stream->priv->channel_map);
|
||||||
|
pa_cvolume_scale(&cv, volume);
|
||||||
|
|
||||||
|
if (!pa_cvolume_equal(gvc_channel_map_get_cvolume(stream->priv->channel_map), &cv)) {
|
||||||
|
gvc_channel_map_volume_changed(stream->priv->channel_map, &cv, FALSE);
|
||||||
|
g_object_notify (G_OBJECT (stream), "volume");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_decibel (GvcMixerStream *stream,
|
||||||
|
gdouble db)
|
||||||
|
{
|
||||||
|
pa_cvolume cv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
cv = *gvc_channel_map_get_cvolume(stream->priv->channel_map);
|
||||||
|
pa_cvolume_scale(&cv, pa_sw_volume_from_dB(db));
|
||||||
|
|
||||||
|
if (!pa_cvolume_equal(gvc_channel_map_get_cvolume(stream->priv->channel_map), &cv)) {
|
||||||
|
gvc_channel_map_volume_changed(stream->priv->channel_map, &cv, FALSE);
|
||||||
|
g_object_notify (G_OBJECT (stream), "volume");
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_get_is_muted (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
return stream->priv->is_muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_get_can_decibel (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
return stream->priv->can_decibel;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
if (is_muted != stream->priv->is_muted) {
|
||||||
|
stream->priv->is_muted = is_muted;
|
||||||
|
g_object_notify (G_OBJECT (stream), "is-muted");
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_can_decibel (GvcMixerStream *stream,
|
||||||
|
gboolean can_decibel)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
if (can_decibel != stream->priv->can_decibel) {
|
||||||
|
stream->priv->can_decibel = can_decibel;
|
||||||
|
g_object_notify (G_OBJECT (stream), "can-decibel");
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gvc_mixer_stream_get_name (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), NULL);
|
||||||
|
return stream->priv->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gvc_mixer_stream_get_description (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), NULL);
|
||||||
|
return stream->priv->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_name (GvcMixerStream *stream,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
g_free (stream->priv->name);
|
||||||
|
stream->priv->name = g_strdup (name);
|
||||||
|
g_object_notify (G_OBJECT (stream), "name");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_description (GvcMixerStream *stream,
|
||||||
|
const char *description)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
g_free (stream->priv->description);
|
||||||
|
stream->priv->description = g_strdup (description);
|
||||||
|
g_object_notify (G_OBJECT (stream), "description");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_is_event_stream (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
return stream->priv->is_event_stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_is_event_stream (GvcMixerStream *stream,
|
||||||
|
gboolean is_event_stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
stream->priv->is_event_stream = is_event_stream;
|
||||||
|
g_object_notify (G_OBJECT (stream), "is-event-stream");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_is_virtual (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
return stream->priv->is_virtual;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_is_virtual (GvcMixerStream *stream,
|
||||||
|
gboolean is_virtual)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
stream->priv->is_virtual = is_virtual;
|
||||||
|
g_object_notify (G_OBJECT (stream), "is-virtual");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gvc_mixer_stream_get_application_id (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), NULL);
|
||||||
|
return stream->priv->application_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_application_id (GvcMixerStream *stream,
|
||||||
|
const char *application_id)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
g_free (stream->priv->application_id);
|
||||||
|
stream->priv->application_id = g_strdup (application_id);
|
||||||
|
g_object_notify (G_OBJECT (stream), "application-id");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_channel_map_volume_changed (GvcChannelMap *channel_map,
|
||||||
|
gboolean set,
|
||||||
|
GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
if (set == TRUE)
|
||||||
|
gvc_mixer_stream_push_volume (stream);
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (stream), "volume");
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_stream_set_channel_map (GvcMixerStream *stream,
|
||||||
|
GvcChannelMap *channel_map)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
if (channel_map != NULL) {
|
||||||
|
g_object_ref (channel_map);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stream->priv->channel_map != NULL) {
|
||||||
|
g_signal_handlers_disconnect_by_func (stream->priv->channel_map,
|
||||||
|
on_channel_map_volume_changed,
|
||||||
|
stream);
|
||||||
|
g_object_unref (stream->priv->channel_map);
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->priv->channel_map = channel_map;
|
||||||
|
|
||||||
|
if (stream->priv->channel_map != NULL) {
|
||||||
|
g_signal_connect (stream->priv->channel_map,
|
||||||
|
"volume-changed",
|
||||||
|
G_CALLBACK (on_channel_map_volume_changed),
|
||||||
|
stream);
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (stream), "channel-map");
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gvc_mixer_stream_get_icon_name (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), NULL);
|
||||||
|
return stream->priv->icon_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_icon_name (GvcMixerStream *stream,
|
||||||
|
const char *icon_name)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
g_free (stream->priv->icon_name);
|
||||||
|
stream->priv->icon_name = g_strdup (icon_name);
|
||||||
|
g_object_notify (G_OBJECT (stream), "icon-name");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_stream_get_base_volume:
|
||||||
|
*
|
||||||
|
* @stream:
|
||||||
|
*
|
||||||
|
* Returns: (type guint32) (transfer none):
|
||||||
|
*/
|
||||||
|
pa_volume_t
|
||||||
|
gvc_mixer_stream_get_base_volume (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), 0);
|
||||||
|
|
||||||
|
return stream->priv->base_volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gvc_mixer_stream_set_base_volume:
|
||||||
|
*
|
||||||
|
* @stream:
|
||||||
|
* @base_volume: (type guint32):
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_base_volume (GvcMixerStream *stream,
|
||||||
|
pa_volume_t base_volume)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
stream->priv->base_volume = base_volume;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GvcMixerStreamPort *
|
||||||
|
gvc_mixer_stream_get_port (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), NULL);
|
||||||
|
g_return_val_if_fail (stream->priv->ports != NULL, NULL);
|
||||||
|
|
||||||
|
for (l = stream->priv->ports; l != NULL; l = l->next) {
|
||||||
|
GvcMixerStreamPort *p = l->data;
|
||||||
|
if (g_strcmp0 (stream->priv->port, p->port) == 0) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert_not_reached ();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_port (GvcMixerStream *stream,
|
||||||
|
const char *port)
|
||||||
|
{
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
g_return_val_if_fail (stream->priv->ports != NULL, FALSE);
|
||||||
|
|
||||||
|
g_free (stream->priv->port);
|
||||||
|
stream->priv->port = g_strdup (port);
|
||||||
|
|
||||||
|
g_free (stream->priv->human_port);
|
||||||
|
stream->priv->human_port = NULL;
|
||||||
|
|
||||||
|
for (l = stream->priv->ports; l != NULL; l = l->next) {
|
||||||
|
GvcMixerStreamPort *p = l->data;
|
||||||
|
if (g_str_equal (stream->priv->port, p->port)) {
|
||||||
|
stream->priv->human_port = g_strdup (p->human_port);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (stream), "port");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_change_port (GvcMixerStream *stream,
|
||||||
|
const char *port)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
return GVC_MIXER_STREAM_GET_CLASS (stream)->change_port (stream, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
const GList *
|
||||||
|
gvc_mixer_stream_get_ports (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
return stream->priv->ports;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
sort_ports (GvcMixerStreamPort *a,
|
||||||
|
GvcMixerStreamPort *b)
|
||||||
|
{
|
||||||
|
if (a->priority == b->priority)
|
||||||
|
return 0;
|
||||||
|
if (a->priority > b->priority)
|
||||||
|
return 1;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_ports (GvcMixerStream *stream,
|
||||||
|
GList *ports)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
g_return_val_if_fail (stream->priv->ports == NULL, FALSE);
|
||||||
|
|
||||||
|
stream->priv->ports = g_list_sort (ports, (GCompareFunc) sort_ports);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gvc_mixer_stream_get_card_index (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), PA_INVALID_INDEX);
|
||||||
|
return stream->priv->card_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_set_card_index (GvcMixerStream *stream,
|
||||||
|
gint card_index)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
stream->priv->card_index = card_index;
|
||||||
|
g_object_notify (G_OBJECT (stream), "card-index");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_stream_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GvcMixerStream *self = GVC_MIXER_STREAM (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PA_CONTEXT:
|
||||||
|
self->priv->pa_context = g_value_get_pointer (value);
|
||||||
|
break;
|
||||||
|
case PROP_INDEX:
|
||||||
|
self->priv->index = g_value_get_ulong (value);
|
||||||
|
break;
|
||||||
|
case PROP_ID:
|
||||||
|
self->priv->id = g_value_get_ulong (value);
|
||||||
|
break;
|
||||||
|
case PROP_CHANNEL_MAP:
|
||||||
|
gvc_mixer_stream_set_channel_map (self, g_value_get_object (value));
|
||||||
|
break;
|
||||||
|
case PROP_NAME:
|
||||||
|
gvc_mixer_stream_set_name (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
case PROP_DESCRIPTION:
|
||||||
|
gvc_mixer_stream_set_description (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
case PROP_APPLICATION_ID:
|
||||||
|
gvc_mixer_stream_set_application_id (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
case PROP_ICON_NAME:
|
||||||
|
gvc_mixer_stream_set_icon_name (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
case PROP_VOLUME:
|
||||||
|
gvc_mixer_stream_set_volume (self, g_value_get_ulong (value));
|
||||||
|
break;
|
||||||
|
case PROP_DECIBEL:
|
||||||
|
gvc_mixer_stream_set_decibel (self, g_value_get_double (value));
|
||||||
|
break;
|
||||||
|
case PROP_IS_MUTED:
|
||||||
|
gvc_mixer_stream_set_is_muted (self, g_value_get_boolean (value));
|
||||||
|
break;
|
||||||
|
case PROP_IS_EVENT_STREAM:
|
||||||
|
gvc_mixer_stream_set_is_event_stream (self, g_value_get_boolean (value));
|
||||||
|
break;
|
||||||
|
case PROP_IS_VIRTUAL:
|
||||||
|
gvc_mixer_stream_set_is_virtual (self, g_value_get_boolean (value));
|
||||||
|
break;
|
||||||
|
case PROP_CAN_DECIBEL:
|
||||||
|
gvc_mixer_stream_set_can_decibel (self, g_value_get_boolean (value));
|
||||||
|
break;
|
||||||
|
case PROP_PORT:
|
||||||
|
gvc_mixer_stream_set_port (self, g_value_get_string (value));
|
||||||
|
break;
|
||||||
|
case PROP_CARD_INDEX:
|
||||||
|
self->priv->card_index = g_value_get_long (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_stream_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GvcMixerStream *self = GVC_MIXER_STREAM (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PA_CONTEXT:
|
||||||
|
g_value_set_pointer (value, self->priv->pa_context);
|
||||||
|
break;
|
||||||
|
case PROP_INDEX:
|
||||||
|
g_value_set_ulong (value, self->priv->index);
|
||||||
|
break;
|
||||||
|
case PROP_ID:
|
||||||
|
g_value_set_ulong (value, self->priv->id);
|
||||||
|
break;
|
||||||
|
case PROP_CHANNEL_MAP:
|
||||||
|
g_value_set_object (value, self->priv->channel_map);
|
||||||
|
break;
|
||||||
|
case PROP_NAME:
|
||||||
|
g_value_set_string (value, self->priv->name);
|
||||||
|
break;
|
||||||
|
case PROP_DESCRIPTION:
|
||||||
|
g_value_set_string (value, self->priv->description);
|
||||||
|
break;
|
||||||
|
case PROP_APPLICATION_ID:
|
||||||
|
g_value_set_string (value, self->priv->application_id);
|
||||||
|
break;
|
||||||
|
case PROP_ICON_NAME:
|
||||||
|
g_value_set_string (value, self->priv->icon_name);
|
||||||
|
break;
|
||||||
|
case PROP_VOLUME:
|
||||||
|
g_value_set_ulong (value,
|
||||||
|
pa_cvolume_max(gvc_channel_map_get_cvolume(self->priv->channel_map)));
|
||||||
|
break;
|
||||||
|
case PROP_DECIBEL:
|
||||||
|
g_value_set_double (value,
|
||||||
|
pa_sw_volume_to_dB(pa_cvolume_max(gvc_channel_map_get_cvolume(self->priv->channel_map))));
|
||||||
|
break;
|
||||||
|
case PROP_IS_MUTED:
|
||||||
|
g_value_set_boolean (value, self->priv->is_muted);
|
||||||
|
break;
|
||||||
|
case PROP_IS_EVENT_STREAM:
|
||||||
|
g_value_set_boolean (value, self->priv->is_event_stream);
|
||||||
|
break;
|
||||||
|
case PROP_IS_VIRTUAL:
|
||||||
|
g_value_set_boolean (value, self->priv->is_virtual);
|
||||||
|
break;
|
||||||
|
case PROP_CAN_DECIBEL:
|
||||||
|
g_value_set_boolean (value, self->priv->can_decibel);
|
||||||
|
break;
|
||||||
|
case PROP_PORT:
|
||||||
|
g_value_set_string (value, self->priv->port);
|
||||||
|
break;
|
||||||
|
case PROP_CARD_INDEX:
|
||||||
|
g_value_set_long (value, self->priv->card_index);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
gvc_mixer_stream_constructor (GType type,
|
||||||
|
guint n_construct_properties,
|
||||||
|
GObjectConstructParam *construct_params)
|
||||||
|
{
|
||||||
|
GObject *object;
|
||||||
|
GvcMixerStream *self;
|
||||||
|
|
||||||
|
object = G_OBJECT_CLASS (gvc_mixer_stream_parent_class)->constructor (type, n_construct_properties, construct_params);
|
||||||
|
|
||||||
|
self = GVC_MIXER_STREAM (object);
|
||||||
|
|
||||||
|
self->priv->id = get_next_stream_serial ();
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_stream_real_change_port (GvcMixerStream *stream,
|
||||||
|
const char *port)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_stream_real_push_volume (GvcMixerStream *stream, gpointer *op)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gvc_mixer_stream_real_change_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_push_volume (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
pa_operation *op;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
if (stream->priv->is_event_stream != FALSE)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
g_debug ("Pushing new volume to stream '%s' (%s)",
|
||||||
|
stream->priv->description, stream->priv->name);
|
||||||
|
|
||||||
|
ret = GVC_MIXER_STREAM_GET_CLASS (stream)->push_volume (stream, (gpointer *) &op);
|
||||||
|
if (ret) {
|
||||||
|
if (stream->priv->change_volume_op != NULL)
|
||||||
|
pa_operation_unref (stream->priv->change_volume_op);
|
||||||
|
stream->priv->change_volume_op = op;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_change_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted)
|
||||||
|
{
|
||||||
|
gboolean ret;
|
||||||
|
g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
|
||||||
|
ret = GVC_MIXER_STREAM_GET_CLASS (stream)->change_is_muted (stream, is_muted);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gvc_mixer_stream_is_running (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
if (stream->priv->change_volume_op == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if ((pa_operation_get_state(stream->priv->change_volume_op) == PA_OPERATION_RUNNING))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
pa_operation_unref(stream->priv->change_volume_op);
|
||||||
|
stream->priv->change_volume_op = NULL;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_stream_class_init (GvcMixerStreamClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->constructor = gvc_mixer_stream_constructor;
|
||||||
|
gobject_class->finalize = gvc_mixer_stream_finalize;
|
||||||
|
gobject_class->set_property = gvc_mixer_stream_set_property;
|
||||||
|
gobject_class->get_property = gvc_mixer_stream_get_property;
|
||||||
|
|
||||||
|
klass->push_volume = gvc_mixer_stream_real_push_volume;
|
||||||
|
klass->change_port = gvc_mixer_stream_real_change_port;
|
||||||
|
klass->change_is_muted = gvc_mixer_stream_real_change_is_muted;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_INDEX,
|
||||||
|
g_param_spec_ulong ("index",
|
||||||
|
"Index",
|
||||||
|
"The index for this stream",
|
||||||
|
0, G_MAXULONG, 0,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_ID,
|
||||||
|
g_param_spec_ulong ("id",
|
||||||
|
"id",
|
||||||
|
"The id for this stream",
|
||||||
|
0, G_MAXULONG, 0,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_CHANNEL_MAP,
|
||||||
|
g_param_spec_object ("channel-map",
|
||||||
|
"channel map",
|
||||||
|
"The channel map for this stream",
|
||||||
|
GVC_TYPE_CHANNEL_MAP,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_PA_CONTEXT,
|
||||||
|
g_param_spec_pointer ("pa-context",
|
||||||
|
"PulseAudio context",
|
||||||
|
"The PulseAudio context for this stream",
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_VOLUME,
|
||||||
|
g_param_spec_ulong ("volume",
|
||||||
|
"Volume",
|
||||||
|
"The volume for this stream",
|
||||||
|
0, G_MAXULONG, 0,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_DECIBEL,
|
||||||
|
g_param_spec_double ("decibel",
|
||||||
|
"Decibel",
|
||||||
|
"The decibel level for this stream",
|
||||||
|
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_NAME,
|
||||||
|
g_param_spec_string ("name",
|
||||||
|
"Name",
|
||||||
|
"Name to display for this stream",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_DESCRIPTION,
|
||||||
|
g_param_spec_string ("description",
|
||||||
|
"Description",
|
||||||
|
"Description to display for this stream",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_APPLICATION_ID,
|
||||||
|
g_param_spec_string ("application-id",
|
||||||
|
"Application identifier",
|
||||||
|
"Application identifier for this stream",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_ICON_NAME,
|
||||||
|
g_param_spec_string ("icon-name",
|
||||||
|
"Icon Name",
|
||||||
|
"Name of icon to display for this stream",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_IS_MUTED,
|
||||||
|
g_param_spec_boolean ("is-muted",
|
||||||
|
"is muted",
|
||||||
|
"Whether stream is muted",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_CAN_DECIBEL,
|
||||||
|
g_param_spec_boolean ("can-decibel",
|
||||||
|
"can decibel",
|
||||||
|
"Whether stream volume can be converted to decibel units",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_IS_EVENT_STREAM,
|
||||||
|
g_param_spec_boolean ("is-event-stream",
|
||||||
|
"is event stream",
|
||||||
|
"Whether stream's role is to play an event",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_IS_VIRTUAL,
|
||||||
|
g_param_spec_boolean ("is-virtual",
|
||||||
|
"is virtual stream",
|
||||||
|
"Whether the stream is virtual",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_PORT,
|
||||||
|
g_param_spec_string ("port",
|
||||||
|
"Port",
|
||||||
|
"The name of the current port for this stream",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_CARD_INDEX,
|
||||||
|
g_param_spec_long ("card-index",
|
||||||
|
"Card index",
|
||||||
|
"The index of the card for this stream",
|
||||||
|
PA_INVALID_INDEX, G_MAXLONG, PA_INVALID_INDEX,
|
||||||
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
|
||||||
|
g_type_class_add_private (klass, sizeof (GvcMixerStreamPrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_stream_init (GvcMixerStream *stream)
|
||||||
|
{
|
||||||
|
stream->priv = GVC_MIXER_STREAM_GET_PRIVATE (stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_port (GvcMixerStreamPort *p)
|
||||||
|
{
|
||||||
|
g_free (p->port);
|
||||||
|
g_free (p->human_port);
|
||||||
|
g_free (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gvc_mixer_stream_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GvcMixerStream *mixer_stream;
|
||||||
|
|
||||||
|
g_return_if_fail (object != NULL);
|
||||||
|
g_return_if_fail (GVC_IS_MIXER_STREAM (object));
|
||||||
|
|
||||||
|
mixer_stream = GVC_MIXER_STREAM (object);
|
||||||
|
|
||||||
|
g_return_if_fail (mixer_stream->priv != NULL);
|
||||||
|
|
||||||
|
g_object_unref (mixer_stream->priv->channel_map);
|
||||||
|
mixer_stream->priv->channel_map = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_stream->priv->name);
|
||||||
|
mixer_stream->priv->name = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_stream->priv->description);
|
||||||
|
mixer_stream->priv->description = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_stream->priv->application_id);
|
||||||
|
mixer_stream->priv->application_id = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_stream->priv->icon_name);
|
||||||
|
mixer_stream->priv->icon_name = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_stream->priv->port);
|
||||||
|
mixer_stream->priv->port = NULL;
|
||||||
|
|
||||||
|
g_free (mixer_stream->priv->human_port);
|
||||||
|
mixer_stream->priv->human_port = NULL;
|
||||||
|
|
||||||
|
g_list_foreach (mixer_stream->priv->ports, (GFunc) free_port, NULL);
|
||||||
|
g_list_free (mixer_stream->priv->ports);
|
||||||
|
mixer_stream->priv->ports = NULL;
|
||||||
|
|
||||||
|
if (mixer_stream->priv->change_volume_op) {
|
||||||
|
pa_operation_unref(mixer_stream->priv->change_volume_op);
|
||||||
|
mixer_stream->priv->change_volume_op = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gvc_mixer_stream_parent_class)->finalize (object);
|
||||||
|
}
|
125
src/gvc/gvc-mixer-stream.h
Normal file
125
src/gvc/gvc-mixer-stream.h
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_MIXER_STREAM_H
|
||||||
|
#define __GVC_MIXER_STREAM_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include "gvc-pulseaudio-fake.h"
|
||||||
|
#include "gvc-channel-map.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GVC_TYPE_MIXER_STREAM (gvc_mixer_stream_get_type ())
|
||||||
|
#define GVC_MIXER_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_STREAM, GvcMixerStream))
|
||||||
|
#define GVC_MIXER_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_STREAM, GvcMixerStreamClass))
|
||||||
|
#define GVC_IS_MIXER_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_STREAM))
|
||||||
|
#define GVC_IS_MIXER_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_STREAM))
|
||||||
|
#define GVC_MIXER_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_STREAM, GvcMixerStreamClass))
|
||||||
|
|
||||||
|
typedef struct GvcMixerStreamPrivate GvcMixerStreamPrivate;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GObject parent;
|
||||||
|
GvcMixerStreamPrivate *priv;
|
||||||
|
} GvcMixerStream;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
/* vtable */
|
||||||
|
gboolean (*push_volume) (GvcMixerStream *stream,
|
||||||
|
gpointer *operation);
|
||||||
|
gboolean (*change_is_muted) (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted);
|
||||||
|
gboolean (*change_port) (GvcMixerStream *stream,
|
||||||
|
const char *port);
|
||||||
|
} GvcMixerStreamClass;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char *port;
|
||||||
|
char *human_port;
|
||||||
|
guint priority;
|
||||||
|
} GvcMixerStreamPort;
|
||||||
|
|
||||||
|
GType gvc_mixer_stream_get_type (void);
|
||||||
|
|
||||||
|
guint gvc_mixer_stream_get_index (GvcMixerStream *stream);
|
||||||
|
guint gvc_mixer_stream_get_id (GvcMixerStream *stream);
|
||||||
|
const GvcChannelMap *gvc_mixer_stream_get_channel_map(GvcMixerStream *stream);
|
||||||
|
const GvcMixerStreamPort *gvc_mixer_stream_get_port (GvcMixerStream *stream);
|
||||||
|
const GList * gvc_mixer_stream_get_ports (GvcMixerStream *stream);
|
||||||
|
gboolean gvc_mixer_stream_change_port (GvcMixerStream *stream,
|
||||||
|
const char *port);
|
||||||
|
|
||||||
|
pa_volume_t gvc_mixer_stream_get_volume (GvcMixerStream *stream);
|
||||||
|
gdouble gvc_mixer_stream_get_decibel (GvcMixerStream *stream);
|
||||||
|
gboolean gvc_mixer_stream_push_volume (GvcMixerStream *stream);
|
||||||
|
pa_volume_t gvc_mixer_stream_get_base_volume (GvcMixerStream *stream);
|
||||||
|
|
||||||
|
gboolean gvc_mixer_stream_get_is_muted (GvcMixerStream *stream);
|
||||||
|
gboolean gvc_mixer_stream_get_can_decibel (GvcMixerStream *stream);
|
||||||
|
gboolean gvc_mixer_stream_change_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted);
|
||||||
|
gboolean gvc_mixer_stream_is_running (GvcMixerStream *stream);
|
||||||
|
const char * gvc_mixer_stream_get_name (GvcMixerStream *stream);
|
||||||
|
const char * gvc_mixer_stream_get_icon_name (GvcMixerStream *stream);
|
||||||
|
const char * gvc_mixer_stream_get_description (GvcMixerStream *stream);
|
||||||
|
const char * gvc_mixer_stream_get_application_id (GvcMixerStream *stream);
|
||||||
|
gboolean gvc_mixer_stream_is_event_stream (GvcMixerStream *stream);
|
||||||
|
gboolean gvc_mixer_stream_is_virtual (GvcMixerStream *stream);
|
||||||
|
gint gvc_mixer_stream_get_card_index (GvcMixerStream *stream);
|
||||||
|
|
||||||
|
/* private */
|
||||||
|
gboolean gvc_mixer_stream_set_volume (GvcMixerStream *stream,
|
||||||
|
pa_volume_t volume);
|
||||||
|
gboolean gvc_mixer_stream_set_decibel (GvcMixerStream *stream,
|
||||||
|
gdouble db);
|
||||||
|
gboolean gvc_mixer_stream_set_is_muted (GvcMixerStream *stream,
|
||||||
|
gboolean is_muted);
|
||||||
|
gboolean gvc_mixer_stream_set_can_decibel (GvcMixerStream *stream,
|
||||||
|
gboolean can_decibel);
|
||||||
|
gboolean gvc_mixer_stream_set_name (GvcMixerStream *stream,
|
||||||
|
const char *name);
|
||||||
|
gboolean gvc_mixer_stream_set_description (GvcMixerStream *stream,
|
||||||
|
const char *description);
|
||||||
|
gboolean gvc_mixer_stream_set_icon_name (GvcMixerStream *stream,
|
||||||
|
const char *name);
|
||||||
|
gboolean gvc_mixer_stream_set_is_event_stream (GvcMixerStream *stream,
|
||||||
|
gboolean is_event_stream);
|
||||||
|
gboolean gvc_mixer_stream_set_is_virtual (GvcMixerStream *stream,
|
||||||
|
gboolean is_event_stream);
|
||||||
|
gboolean gvc_mixer_stream_set_application_id (GvcMixerStream *stream,
|
||||||
|
const char *application_id);
|
||||||
|
gboolean gvc_mixer_stream_set_base_volume (GvcMixerStream *stream,
|
||||||
|
pa_volume_t base_volume);
|
||||||
|
gboolean gvc_mixer_stream_set_port (GvcMixerStream *stream,
|
||||||
|
const char *port);
|
||||||
|
gboolean gvc_mixer_stream_set_ports (GvcMixerStream *stream,
|
||||||
|
GList *ports);
|
||||||
|
gboolean gvc_mixer_stream_set_card_index (GvcMixerStream *stream,
|
||||||
|
gint card_index);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GVC_MIXER_STREAM_H */
|
34
src/gvc/gvc-pulseaudio-fake.h
Normal file
34
src/gvc/gvc-pulseaudio-fake.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GVC_PULSEAUDIO_FAKE_H
|
||||||
|
#define __GVC_PULSEAUDIO_FAKE_H
|
||||||
|
|
||||||
|
#ifdef WITH_INTROSPECTION
|
||||||
|
|
||||||
|
#ifndef PA_API_VERSION
|
||||||
|
typedef int pa_channel_position_t;
|
||||||
|
typedef guint32 pa_volume_t;
|
||||||
|
typedef gpointer pa_context;
|
||||||
|
#endif /* PA_API_VERSION */
|
||||||
|
|
||||||
|
#endif /* WITH_INTROSPECTION */
|
||||||
|
|
||||||
|
#endif /* __GVC_PULSEAUDIO_FAKE_H */
|
Loading…
Reference in New Issue
Block a user