forked from len0rd/rockbox
Added %fc WPS tag to display codec type - moved codectype from track_info struct into mp3info struct, initialise it on MAS platforms, and add it to the WPS.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6748 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2bfd2585a9
commit
961c9a3e41
6 changed files with 88 additions and 24 deletions
|
|
@ -94,7 +94,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Load codec specific track tag information. */
|
/* Load codec specific track tag information. */
|
||||||
switch (track->codectype) {
|
switch (track->id3.codectype) {
|
||||||
case AFMT_MPA_L1:
|
case AFMT_MPA_L1:
|
||||||
case AFMT_MPA_L2:
|
case AFMT_MPA_L2:
|
||||||
case AFMT_MPA_L3:
|
case AFMT_MPA_L3:
|
||||||
|
|
|
||||||
|
|
@ -531,7 +531,7 @@ bool loadcodec(const char *trackname, bool start_play)
|
||||||
codec_path = NULL;
|
codec_path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracks[track_widx].codectype = filetype;
|
tracks[track_widx].id3.codectype = filetype;
|
||||||
tracks[track_widx].codecsize = 0;
|
tracks[track_widx].codecsize = 0;
|
||||||
if (codec_path == NULL)
|
if (codec_path == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -540,7 +540,7 @@ bool loadcodec(const char *trackname, bool start_play)
|
||||||
prev_track = track_widx - 1;
|
prev_track = track_widx - 1;
|
||||||
if (prev_track < 0)
|
if (prev_track < 0)
|
||||||
prev_track = MAX_TRACK-1;
|
prev_track = MAX_TRACK-1;
|
||||||
if (track_count > 0 && filetype == tracks[prev_track].codectype) {
|
if (track_count > 0 && filetype == tracks[prev_track].id3.codectype) {
|
||||||
logf("Reusing prev. codec");
|
logf("Reusing prev. codec");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -667,8 +667,8 @@ bool audio_load_track(int offset, bool start_play, int peek_offset)
|
||||||
|
|
||||||
/* Starting playback from an offset is only support in MPA at the moment */
|
/* Starting playback from an offset is only support in MPA at the moment */
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
if ((tracks[track_widx].codectype==AFMT_MPA_L2) ||
|
if ((tracks[track_widx].id3.codectype==AFMT_MPA_L2) ||
|
||||||
(tracks[track_widx].codectype==AFMT_MPA_L3)) {
|
(tracks[track_widx].id3.codectype==AFMT_MPA_L3)) {
|
||||||
lseek(fd, offset, SEEK_SET);
|
lseek(fd, offset, SEEK_SET);
|
||||||
tracks[track_widx].id3.offset = offset;
|
tracks[track_widx].id3.offset = offset;
|
||||||
mp3_set_elapsed(&tracks[track_widx].id3);
|
mp3_set_elapsed(&tracks[track_widx].id3);
|
||||||
|
|
@ -955,7 +955,7 @@ bool codec_request_next_track_callback(void)
|
||||||
|
|
||||||
ci.reload_codec = false;
|
ci.reload_codec = false;
|
||||||
|
|
||||||
if (cur_ti->codectype != tracks[track_ridx].codectype) {
|
if (cur_ti->id3.codectype != tracks[track_ridx].id3.codectype) {
|
||||||
if (--track_ridx < 0)
|
if (--track_ridx < 0)
|
||||||
track_ridx = MAX_TRACK-1;
|
track_ridx = MAX_TRACK-1;
|
||||||
logf("New codec");
|
logf("New codec");
|
||||||
|
|
|
||||||
|
|
@ -27,23 +27,6 @@
|
||||||
#include "id3.h"
|
#include "id3.h"
|
||||||
#include "mp3data.h"
|
#include "mp3data.h"
|
||||||
|
|
||||||
/* Supported file types. */
|
|
||||||
#define AFMT_MPA_L1 0x0001 // MPEG Audio layer 1
|
|
||||||
#define AFMT_MPA_L2 0x0002 // MPEG Audio layer 2
|
|
||||||
#define AFMT_MPA_L3 0x0004 // MPEG Audio layer 3
|
|
||||||
/* (MPEG-1, 2, 2.5 layers 1, 2 and 3 */
|
|
||||||
#define AFMT_PCM_WAV 0x0008 // Uncompressed PCM in a WAV file
|
|
||||||
#define AFMT_OGG_VORBIS 0x0010 // Ogg Vorbis
|
|
||||||
#define AFMT_FLAC 0x0020 // FLAC
|
|
||||||
#define AFMT_MPC 0x0040 // Musepack
|
|
||||||
#define AFMT_AAC 0x0080 // AAC
|
|
||||||
#define AFMT_APE 0x0100 // Monkey's Audio
|
|
||||||
#define AFMT_WMA 0x0200 // Windows Media Audio
|
|
||||||
#define AFMT_A52 0x0400 // A/52 (aka AC3) audio
|
|
||||||
#define AFMT_REAL 0x0800 // Realaudio
|
|
||||||
#define AFMT_UNKNOWN 0x1000 // Unknown file format
|
|
||||||
#define AFMT_WAVPACK 0x2000 // WavPack
|
|
||||||
|
|
||||||
/* File buffer configuration keys. */
|
/* File buffer configuration keys. */
|
||||||
#define CODEC_SET_FILEBUF_WATERMARK 1
|
#define CODEC_SET_FILEBUF_WATERMARK 1
|
||||||
#define CODEC_SET_FILEBUF_CHUNKSIZE 2
|
#define CODEC_SET_FILEBUF_CHUNKSIZE 2
|
||||||
|
|
@ -58,7 +41,6 @@ struct track_info {
|
||||||
struct mp3info mp3data; /* MP3 metadata */
|
struct mp3info mp3data; /* MP3 metadata */
|
||||||
char *codecbuf; /* Pointer to codec buffer */
|
char *codecbuf; /* Pointer to codec buffer */
|
||||||
size_t codecsize; /* Codec length in bytes */
|
size_t codecsize; /* Codec length in bytes */
|
||||||
int codectype; /* Codec type (example AFMT_MPA_L3) */
|
|
||||||
|
|
||||||
off_t filerem; /* Remaining bytes of file NOT in buffer */
|
off_t filerem; /* Remaining bytes of file NOT in buffer */
|
||||||
off_t filesize; /* File total length */
|
off_t filesize; /* File total length */
|
||||||
|
|
|
||||||
|
|
@ -445,6 +445,9 @@ static char* get_tag(struct mp3entry* cid3,
|
||||||
case 's': /* File Size (in kilobytes) */
|
case 's': /* File Size (in kilobytes) */
|
||||||
snprintf(buf, buf_size, "%d", id3->filesize / 1024);
|
snprintf(buf, buf_size, "%d", id3->filesize / 1024);
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
|
case 'c': /* File Codec */
|
||||||
|
return id3_get_codec(id3);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,37 @@
|
||||||
#ifndef ID3_H
|
#ifndef ID3_H
|
||||||
#define ID3_H
|
#define ID3_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
|
/* Audio file types. */
|
||||||
|
/* NOTE: When adding new audio types, also add to codec_labels[] in id3.c */
|
||||||
|
enum {
|
||||||
|
AFMT_UNKNOWN = 0, /* Unknown file format */
|
||||||
|
|
||||||
|
#if CONFIG_HWCODEC==MASNONE
|
||||||
|
AFMT_MPA_L1, /* MPEG Audio layer 1 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AFMT_MPA_L2, /* MPEG Audio layer 2 */
|
||||||
|
AFMT_MPA_L3, /* MPEG Audio layer 3 */
|
||||||
|
|
||||||
|
#if CONFIG_HWCODEC==MASNONE
|
||||||
|
AFMT_PCM_WAV, /* Uncompressed PCM in a WAV file */
|
||||||
|
AFMT_OGG_VORBIS, /* Ogg Vorbis */
|
||||||
|
AFMT_FLAC, /* FLAC */
|
||||||
|
AFMT_MPC, /* Musepack */
|
||||||
|
AFMT_AAC, /* AAC */
|
||||||
|
AFMT_APE, /* Monkey's Audio */
|
||||||
|
AFMT_WMA, /* Windows Media Audio */
|
||||||
|
AFMT_A52, /* A/52 (aka AC3) audio */
|
||||||
|
AFMT_REAL, /* Realaudio */
|
||||||
|
AFMT_WAVPACK, /* WavPack */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AFMT_ENDMARKER /* THIS MUST BE THE LAST VALUE */
|
||||||
|
};
|
||||||
|
|
||||||
struct mp3entry {
|
struct mp3entry {
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
char *title;
|
char *title;
|
||||||
|
|
@ -33,6 +62,7 @@ struct mp3entry {
|
||||||
int tracknum;
|
int tracknum;
|
||||||
int version;
|
int version;
|
||||||
int layer;
|
int layer;
|
||||||
|
int codectype;
|
||||||
int year;
|
int year;
|
||||||
unsigned char id3version;
|
unsigned char id3version;
|
||||||
unsigned char genre;
|
unsigned char genre;
|
||||||
|
|
@ -76,5 +106,6 @@ enum {
|
||||||
|
|
||||||
bool mp3info(struct mp3entry *entry, const char *filename, bool v1first);
|
bool mp3info(struct mp3entry *entry, const char *filename, bool v1first);
|
||||||
char* id3_get_genre(const struct mp3entry* id3);
|
char* id3_get_genre(const struct mp3entry* id3);
|
||||||
|
char* id3_get_codec(const struct mp3entry* id3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include "config.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "atoi.h"
|
#include "atoi.h"
|
||||||
|
|
@ -77,6 +78,31 @@ static const char* const genres[] = {
|
||||||
"Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall"
|
"Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char* const codec_labels[] = {
|
||||||
|
"???", /* Unknown file format */
|
||||||
|
|
||||||
|
#if CONFIG_HWCODEC==MASNONE
|
||||||
|
"MP1", /* MPEG Audio layer 1 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
"MP2", /* MPEG Audio layer 2 */
|
||||||
|
"MP3", /* MPEG Audio layer 3 */
|
||||||
|
|
||||||
|
#if CONFIG_HWCODEC==MASNONE
|
||||||
|
"WAV", /* Uncompressed PCM in a WAV file */
|
||||||
|
"OGG", /* Ogg Vorbis */
|
||||||
|
"FLAC", /* FLAC */
|
||||||
|
"MPC", /* Musepack */
|
||||||
|
"AAC", /* AAC */
|
||||||
|
"APE", /* Monkey's Audio */
|
||||||
|
"WMA", /* Windows Media Audio */
|
||||||
|
"AC3", /* A/52 (aka AC3) audio */
|
||||||
|
"RA", /* Realaudio */
|
||||||
|
"WV", /* WavPack */
|
||||||
|
#endif
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
char* id3_get_genre(const struct mp3entry* id3)
|
char* id3_get_genre(const struct mp3entry* id3)
|
||||||
{
|
{
|
||||||
if( id3->genre_string )
|
if( id3->genre_string )
|
||||||
|
|
@ -87,6 +113,15 @@ char* id3_get_genre(const struct mp3entry* id3)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* id3_get_codec(const struct mp3entry* id3)
|
||||||
|
{
|
||||||
|
if ((id3->codectype >= 0) && (id3->codectype < AFMT_ENDMARKER)) {
|
||||||
|
return (char*)codec_labels[id3->codectype];
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
HOW TO ADD ADDITIONAL ID3 VERSION 2 TAGS
|
HOW TO ADD ADDITIONAL ID3 VERSION 2 TAGS
|
||||||
Code and comments by Thomas Paul Diffenbach
|
Code and comments by Thomas Paul Diffenbach
|
||||||
|
|
@ -763,6 +798,19 @@ static int getsonglength(int fd, struct mp3entry *entry)
|
||||||
entry->frequency = info.frequency;
|
entry->frequency = info.frequency;
|
||||||
entry->version = info.version;
|
entry->version = info.version;
|
||||||
entry->layer = info.layer;
|
entry->layer = info.layer;
|
||||||
|
switch(entry->layer) {
|
||||||
|
#if CONFIG_HWCODEC==MASNONE
|
||||||
|
case 0:
|
||||||
|
entry->codectype=AFMT_MPA_L1;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case 1:
|
||||||
|
entry->codectype=AFMT_MPA_L2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
entry->codectype=AFMT_MPA_L3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* If the file time hasn't been established, this may be a fixed
|
/* If the file time hasn't been established, this may be a fixed
|
||||||
rate MP3, so just use the default formula */
|
rate MP3, so just use the default formula */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue