[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    new defensive seek patch
From:       Stefan Schimanski <1Stein () gmx ! de>
Date:       2000-08-27 20:40:03
[Download RAW message or body]

Hi,
I have changed the seeking behaviour of Kaiman. Now the play position is only 
set on mouse release. This should reduce the work for the codecs a lot. Can 
anybody approve this patch (Martin?) please?

bye
  Schimmi
["kaiman.patch" (text/x-java)]

diff -U2 head/kaiman.cpp new/kaiman.cpp
--- head/kaiman.cpp	Sun Aug 27 22:33:37 2000
+++ new/kaiman.cpp	Sun Aug 27 22:24:13 2000
@@ -66,5 +66,5 @@
         return true;
     return false;
-}                                                                                    \
 +}
 
 using namespace Arts;
@@ -84,4 +84,5 @@
     _altSkin = config->readBoolEntry( "AltSkin", false );
     _mixerCommand = "kmix"; // Default mixer
+    _seeking = false;
 
     setAcceptDrops(true);
@@ -164,5 +165,5 @@
         KConfig *config = new KConfig("kcmartsrc");
         QCString cmdline;
- 
+
         config->setGroup("Arts");
         bool startRealtime = config->readBoolEntry("StartRealtime",false);
@@ -171,16 +172,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 +197,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) )
@@ -222,10 +223,10 @@
           _playObjectFactory = Arts::Reference("global:Arts_PlayObjectFactory");
         }
- 
+
         if(_playObjectFactory.isNull())
         {
            KMessageBox::error( 0, i18n("Connection to the soundserver failed - make \
sure that artsd is really running.") );  return false;
-        } 
+        }
     }
 
@@ -313,5 +314,10 @@
 
     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")); @@ -454,7 +460,32 @@
 
 
+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;
+}
+
+
 void Kaiman::seek( int sec )
 {
-    if ( !_playObject.isNull() ) {
+   if ( !_playObject.isNull() ) {
         Arts::poTime t;
         t.seconds = sec;
@@ -638,5 +669,5 @@
 void Kaiman::updateArtsDisplay()
 {
- long sec = 0;
+    long sec = 0;
     long all = 0;
     int percent = 0;
@@ -653,10 +684,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
diff -U2 head/kaiman.h new/kaiman.h
--- head/kaiman.h	Sun Aug 27 22:33:37 2000
+++ new/kaiman.h	Sun Aug 27 22:23:26 2000
@@ -78,4 +78,8 @@
     bool tryPlay( bool reverse );
 
+    void seekStart( int value );
+    void seekDrag( int value );
+    void seekStop( int value );
+
     void applyPref();
     void okPref();
@@ -106,4 +110,5 @@
     bool _altSkin;
     int _volume;
+    bool _seeking;
     KaimanPrefDlg *_prefDlg;
 };


_______________________________________________
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