A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Frank Gevaerts
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __MV_H__
23#define __MV_H__
24
25#include <stdbool.h>
26#include <stdint.h>
27#include "config.h"
28
29/* FixMe: These macros are a bit nasty and perhaps misplaced here.
30 We'll get rid of them once decided on how to proceed with multivolume. */
31
32/* Drives are things like a disk, a card, a flash chip. They can have volumes
33 on them */
34#ifdef HAVE_MULTIDRIVE
35#define IF_MD(x...) x /* valist contents or empty */
36#define IF_MD_NONVOID(x...) x /* valist contents or 'void' */
37#define IF_MD_DRV(d) d /* drive argument or '0' */
38#else /* empty definitions if no multi-drive */
39#define IF_MD(x...)
40#define IF_MD_NONVOID(x...) void
41#define IF_MD_DRV(d) 0
42#endif /* HAVE_MULTIDRIVE */
43
44/* Storage size */
45#if (CONFIG_STORAGE & STORAGE_ATA) && defined(HAVE_LBA48)
46typedef uint64_t sector_t;
47#define STORAGE_64BIT_SECTOR
48#elif (CONFIG_STORAGE & STORAGE_SD) && defined(HAVE_SDUC)
49typedef uint64_t sector_t;
50#define STORAGE_64BIT_SECTOR
51#else
52typedef unsigned long sector_t;
53#undef STORAGE_64BIT_SECTOR
54#endif
55
56
57/* Volumes mean things that have filesystems on them, like partitions */
58#ifdef HAVE_MULTIVOLUME
59#define IF_MV(x...) x /* valist contents or empty */
60#define IF_MV_NONVOID(x...) x /* valist contents or 'void' */
61#define IF_MV_VOL(v) v /* volume argument or '0' */
62
63/* Format: "/<DEC###>/foo/bar"
64 * The "DEC" is pure decoration and treated as a comment. Only an unbroken
65 * trailing string of digits within the brackets is parsed as the volume
66 * number.
67 *
68 * IMPORTANT!: Adjust VOL_DEC_MAX_LEN if needed to the longest of these
69 */
70#define DEFAULT_VOL_DEC "Volume"
71
72#if (CONFIG_STORAGE & STORAGE_ATA)
73#define ATA_VOL_DEC "HDD"
74#endif
75#if (CONFIG_STORAGE & STORAGE_MMC)
76#define MMC_VOL_DEC "MMC"
77#endif
78#if (CONFIG_STORAGE & STORAGE_SD)
79#define SD_VOL_DEC "microSD"
80#endif
81#if (CONFIG_STORAGE & STORAGE_NAND)
82#define NAND_VOL_DEC "NAND"
83#endif
84#if (CONFIG_STORAGE & STORAGE_RAMDISK)
85#define RAMDISK_VOL_DEC "RAMDisk"
86#endif
87#if (CONFIG_STORAGE & STORAGE_USB)
88#define USB_VOL_DEC "USB"
89#endif
90#if (CONFIG_STORAGE & STORAGE_HOSTFS)
91#ifndef HOSTFS_VOL_DEC /* overridable */
92#define HOSTFS_VOL_DEC DEFAULT_VOL_DEC
93#endif
94#endif
95
96/* Characters that delimit a volume specifier at any root point in the path.
97 The tokens must be outside of legal filename characters */
98#define VOL_START_TOK '<'
99#define VOL_END_TOK '>'
100#define VOL_DEC_MAX_LEN 7 /* biggest of all xxx_VOL_DEC defines */
101#define VOL_MAX_LEN (1 + VOL_DEC_MAX_LEN + 2 + 1)
102#define VOL_NUM_MAX 100
103
104#ifndef ROOT_VOLUME
105#define ROOT_VOLUME INT_MAX
106#endif
107
108#else /* empty definitions if no multi-volume */
109#define IF_MV(x...)
110#define IF_MV_NONVOID(x...) void
111#define IF_MV_VOL(v) 0
112#endif /* HAVE_MULTIVOLUME */
113
114#define CHECK_VOL(volume) \
115 ((unsigned int)IF_MV_VOL(volume) < NUM_VOLUMES)
116
117#define CHECK_DRV(drive) \
118 ((unsigned int)IF_MD_DRV(drive) < NUM_DRIVES)
119
120/* contains info about a volume */
121struct volumeinfo
122{
123 int drive; /* drive number */
124 int partition; /* partition number (0 for superfloppy drives) */
125};
126
127/* Volume-centric functions (in disk.c) */
128void volume_recalc_free(IF_MV_NONVOID(int volume));
129unsigned int volume_get_cluster_size(IF_MV_NONVOID(int volume));
130void volume_size(IF_MV(int volume,) sector_t *size, sector_t *free);
131#ifdef HAVE_DIRCACHE
132bool volume_ismounted(IF_MV_NONVOID(int volume));
133#endif
134#ifdef HAVE_HOTSWAP
135bool volume_removable(int volume);
136bool volume_present(int volume);
137#else
138#define volume_present(x) 1
139#define volueme_removeable(x) 0
140#endif /* HAVE_HOTSWAP */
141
142#ifdef HAVE_MULTIDRIVE
143int volume_drive(int volume);
144#else /* !HAVE_MULTIDRIVE */
145static inline int volume_drive(int volume)
146{
147 return 0;
148 (void)volume;
149}
150#endif /* HAVE_MULTIDRIVE */
151
152int volume_partition(int volume);
153
154#endif /* __MV_H__ */