-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 13 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.h | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmpeg3/mpeg3io.c | 20 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 18 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.h | 4 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 98 |
6 files changed, 102 insertions, 53 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 9f8ba65..8ede537 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp @@ -33,4 +33,5 @@ #include <assert.h> #include <qapplication.h> +#include <qpe/config.h> //#define HAVE_MMAP @@ -48,4 +49,5 @@ extern "C" { #define MPEG_BUFFER_SIZE 65536 +//#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 //#define debugMsg(a) qDebug(a) #define debugMsg(a) @@ -166,5 +168,8 @@ bool LibMadPlugin::isFileSupported( const QString& path ) { bool LibMadPlugin::open( const QString& path ) { debugMsg( "LibMadPlugin::open" ); - + Config cfg("MediaPlayer"); + cfg.setGroup("Options"); + bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); + qDebug("buffer size is %d", bufferSize); d->bad_last_frame = 0; d->flush = TRUE; @@ -198,5 +203,5 @@ bool LibMadPlugin::open( const QString& path ) { if (d->input.data == 0) { - d->input.data = (unsigned char *)malloc(MPEG_BUFFER_SIZE); + d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); if (d->input.data == 0) { qDebug("error allocating input buffer"); @@ -370,5 +375,5 @@ bool LibMadPlugin::read() { do { - len = ::read(d->input.fd, d->input.data + d->input.length, MPEG_BUFFER_SIZE - d->input.length); + len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); } while (len == -1 && errno == EINTR); @@ -381,5 +386,5 @@ bool LibMadPlugin::read() { d->input.eof = 1; - assert(MPEG_BUFFER_SIZE - d->input.length >= MAD_BUFFER_GUARD); + assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); while (len < MAD_BUFFER_GUARD) diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index b240b77..46cd4a1 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h @@ -104,5 +104,5 @@ private: LibMadPluginData *d; QString info; - +int bufferSize; }; diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c index c5807a7..c5cae00 100644 --- a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c +++ b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c @@ -35,14 +35,14 @@ int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src) long mpeg3io_get_total_bytes(mpeg3_fs_t *fs) { -/* - * struct stat st; - * if(stat(fs->path, &st) < 0) return 0; - * return (long)st.st_size; - */ - - fseek(fs->fd, 0, SEEK_END); - fs->total_bytes = ftell(fs->fd); - fseek(fs->fd, 0, SEEK_SET); - return fs->total_bytes; + + struct stat st; + if(stat(fs->path, &st) < 0) return 0; + return (long)st.st_size; + + +/* fseek(fs->fd, 0, SEEK_END); */ +/* fs->total_bytes = ftell(fs->fd); */ +/* fseek(fs->fd, 0, SEEK_SET); */ +/* return fs->total_bytes; */ } diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 6259b3f..8f3711a 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp @@ -20,4 +20,6 @@ #include <qpe/applnk.h> #include <qpe/resource.h> +#include <qpe/config.h> + #include <qpainter.h> #include <qimage.h> @@ -51,5 +53,5 @@ PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) : QListView( parent, name ) { - qDebug("starting playlistselector"); +// qDebug("starting playlistselector"); // #ifdef USE_PLAYLIST_BACKGROUND // setStaticBackground( TRUE ); @@ -186,2 +188,16 @@ void PlayListSelection::unSelect() setSelected( currentItem(), FALSE); }
\ No newline at end of file + +void PlayListSelection::writeCurrent( Config& cfg ) { + cfg.setGroup("PlayList"); + QListViewItem *item = selectedItem(); + if ( item ) + cfg.writeEntry("current", item->text(0) ); + qDebug(item->text(0)); + +} + +void PlayListSelection::setSelectedItem(const QString &strk ) { +// setSelected( item, TRUE ); +// ensureItemVisible( selectedItem() ); +} diff --git a/core/multimedia/opieplayer/playlistselection.h b/core/multimedia/opieplayer/playlistselection.h index ba37271..d10bc82 100644 --- a/core/multimedia/opieplayer/playlistselection.h +++ b/core/multimedia/opieplayer/playlistselection.h @@ -24,5 +24,5 @@ #include <qlistview.h> #include <qpe/applnk.h> - +#include <qpe/config.h> class PlayListSelection : public QListView { @@ -39,4 +39,6 @@ public slots: void moveSelectedDown(); // Move the media file down the playlist so it is played later void unSelect(); + void writeCurrent( Config &); + void setSelectedItem( const QString & ); bool prev(); bool next(); diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 3b8f6d7..63df715 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -26,4 +26,5 @@ #include <qpe/qpeapplication.h> #include <qpe/lnkproperties.h> +#include <qpe/storage.h> #include <qpe/applnk.h> @@ -217,4 +218,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) audioView->setColumnAlignment(2, Qt::AlignRight); audioView->setAllColumnsShowFocus(TRUE); +// audioView->setMultiSelection( TRUE ); +// audioView->setSelectionMode( QListView::Extended); + tabWidget->insertTab(aTab,tr("Audio")); @@ -239,4 +243,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) videoView->setColumnAlignment(2, Qt::AlignRight); videoView->setAllColumnsShowFocus(TRUE); +// videoView->setMultiSelection( TRUE ); +// videoView->setSelectionMode( QListView::Extended); + QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), @@ -319,7 +326,6 @@ void PlayListWidget::initializeStates() { void PlayListWidget::readConfig( Config& cfg ) { cfg.setGroup("PlayList"); - + QString currentString = cfg.readEntry("current", "" ); int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); - for ( int i = 0; i < noOfFiles; i++ ) { QString entryName; @@ -327,15 +333,17 @@ void PlayListWidget::readConfig( Config& cfg ) { QString linkFile = cfg.readEntry( entryName ); DocLnk lnk( linkFile ); - if ( lnk.isValid() ) + if ( lnk.isValid() ) { d->selectedFiles->addToSelection( lnk ); } } +// d->selectedFiles->setSelectedItem( (const QString &)currentString); +} void PlayListWidget::writeConfig( Config& cfg ) const { - cfg.setGroup("PlayList"); + d->selectedFiles->writeCurrent( cfg); + cfg.setGroup("PlayList"); int noOfFiles = 0; - d->selectedFiles->first(); do { @@ -344,4 +352,5 @@ void PlayListWidget::writeConfig( Config& cfg ) const { QString entryName; entryName.sprintf( "File%i", noOfFiles + 1 ); + qDebug(entryName); cfg.writeEntry( entryName, lnk->linkFile() ); // if this link does exist, add it so we have the file @@ -362,9 +371,7 @@ void PlayListWidget::writeConfig( Config& cfg ) const { noOfFiles++; } - } while ( d->selectedFiles->next() ); - + } + while ( d->selectedFiles->next() ); cfg.writeEntry("NumberOfFiles", noOfFiles ); - - } @@ -387,15 +394,15 @@ void PlayListWidget::clearList() { void PlayListWidget::addAllToList() { - DocLnkSet files; - Global::findDocuments(&files, "video/*;audio/*"); - QListIterator<DocLnk> dit( files.children() ); - for ( ; dit.current(); ++dit ) - d->selectedFiles->addToSelection( **dit ); + DocLnkSet filesAll; + Global::findDocuments(&filesAll, "video/*;audio/*"); + QListIterator<DocLnk> Adit( filesAll.children() ); + for ( ; Adit.current(); ++Adit ) + d->selectedFiles->addToSelection( **Adit ); } void PlayListWidget::addAllMusicToList() { - DocLnkSet files; - Global::findDocuments(&files, "audio/*"); +// DocLnkSet files; +// Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) @@ -405,7 +412,5 @@ void PlayListWidget::addAllMusicToList() { void PlayListWidget::addAllVideoToList() { - DocLnkSet files; - Global::findDocuments(&files, "video/*"); - QListIterator<DocLnk> dit( files.children() ); + QListIterator<DocLnk> dit( vFiles.children() ); for ( ; dit.current(); ++dit ) d->selectedFiles->addToSelection( **dit ); @@ -589,11 +594,14 @@ void PlayListWidget::saveList() { Config cfg( filename +".playlist"); writeConfig( cfg ); - if( playLists->selected()->name() == filename) { -// qDebug("same name so delete lnk"); - QFile().remove(playLists->selected()->file()); - QFile().remove(playLists->selected()->linkFile()); - playLists->reread(); - } +// qDebug("same name so delete lnk??"); +// if( playLists->selected()->name() == filename) { + +// qDebug("same name so delete lnk"); +// QFile().remove(playLists->selected()->file()); +// QFile().remove(playLists->selected()->linkFile()); +// playLists->reread(); +// } +// qDebug("new doclnk"); DocLnk lnk; // lnk.setComment( ""); @@ -602,4 +610,5 @@ void PlayListWidget::saveList() { lnk.setIcon("mpegplayer/playlist2"); lnk.setName( filename); //sets file name + qDebug(filename); if(!lnk.writeLink()) qDebug("Writing doclink did not work"); @@ -622,9 +631,12 @@ void PlayListWidget::loadList( const DocLnk & lnk) { Config cfg( name+".playlist"); readConfig(cfg); + tabWidget->setCurrentPage(0); + Config config( "MediaPlayer" ); config.writeEntry("CurrentPlaylist", name); - d->selectedFiles->first(); +// d->selectedFiles->first(); } + } @@ -784,5 +796,6 @@ void PlayListWidget::btnPlay(bool b) { d->selectedFiles->removeSelected( ); tabWidget->setCurrentPage(1); - d->selectedFiles->unSelect(); + audioView->clearSelection(); +// d->selectedFiles->unSelect(); // mediaPlayerState->setPlaying(FALSE); } @@ -795,5 +808,6 @@ void PlayListWidget::btnPlay(bool b) { d->selectedFiles->removeSelected( ); tabWidget->setCurrentPage(2); - d->selectedFiles->unSelect(); + videoView->clearSelection(); +// d->selectedFiles->unSelect(); // mediaPlayerState->setPlaying(FALSE); } @@ -906,14 +920,20 @@ void PlayListWidget::populateAudioView() { // if(files) // files.~DocLnkSet(); + StorageInfo storageInfo; + const QList<FileSystem> &fs = storageInfo.fileSystems(); + Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); + QListIterator<FileSystem> it ( fs ); audioView->clear(); QString storage; for ( ; dit.current(); ++dit ) { + for( ; it.current(); ++it ){ + const QString name = (*it)->name(); + const QString path = (*it)->path(); + if(dit.current()->file().find(path) != -1 ) storage=name; + } + QListViewItem * newItem; - if(dit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); - else if(dit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); - else if(dit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); - else storage=tr("RAM"); if ( QFile( dit.current()->file()).exists() ) { newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); @@ -924,13 +944,19 @@ void PlayListWidget::populateAudioView() { void PlayListWidget::populateVideoView() { + StorageInfo storageInfo; + const QList<FileSystem> &fs = storageInfo.fileSystems(); + Global::findDocuments(&vFiles, "video/*"); QListIterator<DocLnk> Vdit( vFiles.children() ); + QListIterator<FileSystem> it ( fs ); videoView->clear(); QString storage; for ( ; Vdit.current(); ++Vdit ) { - if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); - else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); - else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); - else storage=tr("RAM"); + for( ; it.current(); ++it ){ + const QString name = (*it)->name(); + const QString path = (*it)->path(); + if( Vdit.current()->file().find(path) != -1 ) storage=name; + } + QListViewItem * newItem; if ( QFile( Vdit.current()->file()).exists() ) { |