Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Enable HTTP streaming on hosted SDL app target (APPLICATION) in addition to simulator

Agent-Logs-Url: https://github.com/tsirysndr/rockbox-zig/sessions/01204b2f-ecfd-481b-95ad-27b6fec2bc48

Co-authored-by: tsirysndr <15877106+tsirysndr@users.noreply.github.com>

authored by

copilot-swe-agent[bot]
tsirysndr
and committed by
GitHub
2edfc096 a6a2fd64

+28 -21
+6 -6
apps/streamfd.c
··· 1 1 /*************************************************************************** 2 - * streamfd.c - Unified stream I/O dispatch for local files and HTTP(S) 3 - * network streams (SDL simulator build only). 2 + * Unified stream I/O dispatch for local files and HTTP(S) network streams. 3 + * Active in the SDL simulator build and the hosted SDL application build. 4 4 * 5 5 * See streamfd.h for the public interface and fd-encoding documentation. 6 6 ***************************************************************************/ 7 7 8 8 #include "config.h" 9 9 10 - #ifdef SIMULATOR 10 + #if defined(SIMULATOR) || defined(APPLICATION) 11 11 12 12 #include "streamfd.h" 13 - #include "file.h" /* for sim_open / sim_read / sim_lseek / sim_close / 14 - sim_filesize (via macros) */ 13 + #include "file.h" /* for app_open / app_read / app_lseek / app_close / 14 + app_filesize and sim_* equivalents (via macros) */ 15 15 #include <string.h> 16 16 #include <stdint.h> 17 17 #include <fcntl.h> ··· 103 103 return filesize(fd); 104 104 } 105 105 106 - #endif /* SIMULATOR */ 106 + #endif /* SIMULATOR || APPLICATION */
+22 -15
apps/streamfd.h
··· 2 2 * streamfd.h - Unified stream I/O abstraction for local files and HTTP(S) 3 3 * network streams. 4 4 * 5 - * In the SDL simulator build, URLs that start with "http://" or "https://" 6 - * are opened as network streams backed by the Rust "netstream" crate. 7 - * All other paths are handled by the normal simulator file system functions. 5 + * In the SDL simulator build and the hosted SDL application build, URLs that 6 + * start with "http://" or "https://" are opened as network streams backed by 7 + * the Rust "netstream" crate. All other paths are handled by the normal 8 + * Rockbox file-system functions. 8 9 * 9 - * File-descriptor encoding (simulator only): 10 + * File-descriptor encoding (simulator / hosted SDL app): 10 11 * fd == -1 : closed / unset sentinel 11 - * fd >= 0 : normal sim_* file descriptor 12 + * fd >= 0 : normal file descriptor 12 13 * fd <= STREAM_HTTP_FD_BASE : HTTP stream handle 13 14 * handle_id = STREAM_HTTP_FD_BASE - fd 14 15 * 15 - * On non-simulator builds, every symbol reduces to the existing Rockbox 16 - * file-system macro/function so there is zero overhead and zero code change 17 - * needed in callers. 16 + * On all other (embedded) builds, every symbol reduces to the existing 17 + * Rockbox file-system macro/function so there is zero overhead and zero code 18 + * change needed in callers. 18 19 ***************************************************************************/ 19 20 20 21 #ifndef APPS_STREAMFD_H 21 22 #define APPS_STREAMFD_H 22 23 23 24 #ifdef SIMULATOR 25 + #define STREAM_HTTP_ENABLED 26 + #elif defined(APPLICATION) 27 + #define STREAM_HTTP_ENABLED 28 + #endif 29 + 30 + #ifdef STREAM_HTTP_ENABLED 24 31 25 32 #include <sys/types.h> 26 33 #include <fcntl.h> ··· 39 46 * Open a path. 40 47 * 41 48 * If @p path begins with "http://" or "https://" the request is forwarded 42 - * to the Rust network layer; otherwise a normal sim_open() is performed. 49 + * to the Rust network layer; otherwise a normal open() is performed. 43 50 * 44 51 * @return A file descriptor >= 0, an HTTP handle <= STREAM_HTTP_FD_BASE, 45 52 * or -1 on error. ··· 48 55 49 56 /** 50 57 * Read up to @p n bytes from @p fd into @p buf. 51 - * Routes to sim_read() for real fds, rb_net_read() for HTTP fds. 58 + * Routes to read() for real fds, rb_net_read() for HTTP fds. 52 59 */ 53 60 ssize_t stream_read(int fd, void *buf, size_t n); 54 61 55 62 /** 56 63 * Seek within @p fd. 57 - * Routes to sim_lseek() for real fds, rb_net_lseek() for HTTP fds. 64 + * Routes to lseek() for real fds, rb_net_lseek() for HTTP fds. 58 65 */ 59 66 off_t stream_lseek(int fd, off_t off, int whence); 60 67 61 68 /** 62 69 * Close @p fd. 63 - * Routes to sim_close() for real fds, rb_net_close() for HTTP fds. 70 + * Routes to close() for real fds, rb_net_close() for HTTP fds. 64 71 * Silently ignores fd == -1. 65 72 * 66 73 * @return 0 on success, -1 on error. ··· 72 79 * 73 80 * For HTTP streams: the Content-Length if known, or a large sentinel 74 81 * value (~2 GiB) if unknown (buffering will truncate on EOF). 75 - * For regular fds: delegates to sim_filesize(). 82 + * For regular fds: delegates to filesize(). 76 83 * 77 84 * @return Size in bytes, or -1 on error. 78 85 */ 79 86 off_t stream_filesize_fd(int fd); 80 87 81 - #else /* !SIMULATOR */ 88 + #else /* !STREAM_HTTP_ENABLED */ 82 89 83 90 /* 84 91 * Non-simulator / embedded builds: map every symbol straight through to ··· 94 101 #define stream_close(fd) close(fd) 95 102 #define stream_filesize_fd(fd) filesize(fd) 96 103 97 - #endif /* SIMULATOR */ 104 + #endif /* STREAM_HTTP_ENABLED */ 98 105 99 106 #endif /* APPS_STREAMFD_H */