author | llornkcor <llornkcor> | 2002-02-25 00:26:33 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-25 00:26:33 (UTC) |
commit | c0446b55fc32b7fdea9f58db06e40da703f5e8ff (patch) (side-by-side diff) | |
tree | b84cbcdf9d2687bb3e8672981a6e62577c98becb | |
parent | 146ed85c70bf6a288294e91baceb9af9ec5b8611 (diff) | |
download | opie-c0446b55fc32b7fdea9f58db06e40da703f5e8ff.zip opie-c0446b55fc32b7fdea9f58db06e40da703f5e8ff.tar.gz opie-c0446b55fc32b7fdea9f58db06e40da703f5e8ff.tar.bz2 |
*** empty log message ***
-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 8 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 16 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 47 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 12 |
4 files changed, 44 insertions, 39 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 59136af..11fd9e8 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp @@ -100,25 +100,25 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume #ifdef Q_OS_WIN32 HWAVEOUT handle; WAVEFORMATEX formatData; formatData.cbSize = sizeof(WAVEFORMATEX); formatData.wFormatTag = WAVE_FORMAT_PCM; formatData.nAvgBytesPerSec = 4 * 44000; formatData.nBlockAlign = 4; formatData.nChannels = 2; formatData.nSamplesPerSec = 44000; formatData.wBitsPerSample = 16; waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) - qDebug( "get volume of audio device failed" ); +// qDebug( "get volume of audio device failed" ); waveOutClose( handle ); leftVolume = volume & 0xFFFF; rightVolume = volume >> 16; #else int mixerHandle = open( "/dev/mixer", O_RDWR ); if ( mixerHandle >= 0 ) { if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) perror("ioctl(\"MIXER_READ\")"); close( mixerHandle ); } else perror("open(\"/dev/mixer\")"); leftVolume = ((volume & 0x00FF) << 16) / 101; @@ -142,25 +142,25 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, HWAVEOUT handle; WAVEFORMATEX formatData; formatData.cbSize = sizeof(WAVEFORMATEX); formatData.wFormatTag = WAVE_FORMAT_PCM; formatData.nAvgBytesPerSec = 4 * 44000; formatData.nBlockAlign = 4; formatData.nChannels = 2; formatData.nSamplesPerSec = 44000; formatData.wBitsPerSample = 16; waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); unsigned int volume = (rightVolume << 16) | leftVolume; if ( waveOutSetVolume( handle, volume ) ) - qDebug( "set volume of audio device failed" ); +// qDebug( "set volume of audio device failed" ); waveOutClose( handle ); #else // Volume can be from 0 to 100 which is 101 distinct values unsigned int rV = (rightVolume * 101) >> 16; # if 0 unsigned int lV = (leftVolume * 101) >> 16; unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); int mixerHandle = 0; if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) perror("ioctl(\"MIXER_WRITE\")"); @@ -183,31 +183,31 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; #endif } AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { d = new AudioDevicePrivate; d->frequency = f; d->channels = chs; d->bytesPerSample = bps; - qDebug("%d",bps); +// qDebug("%d",bps); int format=0; if( bps == 8) format = AFMT_U8; else if( bps <= 0) format = AFMT_S16_LE; else format = AFMT_S16_LE; - qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); +// qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); int fragments = 0x10000 * 8 + sound_fragment_shift; int capabilities = 0; #ifdef KEEP_DEVICE_OPEN if ( AudioDevicePrivate::dspFd == 0 ) { #endif if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { perror("open(\"/dev/dsp\") sending to /dev/null instead"); d->handle = ::open( "/dev/null", O_WRONLY ); diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 859a67a..1ae0059 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -226,32 +226,32 @@ void LoopControl::startAudio() { if ( !isMuted && mediaPlayerState->curDecoder() ) { currentSample = audioSampleCounter + 1; if ( currentSample != audioSampleCounter + 1 ) qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); long samplesRead = 0; bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; long sampleWaitTime = currentSample - sampleWeShouldBeAt; -// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 5000 ) ) { -// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); -// } -// else if ( sampleWaitTime <= -5000 ) { -// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); -// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); -// currentSample = sampleWeShouldBeAt; -// } + if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { + usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); + } + else if ( sampleWaitTime <= -5000 ) { + qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); + //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); + currentSample = sampleWeShouldBeAt; + } audioDevice->write( audioBuffer, samplesRead * 2 * channels ); audioSampleCounter = currentSample + samplesRead - 1; moreAudio = readOk && (audioSampleCounter <= total_audio_samples); } else { moreAudio = FALSE; } diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 4e1543e..269aed8 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -30,25 +30,25 @@ #include <qimage.h> #include <qfile.h> #include <qlayout.h> #include <qlabel.h> #include <qlist.h> #include <qlistbox.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qtoolbutton.h> #include <qtabwidget.h> #include <qlistview.h> #include <qpoint.h> -#include <qtimer.h> +//#include <qtimer.h> #include "playlistselection.h" #include "playlistwidget.h" #include "mediaplayerstate.h" #include <stdlib.h> #define BUTTONS_ON_TOOLBAR #define SIDE_BUTTONS #define CAN_SAVE_LOAD_PLAYLISTS extern MediaPlayerState *mediaPlayerState; @@ -89,26 +89,26 @@ public: connect( this, SIGNAL( activated() ), handler, slot ); addTo( parent ); } }; PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { d = new PlayListWidgetPrivate; d->setDocumentUsed = FALSE; d->current = NULL; - menuTimer = new QTimer( this ,"menu timer"), - connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); +// menuTimer = new QTimer( this ,"menu timer"), +// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); setBackgroundMode( PaletteButton ); setCaption( tr("OpiePlayer") ); setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); setToolBarsMovable( FALSE ); // Create Toolbar QPEToolBar *toolbar = new QPEToolBar( this ); toolbar->setHorizontalStretchable( TRUE ); @@ -195,54 +195,59 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) audioView->addColumn("Size", 45); audioView->addColumn("Media",35); audioView->setColumnAlignment(1, Qt::AlignRight); audioView->setColumnAlignment(2, Qt::AlignRight); tabWidget->insertTab(aTab,"Audio"); // audioView Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); QString storage; for ( ; dit.current(); ++dit ) { QListViewItem * newItem; if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; + else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; else storage="RAM"; - + if ( QFile( dit.current()->file()).exists() ) { newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); + } } // videowidget QWidget *vTab; vTab = new QWidget( tabWidget, "vTab" ); videoView = new QListView( vTab, "Videoview" ); videoView->setMinimumSize(233,260); videoView->addColumn("Title",150); videoView->addColumn("Size",45); videoView->addColumn("Media",35); videoView->setColumnAlignment(1, Qt::AlignRight); videoView->setColumnAlignment(2, Qt::AlignRight); tabWidget->insertTab( vTab,"Video"); Global::findDocuments(&vFiles, "video/*"); QListIterator<DocLnk> Vdit( vFiles.children() ); for ( ; Vdit.current(); ++Vdit ) { if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; + else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; else storage="RAM"; QListViewItem * newItem; + if ( QFile( Vdit.current()->file()).exists() ) { newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); + } } // d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); // d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); // add the library area // d->files->setBackgroundMode( PaletteButton ); // QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); // #ifdef SIDE_BUTTONS @@ -654,40 +659,40 @@ void PlayListWidget::tabChanged(QWidget *widg) { d->tbAddToList->setEnabled(TRUE); } break; case 2: { d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); } break; }; } -void PlayListWidget::cancelMenuTimer() { - if( menuTimer->isActive() ) - menuTimer->stop(); -} +// void PlayListWidget::cancelMenuTimer() { +// if( menuTimer->isActive() ) +// menuTimer->stop(); +// } -void PlayListWidget::showFileMenu() { +// void PlayListWidget::showFileMenu() { -} +// } -void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) -{ -// QListView::contentsMousePressEvent( e ); - menuTimer->start( 750, TRUE ); -} +// void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) +// { +// // QListView::contentsMousePressEvent( e ); +// menuTimer->start( 750, TRUE ); +// } -void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) -{ -// QListView::contentsMouseReleaseEvent( e ); - menuTimer->stop(); -} -// void PlayListWidget::setFullScreen() { +// void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) +// { +// // QListView::contentsMouseReleaseEvent( e ); +// menuTimer->stop(); +// } +// // void PlayListWidget::setFullScreen() { // mediaPlayerState->toggleFullscreen( ); // } // void PlayListWidget::setScaled() { // mediaPlayerState->toggleScaled(); // } diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 3a52dd5..6fe2211 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h @@ -15,50 +15,50 @@ ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef PLAY_LIST_WIDGET_H #define PLAY_LIST_WIDGET_H #include <qmainwindow.h> #include <qpe/applnk.h> #include <qtabwidget.h> -#include <qtimer.h> +/* #include <qtimer.h> */ class PlayListWidgetPrivate; class Config; class QListViewItem; class QListView; class QPoint; class QAction; class QLabel; class PlayListWidget : public QMainWindow { Q_OBJECT public: PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); ~PlayListWidget(); QTabWidget * tabWidget; QAction *fullScreenButton, *scaleButton; DocLnkSet files; DocLnkSet vFiles; QListView *audioView, *videoView, *playlistView; QLabel *libString; // retrieve the current playlist entry (media file link) const DocLnk *current(); void useSelectedDocument(); - QTimer * menuTimer; +/* QTimer * menuTimer; */ public slots: void setDocument( const QString& fileref ); void addToSelection( const DocLnk& ); // Add a media file to the playlist void addToSelection( QListViewItem* ); // Add a media file to the playlist void addToSelection( QListViewItem*, const QPoint&,int ); // Add a media file to the playlist void setActiveWindow(); // need to handle this to show the right view void setPlaylist( bool ); // Show/Hide the playlist void setView( char ); void clearList(); void addAllToList(); void addAllMusicToList(); @@ -67,31 +67,31 @@ public slots: void loadList(); // Load a playlist void playIt( QListViewItem *); bool first(); bool last(); bool next(); bool prev(); void addSelected(); void removeSelected(); void tabChanged(QWidget*); /* void setFullScreen(); */ /* void setScaled(); */ protected: - void contentsMousePressEvent( QMouseEvent * e ); - void contentsMouseReleaseEvent( QMouseEvent * e ); +/* void contentsMousePressEvent( QMouseEvent * e ); */ +/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ private: void initializeStates(); void readConfig( Config& cfg ); void writeConfig( Config& cfg ) const; PlayListWidgetPrivate *d; // Private implementation data protected slots: - void cancelMenuTimer(); - void showFileMenu(); +/* void cancelMenuTimer(); */ +/* void showFileMenu(); */ }; #endif // PLAY_LIST_WIDGET_H |