mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
Negotiate protocol version between server and client. Will allow smoother
protocol modifications in the future. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@621 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
fbaaf5acb7
commit
bc97b29447
8 changed files with 55 additions and 3 deletions
|
|
@ -354,6 +354,19 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
|
|||
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 @@ static void setup_context(pa_context *c, pa_iochannel *io) {
|
|||
}
|
||||
|
||||
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 @@ const char* pa_context_get_server(pa_context *c) {
|
|||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,12 @@ pa_operation* pa_context_set_name(pa_context *c, const char *name, pa_context_su
|
|||
/** 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
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ enum {
|
|||
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 */
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ static const char* const errortab[PA_ERR_MAX] = {
|
|||
[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) {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ struct pa_context {
|
|||
PA_LLIST_HEAD(pa_stream, streams);
|
||||
PA_LLIST_HEAD(pa_operation, operations);
|
||||
|
||||
uint32_t version;
|
||||
uint32_t ctag;
|
||||
uint32_t csyncid;
|
||||
uint32_t error;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ const char* pa_get_library_version(void);
|
|||
* 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue