[polypaudio-commits] r964 - /trunk/src/utils/padsp.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Wed May 24 18:14:07 PDT 2006
Author: lennart
Date: Thu May 25 03:14:06 2006
New Revision: 964
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=964&root=polypaudio&view=rev
Log:
add support to disable emulation of /dev/dsp,/dev/mixer,/dev/sndstat selectively by either passing an environment variable or by defining a symbol __padsp_disable__ in the process
Modified:
trunk/src/utils/padsp.c
Modified: trunk/src/utils/padsp.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/utils/padsp.c?rev=964&root=polypaudio&r1=963&r2=964&view=diff
==============================================================================
--- trunk/src/utils/padsp.c (original)
+++ trunk/src/utils/padsp.c Thu May 25 03:14:06 2006
@@ -191,6 +191,61 @@
}
}
+static int padsp_disabled(void) {
+ static int *sym;
+ static int sym_resolved = 0;
+
+ /* If the current process has a symbol __padsp_disabled__ we use
+ * it to detect whether we should enable our stuff or not. A
+ * program needs to be compiled with -rdynamic for this to work!
+ * The symbol must be an int containing a three bit bitmask: bit 1
+ * -> disable /dev/dsp emulation, bit 2 -> disable /dev/sndstat
+ * emulation, bit 3 -> disable /dev/mixer emulation. Hence a value
+ * 7 disables padsp entirely. */
+
+ pthread_mutex_lock(&func_mutex);
+ if (!sym_resolved) {
+ sym = (int*) dlsym_fn(RTLD_DEFAULT, "__padsp_disabled__");
+ sym_resolved = 1;
+
+ }
+ pthread_mutex_unlock(&func_mutex);
+
+ if (!sym)
+ return 0;
+
+ return *sym;
+}
+
+static int dsp_cloak_enable(void) {
+ if (padsp_disabled() & 1)
+ return 0;
+
+ if (getenv("PADSP_NO_DSP"))
+ return 0;
+
+ return 1;
+}
+
+static int sndstat_cloak_enable(void) {
+ if (padsp_disabled() & 2)
+ return 0;
+
+ if (getenv("PADSP_NO_SNDSTAT"))
+ return 0;
+
+ return 1;
+}
+
+static int mixer_cloak_enable(void) {
+ if (padsp_disabled() & 4)
+ return 0;
+
+ if (getenv("PADSP_NO_MIXER"))
+ return 0;
+
+ return 1;
+}
static pthread_key_t recursion_key;
static void recursion_key_alloc(void) {
@@ -1010,11 +1065,11 @@
return _open(filename, flags, mode);
}
- if (strcmp(filename, "/dev/dsp") == 0 || strcmp(filename, "/dev/adsp") == 0) {
+ if (dsp_cloak_enable() && (strcmp(filename, "/dev/dsp") == 0 || strcmp(filename, "/dev/adsp") == 0)) {
r = dsp_open(flags, &_errno);
- } else if (strcmp(filename, "/dev/mixer") == 0) {
+ } else if (mixer_cloak_enable() && strcmp(filename, "/dev/mixer") == 0) {
r = mixer_open(flags, &_errno);
- } else if (strcmp(filename, "/dev/sndstat") == 0) {
+ } else if (sndstat_cloak_enable() && strcmp(filename, "/dev/sndstat") == 0) {
r = sndstat_open(flags, &_errno);
} else {
function_exit();
More information about the pulseaudio-commits
mailing list