mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-12 23:23:55 +00:00
char-device: Add a read method to simplify reading data
Avoid to pass throught SpiceCharDeviceInterface. When data is read from device the device get marked as active. This is coherent with what is done in red_char_device_read_from_device. Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Acked-by: Julien Ropé <jrope@gmail.com>
This commit is contained in:
parent
3c8037d39f
commit
66dacecda9
@ -947,3 +947,14 @@ RedCharDevice::RedCharDevice(RedsState *reds, SpiceCharDeviceInstance *sin,
|
||||
|
||||
g_queue_init(&priv->write_queue);
|
||||
}
|
||||
|
||||
int RedCharDevice::read(uint8_t *buf, int len)
|
||||
{
|
||||
auto sif = spice_char_device_get_interface(priv->sin);
|
||||
|
||||
int ret = sif->read(priv->sin, buf, len);
|
||||
if (ret > 0) {
|
||||
priv->active = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -174,6 +174,11 @@ public:
|
||||
|
||||
SpiceCharDeviceInstance *get_device_instance();
|
||||
|
||||
/**
|
||||
* Read data from device
|
||||
*/
|
||||
int read(uint8_t *buf, int len);
|
||||
|
||||
red::unique_link<RedCharDevicePrivate> priv;
|
||||
|
||||
//protected:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user