tunnel: don't assert on misaligned reads, closes #597 and rhbz #496310

This commit is contained in:
Lennart Poettering 2009-07-31 00:50:19 +02:00
parent 4f5e2b745e
commit c14f6c179f

View file

@ -55,6 +55,7 @@
#include <pulsecore/core-error.h>
#include <pulsecore/proplist-util.h>
#include <pulsecore/auth-cookie.h>
#include <pulsecore/mcalign.h>
#ifdef TUNNEL_SINK
#include "module-tunnel-sink-symdef.h"
@ -194,6 +195,7 @@ struct userdata {
#else
char *source_name;
pa_source *source;
pa_mcalign *mcalign;
#endif
pa_auth_cookie *auth_cookie;
@ -614,14 +616,23 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
return 0;
}
case SOURCE_MESSAGE_POST:
case SOURCE_MESSAGE_POST: {
pa_memchunk c;
if (PA_SOURCE_IS_OPENED(u->source->thread_info.state))
pa_source_post(u->source, chunk);
pa_mcalign_push(u->mcalign, chunk);
u->counter += (int64_t) chunk->length;
while (pa_mcalign_pop(u->mcalign, &c) >= 0) {
if (PA_SOURCE_IS_OPENED(u->source->thread_info.state))
pa_source_post(u->source, &c);
pa_memblock_unref(c.memblock);
u->counter += (int64_t) c.length;
}
return 0;
}
case SOURCE_MESSAGE_REMOTE_SUSPEND:
@ -1937,6 +1948,8 @@ int pa__init(pa_module*m) {
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
u->mcalign = pa_mcalign_new(pa_frame_size(&u->source->sample_spec));
#endif
pa_xfree(dn);
@ -2030,6 +2043,11 @@ void pa__done(pa_module*m) {
if (u->time_event)
u->core->mainloop->time_free(u->time_event);
#ifndef TUNNEL_SINK
if (u->mcalign)
pa_mcalign_free(u->mcalign);
#endif
#ifdef TUNNEL_SINK
pa_xfree(u->sink_name);
#else