author | llornkcor <llornkcor> | 2003-02-16 21:28:48 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-16 21:28:48 (UTC) |
commit | e0eb3f016d7f8a1e1e5548ef8aa115fef8999697 (patch) (side-by-side diff) | |
tree | cbbabd894c57770cfe6b9ab1da577a50d268e4d4 | |
parent | 73aed6b9a34330b31f05864746269017cd53017d (diff) | |
download | opie-e0eb3f016d7f8a1e1e5548ef8aa115fef8999697.zip opie-e0eb3f016d7f8a1e1e5548ef8aa115fef8999697.tar.gz opie-e0eb3f016d7f8a1e1e5548ef8aa115fef8999697.tar.bz2 |
fix small annoyances and bug
-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 8 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 11 |
2 files changed, 11 insertions, 8 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 136e06c..73e41dc 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp @@ -119,143 +119,143 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, # 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\")"); close( mixerHandle ); } else perror("open(\"/dev/mixer\")"); # else // This is the way this has to be done now I guess, doesn't allow for // independant right and left channel setting, or setting for different outputs Config cfg("qpe"); // qtopia is "Sound" cfg.setGroup("Volume"); // qtopia is "Settings" cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume # endif //#endif // qDebug( "setting volume to: 0x%x", volume ); #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) // Send notification that the volume has changed QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; #endif } AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { qDebug("creating new audio device"); - QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; +// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; d = new AudioDevicePrivate; d->frequency = f; d->channels = chs; d->bytesPerSample = 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); 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"); perror("open(\"/dev/dsp\")"); QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now."); QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); exit(-1); //harsh? // d->handle = ::open( "/dev/null", O_WRONLY ); // WTF?!?! } #ifdef KEEP_DEVICE_OPEN AudioDevicePrivate::dspFd = d->handle; } else { d->handle = AudioDevicePrivate::dspFd; } #endif if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); qDebug("freq %d", d->frequency); if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) perror("ioctl(\"SNDCTL_DSP_SPEED\")"); qDebug("channels %d",d->channels); if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { d->channels = ( d->channels == 1 ) ? 2 : d->channels; if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); } - QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; +// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; d->bufferSize = sound_fragment_bytes; d->unwrittenBuffer = new char[d->bufferSize]; d->unwritten = 0; d->can_GETOSPACE = TRUE; // until we find otherwise //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); } AudioDevice::~AudioDevice() { qDebug("destryo audiodevice"); - QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; +// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; # ifndef KEEP_DEVICE_OPEN close( d->handle ); // Now it should be safe to shut the handle # endif delete d->unwrittenBuffer; delete d; - QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; +// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; } void AudioDevice::volumeChanged( bool muted ) { AudioDevicePrivate::muted = muted; } void AudioDevice::write( char *buffer, unsigned int length ) { int t = ::write( d->handle, buffer, length ); if ( t<0 ) t = 0; if ( t != (int)length) { qDebug("Ahhh!! memcpys 1"); memcpy(d->unwrittenBuffer,buffer+t,length-t); d->unwritten = length-t; } //#endif } unsigned int AudioDevice::channels() const { return d->channels; } unsigned int AudioDevice::frequency() const { return d->frequency; diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 3c5734e..a0bf4db 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -185,65 +185,65 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); pmPlayList->insertSeparator(-1); new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); pmPlayList->insertSeparator(-1); new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); QPopupMenu *pmView = new QPopupMenu( this ); menu->insertItem( tr( "View" ), pmView ); fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); fullScreenButton->addTo(pmView); scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); scaleButton->addTo(pmView); skinsMenu = new QPopupMenu( this ); menu->insertItem( tr( "Skins" ), skinsMenu ); skinsMenu->isCheckable(); connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); populateSkinsMenu(); QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); tabWidget = new QTabWidget( hbox6, "tabWidget" ); - tabWidget->setTabShape(QTabWidget::Triangular); +// tabWidget->setTabShape(QTabWidget::Triangular); QWidget *pTab; pTab = new QWidget( tabWidget, "pTab" ); // playlistView = new QListView( pTab, "playlistview" ); // playlistView->setMinimumSize(236,260); tabWidget->insertTab( pTab,"Playlist"); // Add the playlist area QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); d->playListFrame = vbox3; d->playListFrame ->setMinimumSize(235,260); QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); d->selectedFiles = new PlayListSelection( hbox2); QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch QWidget *aTab; aTab = new QWidget( tabWidget, "aTab" ); audioView = new QListView( aTab, "Audioview" ); @@ -296,65 +296,68 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); ///audioView connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); connect( audioView, SIGNAL( returnPressed( QListViewItem *)), this,SLOT( playIt( QListViewItem *)) ); connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); //videoView connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); connect( videoView, SIGNAL( returnPressed( QListViewItem *)), this,SLOT( playIt( QListViewItem *)) ); connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); //playlists connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); -// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); + connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); + + + connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); setCentralWidget( vbox5 ); Config cfg( "OpiePlayer" ); readConfig( cfg ); QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); loadList(DocLnk( currentPlaylist)); setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); initializeStates(); } PlayListWidget::~PlayListWidget() { Config cfg( "OpiePlayer" ); writeConfig( cfg ); if ( d->current ) delete d->current; delete d; } void PlayListWidget::initializeStates() { d->tbPlay->setOn( mediaPlayerState->playing() ); d->tbLoop->setOn( mediaPlayerState->looping() ); @@ -695,102 +698,102 @@ void PlayListWidget::addSelected() { return; break; case 1: { //audio QListViewItemIterator it( audioView ); for ( ; it.current(); ++it ) { if ( it.current()->isSelected() ) { filename = it.current()->text(3); lnk.setName( QFileInfo(filename).baseName() ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); } } audioView->clearSelection(); // d->selectedFiles->next(); } break; case 2: { // video QListViewItemIterator it( videoView ); for ( ; it.current(); ++it ) { if ( it.current()->isSelected() ) { filename = it.current()->text(3); lnk.setName( QFileInfo(filename).baseName() ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); } } videoView->clearSelection(); } break; }; - tabWidget->setCurrentPage(0); +// tabWidget->setCurrentPage(0); writeCurrentM3u(); } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); } void PlayListWidget::playIt( QListViewItem *) { // d->setDocumentUsed = FALSE; // mediaPlayerState->curPosition =0; qDebug("playIt"); mediaPlayerState->setPlaying(FALSE); mediaPlayerState->setPlaying(TRUE); d->selectedFiles->unSelect(); } void PlayListWidget::addToSelection( QListViewItem *it) { d->setDocumentUsed = FALSE; if(it) { switch ( tabWidget->currentPageIndex()) { case 0: //playlist return; break; }; // case 1: { DocLnk lnk; QString filename; filename=it->text(3); lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); writeCurrentM3u(); - tabWidget->setCurrentPage(0); +// tabWidget->setCurrentPage(0); } } void PlayListWidget::tabChanged(QWidget *) { switch ( tabWidget->currentPageIndex()) { case 0: { if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(TRUE); d->tbAddToList->setEnabled(FALSE); } break; case 1: { audioView->clear(); populateAudioView(); if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); } break; case 2: { videoView->clear(); populateVideoView(); if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); |