[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-multimedia
Subject: Kaiman stability patch
From: Stefan Schimanski <1Stein () gmx ! de>
Date: 2000-08-28 15:01:49
[Download RAW message or body]
Hi,
I've changed a lot of Kaiman MCOP reference handling to address the following
problems:
1) Kaiman will run completely without a running artsd, but it will try to
launch artsd on play (still with the kdeinit_wrapper problem :(
2) The references to arts objects will be recreated for every file to avoid
race conditions that Martin pointed out ( Martin can you please repeat your
stress tests with this version ?)
3) The playing state is now correctly displayed when arts crashes
It looks quite stable for me now. Please try it out and report any problem.
Thnx
Schimmi
["kaiman.patch" (text/english)]
Only in kaiman: .xvpics
Common subdirectories: kaiman.head/CVS and kaiman/CVS
diff -U2 kaiman.head/KaimanStyle.cpp kaiman/KaimanStyle.cpp
--- kaiman.head/KaimanStyle.cpp Wed Aug 16 12:19:33 2000
+++ kaiman/KaimanStyle.cpp Mon Aug 28 12:46:26 2000
@@ -771,5 +771,4 @@
{
_value = 0;
- kdDebug() << "KaimanStyleState" << endl;
}
@@ -890,9 +889,7 @@
} else if ( l_s_elem=="Digit_Small" || l_s_elem=="Digit_Small_Default" ) {
i_smallFont = ref_s_tokens[1];
- kdDebug() << "Digit_Small = " << i_smallFont << endl;
return;
} else if ( l_s_elem=="Digit_Large" || l_s_elem=="Digit_Large_Default" ) {
i_largeFont = ref_s_tokens[1];
- kdDebug() << "Digit_Large = " << i_largeFont << endl;
return;
}
@@ -1294,5 +1291,4 @@
if ( l_kse_elem->filename=="Small" ) l_kse_elem->filename = i_smallFont;
else if ( l_kse_elem->filename=="Large" ) l_kse_elem->filename = \
i_largeFont;
- kdDebug() << "numberElement filename = " << l_kse_elem->filename << endl;
} else if( l_elementType==SliderElement ) {
// slider items
Only in kaiman: Makefile
Only in kaiman: Makefile.in
Common subdirectories: kaiman.head/Skins and kaiman/Skins
diff -U2 kaiman.head/kaiman.cpp kaiman/kaiman.cpp
--- kaiman.head/kaiman.cpp Sun Aug 27 21:58:24 2000
+++ kaiman/kaiman.cpp Mon Aug 28 16:42:32 2000
@@ -66,13 +66,14 @@
return true;
return false;
-} \
+}
using namespace Arts;
Kaiman::Kaiman( const QString &skin )
- : _style(0), _soundServer(Reference("global:Arts_SimpleSoundServer")), \
_prefDlg(0) + : _style(0), _prefDlg(0)
{
KWin::setType( this->winId(), NET::Override );
setBackgroundMode( NoBackground );
+ setAcceptDrops(true);
// init config
@@ -84,8 +85,11 @@
_altSkin = config->readBoolEntry( "AltSkin", false );
_mixerCommand = "kmix"; // Default mixer
+ _seeking = false;
- setAcceptDrops(true);
-
- if (!initArts()) exit(1);
+ // initialise aRts references
+ _playObject = Arts::PlayObject::null();
+ _volumeControl = Arts::StereoVolumeControl::null();
+ _soundServer = Arts::SimpleSoundServer::null();
+ _lastPolledState = Arts::posIdle;
// load skin
@@ -142,5 +146,5 @@
// get a reference to the server to be sure that we're still connected
- _soundServer=Reference("global:Arts_SimpleSoundServer");
+ _soundServer = Reference("global:Arts_SimpleSoundServer");
// remove effect from effect chain
@@ -154,15 +158,19 @@
bool Kaiman::initArts()
{
- _playObjectFactory = Arts::Reference("global:Arts_PlayObjectFactory");
+ _playObject = Arts::PlayObject::null();
+ _volumeControl = Arts::StereoVolumeControl::null();
+ _soundServer = Arts::SimpleSoundServer::null();
+ _lastPolledState = Arts::posIdle;
- if(_playObjectFactory.isNull())
+ _soundServer = Reference("global:Arts_SimpleSoundServer");
+ _playObjectFactory = Arts::Reference("global:Arts_PlayObjectFactory");
+ if( _playObjectFactory.isNull() )
{
// aRts seems not to be running, let's try to run it
// First, let's read the configuration as in kcmarts
-
KConfig *config = new KConfig("kcmartsrc");
QCString cmdline;
-
+
config->setGroup("Arts");
bool startRealtime = config->readBoolEntry("StartRealtime",false);
@@ -171,16 +179,16 @@
// bool fullDuplex = config->readBoolEntry("FullDuplex",false);
int responseTime = config->readNumEntry("ResponseTime",2);
-
+
/* put the value of x11Comm into .mcoprc */
KConfig *X11CommConfig = new KConfig(QDir::homeDirPath()+"/.mcoprc");
-
+
if(x11Comm)
X11CommConfig->writeEntry("GlobalComm","Arts::X11GlobalComm");
else
X11CommConfig->writeEntry("GlobalComm","Arts::TmpGlobalComm");
-
+
X11CommConfig->sync();
delete X11CommConfig;
-
+
cmdline = QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1("kdeinit_wrapper")));
cmdline += " ";
@@ -196,19 +204,19 @@
// if(fullDuplex)
// cmdline += " -d";
-
+
switch(responseTime)
{
- // 8.7 ms
+ // 8.7 ms
case 0: cmdline += " -F 3 -S 512";
break;
- // 40 ms
+ // 40 ms
case 1: cmdline += " -F 7 -S 1024";
break;
- // 255 ms
+ // 255 ms
case 2: cmdline += " -F 5 -S 8192";
break;
}
- int status=system(cmdline);
+ int status=system(cmdline);
if ( status!=-1 && WIFEXITED(status) )
@@ -219,22 +227,25 @@
// but this is better than nothing.
sleep(1);
- _soundServer=Reference("global:Arts_SimpleSoundServer");
+ _soundServer = Reference("global:Arts_SimpleSoundServer");
_playObjectFactory = Arts::Reference("global:Arts_PlayObjectFactory");
}
-
- if(_playObjectFactory.isNull())
+
+ if( _playObjectFactory.isNull() )
{
+ kdDebug() << "Connection to the soundserver failed - make sure that \
artsd is really running." << endl;
KMessageBox::error( 0, i18n("Connection to the soundserver failed - make \
sure that artsd is really running.") ); return false;
- }
+ }
}
- _playObject = Arts::PlayObject::null();
- _lastPolledState = Arts::posIdle;
-
// create a new stereo volume control object on the server
- _volumeControl = \
DynamicCast(_soundServer.createObject("Arts::StereoVolumeControl"));
- _volumeControl.start();
- _volumeEffectID = _soundServer.outstack().insertBottom(_volumeControl, "Volume \
Control"); + if ( !_soundServer.isNull() ) {
+ _volumeControl = \
DynamicCast(_soundServer.createObject("Arts::StereoVolumeControl")); + if ( \
!_volumeControl.isNull() ) { + _volumeControl.start();
+ _volumeEffectID = _soundServer.outstack().insertBottom(_volumeControl, \
"Volume Control"); + _volumeControl.scaleFactor( _volume/100.0 );
+ }
+ }
return true;
@@ -313,14 +324,19 @@
item = _style->find("Position_Slider");
- if( item!=0 ) connect( item, SIGNAL(newValue(int)), this, SLOT(seek(int)) );
+ if( item!=0 ) {
+ connect( item, SIGNAL(newValueDrag(int)), this, SLOT(seekStart(int)) );
+ connect( item, SIGNAL(newValue(int)), this, SLOT(seekDrag(int)) );
+ connect( item, SIGNAL(newValueDrop(int)), this, SLOT(seekStop(int)) );
+ }
+
KaimanStyleSlider* l_elem_volslider = \
static_cast<KaimanStyleSlider*>(_style->find("Volume_Slider")); if ( \
l_elem_volslider!=0 ) {
connect(l_elem_volslider,SIGNAL(newValue(int)),this,SLOT(setVolume(int)));
- l_elem_volslider->setValue( _volume );
+ l_elem_volslider->setValue( _volume, 0, 100 );
}
KaimanStyleValue* volItem = \
static_cast<KaimanStyleValue*>(_style->find("Volume_Item"));
- if ( volItem ) volItem->setValue( _volume );
+ if ( volItem ) volItem->setValue( _volume, 0, 100 );
KaimanStyleText* titleItem = \
static_cast<KaimanStyleText*>(_style->find("Title")); @@ -343,31 +359,37 @@
QString file = url.directory( false )+url.fileName();
kdDebug() << " Kaiman::play " << file << endl;
- _playObject = _playObjectFactory.createPlayObject( file.ascii() );
- if ( _playObjectFactory.error() ) {
- // If connection to artsd was broken, try to reestablish it again
+ if ( !_playObjectFactory.isNull() ) {
+ _playObject = _playObjectFactory.createPlayObject( file.ascii() );
+ if ( !_playObject.isNull() ) {
+ _playObject.play();
+ return _playObject.state()==Arts::posPlaying;
+ } else
+ return false;
+ } else
+ return false;
+}
- if (!initArts()) return false;
- // Cool, we were able to connect.
+bool Kaiman::play( MediaFile *media )
+{
+ // reconnect to arts
+ initArts();
- _playObject = _playObjectFactory.createPlayObject( file.ascii() );
+ if ( !play(media->url()) ) {
+ stop();
+ return false;
}
- if ( _playObject.isNull() ) return false;
-
- _playObject.play();
- return _playObject.state()==Arts::posPlaying;
+ return true;
}
-bool Kaiman::play( MediaFile *media )
+bool Kaiman::playNext( bool reverse )
{
- return play( media->url() );
-}
-
+ // reconnect to arts
+ if ( !initArts() ) return false;
-bool Kaiman::tryPlay( bool reverse )
-{
+ // try to play files
for ( int tries = _mediaManager->count();
tries>0;
@@ -376,5 +398,5 @@
// try to play active media file
MediaFile *media = _mediaManager->active();
- if ( media && play(media) )
+ if ( media && play(media->url()) )
return true;
@@ -392,19 +414,16 @@
void Kaiman::play()
{
+ kdDebug() << "play" << endl;
+
if( !_playObject.isNull() ) {
- if ( _playObject.state()==Arts::posPlaying ) {
- // We are playing => Pause
+ if ( _playObject.state()==Arts::posPlaying )
pause();
- return;
- }
-
- if ( _playObject.state()==Arts::posPaused ) {
+ else
_playObject.play();
- return;
- }
+ } else {
+ _mediaManager->start( false );
+ if ( !playNext(false) )
+ stop();
}
-
- _mediaManager->start( false );
- tryPlay(false);
}
@@ -412,11 +431,11 @@
void Kaiman::pause()
{
- if(!_playObject.isNull()) {
- if ( _lastPolledState==Arts::posPaused ) {
+ kdDebug() << "pause" << endl;
+
+ if( !_playObject.isNull() ) {
+ if ( _lastPolledState==Arts::posPaused )
_playObject.play();
- }
- else {
+ else
_playObject.pause();
- }
}
}
@@ -425,10 +444,18 @@
void Kaiman::stop()
{
- if(!_playObject.isNull()) {
- Arts::poTime l_t_zero(0,0,0,"samples");
- _playObject.seek(l_t_zero);
+ kdDebug() << "stop" << endl;
+
+ if( !_playObject.isNull() ) {
+ Arts::poTime l_t_zero( 0, 0, 0, "samples" );
+ _playObject.seek( l_t_zero );
_playObject.halt();
- _mediaManager->reset();
}
+
+ _playObject = Arts::PlayObject::null();
+ _volumeControl = Arts::StereoVolumeControl::null();
+ _soundServer = Arts::SimpleSoundServer::null();
+ _lastPolledState = Arts::posIdle;
+
+ _mediaManager->reset();
}
@@ -436,4 +463,5 @@
void Kaiman::clear()
{
+ stop();
_mediaManager->clear();
}
@@ -443,5 +471,5 @@
{
if ( _shuffle ) _mediaManager->shuffle(); else _mediaManager->next( false, \
_looping );
- tryPlay( false );
+ if ( !playNext(false) ) stop();
}
@@ -450,5 +478,30 @@
{
if ( _shuffle ) _mediaManager->shuffle(); else _mediaManager->next( true, \
_looping );
- tryPlay( true );
+ if ( !playNext(true) ) stop();
+}
+
+
+void Kaiman::seekStart( int /*value*/ )
+{
+ _seeking = true;
+}
+
+
+void Kaiman::seekDrag( int value )
+{
+ KaimanStyleValue* posItem =
+ static_cast<KaimanStyleValue*>(_style->find("Position_Item"));
+ if ( posItem ) posItem->setValue( value );
+
+ KaimanStyleSlider* posSlider =
+ static_cast<KaimanStyleSlider*>(_style->find("Position_Slider"));
+ if ( posSlider ) posSlider->setValue( value );
+}
+
+
+void Kaiman::seekStop( int value )
+{
+ seek( value );
+ _seeking = false;
}
@@ -456,5 +509,5 @@
void Kaiman::seek( int sec )
{
- if ( !_playObject.isNull() ) {
+ if ( !_playObject.isNull() ) {
Arts::poTime t;
t.seconds = sec;
@@ -505,13 +558,13 @@
if ( vol<0 ) vol=0;
if ( vol>=100 ) vol=100;
-
_volume = vol;
- float volume = pow(2.0,(400.0 - (100-vol)*12 )/200.0);
- if ( vol==1200 ) volume = 0.0;
- _volumeControl.scaleFactor(volume);
+ if ( !_volumeControl.isNull() )
+ _volumeControl.scaleFactor(vol/100.0);
- KaimanStyleValue* item = \
static_cast<KaimanStyleValue*>(_style->find("Volume_Item"));
- if ( item ) item->setValue( vol );
+ KaimanStyleSlider* l_elem_volslider = \
static_cast<KaimanStyleSlider*>(_style->find("Volume_Slider")); + \
KaimanStyleValue* l_elem_volitem = \
static_cast<KaimanStyleValue*>(_style->find("Volume_Item")); + if ( \
l_elem_volslider!=0 ) l_elem_volslider->setValue( _volume, 0, 100 ); + if ( \
l_elem_volitem!=0 ) l_elem_volitem->setValue( _volume, 0, 100 ); }
@@ -520,11 +573,4 @@
{
setVolume( _volume+10 );
-
- KaimanStyleSlider* l_elem_volslider = \
static_cast<KaimanStyleSlider*>(_style->find("Volume_Slider"));
- KaimanStyleValue* l_elem_volitem = \
static_cast<KaimanStyleValue*>(_style->find("Volume_Item"));
- if ( l_elem_volitem!=0 && l_elem_volslider ) {
- l_elem_volslider->setValue( _volume );
- l_elem_volitem->setValue( _volume );
- }
}
@@ -533,11 +579,4 @@
{
setVolume( _volume-10 );
-
- KaimanStyleSlider* l_elem_volslider = \
static_cast<KaimanStyleSlider*>(_style->find("Volume_Slider"));
- KaimanStyleValue* l_elem_volitem = \
static_cast<KaimanStyleValue*>(_style->find("Volume_Item"));
- if ( l_elem_volitem!=0 && l_elem_volslider ) {
- l_elem_volslider->setValue( _volume );
- l_elem_volitem->setValue( _volume );
- }
}
@@ -638,5 +677,5 @@
void Kaiman::updateArtsDisplay()
{
- long sec = 0;
+ long sec = 0;
long all = 0;
int percent = 0;
@@ -653,10 +692,13 @@
// update play position
- KaimanStyleValue* posItem = \
static_cast<KaimanStyleValue*>(_style->find("Position_Item"));
- if ( posItem ) posItem->setValue( sec, 0, all );
-
- KaimanStyleSlider* posSlider =
- static_cast<KaimanStyleSlider*>(_style->find("Position_Slider"));
- if ( posSlider ) posSlider->setValue( sec, 0, all );
+ if ( !_seeking ) {
+ KaimanStyleValue* posItem =
+ static_cast<KaimanStyleValue*>(_style->find("Position_Item"));
+ if ( posItem ) posItem->setValue( sec, 0, all );
+
+ KaimanStyleSlider* posSlider =
+ static_cast<KaimanStyleSlider*>(_style->find("Position_Slider"));
+ if ( posSlider ) posSlider->setValue( sec, 0, all );
+ }
// update time
@@ -730,22 +772,23 @@
void Kaiman::pollArts() {
- if (! _playObject.isNull() ) {
- KaimanStyleButton* l_elem_pause =
+ KaimanStyleButton* l_elem_pause =
static_cast<KaimanStyleButton*>(_style->find("Pause_Button"));
- KaimanStyleButton* l_elem_play =
+ KaimanStyleButton* l_elem_play =
static_cast<KaimanStyleButton*>(_style->find("Play_Button"));
- KaimanStyleState* status = \
static_cast<KaimanStyleState*>(_style->find("Status_Item")); + KaimanStyleState* \
status = static_cast<KaimanStyleState*>(_style->find("Status_Item"));
+ if ( !_playObject.isNull() ) {
// check play object state and update buttons
int newPolledState = _playObject.state();
switch ( newPolledState ) {
case Arts::posIdle:
+ if ( l_elem_pause!=0 ) l_elem_pause->setLit(false);
+ if ( l_elem_play!=0 ) l_elem_play->setLit(false);
+ if ( status ) status->setValue( 0 );
+
if ( _lastPolledState==Arts::posPlaying ) {
if ( _mediaManager->active() )
next();
}
- if ( l_elem_pause!=0 ) l_elem_pause->setLit(false);
- if ( l_elem_play!=0 ) l_elem_play->setLit(false);
- if ( status ) status->setValue( 0 );
break;
@@ -761,5 +804,12 @@
break;
}
- _lastPolledState = newPolledState; ;
+
+ _lastPolledState = newPolledState;
+ } else {
+ if ( _lastPolledState!=Arts::posIdle ) stop();
+
+ if ( l_elem_pause!=0 ) l_elem_pause->setLit(false);
+ if ( l_elem_play!=0 ) l_elem_play->setLit(false);
+ if ( status ) status->setValue( 0 );
}
diff -U2 kaiman.head/kaiman.desktop kaiman/kaiman.desktop
--- kaiman.head/kaiman.desktop Mon Aug 28 06:00:01 2000
+++ kaiman/kaiman.desktop Mon Aug 28 15:20:26 2000
@@ -1,6 +1,5 @@
[Desktop Entry]
-BinaryPattern=kaiman;
Name=KDE Media Player
-Name[cs]=Přehráváč médií
+Name[cs]=Pehrává médií
Name[da]=KDE mediespiller
Name[de]=KDE-Medien-Abspieler
@@ -11,8 +10,8 @@
Name[fr]=Lecteur multimédia
Name[gl]=Reproductor de Multimedia de KDE
-Name[he]=KDE לש הידמה ןג
+Name[he]=KDE ש
Name[hu]=KDE médialejátszó
Name[it]=Lettore multimediale KDE
-Name[mk]=KDE репродукција
+Name[mk]=KDE еподкиа
Name[nl]=KDE Mediaspeler
Name[no]=KDE Mediaspiller
@@ -23,14 +22,12 @@
Name[sl]=Predvajalnik za KDE
Name[sv]=KDE Mediaspelare
-Name[uk]=Програвач медіа-файлів KDE
-Name[zh_CN.GB2312]=KDE 媒体播放器
-Protocols=file;
-MimeType=video/mpeg;audio/x-mp3;audio/x-ogg;audio/x-mpegurl;audio/x-wav;
+Name[uk]=огава меда-айлв KDE
+Name[zh_CN.GB2312]=KDE
Comment=A generic media player
-Comment[cs]=Obecný přehrávač médií
+Comment[cs]=Obecný pehráva médií
Comment[da]=En generisk mediespiller
Comment[de]=Ein einfaches Abspielprogramm für Medien
-Comment[el]=Αναπαραγωγή ολυμέσων
-Comment[eo]=Ĝenerala sonludilo
+Comment[el]=ναααγγή ολμέν
+Comment[eo]=enerala sonludilo
Comment[es]=Un reproductor de medios genérico
Comment[et]=Tavaline meediafailide mängija
@@ -38,8 +35,8 @@
Comment[fr]=Un lecteur multimédia générique
Comment[gl]=Un reproductor xenérico de multimedia
-Comment[he]=יללכ הידמ ןג
+Comment[he]=
Comment[hu]=Egy általános célú médialejátszó
Comment[it]=Un lettore di media generici
-Comment[mk]= епродукција на различни медиуми
+Comment[mk]= еподкиа на азлини медими
Comment[nl]=Een algemene mediaspeler
Comment[no]=En generell mediaspiller
@@ -49,9 +46,12 @@
Comment[pt_BR]=Um reprodutor de mídia genérico
Comment[ro]=Un program generic de redare multimedia
-Comment[sl]=Splošni predvajalnik večpredstavnostnih datotek
+Comment[sl]=Splošni predvajalnik vepredstavnostnih datotek
Comment[sv]=En generell mediaspelare
-Comment[uk]=Програвач основних медіа-файлів
-Comment[zh_CN.GB2312]=通用媒体播放器
-Exec=kaiman %u
+Comment[uk]=огава оновни меда-айлв
+Comment[zh_CN.GB2312]=
+
+MimeType=video/mpeg;audio/x-mp3;audio/x-ogg;audio/x-mpegurl;audio/x-wav
+BinaryPattern=
+Exec=kaiman --show-main-window --play %U
Icon=kaiman
TerminalOptions=
@@ -61,2 +61,7 @@
Terminal=0
InitialPreference=8
+Actions=Enqueue
+
+[Desktop Action Enqueue]
+Exec=kaiman -e %U
+Name=KDE Media Player enqueue
\ No newline at end of file
diff -U2 kaiman.head/kaiman.h kaiman/kaiman.h
--- kaiman.head/kaiman.h Sun Aug 27 21:58:24 2000
+++ kaiman/kaiman.h Mon Aug 28 16:29:05 2000
@@ -76,5 +76,9 @@
bool play( const KURL &url );
bool play( MediaFile *media );
- bool tryPlay( bool reverse );
+ bool playNext( bool reverse );
+
+ void seekStart( int value );
+ void seekDrag( int value );
+ void seekStop( int value );
void applyPref();
@@ -106,4 +110,5 @@
bool _altSkin;
int _volume;
+ bool _seeking;
KaimanPrefDlg *_prefDlg;
};
Only in kaiman: kdebug.dbg
diff -U2 kaiman.head/main.cpp kaiman/main.cpp
--- kaiman.head/main.cpp Sun Aug 27 23:03:23 2000
+++ kaiman/main.cpp Mon Aug 28 02:19:09 2000
@@ -102,7 +102,7 @@
"0.3", description, KAboutData::License_GPL, "(c) 2000 \
Stefan Schimanski, Christian Esken"); aboutData.addAuthor("Stefan Schimanski", 0, \
"1Stein@gmx.de");
- aboutData.addAuthor("Christian Esken", "Style engine + first implementation", \
"esken@kde.org");
- aboutData.addAuthor("Stefan Westerfeld", "aRts", "stefan@space.twc.de");
- aboutData.addAuthor("Martin Vogt", "Audio/Video codecs", "mvogt@rhrk.uni-kl.de");
+ aboutData.addAuthor("Christian Esken", I18N_NOOP("First implementation, style \
engine"), "esken@kde.org"); + aboutData.addAuthor("Stefan Westerfeld", \
I18N_NOOP("aRts"), "stefan@space.twc.de"); + aboutData.addAuthor("Martin Vogt", \
I18N_NOOP("Audio/Video codecs"), "mvogt@rhrk.uni-kl.de");
KCmdLineArgs::init( argc, argv, &aboutData );
@@ -112,5 +112,5 @@
if (!KUniqueApplication::start())
- exit(0);
+ return 0;
KaimanApp app;
_______________________________________________
Kde-multimedia mailing list
Kde-multimedia@master.kde.org
http://master.kde.org/mailman/listinfo/kde-multimedia
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic