libivon 0.1.0
Voice-over-IP library
Loading...
Searching...
No Matches
ivon_audio.h File Reference

Macros

#define IVON_AUDIO_API_VERSION_MAJOR   1
 C ABI for the libivon audio processor.
 
#define IVON_AUDIO_API_VERSION_MINOR   0
 Minor version of the audio C ABI (bump on additive changes).
 
Log level constants (same values across all ivon subsystems).
#define IVON_LOG_LEVEL_TRACE   0
 
#define IVON_LOG_LEVEL_DEBUG   1
 
#define IVON_LOG_LEVEL_INFO   2
 
#define IVON_LOG_LEVEL_WARN   3
 
#define IVON_LOG_LEVEL_ERROR   4
 
#define IVON_LOG_LEVEL_CRITICAL   5
 
#define IVON_LOG_LEVEL_OFF   6
 

Functions

int ivon_audio_api_version_major (void)
 Get the major version of the audio C ABI at runtime.
 
int ivon_audio_api_version_minor (void)
 Get the minor version of the audio C ABI at runtime.
 
ivon_audio_config_t ivon_audio_config_create (void)
 Create a new audio configuration with sane defaults.
 
void ivon_audio_config_destroy (ivon_audio_config_t config)
 Destroy an audio configuration handle. NULL is a safe no-op.
 
void ivon_audio_config_set_frame_duration (ivon_audio_config_t config, ivon_frame_duration_t duration)
 Set the codec frame duration.
 
void ivon_audio_config_set_codec_sample_rate (ivon_audio_config_t config, ivon_codec_sample_rate_t rate)
 Set the codec sample rate.
 
void ivon_audio_config_set_packet_pool_chunks (ivon_audio_config_t config, uint32_t chunks)
 Set packet pool chunk count (each chunk = 1024 buffers).
 
void ivon_audio_config_set_frame_pool_chunks (ivon_audio_config_t config, uint32_t chunks)
 Set frame pool chunk count (each chunk = 256 frames).
 
void ivon_audio_config_set_decoder_workers (ivon_audio_config_t config, uint8_t workers)
 Set the number of decoder worker threads.
 
void ivon_audio_config_set_pipeline_workers (ivon_audio_config_t config, uint8_t workers)
 Set the number of pipeline worker threads.
 
void ivon_audio_config_set_output_channels (ivon_audio_config_t config, uint8_t channels)
 Set output channel count: 1 = mono, 2 = stereo.
 
void ivon_audio_config_set_output_buffer_frames (ivon_audio_config_t config, uint32_t frames)
 Set output ring buffer size in frames.
 
void ivon_audio_config_set_jitter_depth (ivon_audio_config_t config, uint32_t depth)
 Set jitter buffer depth in frames (0 = bypass).
 
void ivon_audio_config_set_encoder_bitrate (ivon_audio_config_t config, uint32_t bitrate)
 Set Opus encoder target bitrate in bits/sec.
 
void ivon_audio_config_set_encoder_fec (ivon_audio_config_t config, int fec)
 Enable/disable Opus in-band FEC (1 = on, 0 = off).
 
void ivon_audio_config_set_encoder_fec_loss_percent (ivon_audio_config_t config, int percent)
 Set expected packet loss percentage hint for FEC.
 
void ivon_audio_config_set_encoder_complexity (ivon_audio_config_t config, int complexity)
 Set Opus encoder complexity 0–10.
 
ivon_audio_t ivon_audio_create (ivon_audio_config_t config)
 Create a new audio processor instance.
 
void ivon_audio_destroy (ivon_audio_t audio)
 Destroy an audio processor and free all resources.
 
void ivon_audio_start (ivon_audio_t audio)
 Start the audio processor (tick coordinator + worker threads).
 
void ivon_audio_stop (ivon_audio_t audio)
 Stop the audio processor.
 
int ivon_audio_is_running (ivon_audio_t audio)
 Check if the processor is running.
 
int ivon_audio_frame_size (ivon_audio_t audio)
 Get the PCM frame size (samples per channel per frame).
 
int ivon_audio_output_channels (ivon_audio_t audio)
 Get the output channel count.
 
int ivon_audio_submit_packet (ivon_audio_t audio, uint64_t sender_id, const unsigned char *data, size_t data_len)
 Submit a received audio packet for decoding (copy-in).
 
int ivon_audio_submit_packet_ex (ivon_audio_t audio, uint64_t sender_id, uint64_t group_id, const unsigned char *data, size_t data_len)
 Submit a received audio packet with a group tag.
 
ivon_audio_output_frame_t ivon_audio_try_read_output (ivon_audio_t audio, float *pcm_out, size_t max_samples)
 Try to read a mixed output frame (copy-out).
 
ivon_packet_buffer_t ivon_audio_acquire_packet_buffer (ivon_audio_t audio)
 Acquire a packet buffer from the audio processor's pool.
 
unsigned char * ivon_packet_buffer_data (ivon_packet_buffer_t buf)
 Get writable pointer to the packet buffer data.
 
const unsigned char * ivon_packet_buffer_data_const (ivon_packet_buffer_t buf)
 Get read-only pointer to the packet buffer data.
 
size_t ivon_packet_buffer_capacity (ivon_packet_buffer_t buf)
 Get the maximum capacity of a packet buffer in bytes.
 
void ivon_packet_buffer_set_length (ivon_packet_buffer_t buf, size_t length)
 Set the number of valid bytes in the buffer.
 
size_t ivon_packet_buffer_length (ivon_packet_buffer_t buf)
 Get the number of valid bytes in the buffer.
 
void ivon_packet_buffer_release (ivon_packet_buffer_t buf)
 Release a packet buffer back to the pool.
 
int ivon_audio_submit_packet_zero_copy (ivon_audio_t audio, ivon_packet_buffer_t buf, uint64_t sender_id)
 Submit a packet buffer for decoding (zero-copy).
 
int ivon_audio_submit_packet_zero_copy_ex (ivon_audio_t audio, ivon_packet_buffer_t buf, uint64_t sender_id, uint64_t group_id)
 Submit a packet buffer with group tag (zero-copy).
 
ivon_packet_buffer_t ivon_audio_try_read_packet_zero_copy (ivon_audio_t audio)
 Try to read an encoded packet for transmission (zero-copy).
 
void ivon_audio_set_pcm_source (ivon_audio_t audio, ivon_audio_pcm_source_fn callback, void *user_data)
 Set the PCM source callback for local audio capture.
 
void ivon_audio_start_speaking (ivon_audio_t audio, ivon_speaking_mode_t mode)
 Start speaking (PTT activated).
 
void ivon_audio_stop_speaking (ivon_audio_t audio)
 Stop speaking (PTT released).
 
int ivon_audio_is_speaking (ivon_audio_t audio)
 Check if currently speaking.
 
size_t ivon_audio_try_read_packet (ivon_audio_t audio, unsigned char *data_out, size_t max_len)
 Try to read an encoded packet for transmission (copy-out).
 
void ivon_audio_set_on_speaking_event (ivon_audio_t audio, ivon_audio_speaking_event_fn callback, void *user_data)
 Set the speaking event callback.
 
void ivon_audio_set_on_pre_dsp (ivon_audio_t audio, ivon_audio_pre_dsp_fn callback, void *user_data)
 Set the pre-DSP callback (mono per-sender, after decode).
 
void ivon_audio_set_on_post_spatial (ivon_audio_t audio, ivon_audio_post_spatial_fn callback, void *user_data)
 Set the post-spatial callback (expanded per-sender, after channel expansion).
 
void ivon_audio_set_on_post_mix (ivon_audio_t audio, ivon_audio_post_mix_fn callback, void *user_data)
 Set the post-mix callback (final mixed output).
 
void ivon_audio_set_sender_gain (ivon_audio_t audio, uint64_t sender_id, float gain)
 Set per-sender gain (linear scale).
 
void ivon_audio_set_sender_muted (ivon_audio_t audio, uint64_t sender_id, int muted)
 Mute or unmute a sender.
 
uint64_t ivon_audio_current_tick (ivon_audio_t audio)
 Get the current tick number.
 
int64_t ivon_audio_max_drift_us (ivon_audio_t audio)
 Get the maximum clock drift in microseconds.
 
uint64_t ivon_audio_dropped_ticks (ivon_audio_t audio)
 Get the number of dropped ticks.
 
void ivon_audio_get_stats (ivon_audio_t audio, ivon_audio_stats_t *out)
 Get aggregate statistics snapshot.
 
void ivon_audio_set_log_level (ivon_audio_t audio, int level)
 Set the audio processor's log level at runtime.
 
int ivon_audio_get_log_level (ivon_audio_t audio)
 Get the audio processor's current log level.
 

Macro Definition Documentation

◆ IVON_AUDIO_API_VERSION_MAJOR

#define IVON_AUDIO_API_VERSION_MAJOR   1

C ABI for the libivon audio processor.

Author
Cliff Foster (Nou) cliff.nosp@m.@idi.nosp@m.-syst.nosp@m.ems..nosp@m.com

All functions use the opaque ivon_audio_t handle and plain C types. Symbols are exported via IDI_IVON_EXPORT when building the shared library.

The audio processor provides:

  • Receive path: submit encoded packets, read mixed PCM output
  • Transmit path: pull PCM via callback, read encoded packets
  • DSP callbacks: pre-DSP, post-spatial, post-mix hooks
  • Per-sender control: gain, mute
See also
ivon_audio_types.h for type definitions.

Major version of the audio C ABI (bump on breaking changes).

◆ IVON_AUDIO_API_VERSION_MINOR

#define IVON_AUDIO_API_VERSION_MINOR   0

Minor version of the audio C ABI (bump on additive changes).

◆ IVON_LOG_LEVEL_CRITICAL

#define IVON_LOG_LEVEL_CRITICAL   5

◆ IVON_LOG_LEVEL_DEBUG

#define IVON_LOG_LEVEL_DEBUG   1

◆ IVON_LOG_LEVEL_ERROR

#define IVON_LOG_LEVEL_ERROR   4

◆ IVON_LOG_LEVEL_INFO

#define IVON_LOG_LEVEL_INFO   2

◆ IVON_LOG_LEVEL_OFF

#define IVON_LOG_LEVEL_OFF   6

◆ IVON_LOG_LEVEL_TRACE

#define IVON_LOG_LEVEL_TRACE   0

◆ IVON_LOG_LEVEL_WARN

#define IVON_LOG_LEVEL_WARN   3

Function Documentation

◆ ivon_audio_acquire_packet_buffer()

ivon_packet_buffer_t ivon_audio_acquire_packet_buffer ( ivon_audio_t  audio)

Acquire a packet buffer from the audio processor's pool.

Parameters
audioThe audio handle.
Returns
Packet buffer handle, or NULL if the pool is exhausted.

◆ ivon_audio_api_version_major()

int ivon_audio_api_version_major ( void  )

Get the major version of the audio C ABI at runtime.

◆ ivon_audio_api_version_minor()

int ivon_audio_api_version_minor ( void  )

Get the minor version of the audio C ABI at runtime.

◆ ivon_audio_config_create()

ivon_audio_config_t ivon_audio_config_create ( void  )

Create a new audio configuration with sane defaults.

Defaults: 20 ms frames, 48 kHz, 2 decoder/pipeline workers, 2 output channels, jitter depth 2, 64 kbps Opus, FEC on.

Call ivon_audio_config_set_*() to customise, then pass to ivon_audio_create(). Destroy with ivon_audio_config_destroy() after creation (the processor copies what it needs).

Returns
A new config handle, or NULL on allocation failure.

◆ ivon_audio_config_destroy()

void ivon_audio_config_destroy ( ivon_audio_config_t  config)

Destroy an audio configuration handle. NULL is a safe no-op.

◆ ivon_audio_config_set_codec_sample_rate()

void ivon_audio_config_set_codec_sample_rate ( ivon_audio_config_t  config,
ivon_codec_sample_rate_t  rate 
)

Set the codec sample rate.

◆ ivon_audio_config_set_decoder_workers()

void ivon_audio_config_set_decoder_workers ( ivon_audio_config_t  config,
uint8_t  workers 
)

Set the number of decoder worker threads.

◆ ivon_audio_config_set_encoder_bitrate()

void ivon_audio_config_set_encoder_bitrate ( ivon_audio_config_t  config,
uint32_t  bitrate 
)

Set Opus encoder target bitrate in bits/sec.

◆ ivon_audio_config_set_encoder_complexity()

void ivon_audio_config_set_encoder_complexity ( ivon_audio_config_t  config,
int  complexity 
)

Set Opus encoder complexity 0–10.

◆ ivon_audio_config_set_encoder_fec()

void ivon_audio_config_set_encoder_fec ( ivon_audio_config_t  config,
int  fec 
)

Enable/disable Opus in-band FEC (1 = on, 0 = off).

◆ ivon_audio_config_set_encoder_fec_loss_percent()

void ivon_audio_config_set_encoder_fec_loss_percent ( ivon_audio_config_t  config,
int  percent 
)

Set expected packet loss percentage hint for FEC.

◆ ivon_audio_config_set_frame_duration()

void ivon_audio_config_set_frame_duration ( ivon_audio_config_t  config,
ivon_frame_duration_t  duration 
)

Set the codec frame duration.

◆ ivon_audio_config_set_frame_pool_chunks()

void ivon_audio_config_set_frame_pool_chunks ( ivon_audio_config_t  config,
uint32_t  chunks 
)

Set frame pool chunk count (each chunk = 256 frames).

◆ ivon_audio_config_set_jitter_depth()

void ivon_audio_config_set_jitter_depth ( ivon_audio_config_t  config,
uint32_t  depth 
)

Set jitter buffer depth in frames (0 = bypass).

◆ ivon_audio_config_set_output_buffer_frames()

void ivon_audio_config_set_output_buffer_frames ( ivon_audio_config_t  config,
uint32_t  frames 
)

Set output ring buffer size in frames.

◆ ivon_audio_config_set_output_channels()

void ivon_audio_config_set_output_channels ( ivon_audio_config_t  config,
uint8_t  channels 
)

Set output channel count: 1 = mono, 2 = stereo.

◆ ivon_audio_config_set_packet_pool_chunks()

void ivon_audio_config_set_packet_pool_chunks ( ivon_audio_config_t  config,
uint32_t  chunks 
)

Set packet pool chunk count (each chunk = 1024 buffers).

◆ ivon_audio_config_set_pipeline_workers()

void ivon_audio_config_set_pipeline_workers ( ivon_audio_config_t  config,
uint8_t  workers 
)

Set the number of pipeline worker threads.

◆ ivon_audio_create()

ivon_audio_t ivon_audio_create ( ivon_audio_config_t  config)

Create a new audio processor instance.

Parameters
configAudio configuration from ivon_audio_config_create(), or NULL for all-defaults.
Returns
A new audio handle, or NULL on failure.

◆ ivon_audio_current_tick()

uint64_t ivon_audio_current_tick ( ivon_audio_t  audio)

Get the current tick number.

◆ ivon_audio_destroy()

void ivon_audio_destroy ( ivon_audio_t  audio)

Destroy an audio processor and free all resources.

Stops the processor if still running, then frees all resources. Passing NULL is a safe no-op.

◆ ivon_audio_dropped_ticks()

uint64_t ivon_audio_dropped_ticks ( ivon_audio_t  audio)

Get the number of dropped ticks.

◆ ivon_audio_frame_size()

int ivon_audio_frame_size ( ivon_audio_t  audio)

Get the PCM frame size (samples per channel per frame).

Returns the actual frame size after server property overrides have been applied. For example: 480 for 10 ms frames, 960 for 20 ms at 48 kHz. Returns 0 if audio is NULL.

◆ ivon_audio_get_log_level()

int ivon_audio_get_log_level ( ivon_audio_t  audio)

Get the audio processor's current log level.

Parameters
audioThe audio handle.
Returns
The current log level (IVON_LOG_LEVEL_*), or IVON_LOG_LEVEL_OFF if the handle is NULL.

◆ ivon_audio_get_stats()

void ivon_audio_get_stats ( ivon_audio_t  audio,
ivon_audio_stats_t out 
)

Get aggregate statistics snapshot.

Fills the provided struct with current counters from the decoder, encoder, and pipeline. Values are approximate while running (worker threads update them without full synchronisation).

Parameters
audioThe audio processor handle.
outPointer to a stats struct to fill. Zeroed first.

◆ ivon_audio_is_running()

int ivon_audio_is_running ( ivon_audio_t  audio)

Check if the processor is running.

Returns
Non-zero if running, zero otherwise.

◆ ivon_audio_is_speaking()

int ivon_audio_is_speaking ( ivon_audio_t  audio)

Check if currently speaking.

Returns
Non-zero if speaking, zero otherwise.

◆ ivon_audio_max_drift_us()

int64_t ivon_audio_max_drift_us ( ivon_audio_t  audio)

Get the maximum clock drift in microseconds.

◆ ivon_audio_output_channels()

int ivon_audio_output_channels ( ivon_audio_t  audio)

Get the output channel count.

Returns the number of interleaved output channels (e.g. 2 for stereo). Returns 0 if audio is NULL.

◆ ivon_audio_set_log_level()

void ivon_audio_set_log_level ( ivon_audio_t  audio,
int  level 
)

Set the audio processor's log level at runtime.

Parameters
audioThe audio handle.
levelOne of the IVON_LOG_LEVEL_* constants (0–6).

◆ ivon_audio_set_on_post_mix()

void ivon_audio_set_on_post_mix ( ivon_audio_t  audio,
ivon_audio_post_mix_fn  callback,
void *  user_data 
)

Set the post-mix callback (final mixed output).

◆ ivon_audio_set_on_post_spatial()

void ivon_audio_set_on_post_spatial ( ivon_audio_t  audio,
ivon_audio_post_spatial_fn  callback,
void *  user_data 
)

Set the post-spatial callback (expanded per-sender, after channel expansion).

◆ ivon_audio_set_on_pre_dsp()

void ivon_audio_set_on_pre_dsp ( ivon_audio_t  audio,
ivon_audio_pre_dsp_fn  callback,
void *  user_data 
)

Set the pre-DSP callback (mono per-sender, after decode).

◆ ivon_audio_set_on_speaking_event()

void ivon_audio_set_on_speaking_event ( ivon_audio_t  audio,
ivon_audio_speaking_event_fn  callback,
void *  user_data 
)

Set the speaking event callback.

Fired from decoder worker threads when a remote sender starts or stops speaking. Must be thread-safe and non-blocking.

◆ ivon_audio_set_pcm_source()

void ivon_audio_set_pcm_source ( ivon_audio_t  audio,
ivon_audio_pcm_source_fn  callback,
void *  user_data 
)

Set the PCM source callback for local audio capture.

Called every 20 ms while speaking. Must be set before start().

Parameters
audioThe audio handle.
callbackPCM source function, or NULL to clear.
user_dataPassed through to the callback.

◆ ivon_audio_set_sender_gain()

void ivon_audio_set_sender_gain ( ivon_audio_t  audio,
uint64_t  sender_id,
float  gain 
)

Set per-sender gain (linear scale).

Applied to mono PCM before DSP callbacks.

Parameters
audioThe audio handle.
sender_idSender to adjust.
gainLinear gain factor (1.0 = unity, 0.0 = silence).

◆ ivon_audio_set_sender_muted()

void ivon_audio_set_sender_muted ( ivon_audio_t  audio,
uint64_t  sender_id,
int  muted 
)

Mute or unmute a sender.

Muted senders are not mixed into output.

Parameters
audioThe audio handle.
sender_idSender to mute/unmute.
mutedNon-zero to mute, zero to unmute.

◆ ivon_audio_start()

void ivon_audio_start ( ivon_audio_t  audio)

Start the audio processor (tick coordinator + worker threads).

Callbacks (PCM source, speaking event, DSP) must be set before calling.

◆ ivon_audio_start_speaking()

void ivon_audio_start_speaking ( ivon_audio_t  audio,
ivon_speaking_mode_t  mode 
)

Start speaking (PTT activated).

◆ ivon_audio_stop()

void ivon_audio_stop ( ivon_audio_t  audio)

Stop the audio processor.

◆ ivon_audio_stop_speaking()

void ivon_audio_stop_speaking ( ivon_audio_t  audio)

Stop speaking (PTT released).

◆ ivon_audio_submit_packet()

int ivon_audio_submit_packet ( ivon_audio_t  audio,
uint64_t  sender_id,
const unsigned char *  data,
size_t  data_len 
)

Submit a received audio packet for decoding (copy-in).

The data buffer should contain the raw audio payload (audio header + Opus data) as received from the fanout layer.

Parameters
audioThe audio handle.
sender_idSender ID from the fanout header.
dataAudio payload bytes.
data_lenLength of the payload in bytes.
Returns
Non-zero if the packet was accepted, zero on error.

◆ ivon_audio_submit_packet_ex()

int ivon_audio_submit_packet_ex ( ivon_audio_t  audio,
uint64_t  sender_id,
uint64_t  group_id,
const unsigned char *  data,
size_t  data_len 
)

Submit a received audio packet with a group tag.

Identical to ivon_audio_submit_packet but carries a group_id that propagates through the DSP pipeline contexts.

Parameters
audioAudio processor handle.
sender_idUnique identifier for the sender.
group_idGroup the packet belongs to (0 = untagged).
dataAudio payload bytes.
data_lenLength of the payload in bytes.
Returns
Non-zero if the packet was accepted, zero on error.

◆ ivon_audio_submit_packet_zero_copy()

int ivon_audio_submit_packet_zero_copy ( ivon_audio_t  audio,
ivon_packet_buffer_t  buf,
uint64_t  sender_id 
)

Submit a packet buffer for decoding (zero-copy).

Always consumes buf — do NOT call ivon_packet_buffer_release() afterwards. If buf is NULL, this is a no-op returning zero.

Parameters
audioThe audio handle.
bufFilled packet buffer (consumed).
sender_idSender ID from the fanout header.
Returns
Non-zero if accepted, zero on error.

◆ ivon_audio_submit_packet_zero_copy_ex()

int ivon_audio_submit_packet_zero_copy_ex ( ivon_audio_t  audio,
ivon_packet_buffer_t  buf,
uint64_t  sender_id,
uint64_t  group_id 
)

Submit a packet buffer with group tag (zero-copy).

See also
ivon_audio_submit_packet_zero_copy

◆ ivon_audio_try_read_output()

ivon_audio_output_frame_t ivon_audio_try_read_output ( ivon_audio_t  audio,
float *  pcm_out,
size_t  max_samples 
)

Try to read a mixed output frame (copy-out).

Copies PCM data into the caller's buffer. The buffer must hold at least IVON_AUDIO_FRAME_SIZE * channels floats.

Parameters
audioThe audio handle.
pcm_outDestination buffer for interleaved float PCM.
max_samplesMaximum number of float samples the buffer can hold.
Returns
A frame descriptor. Check .valid — if zero, no frame was available.

◆ ivon_audio_try_read_packet()

size_t ivon_audio_try_read_packet ( ivon_audio_t  audio,
unsigned char *  data_out,
size_t  max_len 
)

Try to read an encoded packet for transmission (copy-out).

Copies the encoded audio data (audio header + Opus) into the caller's buffer. The buffer should be at least 2048 bytes.

Parameters
audioThe audio handle.
data_outDestination buffer for encoded packet.
max_lenMaximum number of bytes the buffer can hold.
Returns
Number of bytes written, or 0 if no packet was available.

◆ ivon_audio_try_read_packet_zero_copy()

ivon_packet_buffer_t ivon_audio_try_read_packet_zero_copy ( ivon_audio_t  audio)

Try to read an encoded packet for transmission (zero-copy).

Returns a packet buffer handle that the caller reads via ivon_packet_buffer_data_const() / ivon_packet_buffer_length(), then releases via ivon_packet_buffer_release().

Parameters
audioThe audio handle.
Returns
Packet buffer handle, or NULL if no packet was available.

◆ ivon_packet_buffer_capacity()

size_t ivon_packet_buffer_capacity ( ivon_packet_buffer_t  buf)

Get the maximum capacity of a packet buffer in bytes.

Parameters
bufThe packet buffer handle.
Returns
Capacity in bytes, or 0 if buf is NULL.

◆ ivon_packet_buffer_data()

unsigned char * ivon_packet_buffer_data ( ivon_packet_buffer_t  buf)

Get writable pointer to the packet buffer data.

Parameters
bufThe packet buffer handle.
Returns
Pointer to the data area, or NULL if buf is NULL.

◆ ivon_packet_buffer_data_const()

const unsigned char * ivon_packet_buffer_data_const ( ivon_packet_buffer_t  buf)

Get read-only pointer to the packet buffer data.

Parameters
bufThe packet buffer handle.
Returns
Const pointer to the data area, or NULL if buf is NULL.

◆ ivon_packet_buffer_length()

size_t ivon_packet_buffer_length ( ivon_packet_buffer_t  buf)

Get the number of valid bytes in the buffer.

Parameters
bufThe packet buffer handle.
Returns
Valid byte count, or 0 if buf is NULL.

◆ ivon_packet_buffer_release()

void ivon_packet_buffer_release ( ivon_packet_buffer_t  buf)

Release a packet buffer back to the pool.

The buffer is invalid after this call. NULL is a safe no-op.

Parameters
bufThe packet buffer handle (may be NULL).

◆ ivon_packet_buffer_set_length()

void ivon_packet_buffer_set_length ( ivon_packet_buffer_t  buf,
size_t  length 
)

Set the number of valid bytes in the buffer.

Call after filling the buffer and before submitting.

Parameters
bufThe packet buffer handle.
lengthNumber of valid bytes (clamped to capacity).