new libspice api: alloc, initi and free spice server instances.

The implementation can't handle multiple spice server instances at the
same time right now.  The API allows this though, so if we fixup the
implementation some day we don't have to change the API.
This commit is contained in:
Gerd Hoffmann 2010-03-09 14:14:02 +01:00 committed by Alexander Larsson
parent 34e6a0a0d5
commit 232dbd8710
2 changed files with 40 additions and 6 deletions

View File

@ -5388,7 +5388,7 @@ static void init_vd_agent_resources()
const char *version_string = VERSION;
void __attribute__ ((visibility ("default"))) spice_init(CoreInterface *core_interface)
static void do_spice_init(CoreInterface *core_interface)
{
VDInterface *interface = NULL;
@ -5405,10 +5405,6 @@ void __attribute__ ((visibility ("default"))) spice_init(CoreInterface *core_int
if (core_interface->base.minor_version > 1) {
log_proc = core->log;
}
if (!(reds = malloc(sizeof(RedsState)))) {
red_error("reds alloc failed");
}
memset(reds, 0, sizeof(RedsState));
reds->listen_socket = -1;
reds->secure_listen_socket = -1;
reds->peer = NULL;
@ -5476,3 +5472,35 @@ void __attribute__ ((visibility ("default"))) spice_init(CoreInterface *core_int
atexit(reds_exit);
}
void __attribute__ ((visibility ("default"))) spice_init(CoreInterface *core_interface)
{
spice_server_new();
do_spice_init(core_interface);
}
/* new interface */
SpiceServer *spice_server_new(void)
{
/* we can't handle multiple instances (yet) */
ASSERT(reds == NULL);
if (!(reds = malloc(sizeof(RedsState)))) {
red_error("reds alloc failed");
}
memset(reds, 0, sizeof(RedsState));
return reds;
}
int spice_server_init(SpiceServer *s, CoreInterface *core)
{
ASSERT(reds == s);
do_spice_init(core);
red_dispatcher_add_renderer("cairo");
return 0;
}
void spice_server_destroy(SpiceServer *s)
{
ASSERT(reds == s);
reds_exit();
}

View File

@ -20,10 +20,16 @@
#include "vd_interface.h"
/* old interface */
extern const char *spice_usage_str[];
int spice_parse_args(const char *args);
void spice_init(CoreInterface *core);
#endif
/* new interface */
typedef struct RedsState SpiceServer;
SpiceServer *spice_server_new(void);
int spice_server_init(SpiceServer *s, CoreInterface *core);
void spice_server_destroy(SpiceServer *s);
#endif