summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2008-10-14 11:12:20 +0000
committerBjörn Stenberg <bjorn@haxx.se>2008-10-14 11:12:20 +0000
commit9558c4956d3d603c4d132af88633767810f3ba62 (patch)
treeb0d739f6246a7175de106562a2c755724f977cbe /firmware/export
parent91b9c6139b3447d7c0f4f2924ef73a9dc323703b (diff)
downloadrockbox-9558c4956d3d603c4d132af88633767810f3ba62.tar.gz
rockbox-9558c4956d3d603c4d132af88633767810f3ba62.zip
Moved pcm_record from firmware to apps. Cleaned up some. Now all code using struct mp3entry is in apps.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18807 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/audio.h2
-rw-r--r--firmware/export/id3.h246
-rw-r--r--firmware/export/mas.h6
-rw-r--r--firmware/export/mpeg.h66
-rw-r--r--firmware/export/pcm_record.h66
-rw-r--r--firmware/export/replaygain.h33
6 files changed, 6 insertions, 413 deletions
diff --git a/firmware/export/audio.h b/firmware/export/audio.h
index 9530082050..661247df2f 100644
--- a/firmware/export/audio.h
+++ b/firmware/export/audio.h
@@ -30,8 +30,6 @@
30#include "pcm_sampr.h" 30#include "pcm_sampr.h"
31#include "pcm.h" 31#include "pcm.h"
32#ifdef HAVE_RECORDING 32#ifdef HAVE_RECORDING
33#include "pcm_record.h"
34#include "id3.h"
35#include "enc_base.h" 33#include "enc_base.h"
36#endif /* HAVE_RECORDING */ 34#endif /* HAVE_RECORDING */
37#endif /* CONFIG_CODEC == SWCODEC */ 35#endif /* CONFIG_CODEC == SWCODEC */
diff --git a/firmware/export/id3.h b/firmware/export/id3.h
deleted file mode 100644
index da2faf1b12..0000000000
--- a/firmware/export/id3.h
+++ /dev/null
@@ -1,246 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg
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#ifndef ID3_H
22#define ID3_H
23
24#include <stdbool.h>
25#include "config.h"
26#include "file.h"
27
28#define ID3V2_BUF_SIZE 300
29
30/* Audio file types. */
31/* NOTE: The values of the AFMT_* items are used for the %fc tag in the WPS
32 - so new entries MUST be added to the end to maintain compatibility.
33 */
34enum
35{
36 AFMT_UNKNOWN = 0, /* Unknown file format */
37
38 /* start formats */
39
40 AFMT_MPA_L1, /* MPEG Audio layer 1 */
41 AFMT_MPA_L2, /* MPEG Audio layer 2 */
42 AFMT_MPA_L3, /* MPEG Audio layer 3 */
43
44#if CONFIG_CODEC == SWCODEC
45 AFMT_AIFF, /* Audio Interchange File Format */
46 AFMT_PCM_WAV, /* Uncompressed PCM in a WAV file */
47 AFMT_OGG_VORBIS, /* Ogg Vorbis */
48 AFMT_FLAC, /* FLAC */
49 AFMT_MPC, /* Musepack */
50 AFMT_A52, /* A/52 (aka AC3) audio */
51 AFMT_WAVPACK, /* WavPack */
52 AFMT_ALAC, /* Apple Lossless Audio Codec */
53 AFMT_AAC, /* Advanced Audio Coding (AAC) in M4A container */
54 AFMT_SHN, /* Shorten */
55 AFMT_SID, /* SID File Format */
56 AFMT_ADX, /* ADX File Format */
57 AFMT_NSF, /* NESM (NES Sound Format) */
58 AFMT_SPEEX, /* Ogg Speex speech */
59 AFMT_SPC, /* SPC700 save state */
60 AFMT_APE, /* Monkey's Audio (APE) */
61 AFMT_WMA, /* WMAV1/V2 in ASF */
62 AFMT_MOD, /* Amiga MOD File Format */
63 AFMT_SAP, /* Amiga 8Bit SAP Format */
64#endif
65
66 /* add new formats at any index above this line to have a sensible order -
67 specified array index inits are used */
68 /* format arrays defined in id3.c */
69
70 AFMT_NUM_CODECS,
71
72#if CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING)
73 /* masks to decompose parts */
74 CODEC_AFMT_MASK = 0x0fff,
75 CODEC_TYPE_MASK = 0x7000,
76
77 /* switch for specifying codec type when requesting a filename */
78 CODEC_TYPE_DECODER = (0 << 12), /* default */
79 CODEC_TYPE_ENCODER = (1 << 12),
80#endif /* CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) */
81};
82
83#if CONFIG_CODEC == SWCODEC
84#define CODEC_EXTENSION "codec"
85
86#ifdef HAVE_RECORDING
87#define ENCODER_SUFFIX "_enc"
88enum rec_format_indexes
89{
90 __REC_FORMAT_START_INDEX = -1,
91
92 /* start formats */
93
94 REC_FORMAT_PCM_WAV,
95 REC_FORMAT_AIFF,
96 REC_FORMAT_WAVPACK,
97 REC_FORMAT_MPA_L3,
98
99 /* add new formats at any index above this line to have a sensible order -
100 specified array index inits are used
101 REC_FORMAT_CFG_NUM_BITS should allocate enough bits to hold the range
102 REC_FORMAT_CFG_VALUE_LIST should be in same order as indexes
103 */
104
105 REC_NUM_FORMATS,
106
107 REC_FORMAT_DEFAULT = REC_FORMAT_PCM_WAV,
108 REC_FORMAT_CFG_NUM_BITS = 2
109};
110
111#define REC_FORMAT_CFG_VAL_LIST "wave,aiff,wvpk,mpa3"
112
113/* get REC_FORMAT_* corresponding AFMT_* */
114extern const int rec_format_afmt[REC_NUM_FORMATS];
115/* get AFMT_* corresponding REC_FORMAT_* */
116extern const int afmt_rec_format[AFMT_NUM_CODECS];
117
118#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
119 { label, root_fname, enc_root_fname, ext_list }
120#else /* !HAVE_RECORDING */
121#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
122 { label, root_fname, ext_list }
123#endif /* HAVE_RECORDING */
124#else /* !SWCODEC */
125
126#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
127 { label, ext_list }
128#endif /* CONFIG_CODEC == SWCODEC */
129
130/* record describing the audio format */
131struct afmt_entry
132{
133 char label[8]; /* format label */
134#if CONFIG_CODEC == SWCODEC
135 char *codec_root_fn; /* root codec filename (sans _enc and .codec) */
136#ifdef HAVE_RECORDING
137 char *codec_enc_root_fn; /* filename of encoder codec */
138#endif
139#endif
140 char *ext_list; /* double NULL terminated extension
141 list for type with the first as
142 the default for recording */
143};
144
145/* database of labels and codecs. add formats per above enum */
146extern const struct afmt_entry audio_formats[AFMT_NUM_CODECS];
147
148struct mp3entry {
149 char path[MAX_PATH];
150 char* title;
151 char* artist;
152 char* album;
153 char* genre_string;
154 char* disc_string;
155 char* track_string;
156 char* year_string;
157 char* composer;
158 char* comment;
159 char* albumartist;
160 char* grouping;
161 int discnum;
162 int tracknum;
163 int version;
164 int layer;
165 int year;
166 unsigned char id3version;
167 unsigned int codectype;
168 unsigned int bitrate;
169 unsigned long frequency;
170 unsigned long id3v2len;
171 unsigned long id3v1len;
172 unsigned long first_frame_offset; /* Byte offset to first real MP3 frame.
173 Used for skipping leading garbage to
174 avoid gaps between tracks. */
175 unsigned long vbr_header_pos;
176 unsigned long filesize; /* without headers; in bytes */
177 unsigned long length; /* song length in ms */
178 unsigned long elapsed; /* ms played */
179
180 int lead_trim; /* Number of samples to skip at the beginning */
181 int tail_trim; /* Number of samples to remove from the end */
182
183 /* Added for Vorbis */
184 unsigned long samples; /* number of samples in track */
185
186 /* MP3 stream specific info */
187 unsigned long frame_count; /* number of frames in the file (if VBR) */
188
189 /* Used for A52/AC3 */
190 unsigned long bytesperframe; /* number of bytes per frame (if CBR) */
191
192 /* Xing VBR fields */
193 bool vbr;
194 bool has_toc; /* True if there is a VBR header in the file */
195 unsigned char toc[100]; /* table of contents */
196
197 /* these following two fields are used for local buffering */
198 char id3v2buf[ID3V2_BUF_SIZE];
199 char id3v1buf[4][92];
200
201 /* resume related */
202 unsigned long offset; /* bytes played */
203 int index; /* playlist index */
204
205 /* runtime database fields */
206 long tagcache_idx; /* 0=invalid, otherwise idx+1 */
207 int rating;
208 int score;
209 long playcount;
210 long lastplayed;
211 long playtime;
212
213 /* replaygain support */
214
215#if CONFIG_CODEC == SWCODEC
216 char* track_gain_string;
217 char* album_gain_string;
218 long track_gain; /* 7.24 signed fixed point. 0 for no gain. */
219 long album_gain;
220 long track_peak; /* 7.24 signed fixed point. 0 for no peak. */
221 long album_peak;
222#endif
223
224 /* Cuesheet support */
225 int cuesheet_type; /* 0: none, 1: external, 2: embedded */
226
227 /* Musicbrainz Track ID */
228 char* mb_track_id;
229};
230
231enum {
232 ID3_VER_1_0 = 1,
233 ID3_VER_1_1,
234 ID3_VER_2_2,
235 ID3_VER_2_3,
236 ID3_VER_2_4
237};
238
239bool get_mp3_metadata(int fd, struct mp3entry *entry, const char *filename);
240bool mp3info(struct mp3entry *entry, const char *filename);
241char* id3_get_num_genre(unsigned int genre_num);
242int getid3v2len(int fd);
243void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig);
244void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig);
245
246#endif
diff --git a/firmware/export/mas.h b/firmware/export/mas.h
index ab6135cbfa..493ed6a63c 100644
--- a/firmware/export/mas.h
+++ b/firmware/export/mas.h
@@ -163,3 +163,9 @@ int mas_codec_readreg(int reg);
163unsigned long mas_readver(void); 163unsigned long mas_readver(void);
164 164
165#endif 165#endif
166
167#if CONFIG_TUNER & S1A0903X01
168void mas_store_pllfreq(int freq);
169int mas_get_pllfreq(void);
170#endif
171
diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h
deleted file mode 100644
index ce2cff0069..0000000000
--- a/firmware/export/mpeg.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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#ifndef _MPEG_H_
22#define _MPEG_H_
23
24#include <stdbool.h>
25#include "id3.h"
26
27#define MPEG_SWAP_CHUNKSIZE 0x2000
28#define MPEG_HIGH_WATER 2 /* We leave 2 bytes empty because otherwise we
29 wouldn't be able to see the difference between
30 an empty buffer and a full one. */
31#define MPEG_LOW_WATER 0x60000
32#define MPEG_RECORDING_LOW_WATER 0x80000
33#define MPEG_LOW_WATER_CHUNKSIZE 0x40000
34#define MPEG_LOW_WATER_SWAP_CHUNKSIZE 0x10000
35#ifdef HAVE_MMC
36#define MPEG_PLAY_PENDING_THRESHOLD 0x20000
37#define MPEG_PLAY_PENDING_SWAPSIZE 0x20000
38#else
39#define MPEG_PLAY_PENDING_THRESHOLD 0x10000
40#define MPEG_PLAY_PENDING_SWAPSIZE 0x10000
41#endif
42
43#define MPEG_MAX_PRERECORD_SECONDS 30
44
45/* For ID3 info and VBR header */
46#define MPEG_RESERVED_HEADER_SPACE (4096 + 576)
47
48#if (CONFIG_CODEC == MAS3587F) || defined(SIMULATOR)
49
50#if CONFIG_TUNER & S1A0903X01
51int mpeg_get_mas_pllfreq(void);
52#endif
53
54#endif
55unsigned long mpeg_get_last_header(void);
56
57/* in order to keep the recording here, I have to expose this */
58void rec_tick(void);
59void playback_tick(void); /* FixMe: get rid of this, use mp3_get_playtime() */
60
61void audio_set_track_changed_event(void (*handler)(struct mp3entry *id3));
62void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3));
63void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3));
64void audio_set_cuesheet_callback(bool (*handler)(const char *filename));
65
66#endif
diff --git a/firmware/export/pcm_record.h b/firmware/export/pcm_record.h
deleted file mode 100644
index f805313fe5..0000000000
--- a/firmware/export/pcm_record.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Linus Nielsen Feltzing
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 PCM_RECORD_H
23#define PCM_RECORD_H
24
25#define DMA_REC_ERROR_DMA (-1)
26#ifdef HAVE_SPDIF_REC
27#define DMA_REC_ERROR_SPDIF (-2)
28#endif
29
30/** Warnings **/
31/* pcm (dma) buffer has overflowed */
32#define PCMREC_W_PCM_BUFFER_OVF 0x00000001
33/* encoder output buffer has overflowed */
34#define PCMREC_W_ENC_BUFFER_OVF 0x00000002
35/** Errors **/
36/* failed to load encoder */
37#define PCMREC_E_LOAD_ENCODER 0x80001000
38/* error originating in encoder */
39#define PCMREC_E_ENCODER 0x80002000
40/* filename queue has desynced from stream markers */
41#define PCMREC_E_FNQ_DESYNC 0x80004000
42/* I/O error has occurred */
43#define PCMREC_E_IO 0x80008000
44#ifdef DEBUG
45/* encoder has written past end of allotted space */
46#define PCMREC_E_CHUNK_OVF 0x80010000
47#endif /* DEBUG */
48
49/** General functions for high level codec recording **/
50/* pcm_rec_error_clear is deprecated for general use. audio_error_clear
51 should be used */
52void pcm_rec_error_clear(void);
53/* pcm_rec_status is deprecated for general use. audio_status merges the
54 results for consistency with the hardware codec version */
55unsigned long pcm_rec_status(void);
56unsigned long pcm_rec_get_warnings(void);
57void pcm_rec_init(void);
58int pcm_rec_current_bitrate(void);
59int pcm_rec_encoder_afmt(void); /* AFMT_* value, AFMT_UNKNOWN if none */
60int pcm_rec_rec_format(void); /* Format index or -1 otherwise */
61unsigned long pcm_rec_sample_rate(void);
62int pcm_get_num_unprocessed(void);
63
64/* audio.h contains audio_* recording functions */
65
66#endif /* PCM_RECORD_H */
diff --git a/firmware/export/replaygain.h b/firmware/export/replaygain.h
deleted file mode 100644
index dbc079b1d3..0000000000
--- a/firmware/export/replaygain.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 Magnus Holmgren
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 _REPLAYGAIN_H
23#define _REPLAYGAIN_H
24
25#include "id3.h"
26
27long get_replaygain_int(long int_gain);
28long parse_replaygain(const char* key, const char* value,
29 struct mp3entry* entry, char* buffer, int length);
30long parse_replaygain_int(bool album, long gain, long peak,
31 struct mp3entry* entry, char* buffer, int length);
32
33#endif