summaryrefslogtreecommitdiffstats
path: root/polyp/polyplib-context.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-11-17 00:05:25 +0000
committerLennart Poettering <lennart@poettering.net>2004-11-17 00:05:25 +0000
commit0a2bbc528b7865b08139155e0316738a717c4e42 (patch)
tree99166840892bb315fe109436093876386adac51d /polyp/polyplib-context.c
parentf5f6605254d17c5bc06b8c1ec98e8ee09009af10 (diff)
* some commenting work
* add new field "read_only" to memory blocks * add new API function pa_context_get_server() * filter capture data through mcalign on client * make module-tunnel use pa_socket_client_new_string() instead of using pa_resolve_server() directly. * remove pa_resolve_server() * remove debug.h and replace it by a macro definition on the gcc command line * some strbuf cleanups * small fixes in pa_stream for cleanup when server dies * new CLI command "load-sample-dir-lazy" * send FQDN as part of server info * rework mcalign, this time with memory block merging * fix iochannel cleanup when connection dies * check getaddrinfo() results git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@286 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/polyplib-context.c')
-rw-r--r--polyp/polyplib-context.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/polyp/polyplib-context.c b/polyp/polyplib-context.c
index b15dd8e7..15ef60b9 100644
--- a/polyp/polyplib-context.c
+++ b/polyp/polyplib-context.c
@@ -56,8 +56,6 @@
#define AUTOSPAWN_LOCK "autospawn.lock"
-
-
static const struct pa_pdispatch_command command_table[PA_COMMAND_MAX] = {
[PA_COMMAND_REQUEST] = { pa_command_request },
[PA_COMMAND_PLAYBACK_STREAM_KILLED] = { pa_command_stream_killed },
@@ -72,7 +70,6 @@ static void unlock_autospawn_lock_file(struct pa_context *c) {
pa_unlock_lockfile(c->autospawn_lock_fd);
c->autospawn_lock_fd = -1;
}
-
}
struct pa_context *pa_context_new(struct pa_mainloop_api *mainloop, const char *name) {
@@ -106,6 +103,7 @@ struct pa_context *pa_context_new(struct pa_mainloop_api *mainloop, const char *
c->memblock_stat = pa_memblock_stat_new();
c->local = -1;
c->server_list = NULL;
+ c->server = NULL;
c->autospawn_lock_fd = -1;
memset(&c->spawn_api, 0, sizeof(c->spawn_api));
c->do_autospawn = 0;
@@ -155,6 +153,7 @@ static void context_free(struct pa_context *c) {
pa_strlist_free(c->server_list);
pa_xfree(c->name);
+ pa_xfree(c->server);
pa_xfree(c);
}
@@ -246,9 +245,20 @@ static void pstream_memblock_callback(struct pa_pstream *p, uint32_t channel, ui
pa_context_ref(c);
if ((s = pa_dynarray_get(c->record_streams, channel))) {
- if (s->read_callback) {
- s->read_callback(s, (uint8_t*) chunk->memblock->data + chunk->index, chunk->length, s->read_userdata);
- s->counter += chunk->length;
+ pa_mcalign_push(s->mcalign, chunk);
+
+ for (;;) {
+ struct pa_memchunk t;
+
+ if (pa_mcalign_pop(s->mcalign, &t) < 0)
+ break;
+
+ if (s->read_callback) {
+ s->read_callback(s, (uint8_t*) t.memblock->data + t.index, t.length, s->read_userdata);
+ s->counter += chunk->length;
+ }
+
+ pa_memblock_unref(t.memblock);
}
}
@@ -496,6 +506,9 @@ static int try_next_connection(struct pa_context *c) {
}
/* pa_log(__FILE__": Trying to connect to %s...\n", u); */
+
+ pa_xfree(c->server);
+ c->server = pa_xstrdup(u);
if (!(c->client = pa_socket_client_new_string(c->mainloop, u, PA_NATIVE_DEFAULT_PORT)))
continue;
@@ -811,3 +824,15 @@ const char* pa_get_library_version(void) {
return PACKAGE_VERSION;
}
+const char* pa_context_get_server(struct pa_context *c) {
+
+ if (!c->server)
+ return NULL;
+
+ if (*c->server == '{') {
+ char *e = strchr(c->server+1, '}');
+ return e ? e+1 : c->server;
+ }
+
+ return c->server;
+}