Bug 116575

Summary: ktrm.cpp compile failure against libtunepimp-0.4.0
Product: [Applications] juk Reporter: Rex Dieter <rdieter>
Component: generalAssignee: Scott Wheeler <wheeler>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: quick-n-dirty (untested) build fix
another similar tunepimp patch

Description Rex Dieter 2005-11-17 19:26:49 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Fedora RPMs
Compiler:          gcc version 4.0.1 20050727 (Red Hat 4.0.1-5) 
OS:                Linux

$cd kdemultimedia-3.5.0/juk; make ktrm.o
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/kde -I/usr/lib/qt-3.3/include -I/usr/X11R6/include  -I/usr/include/cdda -I/usr/include/taglib   -I/usr/include/kde/arts  -DQT_THREAD_SUPPORT  -D_REENTRANT  -DNDEBUG -DNO_DEBUG -O2 -O2 -m32 -march=i386 -mtune=pentium4 -fno-exceptions -fno-check-new -fno-common -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION -fexceptions -MT ktrm.o -MD -MP -MF ".deps/ktrm.Tpo" -c -o ktrm.o ktrm.cpp; \
then mv -f ".deps/ktrm.Tpo" ".deps/ktrm.Po"; else rm -f ".deps/ktrm.Tpo"; exit 1; fi
ktrm.cpp: In member function `int KTRMRequestHandler::startLookup(KTRMLookup*)':
/usr/include/tunepimp/tp_c.h:639: error: too few arguments to function `int tp_AddFile(void*, const char*, int)'
ktrm.cpp:69: error: at this point in file
ktrm.cpp: In constructor `KTRMRequestHandler::KTRMRequestHandler()':
ktrm.cpp:123: error: `tp_SetUseUTF8' undeclared (first use this function)
ktrm.cpp:123: error: (Each undeclared identifier is reported only once for each function it appears in.)
ktrm.cpp:124: error: invalid conversion from `void (*)(void*, void*, TPCallbackEnum, int)' to `void (*)(void*, void*, TPCallbackEnum, int, TPFileStatus)'
ktrm.cpp:124: error:   initializing argument 2 of `void tp_SetNotifyCallback(void*, void (*)(void*, void*, TPCallbackEnum, int, TPFileStatus), void*)'
ktrm.cpp: In member function `virtual void KTRMLookup::collision()':
ktrm.cpp:506: error: base operand of `->' has non-pointer type `artistresult_t'
ktrm.cpp:507: error: base operand of `->' has non-pointer type `albumresult_t'
ktrm.cpp:509: error: base operand of `->' has non-pointer type `albumresult_t'
make: *** [ktrm.o] Error 1
Comment 1 Rex Dieter 2005-11-17 19:29:10 UTC
Created attachment 13514 [details]
quick-n-dirty (untested) build fix
Comment 2 Rex Dieter 2005-11-17 19:30:28 UTC
Of course, the patch fixes the build against libtunepimp-0.4 but (probably) breaks building against libtunepimp-0.3.
Comment 3 Rex Dieter 2005-11-17 20:14:25 UTC
See also bug #94988 (similar problem w/amarok)
Comment 4 Scott Wheeler 2005-11-18 15:35:02 UTC
I've just downloaded the latest library and will try to do some testing with it today and then get a version into JuK and amaroK that has #ifdef's for the 0.3 and 0.4 versions.  Hopefully it'll make it into 3.5.
Comment 5 Rex Dieter 2005-11-18 16:35:40 UTC
Thanks Scott.
Comment 6 Rex Dieter 2005-11-18 16:44:40 UTC
FYI, with the amarok patch I provided (see bug #94988), it at least compiles, but lookups are very flaky:
1.  Initial musicbrainz lookup, ie, the first lookup on any audio file, (always?) fails.
2.  ~75% of subsequent lookups on the same fail hang.
3.  ~25% of subsequent lookups succeed.  ???

So, I'd venture to guess there's some code changes required.  (-:
Comment 7 Andy Shevchenko 2005-11-25 17:14:25 UTC
Created attachment 13646 [details]
another similar tunepimp patch

I have found this problem also. But, I do not set to 1 the last parameter of
tp_AddFile(). And more convenient to use status parameter of
TRMNotifyCallback() instead of tr_GetStatus() method.
Comment 8 Dirk Mueller 2006-01-17 16:21:21 UTC
SVN commit 499319 by mueller:

musicbrainz 0.4.x support
BUG:116575


 M  +3 -1      configure.in.in  
 M  +26 -3     ktrm.cpp  


--- branches/KDE/3.5/kdemultimedia/juk/configure.in.in #499318:499319
@@ -35,7 +35,9 @@
 fi
 
 if test "x$have_musicbrainz" = xyes; then
-  AC_DEFINE(HAVE_MUSICBRAINZ, 1, [have MusicBrainz])
+  AC_CHECK_LIB(tunepimp, tp_SetFileNameEncoding,
+    AC_DEFINE(HAVE_MUSICBRAINZ, 4, [have MusicBrainz 0.4.x]), 
+    AC_DEFINE(HAVE_MUSICBRAINZ, 1, [have MusicBrainz]))
 else
   AC_DEFINE(HAVE_MUSICBRAINZ, 0, [have MusicBrainz])
 fi
--- branches/KDE/3.5/kdemultimedia/juk/ktrm.cpp #499318:499319
@@ -42,7 +42,11 @@
 
 extern "C"
 {
+#if HAVE_MUSICBRAINZ >= 4
+    static void TRMNotifyCallback(tunepimp_t pimp, void *data, TPCallbackEnum type, int fileId, TPFileStatus status);
+#else
     static void TRMNotifyCallback(tunepimp_t pimp, void *data, TPCallbackEnum type, int fileId);
+#endif
 }
 
 /**
@@ -66,7 +70,11 @@
         int id;
 
         if(!m_fileMap.contains(lookup->file())) {
+#if HAVE_MUSICBRAINZ >= 4
+            id = tp_AddFile(m_pimp, QFile::encodeName(lookup->file()), 0);
+#else
             id = tp_AddFile(m_pimp, QFile::encodeName(lookup->file()));
+#endif
             m_fileMap.insert(lookup->file(), id);
         }
         else {
@@ -120,7 +128,11 @@
         tp_SetAutoSaveThreshold(m_pimp, -1);
         tp_SetMoveFiles(m_pimp, false);
         tp_SetRenameFiles(m_pimp, false);
+#if HAVE_MUSICBRAINZ >= 4
+        tp_SetFileNameEncoding(m_pimp, "UTF-8");
+#else
         tp_SetUseUTF8(m_pimp, true);
+#endif
         tp_SetNotifyCallback(m_pimp, TRMNotifyCallback, 0);
 
         // Re-read proxy config.
@@ -286,14 +298,19 @@
 /**
  * Callback fuction for TunePimp lookup events.
  */
-
-static void TRMNotifyCallback(tunepimp_t pimp, void *, TPCallbackEnum type, int fileId)
+#if HAVE_MUSICBRAINZ >= 4
+static void TRMNotifyCallback(tunepimp_t pimp, void *data, TPCallbackEnum type, int fileId, TPFileStatus status)
+#else
+static void TRMNotifyCallback(tunepimp_t pimp, void *data, TPCallbackEnum type, int fileId)
+#endif
 {
     if(type != tpFileChanged)
         return;
 
     track_t track = tp_GetTrack(pimp, fileId);
+#if HAVE_MUSICBRAINZ < 4
     TPFileStatus status = tr_GetStatus(track);
+#endif
 
     switch(status) {
     case eRecognized:
@@ -503,10 +520,16 @@
                 KTRMResult result;
 
                 result.d->title = QString::fromUtf8(tracks[i]->name);
+#if HAVE_MUSICBRAINZ >= 4
+                result.d->artist = QString::fromUtf8(tracks[i]->artist.name);
+                result.d->album = QString::fromUtf8(tracks[i]->album.name);
+                result.d->year = tracks[i]->album.releaseYear;
+#else 
                 result.d->artist = QString::fromUtf8(tracks[i]->artist->name);
                 result.d->album = QString::fromUtf8(tracks[i]->album->name);
+                result.d->year = tracks[i]->album->releaseYear;
+#endif
                 result.d->track = tracks[i]->trackNum;
-                result.d->year = tracks[i]->album->releaseYear;
                 result.d->relevance = tracks[i]->relevance;
 
                 d->results.append(result);