-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 4 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 18 |
2 files changed, 11 insertions, 11 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 59e06a6..abbe5c8 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp @@ -172,49 +172,49 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, } 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."); @@ -224,61 +224,61 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { // 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; 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" ); - // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; } AudioDevice::~AudioDevice() { qDebug("destryo audiodevice"); // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; // #ifdef Q_OS_WIN32 // waveOutClose( (HWAVEOUT)d->handle ); // #else # ifndef KEEP_DEVICE_OPEN close( d->handle ); // Now it should be safe to shut the handle # endif delete d->unwrittenBuffer; delete d; //#endif // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; } void AudioDevice::volumeChanged( bool muted ) { diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 54e7ceb..b96b1ef 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -55,93 +55,93 @@ MediaButton audioButtons[] = { { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist }; static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ) { setCaption( tr("OpiePlayer") ); Config cfg("OpiePlayer"); cfg.setGroup("AudioWidget"); // QGridLayout *layout = new QGridLayout( this ); // layout->setSpacing( 2); // layout->setMargin( 2); QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); - animatedPix=cfg.readEntry( "animatedPix", "opieplayer/animatedButton"); +// animatedPix=cfg.readEntry( "animatedPix", "opieplayer/animatedButton"); setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) ); pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) ); - pixmaps[3] = new QPixmap( Resource::loadPixmap( animatedPix) ); +// pixmaps[3] = new QPixmap( Resource::loadPixmap( animatedPix) ); songInfo = new Ticker( this ); songInfo->setFocusPolicy( QWidget::NoFocus ); songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); // layout->addMultiCellWidget( songInfo, 0, 0, 0, 2 ); slider = new QSlider( Qt::Horizontal, this ); slider->setFixedWidth( 220 ); slider->setFixedHeight( 20 ); slider->setMinValue( 0 ); slider->setMaxValue( 1 ); slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); slider->setFocusPolicy( QWidget::NoFocus ); slider->setGeometry( QRect( 7, 262, 220, 20 ) ); // layout->addMultiCellWidget( slider, 4, 4, 0, 2 ); connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); } AudioWidget::~AudioWidget() { mediaPlayerState->isStreaming = FALSE; - for ( int i = 0; i < 4; i++ ) + for ( int i = 0; i < 3; i++ ) delete pixmaps[i]; } static bool audioSliderBeingMoved = FALSE; void AudioWidget::sliderPressed() { audioSliderBeingMoved = TRUE; } void AudioWidget::sliderReleased() { audioSliderBeingMoved = FALSE; if ( slider->width() == 0 ) return; long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); mediaPlayerState->setPosition( val ); } void AudioWidget::setPosition( long i ) { // qDebug("set position %d",i); updateSlider( i, mediaPlayerState->length() ); @@ -199,54 +199,54 @@ void AudioWidget::setToggleButton( int i, bool down ) { } void AudioWidget::toggleButton( int i ) { audioButtons[i].isDown = !audioButtons[i].isDown; QPainter p(this); paintButton ( &p, i ); } void AudioWidget::paintButton( QPainter *p, int i ) { int x = audioButtons[i].xPos; int y = audioButtons[i].yPos; int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); } void AudioWidget::timerEvent( QTimerEvent * ) { static int frame = 0; if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { frame = frame >= 7 ? 0 : frame + 1; - int x = audioButtons[AudioPlay].xPos; - int y = audioButtons[AudioPlay].yPos; - QPainter p( this ); - // Optimize to only draw the little bit of the changing images which is different - p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); - p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); +// int x = audioButtons[AudioPlay].xPos; +// int y = audioButtons[AudioPlay].yPos; +// QPainter p( this ); +// // Optimize to only draw the little bit of the changing images which is different +// p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); +// p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); } } void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { for ( int i = 0; i < numButtons; i++ ) { int size = audioButtons[i].isBig; int x = audioButtons[i].xPos; int y = audioButtons[i].yPos; if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the circular button or not // (compared with the radius squared to avoid a square-root of our distance) int radius = 32 + 13 * size; QPoint center = QPoint( x + radius, y + radius ); QPoint dXY = center - event->pos(); int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); bool isOnButton = dist <= (radius * radius); // QRect r( x, y, 64 + 22*size, 64 + 22*size ); // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); qDebug("button toggled1 %d",i); switch (i) { |