A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 91 lines 2.3 kB view raw
1#ifndef RBCODECCONFIG_H_INCLUDED 2#define RBCODECCONFIG_H_INCLUDED 3 4/* Explicit path to avoid issues with name clashes (libopus) */ 5#include "../firmware/export/config.h" 6 7#ifndef __ASSEMBLER__ 8 9/* NULL, offsetof, size_t */ 10#include <stddef.h> 11 12/* ssize_t, off_t, open, close, read, lseek, SEEK_SET, SEEK_CUR, SEEK_END, 13 * O_RDONLY, O_WRONLY, O_CREAT, O_APPEND, MAX_PATH, filesize */ 14#include "file.h" 15 16/* {,u}int{8,16,32,64}_t, , intptr_t, uintptr_t, bool, true, false, swap16, 17 * swap32, hto{be,le}{16,32}, {be,le}toh{16,32}, ROCKBOX_{BIG,LITTLE}_ENDIAN, 18 * {,U}INT{8,16,32,64}_{MIN,MAX} */ 19#include "system.h" 20 21/* HZ, TIME_AFTER, current_tick */ 22#include "kernel.h" 23 24/* MAX_PATH */ 25#include "fs_defines.h" 26 27/* Structure to record some info during processing call */ 28struct dsp_loop_context 29{ 30 long last_yield; 31#ifdef CPU_COLDFIRE 32 unsigned long old_macsr; 33#endif 34}; 35 36static inline void dsp_process_start(struct dsp_loop_context *ctx, bool thread_yield) 37{ 38 /* At least perform one yield before starting */ 39 ctx->last_yield = current_tick; 40 if (thread_yield) 41 { 42 yield(); 43 } 44#if defined(CPU_COLDFIRE) 45 /* set emac unit for dsp processing, and save old macsr, we're running in 46 codec thread context at this point, so can't clobber it */ 47 ctx->old_macsr = coldfire_get_macsr(); 48 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); 49#endif 50} 51 52static inline void dsp_process_loop(struct dsp_loop_context *ctx, bool thread_yield) 53{ 54 /* Yield at least once each tick */ 55 long tick = current_tick; 56 if (TIME_AFTER(tick, ctx->last_yield)) 57 { 58 ctx->last_yield = tick; 59 if (thread_yield) 60 { 61 yield(); 62 } 63 } 64} 65 66static inline void dsp_process_end(struct dsp_loop_context *ctx) 67{ 68#if defined(CPU_COLDFIRE) 69 /* set old macsr again */ 70 coldfire_set_macsr(ctx->old_macsr); 71#endif 72 (void)ctx; 73} 74 75#define DSP_PROCESS_START(yield) \ 76 struct dsp_loop_context __ctx; \ 77 dsp_process_start(&__ctx, yield) 78 79#define DSP_PROCESS_LOOP(yield) \ 80 dsp_process_loop(&__ctx, yield) 81 82#define DSP_PROCESS_END() \ 83 dsp_process_end(&__ctx) 84 85#endif 86 87#define DSP_OUT_MIN_HZ PLAY_SAMPR_HW_MIN 88#define DSP_OUT_MAX_HZ PLAY_SAMPR_MAX 89#define DSP_OUT_DEFAULT_HZ PLAY_SAMPR_DEFAULT 90 91#endif