Index: ChangeLog =================================================================== RCS file: ChangeLog diff -N ChangeLog --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ChangeLog 21 Sep 2002 14:41:20 -0000 1.3 @@ -0,0 +1,29 @@ +2002-09-21 YamaKen + + * LIBMADPLUGIN_JA_1_5_0_3 + + * 日本語ファイル名をサポートした + +2002-08-16 YamaKen + + * LIBMADPLUGIN_JA_1_5_0_2 + + * opie-mediaplayerで再生できない問題を解決した。opie-libmadplugin + に倣ってbool LibMadPlugin::audioReadSamples()の返値の意味を + 'failed'から'succeeded'に修正した。qtopia-free-1.5.0のlibmadplugin + の実装は間違っていると思われる(根拠: libmpeg3pluginは'succeeded'を + 返している) + + * SL-5500に標準で含まれるMP3プラグインを隠すためのスクリプトを追加 + +2002-08-10 YamaKen + + * LIBMADPLUGIN_JA_1_5_0_1 + + * qtopia-free-1.5.0/mpegplayer/libmadをベースに日本語化した + + * SJIS, EUC-JP, ISO8859-1の各文字コードを自動判別 + + * ID3v1タグのみに対応(元にしたlibmadpluginの仕様) + + * ファイルの演奏時間が取得できない(元にしたlibmadpluginの仕様) Index: libmad.pro =================================================================== RCS file: /var/cvsroot/yamaken/devel/zaurus/libmad-ja/libmad.pro,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -u -r1.1.1.1 -r1.3 --- libmad.pro 7 Aug 2002 15:26:17 -0000 1.1.1.1 +++ libmad.pro 21 Sep 2002 14:59:48 -0000 1.3 @@ -1,11 +1,15 @@ +#make CFLAGS+=-DFPM_ARM CXXFLAGS+=-DFPM_ARM +#make CFLAGS+=-DFPM_INTEL CXXFLAGS+=-DFPM_INTEL +#tmake時にごにょごにょと設定が必要。面倒なので生成済Makefileをコピーする TEMPLATE = lib CONFIG += qt warn_on release HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \ layer12.h layer3.h huffman.h libmad_global.h mad.h libmadplugin.h libmadpluginimpl.h SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \ layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp +TRANSLATIONS = libmadplugin_ja.ts TARGET = madplugin -DESTDIR = ../../plugins/codecs +DESTDIR = dist/opt/QtPalmtop/plugins/codecs/ INCLUDEPATH += $(QPEDIR)/include .. DEPENDPATH += ../$(QPEDIR)/include .. LIBS += -lqpe -lm Index: libmadplugin.cpp =================================================================== RCS file: /var/cvsroot/yamaken/devel/zaurus/libmad-ja/libmadplugin.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.6 diff -u -u -r1.1.1.1 -r1.6 --- libmadplugin.cpp 7 Aug 2002 15:26:17 -0000 1.1.1.1 +++ libmadplugin.cpp 21 Sep 2002 14:29:55 -0000 1.6 @@ -32,6 +32,8 @@ #include #include #include +#include +#include //#define HAVE_MMAP @@ -51,6 +53,7 @@ //#define debugMsg(a) qDebug(a) #define debugMsg(a) +static QTextCodec *codec_for_str(const char *str); class Input { public: @@ -111,6 +114,32 @@ return qApp->translate( "MediaPlayer", str, "libmad strings for mp3 file info" ); } +static QTextCodec * +codec_for_str(const char *str) { + static const char *encodings[] = { + //"UTF-8", "SJIS", "eucJP", "ISO 8859-1", NULL //failed to match UTF-8 + "SJIS", "eucJP", "ISO 8859-1", NULL + }; + QTextCodec *codec = NULL, *candidate = NULL; + int i, score = 0, hiscore = 0; + + for (i = 0; encodings[i]; i++) { + candidate = QTextCodec::codecForName(encodings[i]); + if (candidate) { + score = candidate->heuristicContentMatch(str, strlen(str)); + } + if (hiscore < score) { + hiscore = score; + codec = candidate; + } + } + if (!codec) { + codec = QTextCodec::codecForName("ISO 8859-1"); + } + + return codec; +} + class LibMadPluginData { public: @@ -126,6 +155,7 @@ LibMadPlugin::LibMadPlugin() { d = new LibMadPluginData; + d->input.path = 0; d->input.fd = 0; #if defined(HAVE_MMAP) d->input.fdm = 0; @@ -138,6 +168,9 @@ LibMadPlugin::~LibMadPlugin() { close(); + if ( d->input.path ) { + free( (char *)d->input.path ); + } delete d; } @@ -150,14 +183,11 @@ // Other media extensions // "wav","mid","mod","s3m","ogg","avi","mov","sid" - char *ext = strrchr( path.latin1(), '.' ); + QString ext = QFileInfo(path).extension(FALSE); // Test file extension - if ( ext ) { - if ( strncasecmp(ext, ".mp2", 4) == 0 ) - return TRUE; - if ( strncasecmp(ext, ".mp3", 4) == 0 ) - return TRUE; + if (ext == "mp2" || ext == "mp3") { + return TRUE; } return FALSE; @@ -173,7 +203,11 @@ //qDebug( "Opening %s", path.latin1() ); - d->input.path = path.latin1(); + d->input.path = strdup(path.local8Bit()); + if (!d->input.path) { + qDebug("error insufficient memory"); + return FALSE; + } d->input.fd = ::open( d->input.path, O_RDONLY ); if (d->input.fd == -1) { qDebug("error opening %s", d->input.path ); @@ -288,14 +322,19 @@ int LibMadPlugin::audioSamples( int ) { + int seconds, samples; + unsigned int sample_rate; + debugMsg( "LibMadPlugin::audioSamples" ); -/* long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); - qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, d->frame.header.samplerate ); - return d->frame.header.duration.seconds * d->frame.header.samplerate; -*/ - return 10000000; + + sample_rate = d->frame.header.samplerate; + seconds = 99 * 60/*min*/ + 59/*sec*/; + samples = seconds * sample_rate; + qDebug( "LibMadPlugin::audioSamples: %i*%i", seconds, sample_rate ); + + return samples; } @@ -512,7 +551,7 @@ static bool needInput = TRUE; if ( samples == 0 ) - return TRUE; + return FALSE; do { if ( needInput ) @@ -520,13 +559,13 @@ // if ( d->input.eof ) // needInput = FALSE; // else - return TRUE; + return FALSE; } needInput = FALSE; if ( decode( output, samples, samplesMade ) ) - return FALSE; + return TRUE; else needInput = TRUE; } @@ -537,10 +576,10 @@ if ( firstTimeThru ) { firstTimeThru = FALSE; decode( output, samples, samplesMade ); - return FALSE; + return TRUE; } else */ - return TRUE; + return FALSE; } @@ -579,8 +618,14 @@ char *ptr3 = ptr2; while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--; char push2 = *ptr3; *ptr3 = '\0'; - if ( strcmp( ptr, "" ) ) - info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; + if ( strcmp( ptr, "" ) ) { + QTextCodec *codec; + QString unicode_str; + + codec = codec_for_str(ptr); + unicode_str = codec->toUnicode(ptr); + info += ( i != 0 ? ", " : "" ) + label[i] + ": " + unicode_str; + } //qDebug( info.latin1() ); *ptr3 = push2; *ptr2 = push;