[Pkg-kde-extras] Bug#476379: Proposed patch

Yavor Doganov yavor at gnu.org
Wed Jul 15 13:24:27 UTC 2009


tags 476379 + patch
thanks

Please find attached my attempt to port k3b to the new libmpcdec API.
It is based on SVN trunk, as I thought the KDE4 port of k3b will
replace the 1.x KDE3 one pretty soon.  If I have to rework it for the
current version in sid, just let me know.

Apparently playback support was removed (to be replaced by Phonon,
maybe?), so I'm not entirely sure that the patch is correct.
-------------- next part --------------
Index: cmake/modules/FindMuse.cmake
===================================================================
--- cmake/modules/FindMuse.cmake	(revision 977727)
+++ cmake/modules/FindMuse.cmake	(working copy)
@@ -16,15 +16,21 @@
 endif ( MUSE_INCLUDE_DIR AND MUSE_LIBRARIES )
 
 
-FIND_PATH(MUSE_INCLUDE_DIR NAMES mpcdec/mpcdec.h
+FIND_PATH(MUSE_INCLUDE_DIR NAMES mpc/mpcdec.h
 )
 
 if(MUSE_INCLUDE_DIR)
   FIND_LIBRARY(MUSE_LIBRARIES NAMES mpcdec)
+  set(MPC_HEADER_FILE "<mpc/mpcdec.h>")
+else(MUSE_INCLUDE_DIR)
+  FIND_PATH(MUSE_INCLUDE_DIR NAMES mpcdec/mpcdec.h)
+  FIND_LIBRARY(MUSE_LIBRARIES NAMES mpcdec)
   set(MPC_HEADER_FILE "<mpcdec/mpcdec.h>")
+  set(MPC_OLD_API 1)
 else(MUSE_INCLUDE_DIR)
   FIND_PATH(MUSE_INCLUDE_DIR NAMES musepack/musepack.h)
   set(MPC_HEADER_FILE "<musepack/musepack.h>")
+  set(MPC_OLD_API 1)
   FIND_LIBRARY(MUSE_LIBRARIES NAMES musepack )
 endif(MUSE_INCLUDE_DIR)
 
Index: plugins/decoder/musepack/k3bmpcwrapper.cpp
===================================================================
--- plugins/decoder/musepack/k3bmpcwrapper.cpp	(revision 977727)
+++ plugins/decoder/musepack/k3bmpcwrapper.cpp	(working copy)
@@ -19,32 +19,60 @@
 #include <qfile.h>
 
 
+#ifdef MPC_OLD_API
 mpc_int32_t read_impl( void* data, void* ptr, mpc_int32_t size )
 {
   QFile* input = static_cast<QFile*>( data );
+#else
+mpc_int32_t read_impl( mpc_reader* data, void* ptr, mpc_int32_t size )
+{
+  QFile* input = static_cast<QFile*>( data->data );
+#endif
   return input->read( (char*)ptr, size );
 }
 
 
+#ifdef MPC_OLD_API
 mpc_bool_t seek_impl( void* data, mpc_int32_t offset )
 {
   QFile* input = static_cast<QFile*>( data );
+#else
+mpc_bool_t seek_impl( mpc_reader* data, mpc_int32_t offset )
+{
+  QFile* input = static_cast<QFile*>( data->data );
+#endif
   return input->seek( offset );
 }
 
+#ifdef MPC_OLD_API
 mpc_int32_t tell_impl( void* data )
 {
   QFile* input = static_cast<QFile*>( data );
+#else
+mpc_int32_t tell_impl( mpc_reader* data )
+{
+  QFile* input = static_cast<QFile*>( data->data );
+#endif
   return input->pos();
 }
 
+#ifdef MPC_OLD_API
 mpc_int32_t get_size_impl( void* data )
 {
   QFile* input = static_cast<QFile*>( data );
+#else
+mpc_int32_t get_size_impl( mpc_reader* data )
+{
+  QFile* input = static_cast<QFile*>( data->data );
+#endif
   return input->size();
 }
 
+#ifdef MPC_OLD_API
 mpc_bool_t canseek_impl( void* )
+#else
+mpc_bool_t canseek_impl( mpc_reader* )
+#endif
 {
   return true;
 }
@@ -74,7 +102,9 @@
   m_reader->canseek  = canseek_impl;
   m_reader->data     = m_input;
 
+#ifdef MPC_OLD_API
   m_decoder          = new mpc_decoder;
+#endif
 
   m_info             = new mpc_streaminfo;
 }
@@ -85,7 +115,12 @@
   close();
 
   delete m_reader;
+#ifdef MPC_OLD_API
   delete m_decoder;
+#else
+  if( m_decoder )
+    mpc_demux_exit( m_decoder );
+#endif
   delete m_info;
   delete m_input;
 }
@@ -98,6 +133,7 @@
   m_input->setFileName( filename );
 
   if( m_input->open( QIODevice::ReadOnly ) ) {
+#ifdef MPC_OLD_API
     mpc_streaminfo_init( m_info );
     if( mpc_streaminfo_read( m_info, m_reader ) != ERROR_CODE_OK ) {
       kDebug() << "(K3bMpcWrapper) Not a valid musepack file: \"" << filename << "\"";
@@ -106,16 +142,25 @@
     else {
       mpc_decoder_setup( m_decoder, m_reader );
       if( !mpc_decoder_initialize( m_decoder, m_info ) ) {
+#else
+      m_decoder = mpc_demux_init( m_reader );
+      if( !m_decoder ) {
+#endif
 	kDebug() << "(K3bMpcWrapper) failed to initialize the Musepack decoder.";
 	close();
 	return false;
       }
       else {
+#ifndef MPC_OLD_API
+	mpc_demux_get_info( m_decoder, m_info );
+#endif
 	kDebug() << "(K3bMpcWrapper) valid musepack file. " 
 		  << channels() << " Channels and Samplerate: " << samplerate() << endl;
 	return true;
       }
+#ifdef MPC_OLD_API
     }
+#endif
   }
   else
     return false;
@@ -133,8 +178,17 @@
   // FIXME: make this a member variable
   MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
 
+#ifdef MPC_OLD_API
   unsigned int samples = mpc_decoder_decode( m_decoder, sample_buffer, 0, 0 );
+#else
+  unsigned int samples;
+  mpc_frame_info frame;
 
+  frame.buffer = sample_buffer;
+  mpc_demux_decode( m_decoder, &frame );
+  samples = frame.samples;
+#endif
+
   if( samples*channels()*2 > (unsigned int)max ) {
     kDebug() << "(K3bMpcWrapper) buffer not big enough.";
     return -1;
@@ -170,7 +224,11 @@
 
 bool K3bMpcWrapper::seek( const K3b::Msf& msf )
 {
+#ifdef MPC_OLD_API
   return mpc_decoder_seek_seconds( m_decoder, (double)msf.totalFrames()/75.0 );
+#else
+  return mpc_demux_seek_second( m_decoder, (double)msf.totalFrames()/75.0 );
+#endif
 }
 
 
Index: plugins/decoder/musepack/k3bmpcwrapper.h
===================================================================
--- plugins/decoder/musepack/k3bmpcwrapper.h	(revision 977727)
+++ plugins/decoder/musepack/k3bmpcwrapper.h	(working copy)
@@ -49,7 +49,11 @@
  private:
   QFile* m_input;
   mpc_reader* m_reader;
+#ifdef MPC_OLD_API
   mpc_decoder* m_decoder;
+#else
+  mpc_demux* m_decoder;
+#endif
   mpc_streaminfo* m_info;
 };
 
Index: plugins/decoder/musepack/k3bmpc_config.h.cmake
===================================================================
--- plugins/decoder/musepack/k3bmpc_config.h.cmake	(revision 977727)
+++ plugins/decoder/musepack/k3bmpc_config.h.cmake	(working copy)
@@ -1 +1,2 @@
 #define MPC_HEADER_FILE ${MPC_HEADER_FILE}
+#cmakedefine MPC_OLD_API


More information about the pkg-kde-extras mailing list