mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Revert "buffering: remove bufgettail/bufcuttail"
This reverts commit 9e93796407
.
Fixes FS#13626, which is caused by non-audio ID3v1/APE tags at
the end of the audio data stream.
Change-Id: Ic69af14a5d1264b7896a54b5f2ad314022dd98ac
This commit is contained in:
parent
3cb4e63253
commit
2bd88936f7
5 changed files with 107 additions and 2 deletions
|
@ -499,6 +499,44 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname)
|
|||
return get_metadata_ex(id3, fd, trackname, 0);
|
||||
}
|
||||
|
||||
#ifndef __PCTOOL__
|
||||
void strip_tags(int handle_id)
|
||||
{
|
||||
static const unsigned char tag[] = "TAG";
|
||||
static const unsigned char apetag[] = "APETAGEX";
|
||||
size_t len, version;
|
||||
void *tail;
|
||||
|
||||
if (bufgettail(handle_id, 128, &tail) != 128)
|
||||
return;
|
||||
|
||||
if (memcmp(tail, tag, 3) == 0)
|
||||
{
|
||||
/* Skip id3v1 tag */
|
||||
logf("Cutting off ID3v1 tag");
|
||||
bufcuttail(handle_id, 128);
|
||||
}
|
||||
|
||||
/* Get a new tail, as the old one may have been cut */
|
||||
if (bufgettail(handle_id, 32, &tail) != 32)
|
||||
return;
|
||||
|
||||
/* Check for APE tag (look for the APE tag footer) */
|
||||
if (memcmp(tail, apetag, 8) != 0)
|
||||
return;
|
||||
|
||||
/* Read the version and length from the footer */
|
||||
version = get_long_le(&((unsigned char *)tail)[8]);
|
||||
len = get_long_le(&((unsigned char *)tail)[12]);
|
||||
if (version == 2000)
|
||||
len += 32; /* APEv2 has a 32 byte header */
|
||||
|
||||
/* Skip APE tag */
|
||||
logf("Cutting off APE tag (%ldB)", len);
|
||||
bufcuttail(handle_id, len);
|
||||
}
|
||||
#endif /* ! __PCTOOL__ */
|
||||
|
||||
#define MOVE_ENTRY(x) if (x) x += offset;
|
||||
|
||||
void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig)
|
||||
|
|
|
@ -338,6 +338,7 @@ void wipe_mp3entry(struct mp3entry *id3);
|
|||
void fill_metadata_from_path(struct mp3entry *id3, const char *trackname);
|
||||
int get_audio_base_codec_type(int type);
|
||||
const char * get_codec_string(int type);
|
||||
void strip_tags(int handle_id);
|
||||
bool rbcodec_format_is_atomic(int afmt);
|
||||
bool format_buffers_with_offset(int afmt);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue