contrib/gitdm: Add Rivos Inc to the domain map
[qemu/ar7.git] / include / hw / stream.h
blobf166facb090a7853992be6bbacba037f24bd7183
1 #ifndef STREAM_H
2 #define STREAM_H
4 #include "qom/object.h"
6 #define TYPE_STREAM_SINK "stream-sink"
8 typedef struct StreamSinkClass StreamSinkClass;
9 DECLARE_CLASS_CHECKERS(StreamSinkClass, STREAM_SINK,
10 TYPE_STREAM_SINK)
11 #define STREAM_SINK(obj) \
12 INTERFACE_CHECK(StreamSink, (obj), TYPE_STREAM_SINK)
14 typedef struct StreamSink StreamSink;
16 typedef void (*StreamCanPushNotifyFn)(void *opaque);
18 struct StreamSinkClass {
19 InterfaceClass parent;
20 /**
21 * can push - determine if a stream sink is capable of accepting at least
22 * one byte of data. Returns false if cannot accept. If not implemented, the
23 * sink is assumed to always be capable of receiving.
24 * @notify: Optional callback that the sink will call when the sink is
25 * capable of receiving again. Only called if false is returned.
26 * @notify_opaque: opaque data to pass to notify call.
28 bool (*can_push)(StreamSink *obj, StreamCanPushNotifyFn notify,
29 void *notify_opaque);
30 /**
31 * push - push data to a Stream sink. The number of bytes pushed is
32 * returned. If the sink short returns, the master must wait before trying
33 * again, the sink may continue to just return 0 waiting for the vm time to
34 * advance. The can_push() function can be used to trap the point in time
35 * where the sink is ready to receive again, otherwise polling on a QEMU
36 * timer will work.
37 * @obj: Stream sink to push to
38 * @buf: Data to write
39 * @len: Maximum number of bytes to write
40 * @eop: End of packet flag
42 size_t (*push)(StreamSink *obj, unsigned char *buf, size_t len, bool eop);
45 size_t
46 stream_push(StreamSink *sink, uint8_t *buf, size_t len, bool eop);
48 bool
49 stream_can_push(StreamSink *sink, StreamCanPushNotifyFn notify,
50 void *notify_opaque);
53 #endif /* STREAM_H */