A modern, network-enabled music player platform built on Rockbox technology. rockboxd.tsiry-sandratraina.com
rust deno navidrome airplay libadwaita zig mpris snapcast mpd rockbox audio subsonic
2

Configure Feed

Select the types of activity you want to include in your feed.

rockboxd / lib / rbcodec / metadata / sid.c
2.9 kB 88 lines
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * 9 * Copyright (C) 2005 Dave Chapman 10 * 11 * This program is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; either version 2 14 * of the License, or (at your option) any later version. 15 * 16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 17 * KIND, either express or implied. 18 * 19 ****************************************************************************/ 20#include <stdio.h> 21#include <string.h> 22#include <stdlib.h> 23#include <ctype.h> 24#include <inttypes.h> 25#include "platform.h" 26 27#include "metadata.h" 28#include "metadata_common.h" 29#include "metadata_parsers.h" 30#include "rbunicode.h" 31 32/* PSID metadata info is available here: 33 http://www.unusedino.de/ec64/technical/formats/sidplay.html */ 34bool get_sid_metadata(int fd, struct mp3entry* id3) 35{ 36 /* Use the trackname part of the id3 structure as a temporary buffer */ 37 unsigned char* buf = (unsigned char *)id3->path; 38 char *p; 39 40 41 if ((lseek(fd, 0, SEEK_SET) < 0) 42 || (read(fd, buf, 0x80) < 0x80)) 43 { 44 return false; 45 } 46 47 if (memcmp(buf, "PSID", 4) != 0 && memcmp(buf, "RSID", 4) != 0) 48 { 49 return false; 50 } 51 52 p = id3->id3v2buf; 53 54 /* Copy Title (assumed max 0x1f letters + 1 zero byte) */ 55 id3->title = p; 56 buf[0x16+0x1f] = 0; 57 p = iso_decode(&buf[0x16], p, 0, strlen(&buf[0x16])+1); 58 59 /* Copy Artist (assumed max 0x1f letters + 1 zero byte) */ 60 id3->artist = p; 61 buf[0x36+0x1f] = 0; 62 p = iso_decode(&buf[0x36], p, 0, strlen(&buf[0x36])+1); 63 64 /* Copy Year (assumed max 4 letters + 1 zero byte) */ 65 buf[0x56+0x4] = 0; 66 id3->year = atoi(&buf[0x56]); 67 68 /* Copy Album (assumed max 0x1f-0x05 letters + 1 zero byte) */ 69 id3->album = p; 70 buf[0x56+0x1f] = 0; 71 iso_decode(&buf[0x5b], p, 0, strlen(&buf[0x5b])+1); 72 73 id3->bitrate = 706; 74 id3->frequency = 44100; 75 /* New idea as posted by Marco Alanen (ravon): 76 * Set the songlength in seconds to the number of subsongs 77 * so every second represents a subsong. 78 * Users can then skip the current subsong by seeking 79 * 80 * Note: the number of songs is a 16bit value at 0xE, so this code only 81 * uses the lower 8 bits of the counter. 82 */ 83 id3->length = (buf[0xf]-1)*1000; 84 id3->vbr = false; 85 id3->FS_PREFIX(filesize) = filesize(fd); 86 87 return true; 88}