[pulseaudio-commits] r2503 - in /branches/coling/airtunes/src/modules/rtp: raop_client.c raop_client.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Tue Jun 10 16:55:58 PDT 2008
Author: coling
Date: Wed Jun 11 01:55:58 2008
New Revision: 2503
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2503&root=pulseaudio&view=rev
Log:
Add some new public API functions to connect and flush.
This allows us to reconnect upon disconnection but this has thus far proved unreliable.
We no longer close the socket. We leave this to the module thread to do the closing.
We can also flush the remote buffer now.
Refs #69
Modified:
branches/coling/airtunes/src/modules/rtp/raop_client.c
branches/coling/airtunes/src/modules/rtp/raop_client.h
Modified: branches/coling/airtunes/src/modules/rtp/raop_client.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/airtunes/src/modules/rtp/raop_client.c?rev=2503&root=pulseaudio&r1=2502&r2=2503&view=diff
==============================================================================
--- branches/coling/airtunes/src/modules/rtp/raop_client.c (original)
+++ branches/coling/airtunes/src/modules/rtp/raop_client.c Wed Jun 11 01:55:58 2008
@@ -336,28 +336,66 @@
break;
}
+ case STATE_FLUSH:
+ pa_log_debug("RAOP: FLUSHED");
+ break;
+
case STATE_TEARDOWN:
case STATE_SET_PARAMETER:
- case STATE_FLUSH:
break;
case STATE_DISCONNECTED:
pa_assert(c->closed_callback);
- pa_log_debug("RTSP channel closed");
+ pa_assert(c->rtsp);
+
+ pa_log_debug("RTSP control channel closed");
+ pa_rtsp_client_free(c->rtsp);
c->rtsp = NULL;
if (c->fd > 0) {
- pa_close(c->fd);
+ /* We do not close the fd, we leave it to the closed callback to do that */
c->fd = -1;
}
if (c->sc) {
pa_socket_client_unref(c->sc);
c->sc = NULL;
}
+ pa_xfree(c->sid);
+ c->sid = NULL;
c->closed_callback(c->closed_userdata);
break;
}
}
pa_raop_client* pa_raop_client_new(pa_core *core, const char* host)
+{
+ pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
+
+ pa_assert(core);
+ pa_assert(host);
+
+ c->core = core;
+ c->fd = -1;
+ c->host = pa_xstrdup(host);
+
+ if (pa_raop_connect(c)) {
+ pa_raop_client_free(c);
+ return NULL;
+ }
+ return c;
+}
+
+
+void pa_raop_client_free(pa_raop_client* c)
+{
+ pa_assert(c);
+
+ if (c->rtsp)
+ pa_rtsp_client_free(c->rtsp);
+ pa_xfree(c->host);
+ pa_xfree(c);
+}
+
+
+int pa_raop_connect(pa_raop_client* c)
{
char *sci;
struct {
@@ -365,15 +403,15 @@
uint32_t b;
uint32_t c;
} rand_data;
- pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
-
- pa_assert(core);
- pa_assert(host);
-
- c->core = core;
- c->fd = -1;
- c->host = pa_xstrdup(host);
- c->rtsp = pa_rtsp_client_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
+
+ pa_assert(c);
+
+ if (c->rtsp) {
+ pa_log_debug("Connection already in progress");
+ return 0;
+ }
+
+ c->rtsp = pa_rtsp_client_new(c->core->mainloop, c->host, 5000, "iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
/* Initialise the AES encryption system */
pa_random(c->aes_iv, sizeof(c->aes_iv));
@@ -386,23 +424,18 @@
c->sid = pa_sprintf_malloc("%u", rand_data.a);
sci = pa_sprintf_malloc("%08x%08x",rand_data.b, rand_data.c);
pa_rtsp_add_header(c->rtsp, "Client-Instance", sci);
+ pa_xfree(sci);
pa_rtsp_set_callback(c->rtsp, rtsp_cb, c);
- if (pa_rtsp_connect(c->rtsp, c->core->mainloop, host, 5000)) {
- pa_rtsp_client_free(c->rtsp);
- return NULL;
- }
- return c;
-}
-
-
-void pa_raop_client_free(pa_raop_client* c)
-{
- pa_assert(c);
-
- if (c->rtsp)
- pa_rtsp_client_free(c->rtsp);
- pa_xfree(c->host);
- pa_xfree(c);
+ return pa_rtsp_connect(c->rtsp);
+}
+
+
+int pa_raop_flush(pa_raop_client* c)
+{
+ pa_assert(c);
+
+ pa_rtsp_flush(c->rtsp, c->seq, c->rtptime);
+ return 0;
}
Modified: branches/coling/airtunes/src/modules/rtp/raop_client.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/airtunes/src/modules/rtp/raop_client.h?rev=2503&root=pulseaudio&r1=2502&r2=2503&view=diff
==============================================================================
--- branches/coling/airtunes/src/modules/rtp/raop_client.h (original)
+++ branches/coling/airtunes/src/modules/rtp/raop_client.h Wed Jun 11 01:55:58 2008
@@ -33,6 +33,9 @@
pa_raop_client* pa_raop_client_new(pa_core *core, const char* host);
void pa_raop_client_free(pa_raop_client* c);
+int pa_raop_connect(pa_raop_client* c);
+int pa_raop_flush(pa_raop_client* c);
+
int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded);
typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);
More information about the pulseaudio-commits
mailing list