summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/modules/reserve-monitor.c24
-rw-r--r--src/modules/reserve.c25
-rw-r--r--src/tests/voltest.c36
3 files changed, 37 insertions, 48 deletions
diff --git a/src/modules/reserve-monitor.c b/src/modules/reserve-monitor.c
index 97cb9b9e..ab453e61 100644
--- a/src/modules/reserve-monitor.c
+++ b/src/modules/reserve-monitor.c
@@ -64,7 +64,6 @@ static DBusHandlerResult filter_handler(
DBusMessage *s,
void *userdata) {
- DBusMessage *reply;
rm_monitor *m;
DBusError error;
@@ -105,31 +104,10 @@ static DBusHandlerResult filter_handler(
}
}
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
invalid:
- if (!(reply = dbus_message_new_error(
- s,
- DBUS_ERROR_INVALID_ARGS,
- "Invalid arguments")))
- goto oom;
-
- if (!dbus_connection_send(c, reply, NULL))
- goto oom;
-
- dbus_message_unref(reply);
-
dbus_error_free(&error);
- return DBUS_HANDLER_RESULT_HANDLED;
-
-oom:
- if (reply)
- dbus_message_unref(reply);
-
- dbus_error_free(&error);
-
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
int rm_watch(
diff --git a/src/modules/reserve.c b/src/modules/reserve.c
index 5597f177..b4c168cf 100644
--- a/src/modules/reserve.c
+++ b/src/modules/reserve.c
@@ -291,7 +291,6 @@ static DBusHandlerResult filter_handler(
DBusMessage *m,
void *userdata) {
- DBusMessage *reply;
rd_device *d;
DBusError error;
@@ -323,35 +322,13 @@ static DBusHandlerResult filter_handler(
rd_release(d);
}
- return DBUS_HANDLER_RESULT_HANDLED;
}
}
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
invalid:
- if (!(reply = dbus_message_new_error(
- m,
- DBUS_ERROR_INVALID_ARGS,
- "Invalid arguments")))
- goto oom;
-
- if (!dbus_connection_send(c, reply, NULL))
- goto oom;
-
- dbus_message_unref(reply);
-
- dbus_error_free(&error);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-
-oom:
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
diff --git a/src/tests/voltest.c b/src/tests/voltest.c
index 64aec5c6..551f7ecd 100644
--- a/src/tests/voltest.c
+++ b/src/tests/voltest.c
@@ -33,6 +33,8 @@ int main(int argc, char *argv[]) {
pa_cvolume cv;
float b;
pa_channel_map map;
+ pa_volume_t md = 0;
+ unsigned mdn = 0;
printf("Attenuation of sample 1 against 32767: %g dB\n", 20.0*log10(1.0/32767.0));
printf("Smallest possible attenutation > 0 applied to 32767: %li\n", lrint(32767.0*pa_sw_volume_to_linear(1)));
@@ -85,16 +87,48 @@ int main(int argc, char *argv[]) {
printf("After: volume: [%s]; balance: %2.1f (intended: %2.1f) %s\n", pa_cvolume_snprint(s, sizeof(s), &r), k, b, k < b-.05 || k > b+.5 ? "MISMATCH" : "");
}
- for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 1) {
+ for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 51) {
double l = pa_sw_volume_to_linear(v);
pa_volume_t k = pa_sw_volume_from_linear(l);
double db = pa_sw_volume_to_dB(v);
pa_volume_t r = pa_sw_volume_from_dB(db);
+ pa_volume_t w;
pa_assert(k == v);
pa_assert(r == v);
+
+ for (w = PA_VOLUME_MUTED; w < PA_VOLUME_NORM*2; w += 37) {
+
+ double t = pa_sw_volume_to_linear(w);
+ double db2 = pa_sw_volume_to_dB(w);
+ pa_volume_t p, p1, p2;
+ double q, qq;
+
+ p = pa_sw_volume_multiply(v, w);
+ qq = db + db2;
+ p2 = pa_sw_volume_from_dB(qq);
+ q = l*t;
+ p1 = pa_sw_volume_from_linear(q);
+
+ if (p2 > p && p2 - p > md)
+ md = p2 - p;
+ if (p2 < p && p - p2 > md)
+ md = p - p2;
+ if (p1 > p && p1 - p > md)
+ md = p1 - p;
+ if (p1 < p && p - p1 > md)
+ md = p - p1;
+
+ if (p1 != p || p2 != p)
+ mdn++;
+ }
}
+ printf("max deviation: %lu n=%lu\n", (unsigned long) md, (unsigned long) mdn);
+
+ pa_assert(md <= 1);
+ pa_assert(mdn <= 251);
+
return 0;
}