cadb3627fc
librbcodec users must provide these two files when the library is built. rbcodecconfig.h provides configuration #defines and basic types, and will be included by public librbcodec headers, so it must not conflict with the user's code. rbcodecplatform.h provides various OS functions, and will only be included by source files and private headers. This system is intended to provide maximum flexibility for use on embedded systems, where no operating system headers are included. Unix systems can just copy rbcodecconfig-example.h and rbcodecplatform-unix.h with minimal changes. Change-Id: I350a2274d173da391fd1ca00c4202e9760d91def Reviewed-on: http://gerrit.rockbox.org/143 Reviewed-by: Nils Wallménius <nils@rockbox.org> Tested-by: Nils Wallménius <nils@rockbox.org>
97 lines
2.8 KiB
C
97 lines
2.8 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id$
|
|
*
|
|
* Copyright (C) 2007 Dave Chapman
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
****************************************************************************/
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include <inttypes.h>
|
|
#include "platform.h"
|
|
|
|
#include "metadata.h"
|
|
#include "metadata_common.h"
|
|
#include "metadata_parsers.h"
|
|
|
|
bool get_monkeys_metadata(int fd, struct mp3entry* id3)
|
|
{
|
|
/* Use the trackname part of the id3 structure as a temporary buffer */
|
|
unsigned char* buf = (unsigned char *)id3->path;
|
|
unsigned char* header;
|
|
bool rc = false;
|
|
uint32_t descriptorlength;
|
|
uint32_t totalsamples;
|
|
uint32_t blocksperframe, finalframeblocks, totalframes;
|
|
int fileversion;
|
|
|
|
lseek(fd, 0, SEEK_SET);
|
|
|
|
if (read(fd, buf, 4) < 4)
|
|
{
|
|
return rc;
|
|
}
|
|
|
|
if (memcmp(buf, "MAC ", 4) != 0)
|
|
{
|
|
return rc;
|
|
}
|
|
|
|
read(fd, buf + 4, MAX_PATH - 4);
|
|
|
|
fileversion = get_short_le(buf+4);
|
|
if (fileversion < 3970)
|
|
{
|
|
/* Not supported */
|
|
return false;
|
|
}
|
|
|
|
if (fileversion >= 3980)
|
|
{
|
|
descriptorlength = get_long_le(buf+8);
|
|
|
|
header = buf + descriptorlength;
|
|
|
|
blocksperframe = get_long_le(header+4);
|
|
finalframeblocks = get_long_le(header+8);
|
|
totalframes = get_long_le(header+12);
|
|
id3->frequency = get_long_le(header+20);
|
|
}
|
|
else
|
|
{
|
|
/* v3.95 and later files all have a fixed framesize */
|
|
blocksperframe = 73728 * 4;
|
|
|
|
finalframeblocks = get_long_le(buf+28);
|
|
totalframes = get_long_le(buf+24);
|
|
id3->frequency = get_long_le(buf+12);
|
|
}
|
|
|
|
id3->vbr = true; /* All APE files are VBR */
|
|
id3->filesize = filesize(fd);
|
|
|
|
totalsamples = finalframeblocks;
|
|
if (totalframes > 1)
|
|
totalsamples += blocksperframe * (totalframes-1);
|
|
|
|
id3->length = ((int64_t) totalsamples * 1000) / id3->frequency;
|
|
id3->bitrate = (id3->filesize * 8) / id3->length;
|
|
|
|
read_ape_tags(fd, id3);
|
|
return true;
|
|
}
|