20055
|
1 |
--- libcanberra-0.25/src/Makefile.am-orig 2010-09-13 23:46:23.884713926 -0500
|
|
2 |
+++ libcanberra-0.25/src/Makefile.am 2010-09-13 23:46:45.949907623 -0500
|
|
3 |
@@ -60,8 +60,10 @@ libcanberra_la_SOURCES = \
|
|
4 |
fork-detect.c fork-detect.h
|
|
5 |
libcanberra_la_CFLAGS = \
|
|
6 |
$(AM_CFLAGS) \
|
|
7 |
+ $(GCONF_CFLAGS) \
|
|
8 |
$(VORBIS_CFLAGS)
|
|
9 |
libcanberra_la_LIBADD = \
|
|
10 |
+ $(GCONF_LIBS) \
|
|
11 |
$(VORBIS_LIBS)
|
|
12 |
libcanberra_la_LDFLAGS = \
|
|
13 |
-export-dynamic \
|
|
14 |
--- libcanberra-0.25/src/common.c-orig 2010-09-13 19:17:02.032029728 -0500
|
|
15 |
+++ libcanberra-0.25/src/common.c 2010-09-14 00:06:00.628638823 -0500
|
|
16 |
@@ -26,6 +26,8 @@
|
|
17 |
|
|
18 |
#include <stdarg.h>
|
|
19 |
|
|
20 |
+#include <gconf/gconf-client.h>
|
|
21 |
+
|
|
22 |
#include "canberra.h"
|
|
23 |
#include "common.h"
|
|
24 |
#include "malloc.h"
|
|
25 |
@@ -34,6 +36,8 @@
|
|
26 |
#include "macro.h"
|
|
27 |
#include "fork-detect.h"
|
|
28 |
|
|
29 |
+#define GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT "/apps/gnome-volume-control/active-element"
|
|
30 |
+
|
|
31 |
/**
|
|
32 |
* SECTION:canberra
|
|
33 |
* @short_description: General libcanberra API
|
|
34 |
@@ -129,6 +133,7 @@ int ca_context_create(ca_context **_c) {
|
|
35 |
ca_context *c;
|
|
36 |
int ret;
|
|
37 |
const char *d;
|
|
38 |
+ const char *device = NULL;
|
|
39 |
|
|
40 |
ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED);
|
|
41 |
ca_return_val_if_fail(_c, CA_ERROR_INVALID);
|
20106
|
42 |
@@ -153,13 +158,79 @@ int ca_context_create(ca_context **_c) {
|
20055
|
43 |
}
|
|
44 |
}
|
|
45 |
|
|
46 |
- if ((d = getenv("CANBERRA_DEVICE"))) {
|
|
47 |
- if ((ret = ca_context_change_device(c, d)) < 0) {
|
|
48 |
+ /*
|
20106
|
49 |
+ * If the user sets CANBERRA_DEVICE, use that. Then fallback to the
|
|
50 |
+ * gnome-volume-control setting. If neither is set, then do not set
|
|
51 |
+ * the device and just let OSS use its default.
|
20055
|
52 |
+ */
|
|
53 |
+ if ((device = getenv("CANBERRA_DEVICE"))) {
|
|
54 |
+ if ((ret = ca_context_change_device(c, device)) < 0) {
|
|
55 |
ca_context_destroy(c);
|
|
56 |
return ret;
|
|
57 |
}
|
|
58 |
}
|
|
59 |
|
|
60 |
+ /*
|
20106
|
61 |
+ * Note that the following code only works with OSSv4. Also note that
|
|
62 |
+ * gnome-volume-control saves the device via GConf in this format:
|
|
63 |
+ *
|
|
64 |
+ * foo#0 (OSS v4 Audio Mixer)
|
20055
|
65 |
+ *
|
20106
|
66 |
+ * Where the actual device is "/dev/sound/"; followed by the first word
|
|
67 |
+ * in the GConf value with the "#" changed to a ":"; and "dsp" appended
|
|
68 |
+ * to the end. So "foo#0" becomes /dev/sound/foo:0dsp. The "dsp" is
|
|
69 |
+ * needed since canberra uses OSS ioctls.
|
20055
|
70 |
+ */
|
|
71 |
+ if (device == NULL) {
|
|
72 |
+ GConfClient *gconf_client;
|
|
73 |
+ char *gvc_active;
|
|
74 |
+
|
|
75 |
+ gconf_client = gconf_client_get_default ();
|
|
76 |
+
|
|
77 |
+ gvc_active = gconf_client_get_string (gconf_client,
|
|
78 |
+ GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT, NULL);
|
|
79 |
+
|
20106
|
80 |
+ /*
|
|
81 |
+ * Only use the gnome-volume-control setting if the value
|
|
82 |
+ * is associated with an OSS device. Check for "OSS" string
|
|
83 |
+ * in the value since it will be "foo#0 (OSS v4 Audio Mixer)"
|
|
84 |
+ * if using OSS.
|
|
85 |
+ */
|
|
86 |
+ if (gvc_active != NULL && strstr (gvc_active, "OSS") != NULL) {
|
20055
|
87 |
+ char ** element_arr;
|
|
88 |
+ element_arr = g_strsplit (gvc_active, " ", 2);
|
|
89 |
+
|
|
90 |
+ if (element_arr != NULL &&
|
|
91 |
+ element_arr[0] != NULL) {
|
20106
|
92 |
+ char **device_arr = g_strsplit (element_arr[0],
|
|
93 |
+ "#", 2);
|
20055
|
94 |
+ if (device_arr != NULL &&
|
|
95 |
+ device_arr[0] != NULL &&
|
|
96 |
+ device_arr[1] != NULL) {
|
20106
|
97 |
+ /*
|
|
98 |
+ * Need to prepend "/dev/sound/" and
|
|
99 |
+ * append "dsp" to the device name
|
|
100 |
+ * returned by gnome-volume-control.
|
|
101 |
+ * The "dsp" is needed since canberra
|
|
102 |
+ * uses OSS ioctls.
|
|
103 |
+ */
|
|
104 |
+ char * device_name = g_strdup_printf
|
|
105 |
+ ("/dev/sound/%s:%sdsp",
|
|
106 |
+ device_arr[0], device_arr[1]);
|
|
107 |
+ if ((ret = ca_context_change_device(c,
|
|
108 |
+ device_name)) < 0) {
|
20055
|
109 |
+ ca_context_destroy(c);
|
|
110 |
+ return ret;
|
|
111 |
+ }
|
|
112 |
+ g_free (device_name);
|
|
113 |
+ }
|
|
114 |
+ g_strfreev (device_arr);
|
|
115 |
+ }
|
|
116 |
+ g_strfreev (element_arr);
|
|
117 |
+ }
|
|
118 |
+ g_free (gvc_active);
|
|
119 |
+ }
|
|
120 |
+
|
|
121 |
*_c = c;
|
|
122 |
return CA_SUCCESS;
|
|
123 |
}
|
|
124 |
--- libcanberra-0.25/configure.ac-orig 2010-09-13 23:43:25.620576446 -0500
|
|
125 |
+++ libcanberra-0.25/configure.ac 2010-09-13 23:46:13.839034621 -0500
|
|
126 |
@@ -490,6 +490,10 @@ AM_CONDITIONAL([USE_LYNX], [test "x$have
|
|
127 |
|
|
128 |
PKG_CHECK_MODULES(VORBIS, [ vorbisfile ])
|
|
129 |
|
|
130 |
+### GConf (mandatory) ###
|
|
131 |
+
|
|
132 |
+PKG_CHECK_MODULES(GCONF, [ gconf-2.0 ])
|
|
133 |
+
|
|
134 |
### Chose builtin driver ###
|
|
135 |
|
|
136 |
AC_ARG_WITH([builtin],
|