Commit 20641a12 authored by Colin Guthrie's avatar Colin Guthrie
Browse files

rtp: Factor out direct io writing and use ioline instead.

This is how things should have worked orinally, but I obviously misunderstood things a bit.
This seems to prevent the random hangups that were happening previously :)
parent 36714ea5
...@@ -60,7 +60,6 @@ struct pa_rtsp_client { ...@@ -60,7 +60,6 @@ struct pa_rtsp_client {
uint16_t port; uint16_t port;
pa_socket_client *sc; pa_socket_client *sc;
pa_iochannel *io;
pa_ioline *ioline; pa_ioline *ioline;
pa_rtsp_cb_t callback; pa_rtsp_cb_t callback;
...@@ -111,10 +110,8 @@ void pa_rtsp_client_free(pa_rtsp_client* c) { ...@@ -111,10 +110,8 @@ void pa_rtsp_client_free(pa_rtsp_client* c) {
if (c->sc) if (c->sc)
pa_socket_client_unref(c->sc); pa_socket_client_unref(c->sc);
if (c->ioline)
pa_ioline_close(c->ioline); pa_rtsp_disconnect(c);
else if (c->io)
pa_iochannel_free(c->io);
pa_xfree(c->hostname); pa_xfree(c->hostname);
pa_xfree(c->url); pa_xfree(c->url);
...@@ -187,7 +184,6 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) { ...@@ -187,7 +184,6 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
if (!s) { if (!s) {
/* Keep the ioline/iochannel open as they will be freed automatically */ /* Keep the ioline/iochannel open as they will be freed automatically */
c->ioline = NULL; c->ioline = NULL;
c->io = NULL;
c->callback(c, STATE_DISCONNECTED, NULL, c->userdata); c->callback(c, STATE_DISCONNECTED, NULL, c->userdata);
return; return;
} }
...@@ -303,8 +299,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata ...@@ -303,8 +299,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
pa_log("Connection failed: %s", pa_cstrerror(errno)); pa_log("Connection failed: %s", pa_cstrerror(errno));
return; return;
} }
pa_assert(!c->io); pa_assert(!c->ioline);
c->io = io;
c->ioline = pa_ioline_new(io); c->ioline = pa_ioline_new(io);
pa_ioline_set_callback(c->ioline, line_callback, c); pa_ioline_set_callback(c->ioline, line_callback, c);
...@@ -360,9 +355,6 @@ void pa_rtsp_disconnect(pa_rtsp_client *c) { ...@@ -360,9 +355,6 @@ void pa_rtsp_disconnect(pa_rtsp_client *c) {
if (c->ioline) if (c->ioline)
pa_ioline_close(c->ioline); pa_ioline_close(c->ioline);
else if (c->io)
pa_iochannel_free(c->io);
c->io = NULL;
c->ioline = NULL; c->ioline = NULL;
} }
...@@ -408,13 +400,11 @@ static int rtsp_exec(pa_rtsp_client* c, const char* cmd, ...@@ -408,13 +400,11 @@ static int rtsp_exec(pa_rtsp_client* c, const char* cmd,
pa_headerlist* headers) { pa_headerlist* headers) {
pa_strbuf* buf; pa_strbuf* buf;
char* hdrs; char* hdrs;
ssize_t l;
pa_assert(c); pa_assert(c);
pa_assert(c->url); pa_assert(c->url);
pa_assert(cmd);
if (!cmd) pa_assert(c->ioline);
return -1;
pa_log_debug("Sending command: %s", cmd); pa_log_debug("Sending command: %s", cmd);
...@@ -453,7 +443,7 @@ static int rtsp_exec(pa_rtsp_client* c, const char* cmd, ...@@ -453,7 +443,7 @@ static int rtsp_exec(pa_rtsp_client* c, const char* cmd,
hdrs = pa_strbuf_tostring_free(buf); hdrs = pa_strbuf_tostring_free(buf);
/*pa_log_debug("Submitting request:"); /*pa_log_debug("Submitting request:");
pa_log_debug(hdrs);*/ pa_log_debug(hdrs);*/
l = pa_iochannel_write(c->io, hdrs, strlen(hdrs)); pa_ioline_puts(c->ioline, hdrs);
pa_xfree(hdrs); pa_xfree(hdrs);
/* FIXME: this is broken, not necessarily all bytes are written */ /* FIXME: this is broken, not necessarily all bytes are written */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment