Ignore:
Timestamp:
03/29/07 15:42:31 (17 years ago)
Author:
r2d
Message:
  • tag writing OK
  • better tag reading
  • maybe less pb with x64
File:
1 edited

Legend:

Unmodified
Added
Removed
  • winamp-musepack/trunk/mpc_player.cpp

    r253 r254  
    2929#include <mpc/minimax.h>
    3030
    31 #include <taglib/tag.h>
    32 #include <taglib/tfile.h>
    33 
     31#include <tag.h>
     32#include <tfile.h>
     33
     34const char* mpc_player::GenreList [NO_GENRES] = {
     35    "", "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk",
     36    "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies",
     37    "Other", "Pop", "R&B", "Rap", "Reggae", "Rock",
     38    "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks",
     39    "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk",
     40    "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House",
     41    "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass",
     42    "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock",
     43    "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk",
     44    "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta",
     45    "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret",
     46    "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi",
     47    "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical",
     48    "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", "Swing",
     49    "Fast-Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde",
     50    "Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band",
     51    "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson",
     52    "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus",
     53    "Po""rn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba",
     54    "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet",
     55    "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall",
     56    "Goa", "Drum & Bass", "Club House", "Ha""rd""co""re", "Terror",
     57    "Indie", "BritPop", "NegerPunk", "Polsk Punk", "Beat",
     58    "Christian Gangsta", "Heavy Metal", "Black Metal", "Crossover", "Contemporary C",
     59    "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "JPop",
     60    "SynthPop",
     61};
    3462
    3563mpc_player::mpc_player(In_Module * in_mod)
     
    5886        wait_event = 0;
    5987        tag_file = 0;
     88       
     89        TagLib::FileRef fileRef;
     90        fileRef.file()->useWinAnsiCP(true);
    6091}
    6192
     
    189220        if (length_in_ms) *length_in_ms = getLength();
    190221        if (title) {
    191                 if(tag_file == 0) {
     222                if (tag_file == 0)
    192223                        tag_file = new TagLib::FileRef(lastfn, false);
    193                         (tag_file->file())->useWinAnsiCP(true);
    194                 }
    195224
    196225                if (tag_file->isNull() || !tag_file->tag()) {
     
    201230                        TagLib::Tag *tag = tag_file->tag();
    202231                        sprintf(title, "%s - %s", tag->artist().toCString(), tag->title().toCString());
    203                         //tag->artist()
    204                         //tag->album()
    205                         //tag->year()
    206                         //tag->comment()
    207                         //tag->track()
    208                         //tag->genre()
    209232                }
    210233        }
     
    281304                TagLib::Tag *tag = tag_file->tag();
    282305
    283                 //tag->setTitle(wch);
    284                 //tag->setArtist(wch);
    285                 //tag->setAlbum(wch);
    286 
    287                 //TagLib::String year(wch);
    288                 //tag->setYear(year.toInt());
    289 
    290                 //TagLib::String track(wch);
    291                 //tag->setTrack(track.toInt());
    292 
    293                 //tag->setGenre(wch);
    294                 //tag->setComment(wch);
    295 
    296                 tag_file->save(); // FIXME : make all crash
     306                WCHAR buf[2048];
     307
     308                GetDlgItemTextW(hDlg, IDC_TITLE, buf, 2048);
     309                tag->setTitle(buf);
     310                GetDlgItemTextW(hDlg, IDC_ARTIST, buf, 2048);
     311                tag->setArtist(buf);
     312                GetDlgItemTextW(hDlg, IDC_ALBUM, buf, 2048);
     313                tag->setAlbum(buf);
     314                GetDlgItemTextW(hDlg, IDC_YEAR, buf, 2048);
     315                TagLib::String year(buf);
     316                tag->setYear(year.toInt());
     317                GetDlgItemTextW(hDlg, IDC_TRACK, buf, 2048);
     318                TagLib::String track(buf);
     319                tag->setTrack(track.toInt());
     320                GetDlgItemTextW(hDlg, IDC_GENRE, buf, 2048);
     321                tag->setGenre(buf);
     322                GetDlgItemTextW(hDlg, IDC_COMMENT, buf, 2048);
     323                tag->setComment(buf);
     324
     325                tag_file->save();
    297326        }
    298327}
     
    324353        SetDlgItemText(hDlg, IDC_STREAM_INFO, tmp.str().c_str());
    325354
    326         if(tag_file == 0) {
     355        SetDlgItemText(hDlg, IDC_FILE, lastfn);
     356
     357        if (tag_file == 0)
    327358                tag_file = new TagLib::FileRef(lastfn, false);
    328                 (tag_file->file())->useWinAnsiCP(true);
    329         }
    330359
    331360        if (!tag_file->isNull() && tag_file->tag()) {
     
    350379                SetDlgItemTextW(hDlg, IDC_COMMENT, buf);
    351380        }
     381
     382        HWND hGenre = GetDlgItem ( hDlg, IDC_GENRE );
     383        for ( int n = 0; n < NO_GENRES; n++ )
     384        SendMessage ( hGenre, CB_ADDSTRING, 0, (LONG)(LPSTR)GenreList[n] );
    352385}
    353386
     
    358391        {
    359392        case WM_INITDIALOG:
    360                 SetWindowLong(hDlg, DWL_USER, lParam);
     393                SetWindowLongPtr(hDlg, DWLP_USER, lParam);
    361394                ((mpc_player *) lParam)->initDlg(hDlg);
    362395                return TRUE;
     
    367400                        return TRUE;
    368401                } else if (LOWORD(wParam) == IDC_RELOAD) {
    369                         // FIXME : this will not work on X64
    370                         ((mpc_player*)GetWindowLong(hDlg, DWL_USER))->initDlg(hDlg);
     402                        ((mpc_player*)GetWindowLongPtr(hDlg, DWLP_USER))->initDlg(hDlg);
    371403                } else if (LOWORD(wParam) == IDC_SAVE) {
    372                         ((mpc_player*)GetWindowLong(hDlg, DWL_USER))->writeTags(hDlg);
     404                        ((mpc_player*)GetWindowLongPtr(hDlg, DWLP_USER))->writeTags(hDlg);
    373405                        EndDialog(hDlg, LOWORD(wParam));
    374406                        return TRUE;
     
    382414{
    383415        DialogBoxParam(mod->hDllInstance, (LPCTSTR)IDD_INFO_BOX, hwnd, (DLGPROC)About, (LPARAM) this);
    384 
    385         //loadTags(% infoBox);
    386 
    387         //infoBox.ShowDialog();
    388416        return 0;
    389417}
Note: See TracChangeset for help on using the changeset viewer.