author | ar <ar> | 2004-05-02 17:04:41 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-02 17:04:41 (UTC) |
commit | 4d3379027557e251201b531896974a69ae4c665a (patch) (side-by-side diff) | |
tree | 6e813be1aa29131f8f8e91f532f38f8a381e38f4 | |
parent | f8add41b2e0b0371754521b44d95f87fa70a6ff2 (diff) | |
download | opie-4d3379027557e251201b531896974a69ae4c665a.zip opie-4d3379027557e251201b531896974a69ae4c665a.tar.gz opie-4d3379027557e251201b531896974a69ae4c665a.tar.bz2 |
- convert qDebug to odebug
-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 50 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 63 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 72 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 68 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol_threaded.cpp | 54 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayer.cpp | 26 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayerstate.cpp | 34 | ||||
-rw-r--r-- | core/multimedia/opieplayer/modplug/memfile.cpp | 30 | ||||
-rw-r--r-- | core/multimedia/opieplayer/om3u.cpp | 28 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 19 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 176 | ||||
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 39 | ||||
-rw-r--r-- | core/multimedia/opieplayer/vorbis/libtremorplugin.cpp | 31 | ||||
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/wavplugin.cpp | 50 |
14 files changed, 402 insertions, 338 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 355062b..9b64e07 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp @@ -15,31 +15,35 @@ ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // L.J.Potter added better error code Fri 02-15-2002 14:37:47 -#include <stdlib.h> -#include <stdio.h> -#include <qpe/qpeapplication.h> -#include <qpe/config.h> -#include <qmessagebox.h> - #include "audiodevice.h" - -#include <errno.h> +/* OPIE */ +#include <qpe/qpeapplication.h> +#include <qpe/config.h> +#include <opie2/odebug.h> #if !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif +/* QT */ +#include <qmessagebox.h> + +/* STD */ +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> + #if defined(Q_WS_X11) || defined(Q_WS_QWS) #include <fcntl.h> #include <sys/ioctl.h> #include <sys/soundcard.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> @@ -140,38 +144,38 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, // 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 ); +// odebug << "setting volume to: 0x" << volume << "" << oendl; #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"); + // odebug << "creating new audio device" << oendl; // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; d = new AudioDevicePrivate; d->frequency = f; d->channels = chs; d->bytesPerSample = bps; - // qDebug("%d",bps); + // odebug << "" << bps << "" << oendl; 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); + // odebug << "AD- freq " << f << ", channels " << chs << ", b/sample " << bps << ", bitrate " << format << "" << oendl; 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 ) { @@ -195,44 +199,44 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { #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); + // odebug << "freq " << d->frequency << "" << oendl; if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) perror("ioctl(\"SNDCTL_DSP_SPEED\")"); - // qDebug("channels %d",d->channels); + // odebug << "channels " << d->channels << "" << oendl; 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" ); + //if ( chs != d->channels ) odebug << "Wanted " << chs << ", got " << d->channels << " channels" << oendl; + //if ( f != d->frequency ) odebug << "wanted " << f << "Hz, got " << d->frequency << "Hz" << oendl; + //if ( capabilities & DSP_CAP_BATCH ) odebug << "Sound card has local buffer" << oendl; + //if ( capabilities & DSP_CAP_REALTIME )odebug << "Sound card has realtime sync" << oendl; + //if ( capabilities & DSP_CAP_TRIGGER ) odebug << "Sound card has precise trigger" << oendl; + //if ( capabilities & DSP_CAP_MMAP ) odebug << "Sound card can mmap" << oendl; } AudioDevice::~AudioDevice() { - // qDebug("destryo audiodevice"); + // odebug << "destryo audiodevice" << oendl; // 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; @@ -246,17 +250,17 @@ void AudioDevice::volumeChanged( bool 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"); + // odebug << "Ahhh!! memcpys 1" << oendl; memcpy(d->unwrittenBuffer,buffer+t,length-t); d->unwritten = length-t; } //#endif } unsigned int AudioDevice::channels() const @@ -309,14 +313,14 @@ unsigned int AudioDevice::canWrite() const return d->bufferSize; } } int AudioDevice::bytesWritten() { int buffered = 0; if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { - // qDebug( "failed to get audio device position" ); + // odebug << "failed to get audio device position" << oendl; return -1; } return buffered; } diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 7da2d54..376f8d3 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -12,24 +12,29 @@ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#include "audiowidget.h" +#include "mediaplayerstate.h" + +/* OPIE */ #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> +#include <opie2/odebug.h> +/* QT */ #include <qdir.h> -#include "audiowidget.h" -#include "mediaplayerstate.h" +/* STD */ #include <stdlib.h> #include <stdio.h> extern MediaPlayerState *mediaPlayerState; static const int xo = -2; // movable x offset static const int yo = 22; // movable y offset @@ -66,82 +71,82 @@ static void changeTextColor( QWidget *w ) { } static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { setCaption( tr("OpiePlayer") ); - // qDebug("<<<<<audioWidget"); - + // odebug << "<<<<<audioWidget" << oendl; + Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency // QString skinPath = "opieplayer/skins/" + skin; QString skinPath; skinPath = "opieplayer2/skins/" + skin; if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) skinPath = "opieplayer2/skins/default"; - - // qDebug("skin path " + skinPath); - + + // odebug << "skin path " + skinPath << oendl; + pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); imgButtonMask->fill( 0 ); for ( int i = 0; i < 10; i++ ) { QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; masks[i] = new QBitmap( filename ); if ( !masks[i]->isNull() ) { QImage imgMask = masks[i]->convertToImage(); uchar **dest = imgButtonMask->jumpTable(); for ( int y = 0; y < imgUp->height(); y++ ) { uchar *line = dest[y]; - for ( int x = 0; x < imgUp->width(); x++ ) - if ( !qRed( imgMask.pixel( x, y ) ) ) + for ( int x = 0; x < imgUp->width(); x++ ) + if ( !qRed( imgMask.pixel( x, y ) ) ) line[x] = i + 1; } } } for ( int i = 0; i < 11; i++ ) { buttonPixUp[i] = NULL; buttonPixDown[i] = NULL; } - QWidget *d = QApplication::desktop(); - int width = d->width(); - int height = d->height(); + QWidget *d = QApplication::desktop(); + int width = d->width(); + int height = d->height(); if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { -// qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); - QImage img; - img = pixBg->convertToImage(); - pixBg->convertFromImage( img.smoothScale( width, height)); - } +// odebug << "<<<<<<<< scale image >>>>>>>>>>>>" << oendl; + QImage img; + img = pixBg->convertToImage(); + pixBg->convertFromImage( img.smoothScale( width, height)); + } setBackgroundPixmap( *pixBg); songInfo.setFocusPolicy( QWidget::NoFocus ); - + // changeTextColor( &songInfo ); // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); // songInfo.setFrameStyle( QFrame::NoFrame); // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); //NoFrame // songInfo.setForegroundColor(Qt::white); - + slider.setFixedHeight( 20 ); slider.setMinValue( 0 ); slider.setMaxValue( 1 ); slider.setFocusPolicy( QWidget::NoFocus ); slider.setBackgroundPixmap( *pixBg ); time.setFocusPolicy( QWidget::NoFocus ); @@ -167,17 +172,17 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : // setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); this->setFocus(); } AudioWidget::~AudioWidget() { // setPlaying( false); - + for ( int i = 0; i < 10; i++ ) { if(buttonPixUp[i]) delete buttonPixUp[i]; if(buttonPixDown[i]) delete buttonPixDown[i]; } if(pixBg) delete pixBg; if(imgUp) delete imgUp; if(imgDn) delete imgDn; if(imgButtonMask) delete imgButtonMask; @@ -248,17 +253,17 @@ void AudioWidget::sliderReleased() { 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); +// odebug << "set position " << i << "" << oendl; long length = mediaPlayerState->length(); updateSlider( i, length ); } void AudioWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } @@ -295,17 +300,17 @@ static QString timeAsString( long length ) { int minutes = length / 60; int seconds = length % 60; return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); } void AudioWidget::updateSlider( long i, long max ) { this->setFocus(); time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); - + if ( max == 0 ) return; // Will flicker too much if we don't do this // Scale to something reasonable int width = slider.width(); int val = int((double)i * width / max); if ( !audioSliderBeingMoved ) { if ( slider.value() != val ) @@ -361,29 +366,29 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { // The test to see if the mouse click is inside the button or not int x = event->pos().x() - xoff; int y = event->pos().y() - yoff; bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); -// if ( isOnButton && i == AudioVolumeUp ) -// qDebug("on up"); +// if ( isOnButton && i == AudioVolumeUp ) +// odebug << "on up" << oendl; if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); switch (i) { - case AudioVolumeUp: - // qDebug("more clicked"); - emit moreClicked(); + case AudioVolumeUp: + // odebug << "more clicked" << oendl; + emit moreClicked(); return; case AudioVolumeDown: - // qDebug("less clicked"); + // odebug << "less clicked" << oendl; emit lessClicked(); return; case AudioForward: emit forwardClicked(); return; case AudioBack: emit backClicked(); return; @@ -465,17 +470,17 @@ void AudioWidget::paintEvent( QPaintEvent * pe) { void AudioWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity hide(); -// qDebug("Audio F9"); +// odebug << "Audio F9" << oendl; break; case Key_F10: //contacts break; case Key_F11: //menu break; case Key_F12: //home break; case Key_F13: //mail diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 1989b4a..428fc28 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp @@ -14,52 +14,57 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // largly modified by Maximilian Reiss <max.reiss@gmx.de> +#include "libmadplugin.h" + +/* OPIE */ +#include <qpe/config.h> +#include <opie2/odebug.h> + +/* QT */ +#include <qapplication.h> +#include <qmessagebox.h> +#include <qregexp.h> + +/* STD */ #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <ctype.h> #include <errno.h> #include <time.h> #include <locale.h> #include <math.h> #include <assert.h> -#include <qapplication.h> -#include <qmessagebox.h> -#include <qregexp.h> - -#include <qpe/config.h> - // for network handling #include <netinet/in.h> #include <netdb.h> #include <linux/limits.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> //#define HAVE_MMAP #if defined(HAVE_MMAP) # include <sys/mman.h> #endif -#include "libmadplugin.h" extern "C" { #include "mad.h" } #define MPEG_BUFFER_SIZE 65536 @@ -377,31 +382,31 @@ int LibMadPlugin::http_open(const QString& path ) { QString message = tr("Info: "); do { int len; len = http_read_line(tcp_sock, http_request, sizeof(http_request)); if (len == -1) { - // qDebug( "http_open: "+ QString(strerror(errno)) +"\n"); + // odebug << "http_open: "+ QString(strerror(errno)) +"\n" << oendl; return 0; } if (QString(http_request).left(9) == "Location:") { /* redirect */ ::close(tcp_sock); http_request[strlen(http_request) - 1] = '\0'; return http_open(&http_request[10]); } if (QString(http_request).left(4) == "ICY ") { /* This is shoutcast/icecast streaming */ if (strncmp(http_request + 4, "200 ", 4)) { - // qDebug("http_open: " + QString(http_request) + "\n"); + // odebug << "http_open: " + QString(http_request) + "\n" << oendl; return 0; } } else if (QString(http_request).left(4) == "icy-") { /* we can have: icy-noticeX, icy-name, icy-genre, icy-url, icy-pub, icy-metaint, icy-br */ if ( QString( http_request ).left( 8 ) == "icy-name" ) { name = tr("Name: ") + QString(http_request).mid(9, (QString(http_request).length())- 9 ); } else if ( QString( http_request ).left( 9 ) == "icy-genre" ) { genre = tr("Genre: ") + QString(http_request).mid(10, (QString(http_request).length())-10 ); @@ -412,77 +417,77 @@ int LibMadPlugin::http_open(const QString& path ) { } else if ( QString( http_request ).left( 10 ) == "icy-notice" ) { message += QString(http_request).mid(11, QString(http_request).length()-11 ) ; } } } while (strcmp(http_request, "\n") != 0); info = QString(name + genre + url + bitrate + message).replace( QRegExp("\n"), " : " ); - // qDebug("Stream info: " + info); + // odebug << "Stream info: " + info << oendl; return (tcp_sock); } bool LibMadPlugin::open( const QString& path ) { debugMsg( "LibMadPlugin::open" ); Config cfg("OpiePlayer"); cfg.setGroup("Options"); bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); - // qDebug("buffer size is %d", bufferSize); + // odebug << "buffer size is " << bufferSize << "" << oendl; d->bad_last_frame = 0; d->flush = TRUE; info = QString( "" ); - //qDebug( "Opening %s", path.latin1() ); + //odebug << "Opening " << path << "" << oendl; if (path.left( 4 ) == "http" ) { // in case of any error we get 0 here if ( !(http_open(path) == 0) ) { d->input.fd = http_open(path); } else { return FALSE; } } else { d->input.path = path.latin1(); d->input.fd = ::open( d->input.path, O_RDONLY ); // thats a better place, since it should only seek for ID3 tags on mp3 files, not streams printID3Tags(); } if (d->input.fd == -1) { - // qDebug("error opening %s", d->input.path ); + // odebug << "error opening " << d->input.path << "" << oendl; return FALSE; } struct stat stat; if (fstat(d->input.fd, &stat) == -1) { - // qDebug("error calling fstat"); return FALSE; + // odebug << "error calling fstat" << oendl; return FALSE; } if (S_ISREG(stat.st_mode) && stat.st_size > 0) d->input.fileLength = stat.st_size; else d->input.fileLength = 0; - + #if defined(HAVE_MMAP) if (S_ISREG(stat.st_mode) && stat.st_size > 0) { d->input.length = stat.st_size; d->input.fdm = map_file(d->input.fd, &d->input.length); if (d->input.fdm == 0) { - // qDebug("error mmapping file"); return FALSE; + // odebug << "error mmapping file" << oendl; return FALSE; } d->input.data = (unsigned char *)d->input.fdm; } #endif if (d->input.data == 0) { d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); if (d->input.data == 0) { - // qDebug("error allocating input buffer"); + // odebug << "error allocating input buffer" << oendl; return FALSE; } d->input.length = 0; } d->input.eof = 0; mad_stream_init(&d->stream); @@ -500,31 +505,31 @@ bool LibMadPlugin::close() { mad_synth_finish(&d->synth); mad_frame_finish(&d->frame); mad_stream_finish(&d->stream); #if defined(HAVE_MMAP) if (d->input.fdm) { if (unmap_file(d->input.fdm, d->input.length) == -1) { - // qDebug("error munmapping file"); + // odebug << "error munmapping file" << oendl; result = FALSE; } d->input.fdm = 0; d->input.data = 0; } #endif if (d->input.data) { free(d->input.data); d->input.data = 0; } if (::close(d->input.fd) == -1) { - // qDebug("error closing file %s", d->input.path); + // odebug << "error closing file " << d->input.path << "" << oendl; result = FALSE; } d->input.fd = 0; return result; } @@ -540,64 +545,63 @@ int LibMadPlugin::audioStreams() { return 1; } int LibMadPlugin::audioChannels( int ) { debugMsg( "LibMadPlugin::audioChannels" ); /* long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); - qDebug( "LibMadPlugin::audioChannels: %i", d->frame.header.mode > 0 ? 2 : 1 ); + odebug << "LibMadPlugin::audioChannels: " << d->frame.header.mode > 0 ? 2 : 1 << "" << oendl; return d->frame.header.mode > 0 ? 2 : 1; */ return 2; } int LibMadPlugin::audioFrequency( int ) { debugMsg( "LibMadPlugin::audioFrequency" ); long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); - // qDebug( "LibMadPlugin::audioFrequency: %i", d->frame.header.samplerate ); + // odebug << "LibMadPlugin::audioFrequency: " << d->frame.header.samplerate << "" << oendl; return d->frame.header.samplerate; } int LibMadPlugin::audioSamples( int ) { 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 ); + odebug << "LibMadPlugin::audioSamples: " << d->frame.header.duration.seconds << "*" << d->frame.header.samplerate << oendl; return d->frame.header.duration.seconds * d->frame.header.samplerate; */ if ( d->frame.header.bitrate == 0 ) return 0; int samples = (d->input.fileLength / (d->frame.header.bitrate/8)) * d->frame.header.samplerate; // qDebug( "LibMadPlugin::audioSamples: %i * %i * 8 / %i", (int)d->input.fileLength, - // (int)d->frame.header.samplerate, (int)d->frame.header.bitrate ); - // qDebug( "LibMadPlugin::audioSamples: %i", samples ); + // (int)d->frame.header.samplerate, (int)d->frame.header.bitrate ); + // odebug << "LibMadPlugin::audioSamples: " << samples << "" << oendl; return samples; // return 10000000; } bool LibMadPlugin::audioSetSample( long, int ) { debugMsg( "LibMadPlugin::audioSetSample" ); // long totalSamples = audioSamples(0); // if ( totalSamples <= 1 ) // return FALSE; // // Seek to requested position -// qDebug( "seek pos: %i", (int)((double)pos * d->input.fileLength / totalSamples) ); +// odebug << "seek pos: " << (int)((double)pos * d->input.fileLength / totalSamples) << "" << oendl; // ::lseek( d->input.fd, (long)((double)pos * d->input.fileLength / totalSamples), SEEK_SET ); // mad_stream_sync(&d->stream); // mad_stream_init(&d->stream); // mad_frame_init(&d->frame); // mad_synth_init(&d->synth); // return TRUE; @@ -675,17 +679,17 @@ bool LibMadPlugin::read() { } do { len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); } while (len == -1 && errno == EINTR); if (len == -1) { - // qDebug("error reading audio"); + // odebug << "error reading audio" << oendl; return FALSE; } else if (len == 0) { d->input.eof = 1; assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); while (len < MAD_BUFFER_GUARD) @@ -753,17 +757,17 @@ bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) { while (mad_frame_decode(&d->frame, &d->stream) == -1) { if (!MAD_RECOVERABLE(d->stream.error)) { debugMsg( "feed me" ); return FALSE; // Feed me } if ( d->stream.error == MAD_ERROR_BADCRC ) { mad_frame_mute(&d->frame); - // qDebug( "error decoding, bad crc" ); + // odebug << "error decoding, bad crc" << oendl; } } mad_synth_frame(&d->synth, &d->frame); int decodedSamples = d->synth.pcm.length; memcpy( &(buffer[0][offset]), d->synth.pcm.samples[0], decodedSamples * sizeof(mad_fixed_t) ); if ( d->synth.pcm.channels == 2 ) memcpy( &(buffer[1][offset]), d->synth.pcm.samples[1], decodedSamples * sizeof(mad_fixed_t) ); @@ -816,54 +820,54 @@ bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long sampl double LibMadPlugin::getTime() { debugMsg( "LibMadPlugin::getTime" ); return 0.0; } void LibMadPlugin::printID3Tags() { - // qDebug( "LibMadPlugin::printID3Tags" ); + // odebug << "LibMadPlugin::printID3Tags" << oendl; char id3v1[128 + 1]; if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { - // qDebug( "error seeking to id3 tags" ); + // odebug << "error seeking to id3 tags" << oendl; return; } if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { - // qDebug( "error reading in id3 tags" ); + // odebug << "error reading in id3 tags" << oendl; return; } if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) { debugMsg( "sorry, no id3 tags" ); } else { int len[5] = { 30, 30, 30, 4, 30 }; QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) }; char *ptr = id3v1 + 3, *ptr2 = ptr + len[0]; - // qDebug( "ID3 tags in file:" ); + // odebug << "ID3 tags in file:" << oendl; info = ""; for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) { char push = *ptr2; *ptr2 = '\0'; char *ptr3 = ptr2; while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--; char push2 = *ptr3; *ptr3 = '\0'; if ( strcmp( ptr, "" ) ) { if( ((QString)ptr).find(" ") == -1) // don't add anything that has blanks info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; } -// qDebug( info.latin1() ); +// odebug << info.latin1() << oendl; *ptr3 = push2; *ptr2 = push; } if (id3v1[126] == 0 && id3v1[127] != 0) info += tr( ", Track: " ) + id3v1[127]; } if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) { - // qDebug( "error seeking back to beginning" ); + // odebug << "error seeking back to beginning" << oendl; return; } } diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 4ed5921..91153fd 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -14,32 +14,40 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // L.J.Potter added changes Fri 02-15-2002 + +#include "mediaplayerstate.h" +#include "loopcontrol.h" +#include "videowidget.h" +#include "audiodevice.h" + +/* OPIE */ #include <qpe/qpeapplication.h> +#include <qpe/mediaplayerplugininterface.h> +#include <opie2/odebug.h> #ifdef Q_WS_QWS #include <qpe/qcopenvelope_qws.h> #endif + +/* QT */ + +/* STD */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <errno.h> #include <unistd.h> -#include "loopcontrol.h" -#include "videowidget.h" -#include "audiodevice.h" -#include <qpe/mediaplayerplugininterface.h> -#include "mediaplayerstate.h" extern VideoWidget *videoUI; // now only needed to tell it to play a frame extern MediaPlayerState *mediaPlayerState; //#define DecodeLoopDebug(x) qDebug x #define DecodeLoopDebug(x) @@ -95,34 +103,34 @@ void *startAudioThread( void *ptr ) { Mutex *audioMutex; LoopControl::LoopControl( QObject *parent, const char *name ) : QObject( parent, name ) { isMuted = FALSE; connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); - //qDebug("starting loopcontrol"); + //odebug << "starting loopcontrol" << oendl; audioMutex = new Mutex; pthread_attr_init(&audio_attr); #define USE_REALTIME_AUDIO_THREAD #ifdef USE_REALTIME_AUDIO_THREAD // Attempt to set it to real-time round robin if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { sched_param params; params.sched_priority = 50; pthread_attr_setschedparam(&audio_attr,¶ms); } else { - // qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); + // odebug << "Error setting up a realtime thread, reverting to using a normal thread." << oendl; pthread_attr_destroy(&audio_attr); pthread_attr_init(&audio_attr); } #endif - //qDebug("create audio thread"); + //odebug << "create audio thread" << oendl; pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); } LoopControl::~LoopControl() { stop(); } @@ -139,26 +147,26 @@ void LoopControl::timerEvent( QTimerEvent *te ) { if ( te->timerId() == sliderId ) { if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { mediaPlayerState->updatePosition( audioSampleCounter ); } else if ( hasVideoChannel && moreVideo ) { mediaPlayerState->updatePosition( current_frame ); } } - if ( !moreVideo && !moreAudio ) { + if ( !moreVideo && !moreAudio ) { mediaPlayerState->setPlaying( FALSE ); mediaPlayerState->setNext(); } } void LoopControl::setPosition( long pos ) { audioMutex->lock(); -// qDebug("Loop control %d", pos); +// odebug << "Loop control " << pos << "" << oendl; if ( hasVideoChannel && hasAudioChannel ) { playtime.restart(); playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); current_frame = pos + 1; mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); prev_frame = current_frame - 1; currentSample = (int)( (double)current_frame * freq / framerate ); mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); @@ -214,39 +222,39 @@ void LoopControl::startVideo() { } } } void LoopControl::startAudio() { - + audioMutex->lock(); if ( moreAudio ) { if ( !isMuted && mediaPlayerState->curDecoder() ) { currentSample = audioSampleCounter + 1; // if ( currentSample != audioSampleCounter + 1 ) -// qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); +// odebug << "out of sync with decoder " << currentSample << " " << audioSampleCounter << "" << oendl; 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; // this causes drop outs not sure why its even here if ( hasVideoChannel ) { 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 ); + // odebug << "need to catch up by: " << -sampleWaitTime << " (" << currentSample << "," << sampleWeShouldBeAt << ")" << oendl; // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); currentSample = sampleWeShouldBeAt; } } audioDevice->write( audioBuffer, samplesRead * 2 * channels ); if( mediaPlayerState->isStreaming == FALSE) @@ -265,17 +273,17 @@ void LoopControl::startAudio() { audioMutex->unlock(); } void LoopControl::killTimers() { audioMutex->lock(); - if ( hasVideoChannel ) + if ( hasVideoChannel ) killTimer( videoId ); killTimer( sliderId ); threadOkToGo = FALSE; audioMutex->unlock(); } @@ -319,17 +327,17 @@ void LoopControl::setPaused( bool pause ) { } } void LoopControl::stop( bool willPlayAgainShortly ) { #if defined(Q_WS_QWS) && !defined(QT_NO_COP) if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { - disabledSuspendScreenSaver = FALSE; + disabledSuspendScreenSaver = FALSE; // Re-enable the suspend mode QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #endif if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { killTimers(); @@ -344,71 +352,71 @@ void LoopControl::stop( bool willPlayAgainShortly ) { audioDevice = 0; audioBuffer = 0; } audioMutex->unlock(); } audioSampleCounter=0; current_frame=0; - total_audio_samples=0; + total_audio_samples=0; } bool LoopControl::init( const QString& filename ) { stop(); audioMutex->lock(); fileName = filename; stream = 0; // only play stream 0 for now current_frame = total_video_frames = total_audio_samples = 0; - - // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); - + + // odebug << "Using the " << mediaPlayerState->curDecoder()->pluginName() << " decoder" << oendl; + // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin // if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { // if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) { // total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); // mediaPlayerState->libMpeg3Decoder()->close(); // } // } - + if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { audioMutex->unlock(); return FALSE; } hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; if ( hasAudioChannel ) { int astream = 0; if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") ) channels = 2; //dont akx me why, but it needs this hack else channels = mediaPlayerState->curDecoder()->audioChannels( astream ); - // qDebug( "LC- channels = %d", channels ); - + // odebug << "LC- channels = " << channels << "" << oendl; + // if ( !total_audio_samples ) total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); total_audio_samples += 1000; - // qDebug("total samples %d", total_audio_samples); + // odebug << "total samples " << total_audio_samples << "" << oendl; mediaPlayerState->setLength( total_audio_samples ); - + freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); - // qDebug( "LC- frequency = %d", freq ); + // odebug << "LC- frequency = " << freq << "" << oendl; audioSampleCounter = 0; int bits_per_sample; if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); - // qDebug("using stupid hack"); + // odebug << "using stupid hack" << oendl; } else { bits_per_sample=0; } audioDevice = new AudioDevice( freq, channels, bits_per_sample); audioBuffer = new char[ audioDevice->bufferSize() ]; channels = audioDevice->channels(); @@ -446,25 +454,25 @@ bool LoopControl::init( const QString& filename ) { audioMutex->unlock(); return TRUE; } void LoopControl::play() { - // qDebug("LC- play"); + // odebug << "LC- play" << oendl; mediaPlayerState->setPosition( 0); //uglyhack - + #if defined(Q_WS_QWS) && !defined(QT_NO_COP) if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { - disabledSuspendScreenSaver = TRUE; + disabledSuspendScreenSaver = TRUE; previousSuspendMode = hasVideoChannel; // Stop the screen from blanking and power saving state - QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) + QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); } #endif playtime.start(); startTimers(); } diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp index 0a1fc17..9a162c2 100644 --- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp +++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp @@ -14,38 +14,44 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #define _REENTRANT +#include "mediaplayerplugininterface.h" +#include "loopcontrol.h" +#include "audiodevice.h" +#include "videowidget.h" +#include "audiowidget.h" +#include "mediaplayerstate.h" + +/* OPIE */ #include <qpe/qpeapplication.h> #include <qpe/custom.h> -#include <qimage.h> -#include <qpainter.h> + #if !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif -#include "mediaplayerplugininterface.h" + +#include <opie2/odebug.h> + +/* QT */ +#include <qimage.h> +#include <qpainter.h> + +/* STD */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include <pthread.h> -#include "loopcontrol.h" -#include "audiodevice.h" -#include "videowidget.h" -#include "audiowidget.h" -#include "mediaplayerstate.h" - - - extern VideoWidget *videoUI; // now only needed to tell it to play a frame extern MediaPlayerState *mediaPlayerState; #define DecodeLoopDebug(x) qDebug x //#define DecodeLoopDebug(x) @@ -186,17 +192,17 @@ void LoopControl::setPosition( long pos ) { if ( sendingNewPos ) { sendingNewPos = FALSE; return; } if ( hasVideoChannel && hasAudioChannel ) { videoMutex->lock(); audioMutex->lock(); - //qDebug("setting position"); + //odebug << "setting position" << oendl; playtime.restart(); playtime = playtime.addMSecs( -pos * 1000 / framerate ); //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; current_frame = pos + 1; mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); prev_frame = current_frame - 1; currentSample = (int)( current_frame * freq / framerate ); mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); @@ -287,32 +293,32 @@ void LoopControl::startVideo() { current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 ); done = current_frame >= prev_frame; videoMutex->unlock(); if ( !done ) usleep( 1000 ); // wait a bit } while ( !done ); -// qDebug("elapsed: %i %i (%f)", int( playtime.elapsed() ), current_frame, framerate ); +// odebug << "elapsed: " << int( playtime.elapsed() ) << " " << current_frame << " (" << framerate << ")" << oendl; } else { videoMutex->lock(); current_frame++; videoMutex->unlock(); } videoMutex->lock(); bool check = current_frame && current_frame > prev_frame; videoMutex->unlock(); if ( check ) { videoMutex->lock(); if ( current_frame > prev_frame + 1 ) { - // qDebug("skipped a frame"); + // odebug << "skipped a frame" << oendl; mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); } prev_frame = current_frame; if ( moreVideo = videoUI->playVideo() ) emitChangePos = TRUE; videoMutex->unlock(); } @@ -336,17 +342,17 @@ void LoopControl::startAudio() { audioMutex->lock(); currentSample = mediaPlayerState->curDecoder()->audioGetSample( stream ); if ( currentSample == 0 ) currentSample = audioSampleCounter + 1; // if ( currentSample != audioSampleCounter + 1 ) -// qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); +// odebug << "out of sync with decoder " << currentSample << " " << audioSampleCounter << "" << oendl; audioMutex->unlock(); /* int sampleWeShouldBeAt = int( playtime.elapsed() ) * freq / 1000; if ( sampleWeShouldBeAt - currentSample > 20000 ) { mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); currentSample = sampleWeShouldBeAt; @@ -360,77 +366,77 @@ void LoopControl::startAudio() { audioMutex->lock(); long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; //long sampleWeShouldBeAt = long( clock() - begin ) * (double) freq / CLOCKS_PER_SEC; long sampleWaitTime = currentSample - sampleWeShouldBeAt; audioMutex->unlock(); if ( sampleWaitTime >= 0 && sampleWaitTime <= 2000 ) { - //qDebug("sampleWaitTime: %i", sampleWaitTime); + //odebug << "sampleWaitTime: " << sampleWaitTime << "" << oendl; usleep( ( sampleWaitTime * 1000000 ) / ( freq ) ); } else { audioMutex->lock(); if ( sampleWaitTime <= -2000 ) { - // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); + // odebug << "need to catch up by: " << -sampleWaitTime << " (" << currentSample << "," << sampleWeShouldBeAt << ")" << oendl; mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); currentSample = sampleWeShouldBeAt; } audioMutex->unlock(); } audioDevice->write( audioBuffer, samplesRead * 2 * channels ); audioMutex->lock(); // audioSampleCounter += samplesRead; audioSampleCounter = currentSample + samplesRead - 1; audioMutex->unlock(); if ( !hasVideoChannel ) emitChangePos = TRUE; - //qDebug("currentSample: %i audioSampleCounter: %i total_audio_samples: %i", currentSample, audioSampleCounter, total_audio_samples); -// qDebug("current: %i counter: %i total: %i", currentSample, audioSampleCounter, (int)total_audio_samples); + //odebug << "currentSample: " << currentSample << " audioSampleCounter: " << audioSampleCounter << " total_audio_samples: " << total_audio_samples << "" << oendl; +// odebug << "current: " << currentSample << " counter: " << audioSampleCounter << " total: " << (int)total_audio_samples << "" << oendl; moreAudio = audioSampleCounter <= total_audio_samples; } else { if ( mediaPlayerState->curDecoder() && hasAudioChannel ) usleep( 100000 ); // Check every 1/10 sec to see if mute is off else moreAudio = FALSE; } } - // qDebug( "End of file" ); + // odebug << "End of file" << oendl; if ( !moreVideo && !moreAudio ) emitPlayFinished = TRUE; pthread_exit(NULL); } void LoopControl::killTimers() { if ( hasVideoChannel ) { if ( pthread_self() != video_tid ) { if ( pthread_cancel(video_tid) == 0 ) { void *thread_result = 0; if ( pthread_join(video_tid,&thread_result) != 0 ) - // qDebug("thread join error 1"); + // odebug << "thread join error 1" << oendl; pthread_attr_destroy(&video_attr); } } } if ( hasAudioChannel ) { if ( pthread_self() != audio_tid ) { if ( pthread_cancel(audio_tid) == 0 ) { void *thread_result = 0; if ( pthread_join(audio_tid,&thread_result) != 0 ) - // qDebug("thread join error 2"); + // odebug << "thread join error 2" << oendl; pthread_attr_destroy(&audio_attr); } } } } void LoopControl::startTimers() { moreVideo = FALSE; @@ -442,17 +448,17 @@ void LoopControl::startTimers() { pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this); } if ( hasAudioChannel ) { moreAudio = TRUE; pthread_attr_init(&audio_attr); #ifdef USE_REALTIME_AUDIO_THREAD pthread_attr_setschedpolicy(&audio_attr,SCHED_RR); // Real-time round robin - //qDebug("min: %i, max: %i", sched_get_priority_min( SCHED_RR ), sched_get_priority_max( SCHED_RR ) ); + //odebug << "min: " << sched_get_priority_min( SCHED_RR ) << ", max: " << sched_get_priority_max( SCHED_RR ) << "" << oendl; sched_param params; params.sched_priority = 50; pthread_attr_setschedparam(&audio_attr,¶ms); #endif pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); } } @@ -507,17 +513,17 @@ void LoopControl::stop( bool willPlayAgainShortly ) { bool LoopControl::init( const QString& filename ) { stop(); fileName = filename; stream = 0; // only play stream 0 for now current_frame = total_video_frames = total_audio_samples = 0; - // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); + // odebug << "Using the " << mediaPlayerState->curDecoder()->pluginName() << " decoder" << oendl; // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); mediaPlayerState->libMpeg3Decoder()->close(); } } diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp index 6c743ec..15f6928 100644 --- a/core/multimedia/opieplayer/mediaplayer.cpp +++ b/core/multimedia/opieplayer/mediaplayer.cpp @@ -14,26 +14,28 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ -#include <qmessagebox.h> - #include "mediaplayer.h" #include "playlistwidget.h" #include "audiowidget.h" #include "loopcontrol.h" #include "audiodevice.h" - #include "mediaplayerstate.h" +/* OPIE */ +#include <opie2/odebug.h> + +/* QT */ +#include <qmessagebox.h> extern AudioWidget *audioUI; extern PlayListWidget *playList; extern LoopControl *loopControl; extern MediaPlayerState *mediaPlayerState; MediaPlayer::MediaPlayer( QObject *parent, const char *name ) @@ -68,30 +70,30 @@ void MediaPlayer::pauseCheck( bool b ) { void MediaPlayer::play() { mediaPlayerState->setPlaying( FALSE ); mediaPlayerState->setPlaying( TRUE ); } void MediaPlayer::setPlaying( bool play ) { - // qDebug("MediaPlayer setPlaying %d", play); + // odebug << "MediaPlayer setPlaying " << play << "" << oendl; if ( !play ) { mediaPlayerState->setPaused( FALSE ); loopControl->stop( FALSE ); return; } if ( mediaPlayerState->paused() ) { mediaPlayerState->setPaused( FALSE ); return; } - // qDebug("about to ctrash"); + // odebug << "about to ctrash" << oendl; const DocLnk *playListCurrent = playList->current(); - + if ( playListCurrent != NULL ) { loopControl->stop( TRUE ); currentFile = playListCurrent; } if ( currentFile == NULL ) { QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); mediaPlayerState->setPlaying( FALSE ); return; @@ -166,17 +168,17 @@ void MediaPlayer::startDecreasingVolume() { AudioDevice::decreaseVolume(); } void MediaPlayer::startIncreasingVolume() { volumeDirection = +1; startTimer( 100 ); AudioDevice::increaseVolume(); - + } bool drawnOnScreenDisplay = FALSE; unsigned int onScreenDisplayVolume = 0; const int yoff = 110; void MediaPlayer::stopChangingVolume() { killTimers(); @@ -186,29 +188,29 @@ void MediaPlayer::stopChangingVolume() { onScreenDisplayVolume = 0; int w = audioUI->width(); int h = audioUI->height(); audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); } void MediaPlayer::timerEvent( QTimerEvent * ) { -// qDebug("timer"); +// odebug << "timer" << oendl; if ( volumeDirection == +1 ) AudioDevice::increaseVolume(); else if ( volumeDirection == -1 ) AudioDevice::decreaseVolume(); // Display an on-screen display volume unsigned int l, r, v; bool m; AudioDevice::getVolume( l, r, m ); v = ((l + r) * 11) / (2*0xFFFF); if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { -// qDebug("returning %d, %d, %d, %d", v, l, r, m); +// odebug << "returning " << v << ", " << l << ", " << r << ", " << m << "" << oendl; return; } int w = audioUI->width(); int h = audioUI->height(); if ( drawnOnScreenDisplay ) { if ( onScreenDisplayVolume > v ) @@ -225,36 +227,36 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { QFont f; f.setPixelSize( 20 ); f.setBold( TRUE ); p.setFont( f ); p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); for ( unsigned int i = 0; i < 10; i++ ) { - if ( v > i ) + if ( v > i ) p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); - else + else p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); } } void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity break; case Key_F10: //contacts break; case Key_F11: //menu break; case Key_F12: //home - // qDebug("Blank here"); + // odebug << "Blank here" << oendl; break; case Key_F13: //mail break; } } void MediaPlayer::doBlank() { diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index 5bfb87e..b700cd1 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp @@ -12,32 +12,36 @@ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ -#include <qpe/qpeapplication.h> -#include <qpe/qlibrary.h> -#include <qpe/config.h> -#include <qdir.h> -#include <qpe/mediaplayerplugininterface.h> -#include "mediaplayerstate.h" - - #ifdef QT_NO_COMPONENT // Plugins which are compiled in when no plugin architecture available #include "libmad/libmadpluginimpl.h" #include "libmpeg3/libmpeg3pluginimpl.h" #include "wavplugin/wavpluginimpl.h" #endif +#include "mediaplayerstate.h" + +/* OPIE */ +#include <qpe/qpeapplication.h> +#include <qpe/qlibrary.h> +#include <qpe/config.h> +#include <qpe/mediaplayerplugininterface.h> +#include <opie2/odebug.h> + +/* QT */ +#include <qdir.h> + //#define MediaPlayerDebug(x) qDebug x #define MediaPlayerDebug(x) MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { Config cfg( "OpiePlayer" ); @@ -99,18 +103,18 @@ MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { if ( (*it).decoder->isFileSupported( file ) ) { tmpDecoder = (*it).decoder; break; } } if(file.left(4)=="http") isStreaming = TRUE; else - isStreaming = FALSE; - return decoder = tmpDecoder; + isStreaming = FALSE; + return decoder = tmpDecoder; } MediaPlayerDecoder *MediaPlayerState::curDecoder() { return decoder; } @@ -120,38 +124,38 @@ MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { } // ### hack to get true sample count // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { // return libwavdecoder; // } void MediaPlayerState::loadPlugins() { - // qDebug("load plugins"); + // odebug << "load plugins" << oendl; #ifndef QT_NO_COMPONENT QValueList<MediaPlayerPlugin>::Iterator mit; for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { (*mit).iface->release(); (*mit).library->unload(); delete (*mit).library; } pluginList.clear(); QString path = QPEApplication::qpeDir() + "/plugins/codecs"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { MediaPlayerPluginInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); -// qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); +// odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl; if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { -// qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); +// odebug << "loading: " << QString( path + "/" + *it ) << "" << oendl; MediaPlayerPlugin plugin; plugin.library = lib; plugin.iface = iface; plugin.decoder = plugin.iface->decoder(); plugin.encoder = plugin.iface->encoder(); pluginList.append( plugin ); @@ -160,17 +164,17 @@ void MediaPlayerState::loadPlugins() { libmpeg3decoder = plugin.decoder; } else { delete lib; } } #else pluginList.clear(); - + MediaPlayerPlugin plugin0; plugin0.iface = new LibMpeg3PluginImpl; plugin0.decoder = plugin0.iface->decoder(); plugin0.encoder = plugin0.iface->encoder(); pluginList.append( plugin0 ); MediaPlayerPlugin plugin1; plugin1.iface = new LibMadPluginImpl; @@ -180,14 +184,14 @@ void MediaPlayerState::loadPlugins() { MediaPlayerPlugin plugin2; plugin2.iface = new WavPluginImpl; plugin2.decoder = plugin2.iface->decoder(); plugin2.encoder = plugin2.iface->encoder(); pluginList.append( plugin2 ); #endif - if ( pluginList.count() ) + if ( pluginList.count() ) MediaPlayerDebug(( "%i decoders found", pluginList.count() )); else MediaPlayerDebug(( "No decoders found" )); } diff --git a/core/multimedia/opieplayer/modplug/memfile.cpp b/core/multimedia/opieplayer/modplug/memfile.cpp index 8a29997..cd243c7 100644 --- a/core/multimedia/opieplayer/modplug/memfile.cpp +++ b/core/multimedia/opieplayer/modplug/memfile.cpp @@ -14,16 +14,20 @@ You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "memfile.h" +/* OPIE */ +#include <opie2/odebug.h> + +/* STD */ #include <unistd.h> #include <sys/mman.h> MemFile::MemFile() { } MemFile::MemFile( const QString &name ) @@ -42,35 +46,35 @@ void MemFile::close() QFile::close(); } void MemFile::unmap() { #if defined(Q_WS_X11) || defined(Q_WS_QWS) if ( m_data.data() ) { - munmap( m_data.data(), m_data.size() ); - m_data.resetRawData( m_data.data(), m_data.size() ); + munmap( m_data.data(), m_data.size() ); + m_data.resetRawData( m_data.data(), m_data.size() ); } #endif } QByteArray &MemFile::data() { if ( !m_data.data() ) { #if defined(Q_WS_X11) || defined(Q_WS_QWS) - const char *rawData = (const char *)mmap( 0, size(), PROT_READ, - MAP_SHARED, handle(), 0 ); - if ( rawData ) - { - m_data.setRawData( rawData, size() ); - return m_data; - } - else - qDebug( "MemFile: mmap() failed!" ); - // fallback + const char *rawData = (const char *)mmap( 0, size(), PROT_READ, + MAP_SHARED, handle(), 0 ); + if ( rawData ) + { + m_data.setRawData( rawData, size() ); + return m_data; + } + else + odebug << "MemFile: mmap() failed!" << oendl; + // fallback #endif - m_data = readAll(); + m_data = readAll(); } return m_data; } diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp index ae89518..95ed03c 100644 --- a/core/multimedia/opieplayer/om3u.cpp +++ b/core/multimedia/opieplayer/om3u.cpp @@ -26,78 +26,80 @@ If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "om3u.h" +/* OPIE */ +#include <opie2/odebug.h> static inline QString fullBaseName ( const QFileInfo &fi ) { QString str = fi. fileName ( ); return str. left ( str. findRev ( '.' )); } //extern PlayListWidget *playList; Om3u::Om3u( const QString &filePath, int mode) : QStringList (){ -//qDebug("<<<<<<<new m3u "+filePath); +//odebug << "<<<<<<<new m3u "+filePath << oendl; f.setName(filePath); f.open(mode); } Om3u::~Om3u(){} void Om3u::readM3u() { -// qDebug("<<<<<<reading m3u "+f.name()); +// odebug << "<<<<<<reading m3u "+f.name() << oendl; QTextStream t(&f); - t.setEncoding(QTextStream::UnicodeUTF8); + t.setEncoding(QTextStream::UnicodeUTF8); QString s; while ( !t.atEnd() ) { s=t.readLine(); - // qDebug(s); + // odebug << s << oendl; if( s.find( "#", 0, TRUE) == -1 ) { if( s.left(2) == "E:" || s.left(2) == "P:" ) { s = s.right( s.length() -2 ); QFileInfo f( s ); QString name = fullBaseName ( f ); name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); s=s.replace( QRegExp( "\\" ), "/" ); append(s); - // qDebug(s); + // odebug << s << oendl; } else { // is url s.replace( QRegExp( "%20" )," " ); QString name; // if( name.left( 4 ) == "http" ) { // name = s.right( s.length() - 7 ); // } else { name = s; // } append(name); - // qDebug(name); + // odebug << name << oendl; } } } } void Om3u::readPls() { //it's a pls file QTextStream t( &f ); - t.setEncoding(QTextStream::UnicodeUTF8); + t.setEncoding(QTextStream::UnicodeUTF8); QString s; while ( !t.atEnd() ) { s = t.readLine(); if( s.left(4) == "File" ) { s = s.right( s.length() - 6 ); s.replace( QRegExp( "%20" )," "); -// qDebug( "adding " + s + " to playlist" ); +// odebug << "adding " + s + " to playlist" << oendl; // numberofentries=2 // File1=http // Title // Length // Version // File2=http s = s.replace( QRegExp( "\\" ), "/" ); QFileInfo f( s ); @@ -117,38 +119,38 @@ void Om3u::readPls() { //it's a pls file append(s); } } } } void Om3u::write() { //writes list to m3u file QString list; - QTextStream t(&f); + QTextStream t(&f); t.setEncoding(QTextStream::UnicodeUTF8); if(count()>0) { for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { - // qDebug(*it); - t << *it << "\n"; + // odebug << *it << oendl; + t << *it << "\n"; } } // f.close(); } void Om3u::add(const QString &filePath) { //adds to m3u file append(filePath); } void Om3u::remove(const QString &filePath) { //removes from m3u list QString list, currentFile; if(count()>0) { for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { currentFile=*it; - // qDebug(*it); - + // odebug << *it << oendl; + if( filePath != currentFile) list += currentFile+"\n"; } f.writeBlock( list, list.length() ); } } void Om3u::deleteFile(const QString &filePath) {//deletes m3u file diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index ad831cf..58c3966 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp @@ -13,20 +13,25 @@ ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ -#include <qheader.h> - #include "playlistselection.h" +/* OPIE */ +#include <opie2/odebug.h> + +/* QT */ +#include <qheader.h> + +/* STD */ #include <stdlib.h> class PlayListSelectionItem : public QListViewItem { public: PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { setText( 0, f->name() ); setPixmap( 0, f->pixmap() ); } @@ -39,17 +44,17 @@ public: private: const DocLnk *fl; }; PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) : QListView( parent, name ) { -// qDebug("starting playlistselector"); +// odebug << "starting playlistselector" << oendl; // #ifdef USE_PLAYLIST_BACKGROUND // setStaticBackground( TRUE ); // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); // #endif // addColumn("Title",236); // setAllColumnsShowFocus( TRUE ); @@ -61,17 +66,17 @@ PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) PlayListSelection::~PlayListSelection() { } // #ifdef USE_PLAYLIST_BACKGROUND void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { -// qDebug("drawBackground"); +// odebug << "drawBackground" << oendl; p->fillRect( r, QBrush( white ) ); // QImage logo = Resource::loadImage( "launcher/opielogo" ); // if ( !logo.isNull() ) // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); } // #endif @@ -181,28 +186,28 @@ void PlayListSelection::unSelect() setSelected( currentItem(), FALSE); } void PlayListSelection::writeCurrent( Config& cfg ) { cfg.setGroup("PlayList"); QListViewItem *item = selectedItem(); if ( item ) cfg.writeEntry("current", item->text(0) ); - // qDebug(item->text(0)); + // odebug << item->text(0) << oendl; } void PlayListSelection::setSelectedItem(const QString &strk ) { unSelect(); QListViewItemIterator it( this ); for ( ; it.current(); ++it ) { -// qDebug( it.current()->text(0)); +// odebug << it.current()->text(0) << oendl; if( strk == it.current()->text(0)) { -// qDebug( "We have a match "+strk); +// odebug << "We have a match "+strk << oendl; setSelected( it.current(), TRUE); ensureItemVisible( it.current() ); return; } } // setSelected( item, TRUE ); // ensureItemVisible( selectedItem() ); } diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 3609f5d..d85ce50 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -15,35 +15,37 @@ ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // code added by L. J. Potter Sat 03-02-2002 06:17:54 #define QTOPIA_INTERNAL_FSLP -#include <qtoolbar.h> +#include "playlistselection.h" +#include "playlistwidget.h" +#include "mediaplayerstate.h" +#include "inputDialog.h" +#include "audiowidget.h" +#include "videowidget.h" + +/* OPIE */ #include <qpe/qpemenubar.h> #include <qpe/lnkproperties.h> +#include <opie2/odebug.h> +/* QT */ +#include <qtoolbar.h> #include <qaction.h> #include <qlayout.h> #include <qmessagebox.h> - //#include <qtimer.h> -#include "playlistselection.h" -#include "playlistwidget.h" -#include "mediaplayerstate.h" - -#include "inputDialog.h" - +/* STD */ #include <stdlib.h> -#include "audiowidget.h" -#include "videowidget.h" #include <unistd.h> #include <sys/file.h> #include <sys/ioctl.h> #include <sys/soundcard.h> // for setBacklight() #include <linux/fb.h> @@ -140,17 +142,17 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) QToolBar *bar = new QToolBar( this ); bar->setLabel( tr( "Play Operations" ) ); // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", // this , SLOT( addSelected()) ); tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); tbDeletePlaylist->setFlat(TRUE); tbDeletePlaylist->setFixedSize(20,20); - + d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", this , SLOT(addSelected()) ); d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", this , SLOT(removeSelected()) ); // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", this , SLOT( btnPlay(bool) ), TRUE ); d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", @@ -187,46 +189,46 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 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); - + 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; QGridLayout *layoutF = new QGridLayout( pTab ); layoutF->setSpacing( 2); layoutF->setMargin( 2); layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); 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" ); @@ -236,42 +238,42 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) layoutA->setSpacing( 2); layoutA->setMargin( 2); layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); audioView->addColumn( tr("Title"),-1); audioView->addColumn(tr("Size"), -1); audioView->addColumn(tr("Media"),-1); audioView->addColumn( tr( "Path" ), -1 ); - + audioView->setColumnAlignment(1, Qt::AlignRight); audioView->setColumnAlignment(2, Qt::AlignRight); audioView->setAllColumnsShowFocus(TRUE); audioView->setMultiSelection( TRUE ); audioView->setSelectionMode( QListView::Extended); audioView->setSorting( 3, TRUE ); - + tabWidget->insertTab(aTab,tr("Audio")); QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); // audioView // populateAudioView(); // videowidget - + QWidget *vTab; vTab = new QWidget( tabWidget, "vTab" ); videoView = new QListView( vTab, "Videoview" ); QGridLayout *layoutV = new QGridLayout( vTab ); layoutV->setSpacing( 2); layoutV->setMargin( 2); layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); - + videoView->addColumn(tr("Title"),-1); videoView->addColumn(tr("Size"),-1); videoView->addColumn(tr("Media"),-1); videoView->addColumn(tr( "Path" ), -1 ); videoView->setColumnAlignment(1, Qt::AlignRight); videoView->setColumnAlignment(2, Qt::AlignRight); videoView->setAllColumnsShowFocus(TRUE); videoView->setMultiSelection( TRUE ); @@ -298,17 +300,17 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 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)) ); @@ -332,17 +334,17 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) setCentralWidget( vbox5 ); Config cfg( "OpiePlayer" ); readConfig( cfg ); currentPlayList = cfg.readEntry("CurrentPlaylist","default"); loadList(DocLnk( currentPlayList)); setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); - + initializeStates(); } PlayListWidget::~PlayListWidget() { Config cfg( "OpiePlayer" ); writeConfig( cfg ); @@ -384,34 +386,34 @@ void PlayListWidget::writeConfig( Config& cfg ) const { cfg.setGroup("PlayList"); int noOfFiles = 0; d->selectedFiles->first(); do { const DocLnk *lnk = d->selectedFiles->current(); if ( lnk ) { QString entryName; entryName.sprintf( "File%i", noOfFiles + 1 ); -// qDebug(entryName); +// odebug << entryName << oendl; cfg.writeEntry( entryName, lnk->linkFile() ); // if this link does exist, add it so we have the file // next time... if ( !QFile::exists( lnk->linkFile() ) ) { // the way writing lnks doesn't really check for out // of disk space, but check it anyway. // if ( !lnk->writeLink() ) { // QMessageBox::critical( 0, tr("Out of space"), // tr( "There was a problem saving " // "the playlist.\n" // "Your playlist " // "may be missing some entries\n" // "the next time you start it." ) // ); // } - } + } noOfFiles++; } } while ( d->selectedFiles->next() ); cfg.writeEntry("NumberOfFiles", noOfFiles ); } @@ -441,63 +443,63 @@ void PlayListWidget::clearList() { void PlayListWidget::addAllToList() { DocLnkSet filesAll; Global::findDocuments(&filesAll, "video/*;audio/*"); QListIterator<DocLnk> Adit( filesAll.children() ); for ( ; Adit.current(); ++Adit ) if(QFileInfo(Adit.current()->file()).exists()) d->selectedFiles->addToSelection( **Adit ); tabWidget->setCurrentPage(0); - + writeCurrentM3u(); d->selectedFiles->first(); } void PlayListWidget::addAllMusicToList() { QListIterator<DocLnk> dit( files.children() ); - for ( ; dit.current(); ++dit ) + for ( ; dit.current(); ++dit ) if(QFileInfo(dit.current()->file()).exists()) d->selectedFiles->addToSelection( **dit ); tabWidget->setCurrentPage(0); - + writeCurrentM3u(); d->selectedFiles->first(); } void PlayListWidget::addAllVideoToList() { QListIterator<DocLnk> dit( vFiles.children() ); for ( ; dit.current(); ++dit ) if(QFileInfo( dit.current()->file()).exists()) d->selectedFiles->addToSelection( **dit ); tabWidget->setCurrentPage(0); - + writeCurrentM3u(); d->selectedFiles->first(); } void PlayListWidget::setDocument(const QString& fileref) { fromSetDocument = true; d->setDocumentUsed = TRUE; setDocumentEx(fileref); } void PlayListWidget::setDocumentEx(const QString& fileref) { - qDebug("opieplayer receive "+fileref); + odebug << "opieplayer receive "+fileref << oendl; clearList(); DocLnk lnk; QFileInfo fileInfo(fileref); if ( !fileInfo.exists() ) { QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); return; } - // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); + // odebug << "<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref << oendl; QString extension = fileInfo.extension(false); if( extension.find( "m3u", 0, false) != -1) { //is m3u readm3u( fileref); } else if( extension.find( "pls", 0, false) != -1 ) { //is pls readPls( fileref); } else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist @@ -529,55 +531,55 @@ void PlayListWidget::setDocumentEx(const QString& fileref) { mediaPlayerState->setPlaying( FALSE ); qApp->processEvents(); mediaPlayerState->setPlaying( TRUE ); } void PlayListWidget::setActiveWindow() { - // qDebug("SETTING active window"); + // odebug << "SETTING active window" << oendl; // When we get raised we need to ensure that it switches views char origView = mediaPlayerState->view(); mediaPlayerState->setView( 'l' ); // invalidate mediaPlayerState->setView( origView ); // now switch back } void PlayListWidget::useSelectedDocument() { d->setDocumentUsed = FALSE; } const DocLnk *PlayListWidget::current() { // this is fugly switch (tabWidget->currentPageIndex()) { case 0: //playlist { - // qDebug("playlist"); + // odebug << "playlist" << oendl; if ( mediaPlayerState->playlist() ) { return d->selectedFiles->current(); } else if ( d->setDocumentUsed && d->current ) { return d->current; } else { return &(d->files->selectedDocument()); } } break; case 1://audio { - // qDebug("audioView"); + // odebug << "audioView" << oendl; QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { insanityBool=TRUE; return dit; } } - } + } break; case 2: // video { QListIterator<DocLnk> Vdit( vFiles.children() ); for ( ; Vdit.current(); ++Vdit ) { if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { insanityBool=TRUE; return Vdit; @@ -655,29 +657,29 @@ bool PlayListWidget::last() { void PlayListWidget::saveList() { writem3u(); } void PlayListWidget::loadList( const DocLnk & lnk) { QString name = lnk.name(); - // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); + // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name << oendl; if( name.length()>0) { setCaption("OpiePlayer: "+name); - // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); + // odebug << "<<<<<<<<<<<<load list "+ lnk.file() << oendl; clearList(); readm3u(lnk.file()); tabWidget->setCurrentPage(0); } } void PlayListWidget::setPlaylist( bool shown ) { - if ( shown ) + if ( shown ) d->playListFrame->show(); else d->playListFrame->hide(); } void PlayListWidget::setView( char view ) { if ( view == 'l' ) QPEApplication::showWidget( this ); @@ -702,34 +704,34 @@ void PlayListWidget::addSelected() { 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); - writeCurrentM3u(); + writeCurrentM3u(); } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); } void PlayListWidget::playIt( QListViewItem *) { @@ -752,21 +754,21 @@ void PlayListWidget::addToSelection( QListViewItem *it) { // 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); - + if(tabWidget->currentPageIndex() == 0) - writeCurrentM3u(); + writeCurrentM3u(); // tabWidget->setCurrentPage(0); - + } } void PlayListWidget::tabChanged(QWidget *) { switch ( tabWidget->currentPageIndex()) { case 0: { @@ -813,45 +815,45 @@ void PlayListWidget::btnPlay(bool b) { case 0: { // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { // QMessageBox::message("Note","You are trying to play\na malformed url."); // } else { mediaPlayerState->setPlaying(b); insanityBool=FALSE; - qDebug("insanity"); + odebug << "insanity" << oendl; // } } break; case 1: { // d->selectedFiles->unSelect(); addToSelection( audioView->currentItem() ); mediaPlayerState->setPlaying( b); d->selectedFiles->removeSelected( ); d->selectedFiles->unSelect(); tabWidget->setCurrentPage(1); - insanityBool=FALSE; + insanityBool=FALSE; }// audioView->clearSelection(); break; case 2: { - + addToSelection( videoView->currentItem() ); mediaPlayerState->setPlaying( b); // qApp->processEvents(); d->selectedFiles->removeSelected( ); d->selectedFiles->unSelect(); tabWidget->setCurrentPage(2); insanityBool=FALSE; }// videoView->clearSelection(); break; }; - + } void PlayListWidget::deletePlaylist() { switch( QMessageBox::information( this, (tr("Remove Playlist?")), (tr("You really want to delete\nthis playlist?")), (tr("Yes")), (tr("No")), 0 )){ case 0: // Yes clicked, QFile().remove(playLists->selectedDocument().file()); @@ -869,36 +871,36 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int case 1: break; case 2:{ QPopupMenu m; m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); m.insertSeparator(); - if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) + if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); - + m.exec( QCursor::pos() ); } break; }; } void PlayListWidget::playSelected() { btnPlay( true); // d->selectedFiles->unSelect(); } void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) { switch (mouse) { case 1: - + break; case 2:{ QPopupMenu m; m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); // m.insertSeparator(); // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); m.exec( QCursor::pos() ); @@ -910,17 +912,17 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi void PlayListWidget::listDelete() { Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); currentPlayList = cfg.readEntry("CurrentPlaylist",""); QString file; // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); switch ( tabWidget->currentPageIndex()) { - case 0: + case 0: break; case 1: { file = audioView->currentItem()->text(0); QListIterator<DocLnk> Pdit( files.children() ); for ( ; Pdit.current(); ++Pdit ) { if( Pdit.current()->name() == file) { LnkProperties prop( Pdit.current() ); @@ -946,27 +948,27 @@ void PlayListWidget::listDelete() { // } // } } break; }; } void PlayListWidget::scanForAudio() { - // qDebug("scan for audio"); + // odebug << "scan for audio" << oendl; files.detachChildren(); QListIterator<DocLnk> sdit( files.children() ); for ( ; sdit.current(); ++sdit ) { delete sdit.current(); } Global::findDocuments( &files, audioMimes); audioScan = true; } void PlayListWidget::scanForVideo() { - // qDebug("scan for video"); + // odebug << "scan for video" << oendl; vFiles.detachChildren(); QListIterator<DocLnk> sdit( vFiles.children() ); for ( ; sdit.current(); ++sdit ) { delete sdit.current(); } Global::findDocuments(&vFiles, "video/*"); videoScan = true; } @@ -989,19 +991,19 @@ void PlayListWidget::populateAudioView() { if(dit.current()->file().find(path) != -1 ) storage=name; } QListViewItem * newItem; if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { long size; if( dit.current()->file().left(4) == "http" ) size=0; - else + else size = QFile( dit.current()->file() ).size(); - // qDebug(dit.current()->name()); + // odebug << dit.current()->name() << oendl; newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), storage, dit.current()->file()); newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); } } } @@ -1035,17 +1037,17 @@ void PlayListWidget::populateVideoView() { void PlayListWidget::openFile() { QString filename, name; InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { filename = fileDlg->text(); - // qDebug( "Selected filename is " + filename ); + // odebug << "Selected filename is " + filename << oendl; DocLnk lnk; Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); QString m3uFile; m3uFile = filename; if(filename.left(4) == "http") { if(filename.find(":",8,TRUE) != -1) { //found a port @@ -1070,57 +1072,57 @@ void PlayListWidget::openFile() { } else { lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); lnk.removeLinkFile(); writeCurrentM3u(); } } - + if( fileDlg ) { delete fileDlg; } } /* reads m3u and shows files/urls to playlist widget */ -void PlayListWidget::readm3u( const QString &filename ) { - // qDebug( "read m3u filename " + filename ); +void PlayListWidget::readm3u( const QString &filename ) { + // odebug << "read m3u filename " + filename << oendl; Om3u *m3uList; QString s, name; m3uList = new Om3u( filename, IO_ReadOnly ); m3uList->readM3u(); DocLnk lnk; for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { s = *it; - // qDebug("reading "+ s); + // odebug << "reading "+ s << oendl; if(s.left(4)=="http") { lnk.setName( s ); //sets file name lnk.setIcon("opieplayer2/musicfile"); // if(s.right(4) != '.' || s.right(5) != '.') if(s.right(4) != '.' || s.right(5) != '.' ) if( s.right(1) != "/") lnk.setFile( s+"/"); //if url with no extension else lnk.setFile( s ); //sets file name - + } else { // if( QFileInfo( s ).exists() ) { lnk.setName( fullBaseName ( QFileInfo(s))); // if(s.right(4) == '.') {//if regular file - if(s.left(1) != "/") { - // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); + if(s.left(1) != "/") { + // odebug << "set link "+QFileInfo(filename).dirPath()+"/"+s << oendl; lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); lnk.setIcon("SoundPlayer"); } else { - // qDebug("set link2 "+s); + // odebug << "set link2 "+s << oendl; lnk.setFile( s); lnk.setIcon("SoundPlayer"); } } d->selectedFiles->addToSelection( lnk ); } Config config( "OpiePlayer" ); config.setGroup( "PlayList" ); @@ -1130,24 +1132,24 @@ void PlayListWidget::readm3u( const QString &filename ) { currentPlayList=filename; // m3uList->write(); m3uList->close(); if(m3uList) delete m3uList; d->selectedFiles->setSelectedItem( s); setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); - + } /* reads pls and adds files/urls to playlist */ void PlayListWidget::readPls( const QString &filename ) { - // qDebug( "pls filename is " + filename ); + // odebug << "pls filename is " + filename << oendl; Om3u *m3uList; QString s, name; m3uList = new Om3u( filename, IO_ReadOnly ); m3uList->readPls(); for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { s = *it; // s.replace( QRegExp( "%20" )," " ); @@ -1180,30 +1182,30 @@ void PlayListWidget::readPls( const QString &filename ) { m3uList->close(); if(m3uList) delete m3uList; } /* writes current playlist to current m3u file */ void PlayListWidget::writeCurrentM3u() { - // qDebug("writing to current m3u"); + // odebug << "writing to current m3u" << oendl; Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); currentPlayList = cfg.readEntry("CurrentPlaylist",""); Om3u *m3uList; m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); if( d->selectedFiles->first()) { do { - // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); + // odebug << "writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; m3uList->add( d->selectedFiles->current()->file() ); } while ( d->selectedFiles->next() ); - // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); + // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; m3uList->write(); m3uList->close(); if(m3uList) delete m3uList; } } /* @@ -1212,55 +1214,55 @@ void PlayListWidget::writem3u() { InputDialog *fileDlg; fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); fileDlg->exec(); QString name, filename, list; Om3u *m3uList; if( fileDlg->result() == 1 ) { name = fileDlg->text(); - // qDebug( filename ); + // odebug << filename << oendl; if( name.find("/",0,true) != -1) {// assume they specify a file path filename = name; name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); } else //otherwise dump it somewhere noticable filename = QPEApplication::documentDir() + "/" + name; if( filename.right( 3 ) != "m3u" ) //needs filename extension filename += ".m3u"; - + if( d->selectedFiles->first()) { m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); do { m3uList->add( d->selectedFiles->current()->file()); } while ( d->selectedFiles->next() ); - // qDebug( list ); + // odebug << list << oendl; m3uList->write(); m3uList->close(); if(m3uList) delete m3uList; - + if(fileDlg) delete fileDlg; DocLnk lnk; lnk.setFile( filename); lnk.setIcon("opieplayer2/playlist2"); lnk.setName( name); //sets file name - // qDebug(filename); + // odebug << filename << oendl; Config config( "OpiePlayer" ); config.setGroup( "PlayList" ); - + config.writeEntry("CurrentPlaylist",filename); currentPlayList=filename; if(!lnk.writeLink()) { - // qDebug("Writing doclink did not work"); + // odebug << "Writing doclink did not work" << oendl; } setCaption(tr("OpiePlayer: ") + name); } } } @@ -1286,89 +1288,89 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) break; case Key_Q: //add to playlist addSelected(); break; case Key_R: //remove from playlist removeSelected(); break; // case Key_P: //play -// qDebug("Play"); +// odebug << "Play" << oendl; // playSelected(); // break; case Key_Space: // playSelected(); puh break; case Key_1: tabWidget->setCurrentPage(0); break; case Key_2: tabWidget->setCurrentPage(1); break; case Key_3: tabWidget->setCurrentPage(2); break; case Key_4: - tabWidget->setCurrentPage(3); + tabWidget->setCurrentPage(3); break; case Key_Down: if ( !d->selectedFiles->next() ) d->selectedFiles->first(); break; case Key_Up: if ( !d->selectedFiles->prev() ) // d->selectedFiles->last(); break; - + } } void PlayListWidget::keyPressEvent( QKeyEvent *) { -// qDebug("Key press"); +// odebug << "Key press" << oendl; // switch ( e->key() ) { // ////////////////////////////// Zaurus keys // case Key_A: //add to playlist -// qDebug("Add"); +// odebug << "Add" << oendl; // addSelected(); // break; // case Key_R: //remove from playlist // removeSelected(); // break; // case Key_P: //play -// qDebug("Play"); +// odebug << "Play" << oendl; // playSelected(); // break; // case Key_Space: -// qDebug("Play"); +// odebug << "Play" << oendl; // playSelected(); // break; // } } void PlayListWidget::doBlank() { - // qDebug("do blanking"); + // odebug << "do blanking" << oendl; #ifdef QT_QWS_DEVFS fd=open("/dev/fb/0",O_RDWR); #else fd=open("/dev/fb0",O_RDWR); #endif if (fd != -1) { ioctl(fd,FBIOBLANK,1); // close(fd); } } void PlayListWidget::doUnblank() { // this crashes opieplayer with a segfault // int fd; // fd=open("/dev/fb0",O_RDWR); - // qDebug("do unblanking"); + // odebug << "do unblanking" << oendl; if (fd != -1) { ioctl(fd,FBIOBLANK,0); close(fd); } QCopEnvelope h("QPE/System", "setBacklight(int)"); h <<-3;// v[1]; // -3 Force on } @@ -1383,17 +1385,17 @@ void PlayListWidget::populateSkinsMenu() { QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); skinsDir.setFilter( QDir::Dirs ); skinsDir.setSorting(QDir::Name ); const QFileInfoList *skinslist = skinsDir.entryInfoList(); QFileInfoListIterator it( *skinslist ); QFileInfo *fi; while ( ( fi = it.current() ) ) { skinName = fi->fileName(); - // qDebug( fi->fileName() ); + // odebug << fi->fileName() << oendl; if( skinName != "." && skinName != ".." && skinName !="CVS" ) { item = skinsMenu->insertItem( fi->fileName() ) ; } if( skinName == "default" ) { defaultSkinIndex = item; } if( skinName == skin ) { skinsMenu->setItemChecked( item, TRUE ); @@ -1409,28 +1411,28 @@ void PlayListWidget::skinsMenuActivated( int item ) { skinsMenu->setItemChecked( item, TRUE ); Config cfg( "OpiePlayer" ); cfg.setGroup("Options"); cfg.writeEntry("Skin", skinsMenu->text( item ) ); } void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { - // qDebug("qcop message "+msg ); + // odebug << "qcop message "+msg << oendl; QDataStream stream ( data, IO_ReadOnly ); if ( msg == "play()" ) { //plays current selection btnPlay( true); } else if ( msg == "stop()" ) { mediaPlayerState->setPlaying( false); } else if ( msg == "togglePause()" ) { mediaPlayerState->togglePaused(); } else if ( msg == "next()" ) { //select next in lis - mediaPlayerState->setNext(); + mediaPlayerState->setNext(); } else if ( msg == "prev()" ) { //select previous in list - mediaPlayerState->setPrev(); + mediaPlayerState->setPrev(); } else if ( msg == "toggleLooping()" ) { //loop or not loop mediaPlayerState->toggleLooping(); } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled mediaPlayerState->toggleShuffled(); } else if ( msg == "volUp()" ) { //volume more // emit moreClicked(); // emit moreReleased(); } else if ( msg == "volDown()" ) { //volume less diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 164458b..e851044 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp @@ -12,25 +12,30 @@ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ + +#include "videowidget.h" +#include "mediaplayerstate.h" + +/* OPIE */ #include <qpe/resource.h> #include <qpe/mediaplayerplugininterface.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> +#include <opie2/odebug.h> +/* QT */ #include <qdir.h> #include <qslider.h> -#include "videowidget.h" -#include "mediaplayerstate.h" #ifdef Q_WS_QWS # define USE_DIRECT_PAINTER # include <qdirectpainter_qws.h> # include <qgfxraster_qws.h> #endif @@ -77,62 +82,62 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); QString skinPath; skinPath = "opieplayer2/skins/" + skin; if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) skinPath = "opieplayer2/skins/default"; - // qDebug("skin path " + skinPath); + // odebug << "skin path " + skinPath << oendl; // QString skinPath = "opieplayer2/skins/" + skin; pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); imgButtonMask->fill( 0 ); for ( int i = 0; i < 7; i++ ) { QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); - // qDebug("loading "+filename); + // odebug << "loading "+filename << oendl; masks[i] = new QBitmap( filename ); if ( !masks[i]->isNull() ) { QImage imgMask = masks[i]->convertToImage(); uchar **dest = imgButtonMask->jumpTable(); for ( int y = 0; y < imgUp->height(); y++ ) { uchar *line = dest[y]; for ( int x = 0; x < imgUp->width(); x++ ) { if ( !qRed( imgMask.pixel( x, y ) ) ) line[x] = i + 1; } } } } - // qDebug("finished loading first pics"); + // odebug << "finished loading first pics" << oendl; for ( int i = 0; i < 7; i++ ) { buttonPixUp[i] = NULL; buttonPixDown[i] = NULL; } - QWidget *d = QApplication::desktop(); - int width = d->width(); - int height = d->height(); + QWidget *d = QApplication::desktop(); + int width = d->width(); + int height = d->height(); if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { -// qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); - QImage img; - img = pixBg->convertToImage(); - pixBg->convertFromImage( img.smoothScale( width, height)); - } +// odebug << "<<<<<<<< scale image >>>>>>>>>>>>" << oendl; + QImage img; + img = pixBg->convertToImage(); + pixBg->convertFromImage( img.smoothScale( width, height)); + } setBackgroundPixmap( *pixBg ); currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); slider = new QSlider( Qt::Horizontal, this ); slider->setMinValue( 0 ); slider->setMaxValue( 1 ); slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); @@ -348,30 +353,30 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { videoButtons[i].isHeld = FALSE; if ( !videoButtons[i].isToggle ) { setToggleButton( i, FALSE ); } switch(i) { case VideoPlay: { - // qDebug("play"); + // odebug << "play" << oendl; if( !mediaPlayerState->playing()) { mediaPlayerState->setPlaying( true); setToggleButton( i-1, false ); setToggleButton( i, false ); return; } if( mediaPlayerState->isPaused ) { - // qDebug("isPaused"); + // odebug << "isPaused" << oendl; setToggleButton( i, FALSE ); mediaPlayerState->setPaused( FALSE ); return; } else if( !mediaPlayerState->isPaused ) { - // qDebug("is not paused"); + // odebug << "is not paused" << oendl; setToggleButton( i, TRUE ); mediaPlayerState->setPaused( TRUE ); return; } else { return; } } @@ -453,17 +458,17 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { void VideoWidget::closeEvent( QCloseEvent* ) { mediaPlayerState->setList(); } bool VideoWidget::playVideo() { bool result = FALSE; -// qDebug("<<<<<<<<<<<<<<<< play video"); +// odebug << "<<<<<<<<<<<<<<<< play video" << oendl; int stream = 0; int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); int dd = QPixmap::defaultDepth(); int w = height(); int h = width(); diff --git a/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp b/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp index 53c4b2b..0002213 100644 --- a/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp +++ b/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp @@ -14,34 +14,39 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ****************************************************************************/ // fixed and adapted for opieplayer 2003 ljp <llornkcor@handhelds.org> +#include "libtremorplugin.h" + +/* OPIE */ +#include <opie2/odebug.h> + +/* QT */ +#include <qmap.h> + +/* STD */ #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <time.h> #include <locale.h> #include <math.h> #include <assert.h> -#include <qmap.h> - -#include "libtremorplugin.h" - extern "C" { #include "tremor/ivorbisfile.h" } #define MPEG_BUFFER_SIZE 65536 //#define debugMsg(a) qDebug(a) @@ -57,17 +62,17 @@ public: vorbis_comment* vc; bool bos; int csection; QString finfo; }; LibTremorPlugin::LibTremorPlugin() { -qDebug("<<<<<<<<<<<<<TREMOR!!!!!>>>>>>>>>>>>>>>>>>"); +odebug << "<<<<<<<<<<<<<TREMOR!!!!!>>>>>>>>>>>>>>>>>>" << oendl; d = new LibTremorPluginData; d->f = 0; d->vi = 0; d->vc = 0; d->bos = 0; d->csection = 0; d->finfo = ""; } @@ -100,22 +105,22 @@ bool LibTremorPlugin::isFileSupported( const QString& path ) { bool LibTremorPlugin::open( const QString& path ) { debugMsg( "LibTremorPlugin::open" ); d->filename = (char*) path.latin1(); d->f = fopen( d->filename, "r" ); if (d->f == 0) { - qDebug("error opening %s", d->filename ); + odebug << "error opening " << d->filename << "" << oendl; return FALSE; } if (ov_open(d->f, &d->vf, NULL, 0) < 0) { - qDebug("error opening %s", d->filename); + odebug << "error opening " << d->filename << "" << oendl; return FALSE; } d->vc = ov_comment(&d->vf, -1); d->vi = ov_info(&d->vf, -1); d->bos = false; QString comments[] = { "title", "artist", "album", "year", "tracknumber", "" }; @@ -148,29 +153,29 @@ bool LibTremorPlugin::open( const QString& path ) { if (!d->finfo.isEmpty()) { d->finfo += ", "; } d->finfo += cdescr[i] + ": " + v; } } - qDebug("finfo: " + d->finfo); + odebug << "finfo: " + d->finfo << oendl; return TRUE; } bool LibTremorPlugin::close() { debugMsg( "LibTremorPlugin::close" ); int result = TRUE; if (fclose(d->f) == -1) { - qDebug("error closing file %s", d->filename); + odebug << "error closing file " << d->filename << "" << oendl; result = FALSE; } d->f = 0; d->finfo = ""; return result; } @@ -188,23 +193,23 @@ const QString &LibTremorPlugin::fileInfo() { int LibTremorPlugin::audioStreams() { debugMsg( "LibTremorPlugin::audioStreams" ); return 1; } int LibTremorPlugin::audioChannels( int ) { - qDebug( "LibTremorPlugin::audioChannels: %i", d->vi->channels ); + odebug << "LibTremorPlugin::audioChannels: " << d->vi->channels << "" << oendl; return d->vi->channels; } int LibTremorPlugin::audioFrequency( int ) { - qDebug( "LibTremorPlugin::audioFrequency: %ld", d->vi->rate ); + odebug << "LibTremorPlugin::audioFrequency: " << d->vi->rate << "" << oendl; return d->vi->rate; } int LibTremorPlugin::audioSamples( int ) { debugMsg( "LibTremorPlugin::audioSamples" ); return (int) ov_pcm_total(&d->vf,-1); } @@ -218,17 +223,17 @@ bool LibTremorPlugin::audioSetSample( long, int ) { long LibTremorPlugin::audioGetSample( int ) { debugMsg( "LibTremorPlugin::audioGetSample" ); return 0; } bool LibTremorPlugin::audioReadSamples( short *output, int, long samples, long& samplesMade, int ) { -// qDebug( "<<<<<<<<<<<<LibTremorPlugin::audioReadStereoSamples %d", samples ); +// odebug << "<<<<<<<<<<<<LibTremorPlugin::audioReadStereoSamples " << samples << "" << oendl; int old_section = d->csection; char* buf = (char*) output; int length = samples * 4; if ( samples == 0 ) return false; @@ -240,17 +245,17 @@ bool LibTremorPlugin::audioReadSamples( short *output, int, long samples, long& } int n = 4096; if (length < n) { n = length; } long ret = ov_read(&d->vf, buf, n, &d->csection); -// qDebug("%d", ret); +// odebug << "" << ret << "" << oendl; if (ret == 0) { break; } else if (ret < 0) { return true; } if (old_section != d->csection) { d->bos = true; diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index 4e82900..7f3a0a8 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp @@ -14,23 +14,31 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // L.J.Potter added changes Fri 02-15-2002 + +#include "wavplugin.h" + +/* OPIE */ +#include <opie2/odebug.h> + +/* QT */ +#include <qfile.h> + +/* STD */ #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <errno.h> #include <unistd.h> -#include <qfile.h> -#include "wavplugin.h" //#define debugMsg(a) qDebug(a) #define debugMsg(a) struct RiffChunk { char id[4]; Q_UINT32 size; @@ -71,24 +79,24 @@ public: } // expands out samples to the frequency of 44kHz //not any more bool add( short *output, long count, long& done, bool stereo ) { done = 0; if ( input == 0 ) { - qDebug("no input"); + odebug << "no input" << oendl; return FALSE; } while ( count ) { int l,r; if ( getSample(l, r) == FALSE ) { - qDebug("didn't get sample"); + odebug << "didn't get sample" << oendl; return FALSE; } samples_due += chunkdata.samplesPerSec; printf("samples due %d\r", samples_due); fflush(stdout); while ( count && (samples_due > chunkdata.samplesPerSec) ) { *output++ = l; if ( stereo ) @@ -130,27 +138,27 @@ public: } } } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { return FALSE; } #define WAVE_FORMAT_PCM 1 if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { - qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); + odebug << "WAV file: UNSUPPORTED FORMAT " << chunkdata.formatTag << "" << oendl; return FALSE; } } else { // ignored chunk if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { return FALSE; } } } // while - qDebug("bits %d", chunkdata.wBitsPerSample); + odebug << "bits " << chunkdata.wBitsPerSample << "" << oendl; return TRUE; } // gets a sample from the file bool getSample(int& l, int& r) { l = r = 0; @@ -202,17 +210,17 @@ WavPlugin::WavPlugin() { WavPlugin::~WavPlugin() { close(); delete d; } bool WavPlugin::isFileSupported( const QString& path ) { -// qDebug( "WavPlugin::isFileSupported" ); +// odebug << "WavPlugin::isFileSupported" << oendl; char *ext = strrchr( path.latin1(), '.' ); // Test file extension if ( ext ) { if ( strncasecmp(ext, ".raw", 4) == 0 ) return TRUE; if ( strncasecmp(ext, ".wav", 4) == 0 ) @@ -221,86 +229,86 @@ bool WavPlugin::isFileSupported( const QString& path ) { return TRUE; } return FALSE; } bool WavPlugin::open( const QString& path ) { -// qDebug( "WavPlugin::open" ); +// odebug << "WavPlugin::open" << oendl; d->max = d->out = sound_buffer_size; d->wavedata_remaining = 0; d->samples_due = 0; d->input = new QFile( path ); if ( d->input->open(IO_ReadOnly) == FALSE ) { - qDebug("couldn't open file"); + odebug << "couldn't open file" << oendl; delete d->input; d->input = 0; return FALSE; } d->initialise(); qApp->processEvents(); return TRUE; } bool WavPlugin::close() { -// qDebug( "WavPlugin::close" ); +// odebug << "WavPlugin::close" << oendl; d->input->close(); delete d->input; d->input = 0; return TRUE; } bool WavPlugin::isOpen() { -// qDebug( "WavPlugin::isOpen" ); +// odebug << "WavPlugin::isOpen" << oendl; return ( d->input != 0 ); } int WavPlugin::audioStreams() { -// qDebug( "WavPlugin::audioStreams" ); +// odebug << "WavPlugin::audioStreams" << oendl; return 1; } int WavPlugin::audioChannels( int ) { -// qDebug( "WavPlugin::audioChannels" ); +// odebug << "WavPlugin::audioChannels" << oendl; return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples } int WavPlugin::audioFrequency( int ) { -// qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); +// odebug << "WavPlugin::audioFrequency " << d->chunkdata.samplesPerSec << "" << oendl; return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 } int WavPlugin::audioSamples( int ) { -// qDebug( "WavPlugin::audioSamples" ); +// odebug << "WavPlugin::audioSamples" << oendl; return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, // Therefore if source is mono we will double the number of samples } bool WavPlugin::audioSetSample( long, int ) { -// qDebug( "WavPlugin::audioSetSample" ); +// odebug << "WavPlugin::audioSetSample" << oendl; return FALSE; } long WavPlugin::audioGetSample( int ) { -// qDebug( "WavPlugin::audioGetSample" ); +// odebug << "WavPlugin::audioGetSample" << oendl; return 0; } /* bool WavPlugin::audioReadSamples( short *, int, long, int ) { debugMsg( "WavPlugin::audioReadSamples" ); return FALSE; } @@ -320,23 +328,23 @@ bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samples bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { debugMsg( "WavPlugin::audioReadStereoSamples" ); return !d->add( output, samples, samplesMade, TRUE ); } */ bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { -// qDebug( "WavPlugin::audioReadSamples" ); +// odebug << "WavPlugin::audioReadSamples" << oendl; return d->add( output, samples, samplesMade, channels != 1 ); } double WavPlugin::getTime() { -// qDebug( "WavPlugin::getTime" ); //this is a stupid hack here!! +// odebug << "WavPlugin::getTime" << oendl; //this is a stupid hack here!! return d->chunkdata.wBitsPerSample; /*0.0*/; } // int WavPlugin::audioBitsPerSample( int ) { -// // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); -// return d->chunkdata.wBitsPerSample; // +// // odebug << "WavPlugin::audioFormat " << d->chunkdata.wBitsPerSample << "" << oendl; +// return d->chunkdata.wBitsPerSample; // // } |