[polypaudio-commits] r621 - in /trunk: configure.ac src/polyp/context.c src/polyp/context.h src/polyp/def.h src/polyp/error.c src/polyp/internal.h src/polyp/version.h.in src/polypcore/protocol-native.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Thu Mar 2 13:56:17 PST 2006
Author: ossman
Date: Thu Mar 2 22:56:15 2006
New Revision: 621
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=621&root=polypaudio&view=rev
Log:
Negotiate protocol version between server and client. Will allow smoother
protocol modifications in the future.
Modified:
trunk/configure.ac
trunk/src/polyp/context.c
trunk/src/polyp/context.h
trunk/src/polyp/def.h
trunk/src/polyp/error.c
trunk/src/polyp/internal.h
trunk/src/polyp/version.h.in
trunk/src/polypcore/protocol-native.c
Modified: trunk/configure.ac
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/configure.ac?rev=621&root=polypaudio&r1=620&r2=621&view=diff
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Thu Mar 2 22:56:15 2006
@@ -29,6 +29,7 @@
AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/polypaudio/])
AC_SUBST(PA_API_VERSION, 8)
+AC_SUBST(PA_PROTOCOL_VERSION, 8)
if type -p stow > /dev/null && test -d /usr/local/stow ; then
AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
Modified: trunk/src/polyp/context.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/context.c?rev=621&root=polypaudio&r1=620&r2=621&view=diff
==============================================================================
--- trunk/src/polyp/context.c (original)
+++ trunk/src/polyp/context.c Thu Mar 2 22:56:15 2006
@@ -354,6 +354,19 @@
switch(c->state) {
case PA_CONTEXT_AUTHORIZING: {
pa_tagstruct *reply;
+
+ if (pa_tagstruct_getu32(t, &c->version) < 0 ||
+ !pa_tagstruct_eof(t)) {
+ pa_context_fail(c, PA_ERR_PROTOCOL);
+ goto finish;
+ }
+
+ /* Minimum supported version */
+ if (c->version < 8) {
+ pa_context_fail(c, PA_ERR_VERSION);
+ goto finish;
+ }
+
reply = pa_tagstruct_command(c, PA_COMMAND_SET_CLIENT_NAME, &tag);
pa_tagstruct_puts(reply, c->name);
pa_pstream_send_tagstruct(c->pstream, reply);
@@ -400,6 +413,7 @@
}
t = pa_tagstruct_command(c, PA_COMMAND_AUTH, &tag);
+ pa_tagstruct_putu32(t, PA_PROTOCOL_VERSION);
pa_tagstruct_put_arbitrary(t, c->conf->cookie, sizeof(c->conf->cookie));
pa_pstream_send_tagstruct_with_creds(c->pstream, t, 1);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, c);
@@ -936,6 +950,17 @@
return c->server;
}
+uint32_t pa_context_get_protocol_version(pa_context *c) {
+ return PA_PROTOCOL_VERSION;
+}
+
+uint32_t pa_context_get_server_protocol_version(pa_context *c) {
+ assert(c);
+ assert(c->ref >= 1);
+
+ return c->version;
+}
+
pa_tagstruct *pa_tagstruct_command(pa_context *c, uint32_t command, uint32_t *tag) {
pa_tagstruct *t;
Modified: trunk/src/polyp/context.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/context.h?rev=621&root=polypaudio&r1=620&r2=621&view=diff
==============================================================================
--- trunk/src/polyp/context.h (original)
+++ trunk/src/polyp/context.h Thu Mar 2 22:56:15 2006
@@ -115,6 +115,12 @@
/** Return the server name this context is connected to. \since 0.7 */
const char* pa_context_get_server(pa_context *c);
+/** Return the protocol version of the library. \since 0.8 */
+uint32_t pa_context_get_protocol_version(pa_context *c);
+
+/** Return the protocol version of the connected server. \since 0.8 */
+uint32_t pa_context_get_server_protocol_version(pa_context *c);
+
PA_C_DECL_END
#endif
Modified: trunk/src/polyp/def.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/def.h?rev=621&root=polypaudio&r1=620&r2=621&view=diff
==============================================================================
--- trunk/src/polyp/def.h (original)
+++ trunk/src/polyp/def.h Thu Mar 2 22:56:15 2006
@@ -125,6 +125,7 @@
PA_ERR_MODINITFAILED, /**< Module initialization failed */
PA_ERR_BADSTATE, /**< Bad state */
PA_ERR_NODATA, /**< No data */
+ PA_ERR_VERSION, /**< Incompatible protocol version \since 0.8 */
PA_ERR_MAX /**< Not really an error but the first invalid error code */
};
Modified: trunk/src/polyp/error.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/error.c?rev=621&root=polypaudio&r1=620&r2=621&view=diff
==============================================================================
--- trunk/src/polyp/error.c (original)
+++ trunk/src/polyp/error.c Thu Mar 2 22:56:15 2006
@@ -48,6 +48,7 @@
[PA_ERR_MODINITFAILED] = "Module initalization failed",
[PA_ERR_BADSTATE] = "Bad state",
[PA_ERR_NODATA] = "No data",
+ [PA_ERR_VERSION] = "Incompatible protocol version",
};
const char*pa_strerror(int error) {
Modified: trunk/src/polyp/internal.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/internal.h?rev=621&root=polypaudio&r1=620&r2=621&view=diff
==============================================================================
--- trunk/src/polyp/internal.h (original)
+++ trunk/src/polyp/internal.h Thu Mar 2 22:56:15 2006
@@ -57,6 +57,7 @@
PA_LLIST_HEAD(pa_stream, streams);
PA_LLIST_HEAD(pa_operation, operations);
+ uint32_t version;
uint32_t ctag;
uint32_t csyncid;
uint32_t error;
Modified: trunk/src/polyp/version.h.in
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/version.h.in?rev=621&root=polypaudio&r1=620&r2=621&view=diff
==============================================================================
--- trunk/src/polyp/version.h.in (original)
+++ trunk/src/polyp/version.h.in Thu Mar 2 22:56:15 2006
@@ -44,6 +44,10 @@
* PA_API_VERSION undefined. */
#define PA_API_VERSION @PA_API_VERSION@
+/** The current protocol version. Version 8 relates to polypaudio 0.8.
+ * \since 0.8 */
+#define PA_PROTOCOL_VERSION @PA_PROTOCOL_VERSION@
+
PA_C_DECL_END
#endif
Modified: trunk/src/polypcore/protocol-native.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/protocol-native.c?rev=621&root=polypaudio&r1=620&r2=621&view=diff
==============================================================================
--- trunk/src/polypcore/protocol-native.c (original)
+++ trunk/src/polypcore/protocol-native.c Thu Mar 2 22:56:15 2006
@@ -28,6 +28,8 @@
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
+
+#include <polyp/version.h>
#include <polypcore/native-common.h>
#include <polypcore/packet.h>
@@ -111,6 +113,7 @@
struct connection {
int authorized;
+ uint32_t version;
pa_protocol_native *protocol;
pa_client *client;
pa_pstream *pstream;
@@ -866,11 +869,19 @@
static void command_auth(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
const void*cookie;
- assert(c && t);
-
- if (pa_tagstruct_get_arbitrary(t, &cookie, PA_NATIVE_COOKIE_LENGTH) < 0 ||
- !pa_tagstruct_eof(t)) {
- protocol_error(c);
+ pa_tagstruct *reply;
+ assert(c && t);
+
+ if (pa_tagstruct_getu32(t, &c->version) < 0 ||
+ pa_tagstruct_get_arbitrary(t, &cookie, PA_NATIVE_COOKIE_LENGTH) < 0 ||
+ !pa_tagstruct_eof(t)) {
+ protocol_error(c);
+ return;
+ }
+
+ /* Minimum supported version */
+ if (c->version < 8) {
+ pa_pstream_send_error(c->pstream, tag, PA_ERR_VERSION);
return;
}
@@ -915,8 +926,10 @@
c->auth_timeout_event = NULL;
}
}
-
- pa_pstream_send_simple_ack(c->pstream, tag);
+
+ reply = reply_new(tag);
+ pa_tagstruct_putu32(reply, PA_PROTOCOL_VERSION);
+ pa_pstream_send_tagstruct(c->pstream, reply);
}
static void command_set_client_name(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
More information about the pulseaudio-commits
mailing list