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

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/engine/phonon
From:       Shane King <kde () dontletsstart ! com>
Date:       2008-01-20 15:15:56
Message-ID: 1200842156.428933.12069.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 763897 by shakes:

Hack to make seeking of vbr files somewhat usable under windows. Supposedly \
installing wmp 10+ is supposed to make the mp3 decoder support vbr files, but that \
doesn't seem to help, so using a hack unless/until I can figure out how to make it \
behave.


 M  +29 -1     phonon-engine.cpp  
 M  +13 -0     phonon-engine.h  


--- trunk/extragear/multimedia/amarok/src/engine/phonon/phonon-engine.cpp \
#763896:763897 @@ -40,6 +40,9 @@
         , m_mediaObject( 0 )
         , m_audioOutput( 0 )
         , m_fader( 0 )
+#ifdef VBR_SEEK_HACK
+        , m_usedSeekHack( 0 )
+#endif
 {
     debug() << "Yay for Phonon being constructed";
 }
@@ -88,7 +91,7 @@
 
     delete m_fader;
     m_mediaObject->pause();
-    m_mediaObject->seek( offset );
+    seek( offset );
     m_mediaObject->play();
     emit stateChanged( Engine::Playing );
 
@@ -182,7 +185,20 @@
 PhononEngine::position() const
 {
     if( state() != Engine::Empty )
+    {
+#ifdef VBR_SEEK_HACK
+        if( m_usedSeekHack )
+        {
+            Meta::TrackPtr track = EngineController::instance()->currentTrack();
+            if( track )
+            {
+                // work out the amount of real time since the seek, plus the seek \
position in real time +                return m_mediaObject->currentTime() - \
m_usedSeekHack + ((double)m_usedSeekHack * track->length()) / (length() / 1000.0); +  \
} +        }
+#endif
         return m_mediaObject->currentTime();
+    }
 
     return 0;
 }
@@ -197,6 +213,18 @@
 void
 PhononEngine::seek( uint ms )
 {
+#ifdef VBR_SEEK_HACK
+    m_usedSeekHack = 0;
+    if( ms != 0 )
+    {
+        Meta::TrackPtr track = EngineController::instance()->currentTrack();
+        if( track )
+        {
+            ms = ((double)ms * length()) / (track->length() * 1000.0);
+            m_usedSeekHack = ms;
+        }
+    }
+#endif
     m_mediaObject->seek( ms );
 }
 
--- trunk/extragear/multimedia/amarok/src/engine/phonon/phonon-engine.h \
#763896:763897 @@ -24,6 +24,14 @@
     class VolumeFaderEffect;
 }
 
+#ifdef Q_OS_WIN
+// due to the "joys" of DirectShow, we can't accurately seek VBR files
+// so this hack is better than nothing ... scale our seek relative to the
+// garbage it returns for length. This "mostly" works, except in the case
+// of a file with very inconsistent bitrates (eg long sections of silence).
+#define VBR_SEEK_HACK
+#endif
+
 class /*AMAROK_PHONON_ENGINE_EXPORT*/ PhononEngine : public Engine::Base
 {
     Q_OBJECT
@@ -64,6 +72,11 @@
 
 private slots:
     void slotMetaDataChanged();
+
+private:
+#ifdef VBR_SEEK_HACK
+    uint m_usedSeekHack;
+#endif
 };
 
 #endif


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

Configure | About | News | Add a list | Sponsored by KoreLogic