A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1#include "zxconfig.h"
2#include "helpers.h"
3
4int my_getc(int fd){
5 unsigned char c;
6 if ( rb->read(fd, &c, 1) )
7 return c;
8 else
9 return EOF;
10}
11
12off_t my_ftell(int fd){
13 return rb->lseek(fd, 0, SEEK_CUR);
14}
15
16int my_putc(char c , int fd){
17 return rb->write(fd,&c,1);
18}
19
20void *my_malloc(size_t size)
21{
22 static char *offset = NULL;
23 static size_t totalSize = 0;
24 char *ret;
25
26 int remainder = size % 4;
27
28 size = size + 4-remainder;
29
30 if (offset == NULL)
31 {
32 offset = rb->plugin_get_audio_buffer(&totalSize);
33 }
34
35 if (size + 4 > totalSize)
36 {
37 /* We've made our point. */
38 return NULL;
39 }
40
41 ret = offset + 4;
42 *((unsigned int *)offset) = size;
43
44 offset += size + 4;
45 totalSize -= size + 4;
46 return ret;
47
48}