add description field for sinks/sources
authorLennart Poettering <lennart@poettering.net>
Sat, 10 Jul 2004 20:56:38 +0000 (20:56 +0000)
committerLennart Poettering <lennart@poettering.net>
Sat, 10 Jul 2004 20:56:38 +0000 (20:56 +0000)
add owner field to all entities
add client file to source outputs and sink inputs

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@59 fefdeb5f-60dc-0310-8127-8f9354f1896f

30 files changed:
src/cli.c
src/cli.h
src/client.c
src/client.h
src/module-cli.c
src/module-oss-mmap.c
src/module-oss.c
src/module-pipe-sink.c
src/module-protocol-stub.c
src/protocol-cli.c
src/protocol-cli.h
src/protocol-esound.c
src/protocol-esound.h
src/protocol-native.c
src/protocol-native.h
src/protocol-simple.c
src/protocol-simple.h
src/sink.c
src/sink.h
src/sinkinput.c
src/sinkinput.h
src/source.c
src/source.h
src/sourceoutput.c
src/sourceoutput.h
src/strbuf.c
src/strbuf.h
src/todo
src/util.c
src/util.h

index 429aebf..b7fc787 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -83,7 +83,7 @@ static const char prompt[] = ">>> ";
 
 static void client_kill(struct pa_client *c);
 
-struct pa_cli* pa_cli_new(struct pa_core *core, struct pa_iochannel *io) {
+struct pa_cli* pa_cli_new(struct pa_core *core, struct pa_iochannel *io, struct pa_module *m) {
     char cname[256];
     struct pa_cli *c;
     assert(io);
@@ -102,6 +102,7 @@ struct pa_cli* pa_cli_new(struct pa_core *core, struct pa_iochannel *io) {
     assert(c->client);
     c->client->kill = client_kill;
     c->client->userdata = c;
+    c->client->owner = m;
     
     pa_ioline_set_callback(c->line, line_callback, c);
     pa_ioline_puts(c->line, "Welcome to polypaudio! Use \"help\" for usage information.\n");
index 80d9fec..d6250b3 100644 (file)
--- a/src/cli.h
+++ b/src/cli.h
@@ -3,10 +3,11 @@
 
 #include "iochannel.h"
 #include "core.h"
+#include "module.h"
 
 struct pa_cli;
 
-struct pa_cli* pa_cli_new(struct pa_core *core, struct pa_iochannel *io);
+struct pa_cli* pa_cli_new(struct pa_core *core, struct pa_iochannel *io, struct pa_module *m);
 void pa_cli_free(struct pa_cli *cli);
 
 void pa_cli_set_eof_callback(struct pa_cli *cli, void (*cb)(struct pa_cli*c, void *userdata), void *userdata);
index d07f188..fa1a28d 100644 (file)
@@ -14,6 +14,7 @@ struct pa_client *pa_client_new(struct pa_core *core, const char *protocol_name,
     c = malloc(sizeof(struct pa_client));
     assert(c);
     c->name = name ? strdup(name) : NULL;
+    c->owner = NULL;
     c->core = core;
     c->protocol_name = protocol_name;
 
@@ -58,9 +59,13 @@ char *pa_client_list_to_string(struct pa_core *c) {
 
     pa_strbuf_printf(s, "%u client(s).\n", pa_idxset_ncontents(c->clients));
     
-    for (client = pa_idxset_first(c->clients, &index); client; client = pa_idxset_next(c->clients, &index))
+    for (client = pa_idxset_first(c->clients, &index); client; client = pa_idxset_next(c->clients, &index)) {
         pa_strbuf_printf(s, "    index: %u\n\tname: <%s>\n\tprotocol_name: <%s>\n", client->index, client->name, client->protocol_name);
-    
+
+        if (client->owner)
+            pa_strbuf_printf(s, "\towner module: <%u>\n", client->owner->index);
+    }
+        
     return pa_strbuf_tostring_free(s);
 }
 
index 4ca8d96..d603411 100644 (file)
@@ -2,10 +2,12 @@
 #define fooclienthfoo
 
 #include "core.h"
+#include "module.h"
 
 struct pa_client {
     uint32_t index;
 
+    struct pa_module *owner;
     char *name;
     struct pa_core *core;
     const char *protocol_name;
index a6e9582..440c4ba 100644 (file)
@@ -27,7 +27,7 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
     assert(io);
     pa_iochannel_set_noclose(io, 1);
 
-    m->userdata = pa_cli_new(c, io);
+    m->userdata = pa_cli_new(c, io, m);
     assert(m->userdata);
 
     pa_cli_set_eof_callback(m->userdata, eof_cb, m);
index 280484d..772abf9 100644 (file)
@@ -17,6 +17,7 @@
 #include "module.h"
 #include "oss-util.h"
 #include "sample-util.h"
+#include "util.h"
 
 struct userdata {
     struct pa_sink *sink;
@@ -244,6 +245,9 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
             u->source = pa_source_new(c, "oss_input", 0, &u->sample_spec);
             assert(u->source);
             u->source->userdata = u;
+            pa_source_set_owner(u->source, m);
+            u->source->description = pa_sprintf_malloc("Open Sound System PCM/mmap() on '%s'", p);
+            
             
             u->in_memblocks = malloc(sizeof(struct pa_memblock *)*u->in_fragments);
             memset(u->in_memblocks, 0, sizeof(struct pa_memblock *)*u->in_fragments);
@@ -276,6 +280,8 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
             assert(u->sink);
             u->sink->get_latency = sink_get_latency_cb;
             u->sink->userdata = u;
+            pa_sink_set_owner(u->sink, m);
+            u->sink->description = pa_sprintf_malloc("Open Sound System PCM/mmap() on '%s'", p);
             
             u->out_memblocks = malloc(sizeof(struct memblock *)*u->out_fragments);
             memset(u->out_memblocks, 0, sizeof(struct pa_memblock *)*u->out_fragments);
index 5ec9d2d..b067758 100644 (file)
@@ -16,6 +16,7 @@
 #include "module.h"
 #include "oss-util.h"
 #include "sample-util.h"
+#include "util.h"
 
 struct userdata {
     struct pa_sink *sink;
@@ -180,21 +181,25 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
 
     u->core = c;
 
+    if (mode != O_WRONLY) {
+        u->source = pa_source_new(c, "oss_input", 0, &ss);
+        assert(u->source);
+        u->source->userdata = u;
+        pa_source_set_owner(u->source, m);
+        u->sink->description = pa_sprintf_malloc("Open Sound System PCM on '%s'", p);
+    } else
+        u->source = NULL;
+
     if (mode != O_RDONLY) {
-        u->sink = pa_sink_new(c, "dsp", 0, &ss);
+        u->sink = pa_sink_new(c, "oss_output", 0, &ss);
         assert(u->sink);
         u->sink->get_latency = sink_get_latency_cb;
         u->sink->userdata = u;
+        pa_sink_set_owner(u->sink, m);
+        u->sink->description = pa_sprintf_malloc("Open Sound System PCM on '%s'", p);
     } else
         u->sink = NULL;
 
-    if (mode != O_WRONLY) {
-        u->source = pa_source_new(c, "dsp", 0, &ss);
-        assert(u->source);
-        u->source->userdata = u;
-    } else
-        u->source = NULL;
-
     assert(u->source || u->sink);
 
     u->io = pa_iochannel_new(c->mainloop, u->source ? fd : -1, u->sink ? fd : 0);
index efba3b5..67c0240 100644 (file)
@@ -11,6 +11,7 @@
 #include "iochannel.h"
 #include "sink.h"
 #include "module.h"
+#include "util.h"
 
 struct userdata {
     char *filename;
@@ -113,6 +114,9 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
     assert(u->sink);
     u->sink->notify = notify_cb;
     u->sink->userdata = u;
+    pa_sink_set_owner(u->sink, m);
+    u->sink->description = pa_sprintf_malloc("Unix FIFO sink '%s'", p);
+    assert(u->sink->description);
 
     u->io = pa_iochannel_new(c->mainloop, -1, fd);
     assert(u->io);
index 885ea4c..3bb0a07 100644 (file)
@@ -78,9 +78,9 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
 #endif
 
 #ifdef USE_PROTOCOL_SIMPLE
-    m->userdata = pa_protocol_simple_new(c, s, PA_PROTOCOL_SIMPLE_PLAYBACK);
+    m->userdata = pa_protocol_simple_new(c, s, m, PA_PROTOCOL_SIMPLE_PLAYBACK);
 #else
-    m->userdata = protocol_new(c, s);
+    m->userdata = protocol_new(c, s, m);
 #endif
 
     if (!m->userdata) {
index 0cdf2db..55b4a8a 100644 (file)
@@ -5,6 +5,7 @@
 #include "cli.h"
 
 struct pa_protocol_cli {
+    struct pa_module *module;
     struct pa_core *core;
     struct pa_socket_server*server;
     struct pa_idxset *connections;
@@ -22,19 +23,20 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
     struct pa_cli *c;
     assert(s && io && p);
 
-    c = pa_cli_new(p->core, io);
+    c = pa_cli_new(p->core, io, p->module);
     assert(c);
     pa_cli_set_eof_callback(c, cli_eof_cb, p);
 
     pa_idxset_put(p->connections, c, NULL);
 }
 
-struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server) {
+struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m) {
     struct pa_protocol_cli* p;
     assert(core && server);
 
     p = malloc(sizeof(struct pa_protocol_cli));
     assert(p);
+    p->module = m;
     p->core = core;
     p->server = server;
     p->connections = pa_idxset_new(NULL, NULL);
index fc6a7d6..c3bb8b4 100644 (file)
@@ -3,10 +3,11 @@
 
 #include "core.h"
 #include "socket-server.h"
+#include "module.h"
 
 struct pa_protocol_cli;
 
-struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server);
+struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m);
 void pa_protocol_cli_free(struct pa_protocol_cli *n);
 
 #endif
index 4d9ca54..fc4444c 100644 (file)
@@ -50,6 +50,7 @@ struct connection {
 
 struct pa_protocol_esound {
     int public;
+    struct pa_module *module;
     struct pa_core *core;
     struct pa_socket_server *server;
     struct pa_idxset *connections;
@@ -260,6 +261,8 @@ static int esd_proto_stream_play(struct connection *c, esd_proto_t request, cons
     c->sink_input = pa_sink_input_new(sink, name, &ss);
     assert(c->sink_input);
 
+    c->sink_input->owner = c->protocol->module;
+    c->sink_input->client = c->client;
     c->sink_input->peek = sink_input_peek_cb;
     c->sink_input->drop = sink_input_drop_cb;
     c->sink_input->kill = sink_input_kill_cb;
@@ -321,7 +324,9 @@ static int esd_proto_stream_record(struct connection *c, esd_proto_t request, co
     assert(!c->source_output);
     c->source_output = pa_source_output_new(source, name, &ss);
     assert(c->source_output);
-
+    
+    c->source_output->owner = c->protocol->module;
+    c->source_output->client = c->client;
     c->source_output->push = source_output_push_cb;
     c->source_output->kill = source_output_kill_cb;
     c->source_output->userdata = c;
@@ -733,6 +738,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
     assert(c->protocol->core);
     c->client = pa_client_new(c->protocol->core, "ESOUND", cname);
     assert(c->client);
+    c->client->owner = c->protocol->module;
     c->client->kill = client_kill_cb;
     c->client->userdata = c;
     
@@ -768,7 +774,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
 
 /*** entry points ***/
 
-struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server) {
+struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m) {
     struct pa_protocol_esound *p;
     assert(core && server);
 
@@ -779,7 +785,8 @@ struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa
         free(p);
         return NULL;
     }
-    
+
+    p->module = m;
     p->public = 0;
     p->server = server;
     pa_socket_server_set_callback(p->server, on_connection, p);
index cd50559..6071699 100644 (file)
@@ -3,10 +3,11 @@
 
 #include "core.h"
 #include "socket-server.h"
+#include "module.h"
 
 struct pa_protocol_esound;
 
-struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server);
+struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m);
 void pa_protocol_esound_free(struct pa_protocol_esound *p);
 
 #endif
index c7a7cce..d6a5f9b 100644 (file)
@@ -48,6 +48,7 @@ struct connection {
 };
 
 struct pa_protocol_native {
+    struct pa_module *module;
     int public;
     struct pa_core *core;
     struct pa_socket_server *server;
@@ -110,6 +111,8 @@ static struct record_stream* record_stream_new(struct connection *c, struct pa_s
     s->source_output->push = source_output_push_cb;
     s->source_output->kill = source_output_kill_cb;
     s->source_output->userdata = s;
+    s->source_output->owner = c->protocol->module;
+    s->source_output->client = c->client;
 
     s->memblockq = pa_memblockq_new(maxlength, 0, base = pa_sample_size(ss), 0, 0);
     assert(s->memblockq);
@@ -153,6 +156,8 @@ static struct playback_stream* playback_stream_new(struct connection *c, struct
     s->sink_input->kill = sink_input_kill_cb;
     s->sink_input->get_latency = sink_input_get_latency_cb;
     s->sink_input->userdata = s;
+    s->sink_input->owner = c->protocol->module;
+    s->sink_input->client = c->client;
     
     s->memblockq = pa_memblockq_new(maxlength, tlength, pa_sample_size(ss), prebuf, minreq);
     assert(s->memblockq);
@@ -707,6 +712,8 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
     assert(c->client);
     c->client->kill = client_kill_cb;
     c->client->userdata = c;
+    c->client->owner = p->module;
+    
     c->pstream = pa_pstream_new(p->core->mainloop, io);
     assert(c->pstream);
 
@@ -729,7 +736,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
 
 /*** module entry points ***/
 
-struct pa_protocol_native* pa_protocol_native_new(struct pa_core *core, struct pa_socket_server *server) {
+struct pa_protocol_native* pa_protocol_native_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m) {
     struct pa_protocol_native *p;
     assert(core && server);
 
@@ -740,7 +747,8 @@ struct pa_protocol_native* pa_protocol_native_new(struct pa_core *core, struct p
         free(p);
         return NULL;
     }
-    
+
+    p->module = m;
     p->public = 1;
     p->server = server;
     p->core = core;
index 1a26014..811b4e4 100644 (file)
@@ -3,10 +3,11 @@
 
 #include "core.h"
 #include "socket-server.h"
+#include "module.h"
 
 struct pa_protocol_native;
 
-struct pa_protocol_native* pa_protocol_native_new(struct pa_core*core, struct pa_socket_server *server);
+struct pa_protocol_native* pa_protocol_native_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m);
 void pa_protocol_native_free(struct pa_protocol_native *n);
 
 #endif
index e7ca0a7..518d5f2 100644 (file)
@@ -27,6 +27,7 @@ struct connection {
 };
 
 struct pa_protocol_simple {
+    struct pa_module *module;
     struct pa_core *core;
     struct pa_socket_server*server;
     struct pa_idxset *connections;
@@ -258,6 +259,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
     pa_iochannel_socket_peer_to_string(io, cname, sizeof(cname));
     c->client = pa_client_new(p->core, "SIMPLE", cname);
     assert(c->client);
+    c->client->owner = p->module;
     c->client->kill = client_kill_cb;
     c->client->userdata = c;
 
@@ -275,6 +277,8 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
             fprintf(stderr, "Failed to create sink input.\n");
             goto fail;
         }
+        c->sink_input->owner = p->module;
+        c->sink_input->client = c->client;
         
         c->sink_input->peek = sink_input_peek_cb;
         c->sink_input->drop = sink_input_drop_cb;
@@ -304,6 +308,8 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
             fprintf(stderr, "Failed to create source output.\n");
             goto fail;
         }
+        c->source_output->owner = p->module;
+        c->source_output->client = c->client;
         
         c->source_output->push = source_output_push_cb;
         c->source_output->kill = source_output_kill_cb;
@@ -328,12 +334,13 @@ fail:
         connection_free(c);
 }
 
-struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, enum pa_protocol_simple_mode mode) {
+struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, enum pa_protocol_simple_mode mode) {
     struct pa_protocol_simple* p;
     assert(core && server && mode <= PA_PROTOCOL_SIMPLE_DUPLEX && mode > 0);
 
     p = malloc(sizeof(struct pa_protocol_simple));
     assert(p);
+    p->module = m;
     p->core = core;
     p->server = server;
     p->connections = pa_idxset_new(NULL, NULL);
index 15ae36a..6b2a2cd 100644 (file)
@@ -2,6 +2,8 @@
 #define fooprotocolsimplehfoo
 
 #include "socket-server.h"
+#include "module.h"
+#include "core.h"
 
 struct pa_protocol_simple;
 
@@ -11,7 +13,7 @@ enum pa_protocol_simple_mode {
     PA_PROTOCOL_SIMPLE_DUPLEX = 3
 };
 
-struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, enum pa_protocol_simple_mode mode);
+struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, enum pa_protocol_simple_mode mode);
 void pa_protocol_simple_free(struct pa_protocol_simple *n);
 
 #endif
index 8056072..6a9f358 100644 (file)
@@ -8,6 +8,7 @@
 #include "strbuf.h"
 #include "sample-util.h"
 #include "namereg.h"
+#include "util.h"
 
 #define MAX_MIX_CHANNELS 32
 
@@ -16,7 +17,7 @@ struct pa_sink* pa_sink_new(struct pa_core *core, const char *name, int fail, co
     char *n = NULL;
     char st[256];
     int r;
-    assert(core && spec);
+    assert(core && name && spec);
 
     s = malloc(sizeof(struct pa_sink));
     assert(s);
@@ -27,15 +28,14 @@ struct pa_sink* pa_sink_new(struct pa_core *core, const char *name, int fail, co
     }
     
     s->name = strdup(name);
+    s->description = NULL;
+    
+    s->owner = NULL;
     s->core = core;
     s->sample_spec = *spec;
     s->inputs = pa_idxset_new(NULL, NULL);
 
-    if (name) {
-        n = malloc(strlen(name)+9);
-        sprintf(n, "%s_monitor", name);
-    }
-    
+    n = pa_sprintf_malloc("%s_monitor", name);
     s->monitor_source = pa_source_new(core, n, 0, spec);
     assert(s->monitor_source);
     free(n);
@@ -75,6 +75,7 @@ void pa_sink_free(struct pa_sink *s) {
     fprintf(stderr, "sink: freed %u \"%s\"\n", s->index, s->name);
     
     free(s->name);
+    free(s->description);
     free(s);
 }
 
@@ -285,8 +286,19 @@ char *pa_sink_list_to_string(struct pa_core *c) {
             pa_sink_get_latency(sink),
             sink->monitor_source->index,
             ss);
+
+        if (sink->owner)
+            pa_strbuf_printf(s, "\towner module: <%u>\n", sink->owner->index);
+        if (sink->description)
+            pa_strbuf_printf(s, "\tdescription: <%s>\n", sink->description);
     }
     
     return pa_strbuf_tostring_free(s);
 }
 
+void pa_sink_set_owner(struct pa_sink *sink, struct pa_module *m) {
+    sink->owner = m;
+
+    if (sink->monitor_source)
+        pa_source_set_owner(sink->monitor_source, m);
+}
index 7186f53..071ad09 100644 (file)
@@ -13,7 +13,8 @@ struct pa_sink;
 struct pa_sink {
     uint32_t index;
 
-    char *name;
+    char *name, *description;
+    struct pa_module *owner;
     struct pa_core *core;
     struct pa_sample_spec sample_spec;
     struct pa_idxset *inputs;
@@ -42,6 +43,6 @@ char *pa_sink_list_to_string(struct pa_core *core);
 
 struct pa_sink* pa_sink_get_default(struct pa_core *c);
 
-
+void pa_sink_set_owner(struct pa_sink *sink, struct pa_module *m);
 
 #endif
index f3e474b..3cfe49b 100644 (file)
@@ -23,6 +23,8 @@ struct pa_sink_input* pa_sink_input_new(struct pa_sink *s, const char *name, con
     i = malloc(sizeof(struct pa_sink_input));
     assert(i);
     i->name = name ? strdup(name) : NULL;
+    i->client = NULL;
+    i->owner = NULL;
     i->sink = s;
     i->sample_spec = *spec;
 
@@ -96,6 +98,11 @@ char *pa_sink_input_list_to_string(struct pa_core *c) {
             (unsigned) i->volume,
             pa_sink_input_get_latency(i),
             ss);
+
+        if (i->owner)
+            pa_strbuf_printf(s, "\towner module: <%u>\n", i->owner->index);
+        if (i->client)
+            pa_strbuf_printf(s, "\tclient: <%u>\n", i->client->index);
     }
     
     return pa_strbuf_tostring_free(s);
index b28b51e..8c9813e 100644 (file)
@@ -7,11 +7,15 @@
 #include "sample.h"
 #include "memblockq.h"
 #include "resampler.h"
+#include "module.h"
+#include "client.h"
 
 struct pa_sink_input {
     uint32_t index;
 
     char *name;
+    struct pa_module *owner;
+    struct pa_client *client;
     struct pa_sink *sink;
     struct pa_sample_spec sample_spec;
     uint32_t volume;
index 44d7da0..45ccfb2 100644 (file)
@@ -12,7 +12,7 @@ struct pa_source* pa_source_new(struct pa_core *core, const char *name, int fail
     struct pa_source *s;
     char st[256];
     int r;
-    assert(core && spec);
+    assert(core && spec && name);
 
     s = malloc(sizeof(struct pa_source));
     assert(s);
@@ -23,6 +23,9 @@ struct pa_source* pa_source_new(struct pa_core *core, const char *name, int fail
     }
 
     s->name = strdup(name);
+    s->description = NULL;
+
+    s->owner = NULL;
     s->core = core;
     s->sample_spec = *spec;
     s->outputs = pa_idxset_new(NULL, NULL);
@@ -58,6 +61,7 @@ void pa_source_free(struct pa_source *s) {
     fprintf(stderr, "source: freed %u \"%s\"\n", s->index, s->name);
 
     free(s->name);
+    free(s->description);
     free(s);
 }
 
@@ -112,13 +116,21 @@ char *pa_source_list_to_string(struct pa_core *c) {
     
     for (source = pa_idxset_first(c->sources, &index); source; source = pa_idxset_next(c->sources, &index)) {
         char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
-        char mo[256] = "";
-        if (source->monitor_of) 
-            snprintf(mo, sizeof(mo), "\n\tmonitor_of: <%u>", source->monitor_of->index);
         pa_sample_snprint(ss, sizeof(ss), &source->sample_spec);
-        pa_strbuf_printf(s, "  %c index: %u\n\tname: <%s>\n\tsample_spec: <%s>%s\n", source == default_source ? '*' : ' ', source->index, source->name, ss, mo);
+        pa_strbuf_printf(s, "  %c index: %u\n\tname: <%s>\n\tsample_spec: <%s>\n", source == default_source ? '*' : ' ', source->index, source->name, ss);
+
+        if (source->monitor_of) 
+            pa_strbuf_printf(s, "\tmonitor_of: <%u>\n", source->monitor_of->index);
+        if (source->owner)
+            pa_strbuf_printf(s, "\towner module: <%u>\n", source->owner->index);
+        if (source->description)
+            pa_strbuf_printf(s, "\tdescription: <%s>\n", source->description);
     }
     
     return pa_strbuf_tostring_free(s);
 }
 
+void pa_source_set_owner(struct pa_source *s, struct pa_module *m) {
+    assert(s);
+    s->owner = m;
+}
index 3b66cd3..2bc5bea 100644 (file)
@@ -14,7 +14,8 @@ struct pa_source;
 struct pa_source {
     uint32_t index;
     
-    char *name;
+    char *name, *description;
+    struct pa_module *owner;
     struct pa_core *core;
     struct pa_sample_spec sample_spec;
     struct pa_idxset *outputs;
@@ -36,4 +37,6 @@ char *pa_source_list_to_string(struct pa_core *c);
 
 struct pa_source* pa_source_get_default(struct pa_core *c);
 
+void pa_source_set_owner(struct pa_source *s, struct pa_module *m);
+
 #endif
index 442dc7f..ea72757 100644 (file)
@@ -18,6 +18,8 @@ struct pa_source_output* pa_source_output_new(struct pa_source *s, const char *n
     o = malloc(sizeof(struct pa_source_output));
     assert(o);
     o->name = name ? strdup(name) : NULL;
+    o->client = NULL;
+    o->owner = NULL;
     o->source = s;
     o->sample_spec = *spec;
 
@@ -77,6 +79,10 @@ char *pa_source_output_list_to_string(struct pa_core *c) {
             o->name,
             o->source->index,
             ss);
+        if (o->owner)
+            pa_strbuf_printf(s, "\towner module: <%u>\n", o->owner->index);
+        if (o->client)
+            pa_strbuf_printf(s, "\tclient: <%u>\n", o->client->index);
     }
     
     return pa_strbuf_tostring_free(s);
index fb60182..dfd076d 100644 (file)
@@ -7,11 +7,15 @@
 #include "sample.h"
 #include "memblockq.h"
 #include "resampler.h"
+#include "module.h"
+#include "client.h"
 
 struct pa_source_output {
     uint32_t index;
 
     char *name;
+    struct pa_module *owner;
+    struct pa_client *client;
     struct pa_source *source;
     struct pa_sample_spec sample_spec;
     
index c2a6518..2082002 100644 (file)
@@ -87,6 +87,8 @@ void pa_strbuf_puts(struct pa_strbuf *sb, const char *t) {
     sb->length += l;
 }
 
+/* The following is based on an example from the GNU libc documentation */
+
 int pa_strbuf_printf(struct pa_strbuf *sb, const char *format, ...) {
     int r, size = 100;
     struct chunk *c = NULL;
index bb97204..ab0c6a7 100644 (file)
@@ -8,7 +8,7 @@ void pa_strbuf_free(struct pa_strbuf *sb);
 char *pa_strbuf_tostring(struct pa_strbuf *sb);
 char *pa_strbuf_tostring_free(struct pa_strbuf *sb);
 
-int pa_strbuf_printf(struct pa_strbuf *sb, const char *format, ...);
+int pa_strbuf_printf(struct pa_strbuf *sb, const char *format, ...) __attribute__ ((format (printf, 2, 3)));;
 void pa_strbuf_puts(struct pa_strbuf *sb, const char *t);
 
 #endif
index 8c647a8..36e69a1 100644 (file)
--- a/src/todo
+++ b/src/todo
@@ -3,10 +3,6 @@
 
 - config parser/cmdline
 
-- description field for all entities
-- client field for sinkinput/sourceoutput
-- module field for all entities
-
 - move more stuff from module-oss[-dma] to liboss-util
 
 - create libstatustext, libsocketutil
index 6fe4bbe..aceb772 100644 (file)
@@ -1,3 +1,5 @@
+#include <stdarg.h>
+#include <stdlib.h>
 #include <signal.h>
 #include <errno.h>
 #include <assert.h>
@@ -230,3 +232,31 @@ void pa_check_for_sigpipe(void) {
     if (sa.sa_handler == SIG_DFL)
         fprintf(stderr, "polypaudio: WARNING: SIGPIPE is not trapped. This might cause malfunction!\n");
 }
+
+/* The following is based on an example from the GNU libc documentation */
+char *pa_sprintf_malloc(const char *format, ...) {
+    int  size = 100;
+    char *c = NULL;
+    
+    assert(format);
+    
+    for(;;) {
+        int r;
+        va_list ap;
+
+        c = realloc(c, size);
+        assert(c);
+
+        va_start(ap, format);
+        r = vsnprintf(c, size, format, ap);
+        va_end(ap);
+        
+        if (r > -1 && r < size)
+            return c;
+
+        if (r > -1)    /* glibc 2.1 */
+            size = r+1; 
+        else           /* glibc 2.0 */
+            size *= 2;
+    }
+}
index dba89ee..c5c6db8 100644 (file)
@@ -23,4 +23,6 @@ int pa_unix_socket_remove_stale(const char *fn);
 
 void pa_check_for_sigpipe(void);
 
+char *pa_sprintf_malloc(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
+
 #endif