ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_audio_source_memory.c File Reference

Fixed PCM replay backend implementation. More...

#include "ra8_audio_source_memory.h"
#include <stddef.h>
#include <string.h>
#include "ra8_audio_internal.h"
Include dependency graph for ra8_audio_source_memory.c:

Go to the source code of this file.

Functions

static ra8_err_t internal_memory_get_info (void *ctx, ra8_audio_source_info_t *out_info)
 Report metadata for the fixed memory frame.
static ra8_err_t internal_memory_capture (void *ctx, const ra8_audio_buffer_t *buffer, ra8_audio_frame_t *out_frame)
 Copy the fixed memory frame into a caller buffer.
static ra8_err_t internal_memory_stop (void *ctx)
 Stop the memory replay backend.
ra8_err_t ra8_audio_source_memory_init (ra8_audio_source_t *source, ra8_audio_source_memory_state_t *state, const ra8_audio_frame_t *frame)
 Bind one immutable PCM frame as a repeatable audio source.

Variables

static const ra8_audio_source_iface_t s_memory_source_iface

Detailed Description

Fixed PCM replay backend implementation.

Copies one immutable caller-owned fixture into each supplied output buffer and reports its validated PCM metadata without allocation.

Tag
[Ring 4 / Service] {World: NS}
Since
0.1.0

Definition in file ra8_audio_source_memory.c.

Function Documentation

◆ internal_memory_capture()

ra8_err_t internal_memory_capture ( void * ctx,
const ra8_audio_buffer_t * buffer,
ra8_audio_frame_t * out_frame )
static

Copy the fixed memory frame into a caller buffer.

Replays the configured fixture without allocating or retaining the output buffer.

Parameters
[in]ctxMemory-source state supplied during initialization.
[in]bufferCaller-owned destination buffer descriptor.
[out]out_frameDescriptor for the copied frame.
Returns
Repository error code.
Return values
k_ra8_okThe fixture was copied successfully.
k_ra8_err_null_ptrA required pointer is null.
k_ra8_err_invalid_sizeThe destination is too small.
Precondition
ctx points to initialized memory-source state.
buffer->data points to writable storage of buffer->capacity bytes.
Postcondition
On success, out_frame->data aliases buffer->data.
The configured fixture remains unchanged.
Note
The facade validates the returned descriptor after this callback.
Since
0.1.0

Definition at line 76 of file ra8_audio_source_memory.c.

References ra8_audio_frame_t::bytes, ra8_audio_buffer_t::capacity, ra8_audio_buffer_t::data, ra8_audio_frame_t::data, ra8_audio_source_memory_state_t::frame, k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_ok, and memcpy().

◆ internal_memory_get_info()

ra8_err_t internal_memory_get_info ( void * ctx,
ra8_audio_source_info_t * out_info )
static

Report metadata for the fixed memory frame.

Copies the immutable fixture geometry into the generic source-info structure.

Parameters
[in]ctxMemory-source state supplied during initialization.
[out]out_infoDestination for the frame metadata.
Returns
Repository error code.
Return values
k_ra8_okMetadata was copied successfully.
k_ra8_err_null_ptrA required pointer is null.
Precondition
ctx points to an initialized memory-source state.
out_info points to writable storage.
Postcondition
On success, out_info describes the stored fixture exactly.
The stored fixture and source state remain unchanged.
Note
This backend exposes one fixed frame geometry.
Since
0.1.0

Definition at line 38 of file ra8_audio_source_memory.c.

References ra8_audio_frame_t::bytes, ra8_audio_frame_t::channels, ra8_audio_frame_t::format, ra8_audio_source_memory_state_t::frame, k_ra8_err_null_ptr, k_ra8_ok, RA8_INTERNAL, ra8_audio_frame_t::sample_count, ra8_audio_frame_t::sample_rate_hz, and ra8_audio_frame_t::valid_bits.

◆ internal_memory_stop()

ra8_err_t internal_memory_stop ( void * ctx)
static

Stop the memory replay backend.

Acknowledges the stop request because the backend owns no active hardware.

Parameters
[in]ctxMemory-source state supplied during initialization.
Returns
Repository error code.
Return values
k_ra8_okThe no-op stop completed.
k_ra8_err_null_ptrThe state pointer is null.
Precondition
ctx points to storage retained by the caller.
No concurrent mutation of the source state occurs.
Postcondition
The state contents remain unchanged.
No hardware or allocator state is modified.
Note
The facade clears its source handle after a successful stop.
Since
0.1.0

Definition at line 111 of file ra8_audio_source_memory.c.

References k_ra8_err_null_ptr, k_ra8_ok, and RA8_INTERNAL.

◆ ra8_audio_source_memory_init()

ra8_err_t ra8_audio_source_memory_init ( ra8_audio_source_t * source,
ra8_audio_source_memory_state_t * state,
const ra8_audio_frame_t * frame )
nodiscard

Bind one immutable PCM frame as a repeatable audio source.

Parameters
[out]sourceCaller-owned source handle.
[out]stateCaller-owned backend state.
[in]frameValid immutable PCM frame retained by the caller.
Returns
Error code.
Return values
k_ra8_okSource bound.
k_ra8_err_null_ptrAn argument was nullptr.
otherPropagated frame-validation error.
Precondition
frame->data remains readable until the source is stopped.
Postcondition
Captures copy the fixed frame into caller storage.
Note
Not thread-safe with respect to the same state.
Since
0.1.0

Definition at line 126 of file ra8_audio_source_memory.c.

References ra8_audio_source_t::ctx, ra8_audio_source_memory_state_t::frame, ra8_audio_source_t::iface, k_ra8_err_null_ptr, k_ra8_ok, ra8_audio_frame_validate(), and s_memory_source_iface.

Variable Documentation

◆ s_memory_source_iface

const ra8_audio_source_iface_t s_memory_source_iface
static
Initial value:
= {
.stream_start = nullptr,
}
static ra8_err_t internal_memory_stop(void *ctx)
Stop the memory replay backend.
static ra8_err_t internal_memory_get_info(void *ctx, ra8_audio_source_info_t *out_info)
Report metadata for the fixed memory frame.
static ra8_err_t internal_memory_capture(void *ctx, const ra8_audio_buffer_t *buffer, ra8_audio_frame_t *out_frame)
Copy the fixed memory frame into a caller buffer.

Definition at line 119 of file ra8_audio_source_memory.c.

Referenced by ra8_audio_source_memory_init(), and ra8_camera_source_memory_init().