1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Dave Chapman
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
29 #include "metadata_common.h"
30 #include "metadata_parsers.h"
31 #include "rbunicode.h"
33 /* PSID metadata info is available here:
34 http://www.unusedino.de/ec64/technical/formats/sidplay.html */
35 bool get_sid_metadata(int fd
, struct mp3entry
* id3
)
37 /* Use the trackname part of the id3 structure as a temporary buffer */
38 unsigned char* buf
= (unsigned char *)id3
->path
;
42 if ((lseek(fd
, 0, SEEK_SET
) < 0)
43 || (read(fd
, buf
, 0x80) < 0x80))
48 if ((memcmp(buf
, "PSID", 4) != 0))
55 /* Copy Title (assumed max 0x1f letters + 1 zero byte) */
58 p
= iso_decode(&buf
[0x16], p
, 0, strlen(&buf
[0x16])+1);
60 /* Copy Artist (assumed max 0x1f letters + 1 zero byte) */
63 p
= iso_decode(&buf
[0x36], p
, 0, strlen(&buf
[0x36])+1);
65 /* Copy Year (assumed max 4 letters + 1 zero byte) */
67 id3
->year
= atoi(&buf
[0x56]);
69 /* Copy Album (assumed max 0x1f-0x05 letters + 1 zero byte) */
72 iso_decode(&buf
[0x5b], p
, 0, strlen(&buf
[0x5b])+1);
75 id3
->frequency
= 44100;
76 /* New idea as posted by Marco Alanen (ravon):
77 * Set the songlength in seconds to the number of subsongs
78 * so every second represents a subsong.
79 * Users can then skip the current subsong by seeking
81 * Note: the number of songs is a 16bit value at 0xE, so this code only
82 * uses the lower 8 bits of the counter.
84 id3
->length
= (buf
[0xf]-1)*1000;
86 id3
->filesize
= filesize(fd
);