libcanberra-02-device.diff revision 19025
19025N/A--- libcanberra-0.25/src/Makefile.am-orig 2010-09-13 23:46:23.884713926 -0500
19025N/A+++ libcanberra-0.25/src/Makefile.am 2010-09-13 23:46:45.949907623 -0500
19025N/A@@ -60,8 +60,10 @@ libcanberra_la_SOURCES = \
19025N/A fork-detect.c fork-detect.h
19025N/A libcanberra_la_CFLAGS = \
19025N/A $(AM_CFLAGS) \
19025N/A+ $(GCONF_CFLAGS) \
19025N/A $(VORBIS_CFLAGS)
19025N/A libcanberra_la_LIBADD = \
19025N/A+ $(GCONF_LIBS) \
19025N/A $(VORBIS_LIBS)
19025N/A libcanberra_la_LDFLAGS = \
19025N/A -export-dynamic \
19025N/A--- libcanberra-0.25/src/common.c-orig 2010-09-13 19:17:02.032029728 -0500
19025N/A+++ libcanberra-0.25/src/common.c 2010-09-14 00:06:00.628638823 -0500
19025N/A@@ -26,6 +26,8 @@
19025N/A
19025N/A #include <stdarg.h>
19025N/A
19025N/A+#include <gconf/gconf-client.h>
19025N/A+
19025N/A #include "canberra.h"
19025N/A #include "common.h"
19025N/A #include "malloc.h"
19025N/A@@ -34,6 +36,8 @@
19025N/A #include "macro.h"
19025N/A #include "fork-detect.h"
19025N/A
19025N/A+#define GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT "/apps/gnome-volume-control/active-element"
19025N/A+
19025N/A /**
19025N/A * SECTION:canberra
19025N/A * @short_description: General libcanberra API
19025N/A@@ -129,6 +133,7 @@ int ca_context_create(ca_context **_c) {
19025N/A ca_context *c;
19025N/A int ret;
19025N/A const char *d;
19025N/A+ const char *device = NULL;
19025N/A
19025N/A ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED);
19025N/A ca_return_val_if_fail(_c, CA_ERROR_INVALID);
19025N/A@@ -153,13 +158,79 @@ int ca_context_create(ca_context **_c) {
19025N/A }
19025N/A }
19025N/A
19025N/A- if ((d = getenv("CANBERRA_DEVICE"))) {
19025N/A- if ((ret = ca_context_change_device(c, d)) < 0) {
19025N/A+ /*
19025N/A+ * If the user sets CANBERRA_DEVICE, use that. Then fallback to the
19025N/A+ * gnome-volume-control setting. If neither is set, then do not set
19025N/A+ * the device and just let OSS use its default.
19025N/A+ */
19025N/A+ if ((device = getenv("CANBERRA_DEVICE"))) {
19025N/A+ if ((ret = ca_context_change_device(c, device)) < 0) {
19025N/A ca_context_destroy(c);
19025N/A return ret;
19025N/A }
19025N/A }
19025N/A
19025N/A+ /*
19025N/A+ * Note that the following code only works with OSSv4. Also note that
19025N/A+ * gnome-volume-control saves the device via GConf in this format:
19025N/A+ *
19025N/A+ * foo#0 (OSS v4 Audio Mixer)
19025N/A+ *
19025N/A+ * Where the actual device is "/dev/sound/"; followed by the first word
19025N/A+ * in the GConf value with the "#" changed to a ":"; and "dsp" appended
19025N/A+ * to the end. So "foo#0" becomes /dev/sound/foo:0dsp. The "dsp" is
19025N/A+ * needed since canberra uses OSS ioctls.
19025N/A+ */
19025N/A+ if (device == NULL) {
19025N/A+ GConfClient *gconf_client;
19025N/A+ char *gvc_active;
19025N/A+
19025N/A+ gconf_client = gconf_client_get_default ();
19025N/A+
19025N/A+ gvc_active = gconf_client_get_string (gconf_client,
19025N/A+ GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT, NULL);
19025N/A+
19025N/A+ /*
19025N/A+ * Only use the gnome-volume-control setting if the value
19025N/A+ * is associated with an OSS device. Check for "OSS" string
19025N/A+ * in the value since it will be "foo#0 (OSS v4 Audio Mixer)"
19025N/A+ * if using OSS.
19025N/A+ */
19025N/A+ if (gvc_active != NULL && strstr (gvc_active, "OSS") != NULL) {
19025N/A+ char ** element_arr;
19025N/A+ element_arr = g_strsplit (gvc_active, " ", 2);
19025N/A+
19025N/A+ if (element_arr != NULL &&
19025N/A+ element_arr[0] != NULL) {
19025N/A+ char **device_arr = g_strsplit (element_arr[0],
19025N/A+ "#", 2);
19025N/A+ if (device_arr != NULL &&
19025N/A+ device_arr[0] != NULL &&
19025N/A+ device_arr[1] != NULL) {
19025N/A+ /*
19025N/A+ * Need to prepend "/dev/sound/" and
19025N/A+ * append "dsp" to the device name
19025N/A+ * returned by gnome-volume-control.
19025N/A+ * The "dsp" is needed since canberra
19025N/A+ * uses OSS ioctls.
19025N/A+ */
19025N/A+ char * device_name = g_strdup_printf
19025N/A+ ("/dev/sound/%s:%sdsp",
19025N/A+ device_arr[0], device_arr[1]);
19025N/A+ if ((ret = ca_context_change_device(c,
19025N/A+ device_name)) < 0) {
19025N/A+ ca_context_destroy(c);
19025N/A+ return ret;
19025N/A+ }
19025N/A+ g_free (device_name);
19025N/A+ }
19025N/A+ g_strfreev (device_arr);
19025N/A+ }
19025N/A+ g_strfreev (element_arr);
19025N/A+ }
19025N/A+ g_free (gvc_active);
19025N/A+ }
19025N/A+
19025N/A *_c = c;
19025N/A return CA_SUCCESS;
19025N/A }
19025N/A--- libcanberra-0.25/configure.ac-orig 2010-09-13 23:43:25.620576446 -0500
19025N/A+++ libcanberra-0.25/configure.ac 2010-09-13 23:46:13.839034621 -0500
19025N/A@@ -490,6 +490,10 @@ AM_CONDITIONAL([USE_LYNX], [test "x$have
19025N/A
19025N/A PKG_CHECK_MODULES(VORBIS, [ vorbisfile ])
19025N/A
19025N/A+### GConf (mandatory) ###
19025N/A+
19025N/A+PKG_CHECK_MODULES(GCONF, [ gconf-2.0 ])
19025N/A+
19025N/A ### Chose builtin driver ###
19025N/A
19025N/A AC_ARG_WITH([builtin],