]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/stream.h
Trivial grammar and spelling fixes
[mirror_qemu.git] / include / hw / stream.h
CommitLineData
669b4983
PC
1#ifndef STREAM_H
2#define STREAM_H 1
3
4#include "qemu-common.h"
14cccb61 5#include "qom/object.h"
669b4983
PC
6
7/* stream slave. Used until qdev provides a generic way. */
8#define TYPE_STREAM_SLAVE "stream-slave"
9
10#define STREAM_SLAVE_CLASS(klass) \
11 OBJECT_CLASS_CHECK(StreamSlaveClass, (klass), TYPE_STREAM_SLAVE)
12#define STREAM_SLAVE_GET_CLASS(obj) \
13 OBJECT_GET_CLASS(StreamSlaveClass, (obj), TYPE_STREAM_SLAVE)
14#define STREAM_SLAVE(obj) \
15 INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE)
16
17typedef struct StreamSlave {
18 Object Parent;
19} StreamSlave;
20
35e60bfd
PC
21typedef void (*StreamCanPushNotifyFn)(void *opaque);
22
669b4983
PC
23typedef struct StreamSlaveClass {
24 InterfaceClass parent;
35e60bfd
PC
25 /**
26 * can push - determine if a stream slave is capable of accepting at least
27 * one byte of data. Returns false if cannot accept. If not implemented, the
805a2505 28 * slave is assumed to always be capable of receiving.
35e60bfd 29 * @notify: Optional callback that the slave will call when the slave is
805a2505 30 * capable of receiving again. Only called if false is returned.
35e60bfd
PC
31 * @notify_opaque: opaque data to pass to notify call.
32 */
33 bool (*can_push)(StreamSlave *obj, StreamCanPushNotifyFn notify,
34 void *notify_opaque);
35 /**
36 * push - push data to a Stream slave. The number of bytes pushed is
37 * returned. If the slave short returns, the master must wait before trying
38 * again, the slave may continue to just return 0 waiting for the vm time to
39 * advance. The can_push() function can be used to trap the point in time
805a2505 40 * where the slave is ready to receive again, otherwise polling on a QEMU
35e60bfd
PC
41 * timer will work.
42 * @obj: Stream slave to push to
43 * @buf: Data to write
44 * @len: Maximum number of bytes to write
45 */
42bb9c91 46 size_t (*push)(StreamSlave *obj, unsigned char *buf, size_t len);
669b4983
PC
47} StreamSlaveClass;
48
35e60bfd 49size_t
42bb9c91 50stream_push(StreamSlave *sink, uint8_t *buf, size_t len);
669b4983 51
35e60bfd
PC
52bool
53stream_can_push(StreamSlave *sink, StreamCanPushNotifyFn notify,
54 void *notify_opaque);
55
56
669b4983 57#endif /* STREAM_H */