summaryrefslogtreecommitdiffstats
path: root/src/ao_polyp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ao_polyp.c')
-rw-r--r--src/ao_polyp.c25
1 files changed, 22 insertions, 3 deletions
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 <assert.h>
#include <string.h>
#include <signal.h>
+#include <limits.h>
#include <polyp/polyplib-simple.h>
#include <ao/ao.h>
@@ -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;