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
;
43 if ((lseek(fd
, 0, SEEK_SET
) < 0)
44 || ((read_bytes
= read(fd
, buf
, 0x80)) < 0x80))
49 if ((memcmp(buf
, "PSID",4) != 0))
56 /* Copy Title (assumed max 0x1f letters + 1 zero byte) */
59 p
= iso_decode(&buf
[0x16], p
, 0, strlen(&buf
[0x16])+1);
61 /* Copy Artist (assumed max 0x1f letters + 1 zero byte) */
64 p
= iso_decode(&buf
[0x36], p
, 0, strlen(&buf
[0x36])+1);
66 /* Copy Year (assumed max 4 letters + 1 zero byte) */
68 id3
->year
= atoi(&buf
[0x56]);
70 /* Copy Album (assumed max 0x1f-0x05 letters + 1 zero byte) */
73 p
= iso_decode(&buf
[0x5b], p
, 0, strlen(&buf
[0x5b])+1);
76 id3
->frequency
= 44100;
77 /* New idea as posted by Marco Alanen (ravon):
78 * Set the songlength in seconds to the number of subsongs
79 * so every second represents a subsong.
80 * Users can then skip the current subsong by seeking
82 * Note: the number of songs is a 16bit value at 0xE, so this code only
83 * uses the lower 8 bits of the counter.
85 id3
->length
= (buf
[0xf]-1)*1000;
87 id3
->filesize
= filesize(fd
);