diff options
Diffstat (limited to 'plugins/sid')
-rw-r--r-- | plugins/sid/Makefile.am | 6 | ||||
-rw-r--r-- | plugins/sid/csid.cpp | 96 | ||||
-rw-r--r-- | plugins/sid/csid.h | 4 | ||||
-rw-r--r-- | plugins/sid/plugin.c | 39 | ||||
-rw-r--r-- | plugins/sid/sidplay-libs/libsidplay/src/sidtune/SidTune.cpp | 13 |
5 files changed, 92 insertions, 66 deletions
diff --git a/plugins/sid/Makefile.am b/plugins/sid/Makefile.am index 38caa014..f5408088 100644 --- a/plugins/sid/Makefile.am +++ b/plugins/sid/Makefile.am @@ -103,9 +103,9 @@ sidplay-libs/libsidplay/src/kernal.bin\ sidplay-libs/libsidplay/src/psiddrv.bin\ sidplay-libs/libsidplay/src/poweron.bin -sid_la_LIBADD = -lstdc++ -sid_la_LDFLAGS = -module +sid_la_LDFLAGS = -module -nostdlib -lsupc++ AM_CFLAGS = $(CFLAGS) -std=c99 -I$(sidpath)/libsidplay/include -I$(sidpath)/builders/resid-builder/include -fPIC -AM_CPPFLAGS = $(CXXFLAGS) -DHAVE_UNIX -I$(sidpath) -I$(sidpath)/unix -I$(sidpath)/libsidplay -I$(sidpath)/libsidplay/include -I$(sidpath)/libsidplay/include/sidplay -I$(sidpath)/libsidutils/include/sidplay/utils -I$(sidpath)/builders/resid-builder/include/sidplay/builders -I$(sidpath)/builders/resid-builder/include -DHAVE_STRCASECMP -DHAVE_STRNCASECMP +AM_CPPFLAGS = $(CXXFLAGS) -DHAVE_UNIX -I$(sidpath) -I$(sidpath)/unix -I$(sidpath)/libsidplay -I$(sidpath)/libsidplay/include -I$(sidpath)/libsidplay/include/sidplay -I$(sidpath)/libsidutils/include/sidplay/utils -I$(sidpath)/builders/resid-builder/include/sidplay/builders -I$(sidpath)/builders/resid-builder/include -DHAVE_STRCASECMP -DHAVE_STRNCASECMP -fno-exceptions -fno-rtti -fno-unwind-tables + endif diff --git a/plugins/sid/csid.cpp b/plugins/sid/csid.cpp index ccb2ecb3..ffdd4548 100644 --- a/plugins/sid/csid.cpp +++ b/plugins/sid/csid.cpp @@ -1,6 +1,6 @@ /* DeaDBeeF - ultimate music player for GNU/Linux systems with X11 - Copyright (C) 2009-2010 Alexey Yakovenko <waker@users.sourceforge.net> + Copyright (C) 2009-2011 Alexey Yakovenko <waker@users.sourceforge.net> 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 @@ -34,12 +34,26 @@ #include "../../deadbeef.h" #include "csid.h" +#ifndef ANDROID +int _Unwind_Resume_or_Rethrow; +int _Unwind_RaiseException; +int _Unwind_GetLanguageSpecificData; +int _Unwind_Resume; +int _Unwind_DeleteException; +int _Unwind_GetTextRelBase; +int _Unwind_SetIP; +int _Unwind_GetDataRelBase; +int _Unwind_GetRegionStart; +int _Unwind_SetGR; +int _Unwind_GetIPInfo; +#endif + extern DB_decoder_t sid_plugin; //#define trace(...) { fprintf(stderr, __VA_ARGS__); } #define trace(fmt,...) -static DB_functions_t *deadbeef; +DB_functions_t *deadbeef; #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) @@ -94,8 +108,9 @@ sldb_load() sldb_disable = 1; return; } - const char *conf_hvsc_path = deadbeef->conf_get_str ("hvsc_path", NULL); - if (!conf_hvsc_path) { + char conf_hvsc_path[1000]; + deadbeef->conf_get_str ("hvsc_path", "", conf_hvsc_path, sizeof (conf_hvsc_path)); + if (!conf_hvsc_path[0]) { sldb_disable = 1; return; } @@ -276,7 +291,7 @@ sldb_find (const uint8_t *digest) { } DB_fileinfo_t * -csid_open (void) { +csid_open (uint32_t hints) { DB_fileinfo_t *_info = (DB_fileinfo_t *)malloc (sizeof (sid_info_t)); memset (_info, 0, sizeof (sid_info_t)); return _info; @@ -288,26 +303,28 @@ csid_init (DB_fileinfo_t *_info, DB_playItem_t *it) { // libsidplay crashes if file doesn't exist // so i have to check it here - FILE *fp = fopen (it->fname, "rb"); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp ){ return -1; } - fclose (fp); + deadbeef->fclose (fp); info->sidplay = new sidplay2; info->resid = new ReSIDBuilder ("wtf"); info->resid->create (info->sidplay->info ().maxsids); -// resid->create (1); info->resid->filter (true); int samplerate = deadbeef->conf_get_int ("sid.samplerate", 44100); - int bps = deadbeef->get_output ()->bitspersample (); + int bps = deadbeef->conf_get_int ("sid.bps", 16); + if (bps != 16 && bps != 8) { + bps = 16; + } info->resid->sampling (samplerate); info->duration = deadbeef->pl_get_item_duration (it); - info->tune = new SidTune (it->fname); + info->tune = new SidTune (deadbeef->pl_find_meta (it, ":URI")); - info->tune->selectSong (it->tracknum+1); + info->tune->selectSong (deadbeef->pl_find_meta_int (it, ":TRACKNUM", 0)+1); sid2_config_t conf; conf = info->sidplay->config (); conf.frequency = samplerate; @@ -319,9 +336,10 @@ csid_init (DB_fileinfo_t *_info, DB_playItem_t *it) { info->sidplay->load (info->tune); _info->plugin = &sid_plugin; - _info->channels = info->tune->isStereo () ? 2 : 1; - _info->bps = bps; - _info->samplerate = conf.frequency; + _info->fmt.channels = conf.playback == sid2_stereo ? 2 : 1; + _info->fmt.bps = bps; + _info->fmt.samplerate = conf.frequency; + _info->fmt.channelmask = _info->fmt.channels == 1 ? DDB_SPEAKER_FRONT_LEFT : (DDB_SPEAKER_FRONT_LEFT | DDB_SPEAKER_FRONT_RIGHT); _info->readpos = 0; int maxsids = info->sidplay->info ().maxsids; @@ -354,24 +372,15 @@ csid_read (DB_fileinfo_t *_info, char *bytes, int size) { if (_info->readpos > info->duration) { return 0; } - int rd = info->sidplay->play (bytes, size/_info->channels); - _info->readpos += size/_info->channels/2 / (float)_info->samplerate; -#if 0 -#if WORDS_BIGENDIAN - // convert samples from le to be - int n = rd * _info->channels/2; - int16_t *ptr = (int16_t *)bytes; - while (n > 0) { - int16_t out; - le_int16 (*ptr, (unsigned char *)&out); - *ptr = out; - ptr++; - n--; - } -#endif -#endif - return rd * _info->channels; + int rd = info->sidplay->play (bytes, size); + + int samplesize = (_info->fmt.bps>>3) * _info->fmt.channels; + + _info->readpos += rd / samplesize / (float)_info->fmt.samplerate; + + return size; + } int @@ -386,11 +395,11 @@ csid_seek (DB_fileinfo_t *_info, float time) { t -= _info->readpos; } info->resid->filter (false); - int samples = t * _info->samplerate; - samples *= 2 * _info->channels; - uint16_t buffer[2048 * _info->channels]; + int samples = t * _info->fmt.samplerate; + samples *= (_info->fmt.bps>>3) * _info->fmt.channels; + uint16_t buffer[2048 * _info->fmt.channels]; while (samples > 0) { - int n = min (samples, 2048) * _info->channels; + int n = min (samples, 2048) * _info->fmt.channels; int done = info->sidplay->play (buffer, n); if (done < n) { trace ("sid seek failure\n"); @@ -478,15 +487,13 @@ csid_insert (DB_playItem_t *after, const char *fname) { // Include number of songs. endian_little16 (tmp,tune->getInfo ().songs); myMD5.append (tmp,sizeof(tmp)); - { // Include song speed for each song. - //uint_least16_t currentSong = tune->getInfo ().currentSong; + { + // Include song speed for each song. for (uint_least16_t s = 1; s <= tune->getInfo ().songs; s++) { tune->selectSong (s); myMD5.append (&tune->getInfo ().songSpeed,1); } - // Restore old song - //tune->selectSong (currentSong); } // Deal with PSID v2NG clock speed flags: Let only NTSC // clock speed change the MD5 fingerprint. That way the @@ -499,7 +506,6 @@ csid_insert (DB_playItem_t *after, const char *fname) { memcpy (sig, myMD5.getDigest (), 16); #endif -// sldb_load (); int song = -1; if (sldb_loaded) { song = sldb_find (sig); @@ -509,10 +515,8 @@ csid_insert (DB_playItem_t *after, const char *fname) { for (int s = 0; s < tunes; s++) { trace ("select %d...\n", s); if (tune->selectSong (s+1)) { - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (sid_plugin.plugin.id); - it->fname = strdup (fname); - it->tracknum = s; + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, sid_plugin.plugin.id); + deadbeef->pl_set_meta_int (it, ":TRACKNUM", s); SidTuneInfo sidinfo; tune->getInfo (sidinfo); int i = sidinfo.numberOfInfoStrings; @@ -549,7 +553,7 @@ csid_insert (DB_playItem_t *after, const char *fname) { deadbeef->pl_add_meta (it, "title", NULL); } - float length = 120; + float length = deadbeef->conf_get_float ("sid.defaultlength", 180); if (sldb_loaded) { if (song >= 0 && sldb->sldb_lengths[song][s] >= 0) { length = sldb->sldb_lengths[song][s]; @@ -563,7 +567,7 @@ csid_insert (DB_playItem_t *after, const char *fname) { // } } deadbeef->pl_set_item_duration (it, length); - it->filetype = "SID"; + deadbeef->pl_add_meta (it, ":FILETYPE", "SID"); after = deadbeef->pl_insert_item (after, it); deadbeef->pl_item_unref (it); diff --git a/plugins/sid/csid.h b/plugins/sid/csid.h index 273daa2c..c35be3d7 100644 --- a/plugins/sid/csid.h +++ b/plugins/sid/csid.h @@ -1,6 +1,6 @@ /* DeaDBeeF - ultimate music player for GNU/Linux systems with X11 - Copyright (C) 2009-2010 Alexey Yakovenko <waker@users.sourceforge.net> + Copyright (C) 2009-2011 Alexey Yakovenko <waker@users.sourceforge.net> 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 @@ -23,7 +23,7 @@ extern "C" { #endif -DB_fileinfo_t *csid_open (void); +DB_fileinfo_t *csid_open (uint32_t hints); int csid_init (DB_fileinfo_t *_info, DB_playItem_t *it); void csid_free (DB_fileinfo_t *); int csid_read (DB_fileinfo_t *, char *bytes, int size); diff --git a/plugins/sid/plugin.c b/plugins/sid/plugin.c index 9a2e9a27..c8f1f7b0 100644 --- a/plugins/sid/plugin.c +++ b/plugins/sid/plugin.c @@ -1,6 +1,6 @@ /* DeaDBeeF - ultimate music player for GNU/Linux systems with X11 - Copyright (C) 2009-2010 Alexey Yakovenko <waker@users.sourceforge.net> + Copyright (C) 2009-2011 Alexey Yakovenko <waker@users.sourceforge.net> 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 @@ -22,21 +22,42 @@ static const char *exts[] = { "sid",NULL }; const char *filetypes[] = { "SID", NULL }; static const char settings_dlg[] = - "property \"Enable HVSC\" checkbox hvsc_enable 0;\n" - "property \"HVSC path\" file hvsc_path \"\";\n" - "property \"Samplerate\" entry sid.samplerate 48000;\n" + "property \"Enable HVSC Songlength DB\" checkbox hvsc_enable 0;\n" + "property \"Songlengths.txt (from HVSC)\" file hvsc_path \"\";\n" + "property \"Samplerate\" entry sid.samplerate 44100;\n" + "property \"Bits per sample (8 or 16)\" entry sid.bps 16;\n" + "property \"Default song length (sec)\" entry sid.defaultlength 180;\n" ; // define plugin interface DB_decoder_t sid_plugin = { DB_PLUGIN_SET_API_VERSION .plugin.type = DB_PLUGIN_DECODER, - .plugin.version_major = 0, - .plugin.version_minor = 1, + .plugin.version_major = 1, + .plugin.version_minor = 0, .plugin.name = "SID decoder", .plugin.descr = "SID player based on libsidplay2", - .plugin.author = "Alexey Yakovenko", - .plugin.email = "waker@users.sourceforge.net", + .plugin.copyright = + "Copyright (C) 2009-2011 Alexey Yakovenko <waker@users.sourceforge.net>\n" + "\n" + "Uses modified libsidplay2-2.1.0\n" + "Commodore 64 SID emulation library\n" + "Copyright (C) Simon White and other authors\n" + "\n" + "This program is free software; you can redistribute it and/or\n" + "modify it under the terms of the GNU General Public License\n" + "as published by the Free Software Foundation; either version 2\n" + "of the License, or (at your option) any later version.\n" + "\n" + "This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU General Public License\n" + "along with this program; if not, write to the Free Software\n" + "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n" + , .plugin.website = "http://deadbeef.sf.net", .plugin.start = csid_start, .plugin.stop = csid_stop, @@ -45,7 +66,7 @@ DB_decoder_t sid_plugin = { .open = csid_open, .init = csid_init, .free = csid_free, - .read_int16 = csid_read, + .read = csid_read, .seek = csid_seek, .seek_sample = NULL, .insert = csid_insert, diff --git a/plugins/sid/sidplay-libs/libsidplay/src/sidtune/SidTune.cpp b/plugins/sid/sidplay-libs/libsidplay/src/sidtune/SidTune.cpp index 4dfba1d7..fdbd64e1 100644 --- a/plugins/sid/sidplay-libs/libsidplay/src/sidtune/SidTune.cpp +++ b/plugins/sid/sidplay-libs/libsidplay/src/sidtune/SidTune.cpp @@ -25,6 +25,7 @@ #include "sidendian.h" #include "PP20.h" #include <stdio.h> +#include "../../../../../../../deadbeef.h" #ifdef HAVE_EXCEPTIONS # include <new> @@ -32,6 +33,8 @@ #include <string.h> #include <limits.h> +extern DB_functions_t *deadbeef; + #if defined(HAVE_IOS_OPENMODE) typedef std::ios::openmode openmode; #else @@ -252,7 +255,7 @@ bool SidTune::loadFile(const char* fileName, Buffer_sidtt<const uint_least8_t>& Buffer_sidtt<uint_least8_t> fileBuf; uint_least32_t fileLen = 0; - FILE *fp = fopen (fileName, "rb"); + DB_FILE *fp = deadbeef->fopen (fileName); if (!fp) { @@ -261,9 +264,7 @@ bool SidTune::loadFile(const char* fileName, Buffer_sidtt<const uint_least8_t>& } else { - fseek (fp, 0, SEEK_END); - fileLen = ftell (fp); - rewind (fp); + fileLen = deadbeef->fgetlength(fp); #ifdef HAVE_EXCEPTIONS if ( !fileBuf.assign(new(std::nothrow) uint_least8_t[fileLen],fileLen) ) #else @@ -274,7 +275,7 @@ bool SidTune::loadFile(const char* fileName, Buffer_sidtt<const uint_least8_t>& return false; } uint_least32_t restFileLen = fileLen; - int res = fread((char*)fileBuf.get()+(fileLen-restFileLen),1,restFileLen,fp); + int res = deadbeef->fread((char*)fileBuf.get()+(fileLen-restFileLen),1,restFileLen,fp); if ( res != restFileLen ) { info.statusString = SidTune::txt_cantLoadFile; @@ -285,7 +286,7 @@ bool SidTune::loadFile(const char* fileName, Buffer_sidtt<const uint_least8_t>& info.statusString = SidTune::txt_noErrors; } } - fclose(fp); + deadbeef->fclose(fp); if ( fileLen==0 ) { info.statusString = SidTune::txt_empty; |