openjdk-23: use OpenJDK 23 as the boot JDK
[oi-userland.git] / components / library / libcanberra / patches / 02-device.patch
blob70e4fe903357571f646ea36a81f5aa46d5fdf8d3
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 @@
18 #include <stdarg.h>
20 +#include <gconf/gconf-client.h>
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"
29 +#define GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT "/apps/gnome-volume-control/active-element"
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;
40 ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED);
41 ca_return_val_if_fail(_c, CA_ERROR_INVALID);
42 @@ -153,13 +158,79 @@ int ca_context_create(ca_context **_c) {
46 - if ((d = getenv("CANBERRA_DEVICE"))) {
47 - if ((ret = ca_context_change_device(c, d)) < 0) {
48 + /*
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.
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;
60 + /*
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)
65 + *
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.
70 + */
71 + if (device == NULL) {
72 + GConfClient *gconf_client;
73 + char *gvc_active;
75 + gconf_client = gconf_client_get_default ();
77 + gvc_active = gconf_client_get_string (gconf_client,
78 + GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT, NULL);
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) {
87 + char ** element_arr;
88 + element_arr = g_strsplit (gvc_active, " ", 2);
90 + if (element_arr != NULL &&
91 + element_arr[0] != NULL) {
92 + char **device_arr = g_strsplit (element_arr[0],
93 + "#", 2);
94 + if (device_arr != NULL &&
95 + device_arr[0] != NULL &&
96 + device_arr[1] != NULL) {
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) {
109 + ca_context_destroy(c);
110 + return ret;
112 + g_free (device_name);
114 + g_strfreev (device_arr);
116 + g_strfreev (element_arr);
118 + g_free (gvc_active);
121 *_c = c;
122 return CA_SUCCESS;
124 --- libcanberra-0.30/configure.ac.orig 2012-09-25 02:21:07.000000000 +0200
125 +++ libcanberra-0.30/configure.ac 2023-12-17 10:33:04.145775951 +0100
126 @@ -114,9 +114,6 @@
127 -fdata-sections])
128 AC_SUBST([WARNINGFLAGS], $with_cflags)
130 -CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
131 - -Wl,--as-needed \
132 - -Wl,--gc-sections])
133 AC_SUBST([GCLDFLAGS], $with_ldflags)
135 #### libtool stuff ####
136 @@ -585,6 +582,10 @@
138 PKG_CHECK_MODULES(VORBIS, [ vorbisfile ])
140 +### GConf (mandatory) ###
142 +PKG_CHECK_MODULES(GCONF, [ gconf-2.0 ])
144 ### Chose builtin driver ###
146 AC_ARG_WITH([builtin],