author | llornkcor <llornkcor> | 2003-02-25 23:38:02 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-25 23:38:02 (UTC) |
commit | 94cb45ce60cc00d719a802baeb8acf74f42150d2 (patch) (side-by-side diff) | |
tree | 27f70d60579a5301f04986e56cf4bfa2067dad9c /core | |
parent | bde9ed97c92b6f7eefa8a66d9f58aa4c78127733 (diff) | |
download | opie-94cb45ce60cc00d719a802baeb8acf74f42150d2.zip opie-94cb45ce60cc00d719a802baeb8acf74f42150d2.tar.gz opie-94cb45ce60cc00d719a802baeb8acf74f42150d2.tar.bz2 |
remove libmad depending on libmpeg3, and fix crash when skin not found
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 12 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 20 |
2 files changed, 18 insertions, 14 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 9a55608..3dfe182 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -14,33 +14,33 @@ ** 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/resource.h> #include <qpe/config.h> #include <qwidget.h> #include <qpixmap.h> #include <qbutton.h> #include <qpainter.h> #include <qframe.h> #include <qlayout.h> - +#include <qdir.h> #include "audiowidget.h" #include "mediaplayerstate.h" #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 struct MediaButton { bool isToggle, isHeld, isDown; }; @@ -68,38 +68,42 @@ static void changeTextColor( QWidget *w ) { p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); w->setPalette( p ); } 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"); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); - //skin = "scaleTest"; + //skin = "scaleTest"; // color of background, frame, degree of transparency // QString skinPath = "opieplayer/skins/" + skin; - QString skinPath = "opieplayer2/skins/" + skin; - qDebug("skin path "+skinPath); + QString skinPath; + skinPath = "opieplayer2/skins/" + skin; + if(!QDir(skinPath).exists()) + skinPath = "opieplayer2/skins/default"; + + qDebug("skin path " + skinPath); 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++ ) { diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index ba14882..8cf0a75 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -87,50 +87,50 @@ void *startAudioThread( void *ptr ) { if ( threadOkToGo && mpegView->moreAudio ) mpegView->startAudio(); else usleep( 10000 ); // Semi-buzy-wait till we are playing again } return 0; } 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"); +qDebug("starting loopcontrol"); 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." ); pthread_attr_destroy(&audio_attr); pthread_attr_init(&audio_attr); } #endif -//qDebug("create audio thread"); +qDebug("create audio thread"); pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); } LoopControl::~LoopControl() { stop(); } static long prev_frame = 0; static int currentSample = 0; void LoopControl::timerEvent( QTimerEvent *te ) { if ( te->timerId() == videoId ) @@ -351,62 +351,62 @@ void LoopControl::stop( bool willPlayAgainShortly ) { current_frame=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() ); // ### 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()->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 ); - if ( !total_audio_samples ) +// if ( !total_audio_samples ) total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); total_audio_samples += 1000; - + qDebug("total samples %d", total_audio_samples); mediaPlayerState->setLength( total_audio_samples ); freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); qDebug( "LC- frequency = %d", freq ); audioSampleCounter = 0; int bits_per_sample; if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); qDebug("using stupid hack"); } else { bits_per_sample=0; } audioDevice = new AudioDevice( freq, channels, bits_per_sample); audioBuffer = new char[ audioDevice->bufferSize() ]; |