From c2f6d090c795bba9ef405908cee06bba79a87f1f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 1 Apr 2009 03:03:20 +0200 Subject: don't access i->sink if it is not set --- src/pulsecore/sink-input.c | 8 +++++--- src/pulsecore/source-output.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index da422428..537f198d 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -845,10 +845,12 @@ pa_usec_t pa_sink_input_set_requested_latency(pa_sink_input *i, pa_usec_t usec) /* If this sink input is not realized yet or we are being moved, * we have to touch the thread info data directly */ - pa_sink_get_latency_range(i->sink, &min_latency, &max_latency); + if (i->sink) { + pa_sink_get_latency_range(i->sink, &min_latency, &max_latency); - if (usec != (pa_usec_t) -1) - usec = PA_CLAMP(usec, min_latency, max_latency); + if (usec != (pa_usec_t) -1) + usec = PA_CLAMP(usec, min_latency, max_latency); + } i->thread_info.requested_sink_latency = usec; diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 550b6571..5c240063 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -542,10 +542,12 @@ pa_usec_t pa_source_output_set_requested_latency(pa_source_output *o, pa_usec_t /* If this source output is not realized yet or is being moved, we * have to touch the thread info data directly */ - pa_source_get_latency_range(o->source, &min_latency, &max_latency); + if (o->source) { + pa_source_get_latency_range(o->source, &min_latency, &max_latency); - if (usec != (pa_usec_t) -1) - usec = PA_CLAMP(usec, min_latency, max_latency); + if (usec != (pa_usec_t) -1) + usec = PA_CLAMP(usec, min_latency, max_latency); + } o->thread_info.requested_source_latency = usec; -- cgit From 75a8d18285f247b8a15dda8a3b545455d564d119 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 1 Apr 2009 03:04:39 +0200 Subject: pass destination source/sink when moving streams so that we can access them --- src/pulsecore/protocol-native.c | 20 ++++++++++---------- src/pulsecore/sink-input.c | 2 +- src/pulsecore/sink-input.h | 10 ++++++---- src/pulsecore/source-output.c | 2 +- src/pulsecore/source-output.h | 10 ++++++---- 5 files changed, 24 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 4f1d9b4b..e11d7a6c 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -213,7 +213,7 @@ enum { static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk); static void sink_input_kill_cb(pa_sink_input *i); static void sink_input_suspend_cb(pa_sink_input *i, pa_bool_t suspend); -static void sink_input_moving_cb(pa_sink_input *i); +static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest); static void sink_input_process_rewind_cb(pa_sink_input *i, size_t nbytes); static void sink_input_update_max_rewind_cb(pa_sink_input *i, size_t nbytes); static void sink_input_update_max_request_cb(pa_sink_input *i, size_t nbytes); @@ -225,7 +225,7 @@ static void playback_stream_request_bytes(struct playback_stream*s); static void source_output_kill_cb(pa_source_output *o); static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk); static void source_output_suspend_cb(pa_source_output *o, pa_bool_t suspend); -static void source_output_moving_cb(pa_source_output *o); +static void source_output_moving_cb(pa_source_output *o, pa_source *dest); static pa_usec_t source_output_get_latency_cb(pa_source_output *o); static void source_output_send_event_cb(pa_source_output *o, const char *event, pa_proplist *pl); @@ -1572,7 +1572,7 @@ static void sink_input_suspend_cb(pa_sink_input *i, pa_bool_t suspend) { } /* Called from main context */ -static void sink_input_moving_cb(pa_sink_input *i) { +static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) { playback_stream *s; pa_tagstruct *t; @@ -1591,9 +1591,9 @@ static void sink_input_moving_cb(pa_sink_input *i) { pa_tagstruct_putu32(t, PA_COMMAND_PLAYBACK_STREAM_MOVED); pa_tagstruct_putu32(t, (uint32_t) -1); /* tag */ pa_tagstruct_putu32(t, s->index); - pa_tagstruct_putu32(t, i->sink->index); - pa_tagstruct_puts(t, i->sink->name); - pa_tagstruct_put_boolean(t, pa_sink_get_state(i->sink) == PA_SINK_SUSPENDED); + pa_tagstruct_putu32(t, dest->index); + pa_tagstruct_puts(t, dest->name); + pa_tagstruct_put_boolean(t, pa_sink_get_state(dest) == PA_SINK_SUSPENDED); if (s->connection->version >= 13) { pa_tagstruct_putu32(t, s->buffer_attr.maxlength); @@ -1685,7 +1685,7 @@ static void source_output_suspend_cb(pa_source_output *o, pa_bool_t suspend) { } /* Called from main context */ -static void source_output_moving_cb(pa_source_output *o) { +static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { record_stream *s; pa_tagstruct *t; @@ -1705,9 +1705,9 @@ static void source_output_moving_cb(pa_source_output *o) { pa_tagstruct_putu32(t, PA_COMMAND_RECORD_STREAM_MOVED); pa_tagstruct_putu32(t, (uint32_t) -1); /* tag */ pa_tagstruct_putu32(t, s->index); - pa_tagstruct_putu32(t, o->source->index); - pa_tagstruct_puts(t, o->source->name); - pa_tagstruct_put_boolean(t, pa_source_get_state(o->source) == PA_SOURCE_SUSPENDED); + pa_tagstruct_putu32(t, dest->index); + pa_tagstruct_puts(t, dest->name); + pa_tagstruct_put_boolean(t, pa_source_get_state(dest) == PA_SOURCE_SUSPENDED); if (s->connection->version >= 13) { pa_tagstruct_putu32(t, s->buffer_attr.maxlength); diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 537f198d..0ed16dd8 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -1167,7 +1167,7 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) { new_resampler = NULL; if (i->moving) - i->moving(i); + i->moving(i, dest); i->sink = dest; i->save_sink = save; diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h index 4e29be67..e7a555df 100644 --- a/src/pulsecore/sink-input.h +++ b/src/pulsecore/sink-input.h @@ -144,13 +144,15 @@ struct pa_sink_input { * disconnected from its sink. Called from IO thread context */ void (*detach) (pa_sink_input *i); /* may be NULL */ - /* If non-NULL called whenever the the sink this input is attached + /* If non-NULL called whenever the sink this input is attached * to suspends or resumes. Called from main context */ void (*suspend) (pa_sink_input *i, pa_bool_t b); /* may be NULL */ - /* If non-NULL called whenever the the sink this input is attached - * to changes. Called from main context */ - void (*moving) (pa_sink_input *i); /* may be NULL */ + /* If non-NULL called whenever the sink input is moved to a new + * sink. Called from main context after the sink input has been + * detached from the old sink and before it has been attached to + * the new sink. */ + void (*moving) (pa_sink_input *i, pa_sink *dest); /* may be NULL */ /* Supposed to unlink and destroy this stream. Called from main * context. */ diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 5c240063..27f24cd1 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -747,7 +747,7 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t new_resampler = NULL; if (o->moving) - o->moving(o); + o->moving(o, dest); o->source = dest; o->save_source = save; diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h index 8d57ded4..9f5f7744 100644 --- a/src/pulsecore/source-output.h +++ b/src/pulsecore/source-output.h @@ -116,13 +116,15 @@ struct pa_source_output { * disconnected from its source. Called from IO thread context */ void (*detach) (pa_source_output *o); /* may be NULL */ - /* If non-NULL called whenever the the source this output is attached + /* If non-NULL called whenever the source this output is attached * to suspends or resumes. Called from main context */ void (*suspend) (pa_source_output *o, pa_bool_t b); /* may be NULL */ - /* If non-NULL called whenever the the source this output is attached - * to changes. Called from main context */ - void (*moving) (pa_source_output *o); /* may be NULL */ + /* If non-NULL called whenever the source output is moved to a new + * source. Called from main context after the stream was detached + * from the old source and before it is attached to the new + * source. */ + void (*moving) (pa_source_output *o, pa_source *dest); /* may be NULL */ /* Supposed to unlink and destroy this stream. Called from main * context. */ -- cgit From dcb24f5068f54f0fd3c30b691b8e3735973d008b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 1 Apr 2009 16:15:27 +0200 Subject: load bt discover module only when installed --- src/daemon/default.pa.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in index 57ccd9f4..fa0683e1 100755 --- a/src/daemon/default.pa.in +++ b/src/daemon/default.pa.in @@ -58,9 +58,9 @@ load-module module-detect .endif ### Automatically load driver modules for Bluetooth hardware -#.ifexists module-bluetooth-discover@PA_SOEXT@ +.ifexists module-bluetooth-discover@PA_SOEXT@ load-module module-bluetooth-discover -#.endif +.endif ### Load several protocols .ifexists module-esound-protocol-unix@PA_SOEXT@ -- cgit From 380e97a596e8e7be122285b005a50635e20d58fc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 1 Apr 2009 21:15:52 +0200 Subject: use machine id instead of hostname to identify local connections --- src/modules/module-x11-publish.c | 8 ++++---- src/pulsecore/parseaddr.c | 10 ++++++---- src/pulsecore/socket-server.c | 22 +++++++++++++--------- 3 files changed, 23 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/modules/module-x11-publish.c b/src/modules/module-x11-publish.c index 7d71067b..83e69d1b 100644 --- a/src/modules/module-x11-publish.c +++ b/src/modules/module-x11-publish.c @@ -136,7 +136,7 @@ static void x11_kill_cb(pa_x11_wrapper *w, void *userdata) { int pa__init(pa_module*m) { struct userdata *u; pa_modargs *ma = NULL; - char hn[256], un[128]; + char *mid; char hx[PA_NATIVE_COOKIE_LENGTH*2+1]; const char *t; @@ -164,10 +164,10 @@ int pa__init(pa_module*m) { if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL)))) goto fail; - if (!pa_get_fqdn(hn, sizeof(hn)) || !pa_get_user_name(un, sizeof(un))) - goto fail; + mid = pa_machine_id(); + u->id = pa_sprintf_malloc("%lu@%s/%lu", (unsigned long) getuid(), mid, (unsigned long) getpid()); + pa_xfree(mid); - u->id = pa_sprintf_malloc("%s@%s/%u", un, hn, (unsigned) getpid()); pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", u->id); publish_servers(u, pa_native_protocol_servers(u->protocol)); diff --git a/src/pulsecore/parseaddr.c b/src/pulsecore/parseaddr.c index c5cd7fe7..5b531220 100644 --- a/src/pulsecore/parseaddr.c +++ b/src/pulsecore/parseaddr.c @@ -87,13 +87,15 @@ int pa_parse_address(const char *name, pa_parsed_address *ret_p) { ret_p->type = PA_PARSED_ADDRESS_TCP_AUTO; if (*name == '{') { - char hn[256], *pfx; - /* The URL starts with a host specification for detecting local connections */ + char *id, *pfx; - if (!pa_get_host_name(hn, sizeof(hn))) + /* The URL starts with a host id for detecting local connections */ + if (!(id = pa_machine_id())) return -1; - pfx = pa_sprintf_malloc("{%s}", hn); + pfx = pa_sprintf_malloc("{%s}", id); + pa_xfree(id); + if (!pa_startswith(name, pfx)) { pa_xfree(pfx); /* Not local */ diff --git a/src/pulsecore/socket-server.c b/src/pulsecore/socket-server.c index 6a4405e3..8147b27f 100644 --- a/src/pulsecore/socket-server.c +++ b/src/pulsecore/socket-server.c @@ -467,11 +467,13 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) { pa_snprintf(c, l, "tcp6:%s:%u", fqdn, (unsigned) ntohs(sa.sin6_port)); } else if (memcmp(&in6addr_loopback, &sa.sin6_addr, sizeof(in6addr_loopback)) == 0) { - char hn[256]; - if (!pa_get_host_name(hn, sizeof(hn))) + char *id; + + if (!(id = pa_machine_id())) return NULL; - pa_snprintf(c, l, "{%s}tcp6:localhost:%u", hn, (unsigned) ntohs(sa.sin6_port)); + pa_snprintf(c, l, "{%s}tcp6:localhost:%u", id, (unsigned) ntohs(sa.sin6_port)); + pa_xfree(id); } else { char ip[INET6_ADDRSTRLEN]; @@ -503,11 +505,13 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) { pa_snprintf(c, l, "tcp:%s:%u", fqdn, (unsigned) ntohs(sa.sin_port)); } else if (sa.sin_addr.s_addr == INADDR_LOOPBACK) { - char hn[256]; - if (!pa_get_host_name(hn, sizeof(hn))) + char *id; + + if (!(id = pa_machine_id())) return NULL; - pa_snprintf(c, l, "{%s}tcp:localhost:%u", hn, (unsigned) ntohs(sa.sin_port)); + pa_snprintf(c, l, "{%s}tcp:localhost:%u", id, (unsigned) ntohs(sa.sin_port)); + pa_xfree(id); } else { char ip[INET_ADDRSTRLEN]; @@ -523,15 +527,15 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) { } case SOCKET_SERVER_UNIX: { - char hn[256]; + char *id; if (!s->filename) return NULL; - if (!pa_get_host_name(hn, sizeof(hn))) + if (!(id = pa_machine_id())) return NULL; - pa_snprintf(c, l, "{%s}unix:%s", hn, s->filename); + pa_snprintf(c, l, "{%s}unix:%s", id, s->filename); return c; } -- cgit