summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-05-19 17:56:59 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-05-19 17:56:59 -0500
commit48eceea130d982dcc2ccc8d535ed6af2b1d57266 (patch)
treeb0764d860d11d5ca1f432ac803d5ff4fae1bedc6
parenta0bd69803e169ee609f86395514e25300dd759b9 (diff)
downloadamarok-48eceea130d982dcc2ccc8d535ed6af2b1d57266.tar.gz
amarok-48eceea130d982dcc2ccc8d535ed6af2b1d57266.zip
Use xine-ui relative seek method to work around long-standing libxine FLAC seek failure
This resolves Bug 1204
-rw-r--r--amarok/src/engine/xine/xine-engine.cpp56
1 files changed, 47 insertions, 9 deletions
diff --git a/amarok/src/engine/xine/xine-engine.cpp b/amarok/src/engine/xine/xine-engine.cpp
index b2a6c5ab..5aadf3ce 100644
--- a/amarok/src/engine/xine/xine-engine.cpp
+++ b/amarok/src/engine/xine/xine-engine.cpp
@@ -47,10 +47,12 @@ extern "C"
#define LLONG_MAX 9223372036854775807LL
#endif
-
//define this to use xine in a more standard way
//#define XINE_SAFE_MODE
+//define this to enable libxine debug spew
+//#define XINE_DEBUG_ENGINE 1
+
///some logging static globals
namespace Log
@@ -174,8 +176,13 @@ XineEngine::makeNewStream()
return false;
}
- if( m_eventQueue )
+ #ifdef XINE_DEBUG_ENGINE
+ xine_set_param(m_stream, XINE_PARAM_VERBOSITY, XINE_VERBOSITY_DEBUG);
+ #endif // XINE_DEBUG_ENGINE
+
+ if( m_eventQueue ) {
xine_event_dispose_queue( m_eventQueue );
+ }
xine_event_create_listener_thread(
m_eventQueue = xine_event_new_queue( m_stream ),
@@ -203,8 +210,9 @@ XineEngine::makeNewStream()
bool
XineEngine::ensureStream()
{
- if( !m_stream )
+ if( !m_stream ) {
return makeNewStream();
+ }
return true;
}
@@ -242,7 +250,7 @@ XineEngine::load( const KURL &url, bool isStream )
setEqualizerParameters( m_intPreamp, m_equalizerGains );
}
- // for users who stubbonly refuse to use DMIX or buy a good soundcard
+ // for users who stubbornly refuse to use DMIX or buy a good soundcard
// why doesn't xine do this? I cannot say.
xine_close( m_stream );
@@ -448,8 +456,9 @@ XineEngine::state() const
uint
XineEngine::position() const
{
- if ( state() == Engine::Empty )
+ if ( state() == Engine::Empty ) {
return 0;
+ }
int pos;
int time = 0;
@@ -509,16 +518,45 @@ XineEngine::length() const
void
XineEngine::seek( uint ms )
{
- if( !ensureStream() )
+ if( !ensureStream() ) {
+ return;
+ }
+
+ bool seekable = (xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ) != 0);
+ if (!seekable) {
return;
+ }
+
+ bool use_xine_ui_seek_method = false;
+ TQString audioCodec = TQString::fromUtf8(xine_get_meta_info(m_stream, XINE_META_INFO_SYSTEMLAYER));
+ if (audioCodec == "FLAC") {
+ // Work around Xine bug with FLAC files
+ // See Bug 1204
+ use_xine_ui_seek_method = true;
+ }
if( xine_get_param( m_stream, XINE_PARAM_SPEED ) == XINE_SPEED_PAUSE ) {
// FIXME this is a xine API issue really, they need to add a seek function
- xine_play( m_stream, 0, (int)ms );
+ if (use_xine_ui_seek_method) {
+ int pos, time, length = 0;
+ xine_get_pos_length( m_stream, &pos, &time, &length );
+ xine_play( m_stream, ((ms*65535.0)/length), 0 );
+ }
+ else {
+ xine_play( m_stream, 0, (int)ms );
+ }
xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
}
- else
- xine_play( m_stream, 0, (int)ms );
+ else {
+ if (use_xine_ui_seek_method) {
+ int pos, time, length = 0;
+ xine_get_pos_length( m_stream, &pos, &time, &length );
+ xine_play( m_stream, ((ms*65535.0)/length), 0 );
+ }
+ else {
+ xine_play( m_stream, 0, (int)ms );
+ }
+ }
}
void