mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-05 03:44:46 +00:00
char-device: Remove RedCharDeviceClass::{un, }ref_msg_to_client
Now that client messages are always RedPipeItem, we don't need virtual functions to know how to ref/unref them.
This commit is contained in:
parent
021d960471
commit
48e85a11c7
@ -110,24 +110,6 @@ red_char_device_read_one_msg_from_device(RedCharDevice *dev)
|
||||
return klass->read_one_msg_from_device(dev->priv->sin, dev->priv->opaque);
|
||||
}
|
||||
|
||||
static PipeItem *
|
||||
red_char_device_ref_msg_to_client(RedCharDevice *dev,
|
||||
PipeItem *msg)
|
||||
{
|
||||
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
|
||||
|
||||
return klass->ref_msg_to_client(msg, dev->priv->opaque);
|
||||
}
|
||||
|
||||
static void
|
||||
red_char_device_unref_msg_to_client(RedCharDevice *dev,
|
||||
PipeItem *msg)
|
||||
{
|
||||
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
|
||||
|
||||
klass->unref_msg_to_client(msg, dev->priv->opaque);
|
||||
}
|
||||
|
||||
static void
|
||||
red_char_device_send_msg_to_client(RedCharDevice *dev,
|
||||
PipeItem *msg,
|
||||
@ -215,7 +197,7 @@ static void red_char_device_client_send_queue_free(RedCharDevice *dev,
|
||||
link);
|
||||
|
||||
ring_remove(item);
|
||||
red_char_device_unref_msg_to_client(dev, msg_item->msg);
|
||||
pipe_item_unref(msg_item->msg);
|
||||
free(msg_item);
|
||||
}
|
||||
dev_client->num_send_tokens += dev_client->send_queue_size;
|
||||
@ -331,7 +313,7 @@ static void red_char_device_add_msg_to_client_queue(RedCharDeviceClient *dev_cli
|
||||
}
|
||||
|
||||
msg_item = spice_new0(RedCharDeviceMsgToClientItem, 1);
|
||||
msg_item->msg = red_char_device_ref_msg_to_client(dev, msg);
|
||||
msg_item->msg = pipe_item_ref(msg);
|
||||
ring_add(&dev_client->send_queue, &msg_item->link);
|
||||
dev_client->send_queue_size++;
|
||||
if (!dev_client->wait_for_tokens_started) {
|
||||
@ -401,7 +383,7 @@ static int red_char_device_read_from_device(RedCharDevice *dev)
|
||||
}
|
||||
did_read = TRUE;
|
||||
red_char_device_send_msg_to_clients(dev, msg);
|
||||
red_char_device_unref_msg_to_client(dev, msg);
|
||||
pipe_item_unref(msg);
|
||||
max_send_tokens--;
|
||||
}
|
||||
dev->priv->during_read_from_device = 0;
|
||||
@ -426,7 +408,7 @@ static void red_char_device_client_send_queue_push(RedCharDeviceClient *dev_clie
|
||||
red_char_device_send_msg_to_client(dev_client->dev,
|
||||
msg_item->msg,
|
||||
dev_client->client);
|
||||
red_char_device_unref_msg_to_client(dev_client->dev, msg_item->msg);
|
||||
pipe_item_unref(msg_item->msg);
|
||||
dev_client->send_queue_size--;
|
||||
free(msg_item);
|
||||
}
|
||||
|
||||
@ -58,12 +58,10 @@ struct RedCharDeviceClass
|
||||
* or till the reading fails */
|
||||
PipeItem* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin,
|
||||
void *opaque);
|
||||
PipeItem* (*ref_msg_to_client)(PipeItem *msg, void *opaque);
|
||||
void (*unref_msg_to_client)(PipeItem *msg, void *opaque);
|
||||
|
||||
/* after this call, the message is unreferenced */
|
||||
void (*send_msg_to_client)(PipeItem *msg,
|
||||
RedClient *client,
|
||||
void *opaque); /* after this call, the message is unreferenced */
|
||||
void *opaque);
|
||||
|
||||
/* The cb is called when a predefined number of write buffers were consumed by the
|
||||
* device */
|
||||
|
||||
@ -855,18 +855,6 @@ static PipeItem *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PipeItem *vdi_port_ref_msg_to_client(PipeItem *msg,
|
||||
void *opaque)
|
||||
{
|
||||
return pipe_item_ref(msg);
|
||||
}
|
||||
|
||||
static void vdi_port_unref_msg_to_client(PipeItem *msg,
|
||||
void *opaque)
|
||||
{
|
||||
pipe_item_unref(msg);
|
||||
}
|
||||
|
||||
/* after calling this, we unref the message, and the ref is in the instance side */
|
||||
static void vdi_port_send_msg_to_client(PipeItem *msg,
|
||||
RedClient *client,
|
||||
@ -4331,8 +4319,6 @@ red_char_device_vdi_port_class_init(RedCharDeviceVDIPortClass *klass)
|
||||
object_class->constructed = red_char_device_vdi_port_constructed;
|
||||
|
||||
char_dev_class->read_one_msg_from_device = vdi_port_read_one_msg_from_device;
|
||||
char_dev_class->ref_msg_to_client = vdi_port_ref_msg_to_client;
|
||||
char_dev_class->unref_msg_to_client = vdi_port_unref_msg_to_client;
|
||||
char_dev_class->send_msg_to_client = vdi_port_send_msg_to_client;
|
||||
char_dev_class->send_tokens_to_client = vdi_port_send_tokens_to_client;
|
||||
char_dev_class->remove_client = vdi_port_remove_client;
|
||||
|
||||
@ -166,18 +166,6 @@ static PipeItem *smartcard_read_msg_from_device(SpiceCharDeviceInstance *sin,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PipeItem *smartcard_ref_msg_to_client(PipeItem *msg,
|
||||
void *opaque)
|
||||
{
|
||||
return pipe_item_ref(msg);
|
||||
}
|
||||
|
||||
static void smartcard_unref_msg_to_client(PipeItem *msg,
|
||||
void *opaque)
|
||||
{
|
||||
pipe_item_ref(msg);
|
||||
}
|
||||
|
||||
static void smartcard_send_msg_to_client(PipeItem *msg,
|
||||
RedClient *client,
|
||||
void *opaque)
|
||||
@ -857,8 +845,6 @@ red_char_device_smartcard_class_init(RedCharDeviceSmartcardClass *klass)
|
||||
object_class->finalize = red_char_device_smartcard_finalize;
|
||||
|
||||
char_dev_class->read_one_msg_from_device = smartcard_read_msg_from_device;
|
||||
char_dev_class->ref_msg_to_client = smartcard_ref_msg_to_client;
|
||||
char_dev_class->unref_msg_to_client = smartcard_unref_msg_to_client;
|
||||
char_dev_class->send_msg_to_client = smartcard_send_msg_to_client;
|
||||
char_dev_class->send_tokens_to_client = smartcard_send_tokens_to_client;
|
||||
char_dev_class->remove_client = smartcard_remove_client;
|
||||
|
||||
@ -105,20 +105,8 @@ enum {
|
||||
PIPE_ITEM_TYPE_PORT_EVENT,
|
||||
};
|
||||
|
||||
static PipeItem *spicevmc_chardev_ref_msg_to_client(PipeItem *msg,
|
||||
void *opaque)
|
||||
{
|
||||
return pipe_item_ref(msg);
|
||||
}
|
||||
|
||||
static void spicevmc_chardev_unref_msg_to_client(PipeItem *msg,
|
||||
void *opaque)
|
||||
{
|
||||
pipe_item_unref(msg);
|
||||
}
|
||||
|
||||
static PipeItem *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *sin,
|
||||
void *opaque)
|
||||
void *opaque)
|
||||
{
|
||||
SpiceVmcState *state = opaque;
|
||||
SpiceCharDeviceInterface *sif;
|
||||
@ -599,8 +587,6 @@ red_char_device_spicevmc_class_init(RedCharDeviceSpiceVmcClass *klass)
|
||||
RedCharDeviceClass *char_dev_class = RED_CHAR_DEVICE_CLASS(klass);
|
||||
|
||||
char_dev_class->read_one_msg_from_device = spicevmc_chardev_read_msg_from_dev;
|
||||
char_dev_class->ref_msg_to_client = spicevmc_chardev_ref_msg_to_client;
|
||||
char_dev_class->unref_msg_to_client = spicevmc_chardev_unref_msg_to_client;
|
||||
char_dev_class->send_msg_to_client = spicevmc_chardev_send_msg_to_client;
|
||||
char_dev_class->send_tokens_to_client = spicevmc_char_dev_send_tokens_to_client;
|
||||
char_dev_class->remove_client = spicevmc_char_dev_remove_client;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user