From 8521643835451e9009ce66387d9711f4d4e731b4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 12 Sep 2004 19:36:34 +0000 Subject: build system fix update to polypaudio 0.5 show program name in client name git-svn-id: file:///home/lennart/svn/public/libao-pulse/trunk@10 a8d83910-18e2-0310-866c-8ed7f9518005 --- src/ao_polyp.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/ao_polyp.c') diff --git a/src/ao_polyp.c b/src/ao_polyp.c index b50c4ef..23e7844 100644 --- a/src/ao_polyp.c +++ b/src/ao_polyp.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -54,7 +55,11 @@ typedef struct ao_polyp_internal { char *server, *sink; } ao_polyp_internal; -/* Yes, this is very ugly, but required... */ +/* Dirty trick: import these two functions from polyplib */ +char *pa_get_binary_name(char *s, size_t l); +char *pa_path_get_filename(const char *p); + +/* Yes, this is very ugly, but required nonetheless... */ static void disable_sigpipe(void) { struct sigaction sa; @@ -68,6 +73,7 @@ static void disable_sigpipe(void) { } int ao_plugin_test(void) { + char p[PATH_MAX], t[256], t2[256], *fn = NULL; struct pa_simple *s; static const struct pa_sample_spec ss = { .format = PA_SAMPLE_S16LE, @@ -80,7 +86,13 @@ int ao_plugin_test(void) { if (getenv("POLYP_SERVER") || getenv("POLYP_SINK")) return 1; - if (!(s = pa_simple_new(NULL, "libao", PA_STREAM_PLAYBACK, NULL, "libao test", &ss, NULL, NULL))) + if (pa_get_binary_name(p, sizeof(p))) { + fn = pa_path_get_filename(p); + snprintf(t, sizeof(t), "libao[%s]", fn); + snprintf(t2, sizeof(t2), "libao[%s] test", fn); + } + + if (!(s = pa_simple_new(NULL, fn ? t : "libao", PA_STREAM_PLAYBACK, NULL, fn ? t2 : "libao test", &ss, NULL, NULL))) return 0; pa_simple_free(s); @@ -126,6 +138,7 @@ int ao_plugin_set_option(ao_device *device, const char *key, const char *value) } int ao_plugin_open(ao_device *device, ao_sample_format *format) { + char p[PATH_MAX], t[256], t2[256], *fn = NULL; ao_polyp_internal *internal; struct pa_sample_spec ss; @@ -147,8 +160,14 @@ int ao_plugin_open(ao_device *device, ao_sample_format *format) { ss.rate = format->rate; disable_sigpipe(); + + if (pa_get_binary_name(p, sizeof(p))) { + fn = pa_path_get_filename(p); + snprintf(t, sizeof(t), "libao[%s]", fn); + snprintf(t2, sizeof(t2), "libao[%s] playback stream", fn); + } - if (!(internal->simple = pa_simple_new(internal->server, "libao", PA_STREAM_PLAYBACK, internal->sink, "libao Playback Stream", &ss, NULL, NULL))) + if (!(internal->simple = pa_simple_new(internal->server, fn ? t : "libao", PA_STREAM_PLAYBACK, internal->sink, fn ? t2 : "libao playback stream", &ss, NULL, NULL))) return 0; device->driver_byte_format = AO_FMT_NATIVE; -- cgit