[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v1.0-dev-263-ge5f547f
Colin Guthrie
gitmailer-noreply at 0pointer.de
Wed Apr 20 03:20:21 PDT 2011
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from 1f602ded57bbae5d33e0a239a543e1009ea2634d (commit)
- Log -----------------------------------------------------------------
e5f547f filter-apply: Make housekeeping optional
e727068 filter: Move the proplist defines into the central place and document them.
c376ac5 tests: improve resampler test
-----------------------------------------------------------------------
Summary of changes:
src/modules/module-filter-apply.c | 17 ++-
src/modules/module-filter-heuristics.c | 3 -
src/pulse/proplist.h | 6 +
src/tests/resampler-test.c | 207 ++++++++++++++++++++++++++++++--
4 files changed, 217 insertions(+), 16 deletions(-)
-----------------------------------------------------------------------
commit c376ac5920fdeb46ca844d9518e22f17adffb635
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date: Tue Apr 19 13:29:19 2011 +0300
tests: improve resampler test
diff --git a/src/tests/resampler-test.c b/src/tests/resampler-test.c
index 82198b5..69d7ab0 100644
--- a/src/tests/resampler-test.c
+++ b/src/tests/resampler-test.c
@@ -22,7 +22,13 @@
#endif
#include <stdio.h>
+#include <getopt.h>
+#include <locale.h>
+#include <pulse/i18n.h>
+#include <pulse/pulseaudio.h>
+
+#include <pulse/rtclock.h>
#include <pulse/sample.h>
#include <pulse/volume.h>
@@ -31,6 +37,8 @@
#include <pulsecore/endianmacros.h>
#include <pulsecore/memblock.h>
#include <pulsecore/sample-util.h>
+#include <pulsecore/core-rtclock.h>
+#include <pulsecore/core-util.h>
static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
void *d;
@@ -241,10 +249,78 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) {
return r;
}
+static void help(const char *argv0) {
+ printf(_("%s [options]\n\n"
+ "-h, --help Show this help\n"
+ "-v, --verbose Print debug messages\n"
+ " --from-rate=SAMPLERATE From sample rate in Hz (defaults to 44100)\n"
+ " --from-format=SAMPLEFORMAT From sample type (defaults to s16le)\n"
+ " --from-channels=CHANNELS From number of channels (defaults to 1)\n"
+ " --to-rate=SAMPLERATE To sample rate in Hz (defaults to 44100)\n"
+ " --to-format=SAMPLEFORMAT To sample type (defaults to s16le)\n"
+ " --to-channels=CHANNELS To number of channels (defaults to 1)\n"
+ " --resample-method=METHOD Resample method (defaults to auto)\n"
+ " --seconds=SECONDS From stream duration (defaults to 60)\n"
+ "\n"
+ "If the formats are not specified, the test performs all formats combinations,\n"
+ "back and forth.\n"
+ "\n"
+ "Sample type must be one of s16le, s16be, u8, float32le, float32be, ulaw, alaw,\n"
+ "32le, s32be (defaults to s16ne)\n"
+ "\n"
+ "See --dump-resample-methods for possible values of resample methods.\n"),
+ argv0);
+}
+
+enum {
+ ARG_VERSION = 256,
+ ARG_FROM_SAMPLERATE,
+ ARG_FROM_SAMPLEFORMAT,
+ ARG_FROM_CHANNELS,
+ ARG_TO_SAMPLERATE,
+ ARG_TO_SAMPLEFORMAT,
+ ARG_TO_CHANNELS,
+ ARG_SECONDS,
+ ARG_RESAMPLE_METHOD,
+ ARG_DUMP_RESAMPLE_METHODS
+};
+
+static void dump_resample_methods(void) {
+ int i;
+
+ for (i = 0; i < PA_RESAMPLER_MAX; i++)
+ if (pa_resample_method_supported(i))
+ printf("%s\n", pa_resample_method_to_string(i));
+
+}
+
int main(int argc, char *argv[]) {
- pa_mempool *pool;
+ pa_mempool *pool = NULL;
pa_sample_spec a, b;
pa_cvolume v;
+ int ret = 1, verbose = 0, c;
+ pa_bool_t all_formats = TRUE;
+ pa_resample_method_t method;
+ int seconds;
+
+ static const struct option long_options[] = {
+ {"help", 0, NULL, 'h'},
+ {"verbose", 0, NULL, 'v'},
+ {"version", 0, NULL, ARG_VERSION},
+ {"from-rate", 1, NULL, ARG_FROM_SAMPLERATE},
+ {"from-format", 1, NULL, ARG_FROM_SAMPLEFORMAT},
+ {"from-channels", 1, NULL, ARG_FROM_CHANNELS},
+ {"to-rate", 1, NULL, ARG_TO_SAMPLERATE},
+ {"to-format", 1, NULL, ARG_TO_SAMPLEFORMAT},
+ {"to-channels", 1, NULL, ARG_TO_CHANNELS},
+ {"seconds", 1, NULL, ARG_SECONDS},
+ {"resample-method", 1, NULL, ARG_RESAMPLE_METHOD},
+ {"dump-resample-methods", 0, NULL, ARG_DUMP_RESAMPLE_METHODS},
+ {NULL, 0, NULL, 0}
+ };
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
pa_log_set_level(PA_LOG_DEBUG);
@@ -252,22 +328,131 @@ int main(int argc, char *argv[]) {
a.channels = b.channels = 1;
a.rate = b.rate = 44100;
-
+ a.format = b.format = PA_SAMPLE_S16LE;
v.channels = a.channels;
v.values[0] = pa_sw_volume_from_linear(0.5);
+ method = PA_RESAMPLER_AUTO;
+ seconds = 60;
+
+ while ((c = getopt_long(argc, argv, "hv", long_options, NULL)) != -1) {
+
+ switch (c) {
+ case 'h' :
+ help(argv[0]);
+ ret = 0;
+ goto quit;
+
+ case 'v':
+ pa_log_set_level(PA_LOG_DEBUG);
+ verbose = 1;
+ ret = 0;
+ break;
+
+ case ARG_VERSION:
+ printf(_("%s %s\n"), argv[0], PACKAGE_VERSION);
+ ret = 0;
+ goto quit;
+
+ case ARG_DUMP_RESAMPLE_METHODS:
+ dump_resample_methods();
+ ret = 0;
+ goto quit;
+
+ case ARG_FROM_CHANNELS:
+ a.channels = (uint8_t) atoi(optarg);
+ break;
+
+ case ARG_FROM_SAMPLEFORMAT:
+ a.format = pa_parse_sample_format(optarg);
+ all_formats = FALSE;
+ break;
+
+ case ARG_FROM_SAMPLERATE:
+ a.rate = (uint32_t) atoi(optarg);
+ break;
+
+ case ARG_TO_CHANNELS:
+ b.channels = (uint8_t) atoi(optarg);
+ break;
+
+ case ARG_TO_SAMPLEFORMAT:
+ b.format = pa_parse_sample_format(optarg);
+ all_formats = FALSE;
+ break;
+
+ case ARG_TO_SAMPLERATE:
+ b.rate = (uint32_t) atoi(optarg);
+ break;
+
+ case ARG_SECONDS:
+ seconds = atoi(optarg);
+ break;
+
+ case ARG_RESAMPLE_METHOD:
+ if (*optarg == '\0' || pa_streq(optarg, "help")) {
+ dump_resample_methods();
+ ret = 0;
+ goto quit;
+ }
+ method = pa_parse_resample_method(optarg);
+ break;
+
+ default:
+ goto quit;
+ }
+ }
+
+ pa_assert_se(pool = pa_mempool_new(FALSE, 0));
+
+ if (!all_formats) {
+
+ pa_resampler *resampler;
+ pa_memchunk i, j;
+ pa_usec_t ts;
+
+ if (verbose) {
+ printf(_("Compilation CFLAGS: %s\n"), PA_CFLAGS);
+ printf(_("=== %d seconds: %d Hz %d ch (%s) -> %d Hz %d ch (%s)\n"), seconds,
+ a.rate, a.channels, pa_sample_format_to_string(a.format),
+ b.rate, b.channels, pa_sample_format_to_string(b.format));
+ }
+
+ ts = pa_rtclock_now();
+ pa_assert_se(resampler = pa_resampler_new(pool, &a, NULL, &b, NULL, method, 0));
+ printf("init: %llu\n", pa_rtclock_now() - ts);
+
+ i.memblock = pa_memblock_new(pool, pa_usec_to_bytes(1*PA_USEC_PER_SEC, &a) / pa_frame_size(&a));
+
+ ts = pa_rtclock_now();
+ i.length = pa_memblock_get_length(i.memblock);
+ i.index = 0;
+ while (seconds--) {
+ pa_resampler_run(resampler, &i, &j);
+ pa_memblock_unref(j.memblock);
+ }
+ printf("resampling: %llu\n", pa_rtclock_now() - ts);
+ pa_memblock_unref(i.memblock);
+
+ pa_resampler_free(resampler);
+
+ ret = 0;
+ goto quit;
+ }
+
for (a.format = 0; a.format < PA_SAMPLE_MAX; a.format ++) {
for (b.format = 0; b.format < PA_SAMPLE_MAX; b.format ++) {
pa_resampler *forth, *back;
pa_memchunk i, j, k;
- printf("=== %s -> %s -> %s -> /2\n",
- pa_sample_format_to_string(a.format),
- pa_sample_format_to_string(b.format),
- pa_sample_format_to_string(a.format));
+ if (verbose)
+ printf("=== %s -> %s -> %s -> /2\n",
+ pa_sample_format_to_string(a.format),
+ pa_sample_format_to_string(b.format),
+ pa_sample_format_to_string(a.format));
- pa_assert_se(forth = pa_resampler_new(pool, &a, NULL, &b, NULL, PA_RESAMPLER_AUTO, 0));
- pa_assert_se(back = pa_resampler_new(pool, &b, NULL, &a, NULL, PA_RESAMPLER_AUTO, 0));
+ pa_assert_se(forth = pa_resampler_new(pool, &a, NULL, &b, NULL, method, 0));
+ pa_assert_se(back = pa_resampler_new(pool, &b, NULL, &a, NULL, method, 0));
i.memblock = generate_block(pool, &a);
i.length = pa_memblock_get_length(i.memblock);
@@ -296,7 +481,9 @@ int main(int argc, char *argv[]) {
}
}
- pa_mempool_free(pool);
+ quit:
+ if (pool)
+ pa_mempool_free(pool);
- return 0;
+ return ret;
}
commit e7270689567c55e4b68299cd9f399ca8ec34a85c
Author: Colin Guthrie <colin at mageia.org>
Date: Wed Apr 20 09:25:31 2011 +0100
filter: Move the proplist defines into the central place and document them.
diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index d4bded5..c29e74d 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -36,9 +36,6 @@
#include "module-filter-apply-symdef.h"
-#define PA_PROP_FILTER_WANT "filter.want"
-#define PA_PROP_FILTER_SUPPRESS "filter.suppress"
-
PA_MODULE_AUTHOR("Colin Guthrie");
PA_MODULE_DESCRIPTION("Load filter sinks automatically when needed");
diff --git a/src/modules/module-filter-heuristics.c b/src/modules/module-filter-heuristics.c
index fb01f85..bd8a600 100644
--- a/src/modules/module-filter-heuristics.c
+++ b/src/modules/module-filter-heuristics.c
@@ -33,9 +33,6 @@
#include "module-filter-heuristics-symdef.h"
-#define PA_PROP_FILTER_WANT "filter.want"
-#define PA_PROP_FILTER_SUPPRESS "filter.suppress"
-
PA_MODULE_AUTHOR("Colin Guthrie");
PA_MODULE_DESCRIPTION("Detect when various filters are desirable");
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 5db3ada..4670d61 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -62,6 +62,12 @@ PA_C_DECL_BEGIN
/** For streams: logic role of this media. One of the strings "video", "music", "game", "event", "phone", "animation", "production", "a11y", "test" */
#define PA_PROP_MEDIA_ROLE "media.role"
+/** For streams: the name of a filter that is desired, e.g. "echo-cancel" or "equalizer-sink" \since 1.0 */
+#define PA_PROP_FILTER_WANT "filter.want"
+
+/** For streams: the name of a filter that should specifically suppressed (i.e. overrides PA_PROP_FILTER_WANT). Useful for the times that PA_PROP_FILTER_WANT is automatically added (e.g. echo-cancellation for phone streams when $VOIP_APP does it's own, internal AEC) \since 1.0 */
+#define PA_PROP_FILTER_SUPPRESS "filter.suppress"
+
/** For event sound streams: XDG event sound name. e.g. "message-new-email" (Event sound streams are those with media.role set to "event") */
#define PA_PROP_EVENT_ID "event.id"
commit e5f547fe705c4e51cb09d72c2e1682d345c8f3e4
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date: Wed Apr 20 13:45:48 2011 +0530
filter-apply: Make housekeeping optional
Adds an autoclean option (defaults to TRUE) that controls whether
module-filter-apply cleans up unused modules or not. This is useful in
cases where you know that a filter will be used often and thus can avoid
overhead from repeated module load/unload.
diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index c29e74d..c898971 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -25,6 +25,7 @@
#include <pulse/timeval.h>
#include <pulse/rtclock.h>
+#include <pulse/i18n.h>
#include <pulsecore/macro.h>
#include <pulsecore/hashmap.h>
@@ -41,11 +42,14 @@ PA_MODULE_AUTHOR("Colin Guthrie");
PA_MODULE_DESCRIPTION("Load filter sinks automatically when needed");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_USAGE(_("autoclean=<automatically unload unused filters?>"));
static const char* const valid_modargs[] = {
+ "autoclean",
NULL
};
+#define DEFAULT_AUTOCLEAN TRUE
#define HOUSEKEEPING_INTERVAL (10 * PA_USEC_PER_SEC)
struct filter {
@@ -63,6 +67,7 @@ struct userdata {
*sink_input_proplist_slot,
*sink_input_unlink_slot,
*sink_unlink_slot;
+ pa_bool_t autoclean;
pa_time_event *housekeeping_time_event;
};
@@ -149,6 +154,9 @@ static void housekeeping_time_callback(pa_mainloop_api*a, pa_time_event* e, cons
static void trigger_housekeeping(struct userdata *u) {
pa_assert(u);
+ if (!u->autoclean)
+ return;
+
if (u->housekeeping_time_event)
return;
@@ -342,6 +350,12 @@ int pa__init(pa_module *m) {
u->core = m->core;
+ u->autoclean = DEFAULT_AUTOCLEAN;
+ if (pa_modargs_get_value_boolean(ma, "autoclean", &u->autoclean) < 0) {
+ pa_log("Failed to parse autoclean value");
+ goto fail;
+ }
+
u->filters = pa_hashmap_new(filter_hash, filter_compare);
u->sink_input_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_put_cb, u);
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list