Defined in carb/audio/AudioStreamerUtils.h

class EventListener : private omni::extras::DataListener

A listener for data from an EventStreamer.

This allows an easy way to bind the necessary callbacks to receive audio data from the stream.

Public Functions

inline EventListener(carb::events::IEventStreamPtr p, std::function<void(const carb::audio::SoundFormat *fmt)> open, std::function<void(const void *data, size_t bytes)> writeData, std::function<void()> close)



All that needs to be done to start receiving data is to create this class. Once the class is created, the callbacks will start being sent. Note that you must create the listener before the audio stream opens, otherwise the open event will never be received, so you will not receive data until the stream closes and re-opens.

  • p[inout] The event stream that was returned from the getEventStream() call from an EventStreamer.

  • open[in] The callback which is sent when the audio stream is first opened. This is used to provide information about the data in the audio stream.

  • writeData[in] The callback which is sent when a buffer of data is sent from the stream. These callbacks are only sent after an open() callback has been sent. Note that the data sent here may not be properly aligned for its data type due to the nature of events::IEvents, so you should memcpy the data somewhere that’s aligned for safety.

  • close[in] This is called when the audio stream is closed.

Protected Functions

inline void onDataReceived(const void *payload, size_t bytes, omni::extras::DataStreamType type) noexcept override

Function to pass received data to this audio streamer’s destination.

  • payload[in] The packet of data that was received. This is expected to contain the next group of audio frames in the stream on each call.

  • bytes[in] The length of payload in bytes.

  • type[in] The data type ID of the data contained in payload. This is ignored since calls to this handler are always expected to be plain data for the stream.


No return value.

inline void onEventReceived(const carb::events::IEvent *e) noexcept override

Handler function for non-data events on the stream.


e[in] The event that was received. This will either be an ‘open’ or ‘close’ event depending on the value of this event’s ‘type’ member.


No return value.