esp32-audio-player 0.1.0
Audio player engine for ESP32
Loading...
Searching...
No Matches
stream.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
6#pragma once
7
8#include "audio_player/base.h"
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14typedef struct core_stream core_stream_t;
15
16typedef struct {
18 int32_t (*read)(void *ctx, void *buf, size_t len);
20 int (*seek)(void *ctx, int64_t offset, int whence);
21 int64_t (*tell)(void *ctx);
22 int64_t (*size)(void *ctx);
23 void (*close)(void *ctx);
25
28
30core_stream_t *core_stream_open_file(const char *path, size_t buf_size);
31
33core_stream_t *core_stream_open_memory(const void *data, size_t len, bool take_ownership);
34
35int32_t core_stream_read(core_stream_t *s, void *buf, size_t len);
37int core_stream_read_exact(core_stream_t *s, void *buf, size_t len);
38int core_stream_seek(core_stream_t *s, int64_t offset, int whence);
39int core_stream_skip(core_stream_t *s, int64_t bytes);
43
45int core_stream_read_u8(core_stream_t *s, uint8_t *out);
46int core_stream_read_le16(core_stream_t *s, uint16_t *out);
47int core_stream_read_le32(core_stream_t *s, uint32_t *out);
48int core_stream_read_le64(core_stream_t *s, uint64_t *out);
49int core_stream_read_be16(core_stream_t *s, uint16_t *out);
50int core_stream_read_be24(core_stream_t *s, uint32_t *out);
51int core_stream_read_be32(core_stream_t *s, uint32_t *out);
52int core_stream_read_be64(core_stream_t *s, uint64_t *out);
53
54#ifdef __cplusplus
55}
56#endif
Base definitions shared by every core module: error codes, memory, logging, locks.
int core_stream_read_be24(core_stream_t *s, uint32_t *out)
int core_stream_read_le16(core_stream_t *s, uint16_t *out)
int core_stream_read_le32(core_stream_t *s, uint32_t *out)
core_stream_t * core_stream_create(const core_stream_ops_t *ops, void *ctx)
Wrap custom ops. The stream owns ctx and calls ops->close on core_stream_close.
int core_stream_skip(core_stream_t *s, int64_t bytes)
int core_stream_read_exact(core_stream_t *s, void *buf, size_t len)
Reads exactly len bytes or fails with CORE_EOF / CORE_EIO.
struct core_stream core_stream_t
Definition stream.h:14
int core_stream_read_be64(core_stream_t *s, uint64_t *out)
int core_stream_read_le64(core_stream_t *s, uint64_t *out)
core_stream_t * core_stream_open_memory(const void *data, size_t len, bool take_ownership)
Read-only view of memory. If take_ownership, core_free(data) on close.
int64_t core_stream_tell(core_stream_t *s)
int core_stream_read_u8(core_stream_t *s, uint8_t *out)
Little/big-endian readers. Return CORE_OK or error; value written to *out.
void core_stream_close(core_stream_t *s)
int core_stream_read_be16(core_stream_t *s, uint16_t *out)
int core_stream_seek(core_stream_t *s, int64_t offset, int whence)
core_stream_t * core_stream_open_file(const char *path, size_t buf_size)
Open a file with an internal read buffer of buf_size bytes (0 = default 16 KiB).
int core_stream_read_be32(core_stream_t *s, uint32_t *out)
int32_t core_stream_read(core_stream_t *s, void *buf, size_t len)
int64_t core_stream_size(core_stream_t *s)
Definition stream.h:16