Permalink
Browse files

Remove 64-bit helper functions as Qt4 does it already

Refs #6256

This has been languishing in the ticket for 2 years.  I have reapplied the
patch, and gotten rid of the new users of the helpers.  90+% of this is Isaac's
work, so he's getting the credit.

Still need to update bindings/mythweb and bump proto version

Signed-off-by: Gavin Hurlbut <ghurlbut@mythtv.org>
  • Loading branch information...
1 parent 1b1d0a9 commit 1508085eb3cf5f5b88afdfb92465507a0e669a81 Isaac Richards committed with Beirdo May 25, 2011
@@ -8,7 +8,6 @@
#include "remoteutil.h"
#include "programinfo.h"
#include "mythcorecontext.h"
-#include "decodeencode.h"
#include "storagegroup.h"
#include "mythevent.h"
@@ -55,8 +54,8 @@ vector<FileSystemInfo> RemoteGetFreeSpace(void)
fsInfo.fsID = (*(it++)).toInt();
fsInfo.dirID = (*(it++)).toInt();
fsInfo.blocksize = (*(it++)).toInt();
- fsInfo.totalSpaceKB = decodeLongLong(strlist, it);
- fsInfo.usedSpaceKB = decodeLongLong(strlist, it);
+ fsInfo.totalSpaceKB = (*(it++)).toLongLong();
+ fsInfo.usedSpaceKB = (*(it++)).toLongLong();
fsInfos.push_back(fsInfo);
}
}
@@ -1,124 +0,0 @@
-// C++ headers
-#include <iostream>
-
-using namespace std;
-
-// C headers
-#include <cerrno>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <time.h>
-
-// System specific C headers
-#include "compat.h"
-
-// Qt headers
-#include <QImage>
-#include <QPainter>
-#include <QPixmap>
-#include <QFont>
-#include <QFile>
-#include <QDir>
-#include <QFileInfo>
-
-#include "compat.h"
-#include "mythverbose.h"
-
-#include "decodeencode.h"
-
-/** \fn encodeLongLong(QStringList&,long long)
- * \brief Encodes a long for streaming in the MythTV protocol.
- *
- * We need this for Qt3.1 compatibility, since it will not
- * print or read a 64 bit number directly.
- * We encode the long long as strings representing two signed
- * 32 bit integers.
- *
- * \sa decodeLongLong(QStringList&,uint)
- * decodeLongLong(QStringList&,QStringList::const_iterator&)
- */
-void encodeLongLong(QStringList &list, long long num)
-{
- list << QString::number((int)(num >> 32));
- list << QString::number((int)(num & 0xffffffffLL));
-}
-
-/** \fn decodeLongLong(QStringList&,uint)
- * \brief Inefficiently decodes a long encoded for streaming in the MythTV protocol.
- *
- * We need this for Qt3.1 compatibility, since it will not
- * print or read a 64 bit number directly.
- *
- * The long long is represented as two signed 32 bit integers.
- *
- * Note: This decode performs two O(n) linear searches of the list,
- * The iterator decode function is much more efficient.
- *
- * \param list List to search for offset and offset+1 in.
- * \param offset Offset in list where to find first 32 bits of
- * long long.
- * \sa encodeLongLong(QStringList&,long long),
- * decodeLongLong(QStringList&,QStringList::const_iterator&)
- */
-long long decodeLongLong(QStringList &list, uint offset)
-{
- long long retval = 0;
- if (offset >= (uint)list.size())
- {
- VERBOSE(VB_IMPORTANT,
- "decodeLongLong() called with offset >= list size.");
- return retval;
- }
-
- int l1 = list[offset].toInt();
- int l2 = list[offset + 1].toInt();
-
- retval = ((long long)(l2) & 0xffffffffLL) | ((long long)(l1) << 32);
-
- return retval;
-}
-
-/** \fn decodeLongLong(QStringList&,QStringList::const_iterator&)
- * \brief Decodes a long encoded for streaming in the MythTV protocol.
- *
- * We need this for Qt3.1 compatibility, since it will not
- * print or read a 64 bit number directly.
- *
- * The long long is represented as two signed 32 bit integers.
- *
- * \param list List to search for offset and offset+1 in.
- * \param it Iterator pointing to first 32 bits of long long.
- * \sa encodeLongLong(QStringList&,long long),
- * decodeLongLong(QStringList&,uint)
- */
-long long decodeLongLong(QStringList &list, QStringList::const_iterator &it)
-{
- (void)list;
-
- long long retval = 0;
-
- bool ok = true;
- int l1=0, l2=0;
-
- if (it == list.end())
- ok = false;
- else
- l1 = (*(it++)).toInt();
-
- if (it == list.end())
- ok = false;
- else
- l2 = (*(it++)).toInt();
-
- if (!ok)
- {
- VERBOSE(VB_IMPORTANT,
- "decodeLongLong() called with the iterator too close "
- "to the end of the list.");
- return 0;
- }
-
- retval = ((long long)(l2) & 0xffffffffLL) | ((long long)(l1) << 32);
-
- return retval;
-}
@@ -1,17 +0,0 @@
-#ifndef DECODEENCODE_H_
-#define DECODEENCODE_H_
-
-#include <algorithm>
-using namespace std;
-
-#include <QStringList>
-
-// This is necessary for GCC 3.3, which has llabs(long long)
-// // but not abs(long long) or std::llabs(long long)
- MBASE_PUBLIC inline long long absLongLong(long long n) { return n >= 0 ? n : -n; }
-
- MBASE_PUBLIC void encodeLongLong(QStringList &list, long long num);
- MBASE_PUBLIC long long decodeLongLong(QStringList &list, uint offset);
- MBASE_PUBLIC long long decodeLongLong(QStringList &list, QStringList::const_iterator &it);
-
-#endif // DECODEENCODE_H_
@@ -15,7 +15,7 @@ HEADERS += mythbaseexp.h mythdbcon.h mythdb.h mythdbparams.h oldsettings.h
HEADERS += mythverbose.h mythversion.h compat.h mythconfig.h
HEADERS += mythobservable.h mythevent.h httpcomms.h mcodecs.h
HEADERS += mythtimer.h mythsignalingtimer.h mythdirs.h exitcodes.h
-HEADERS += lcddevice.h mythstorage.h remotefile.h decodeencode.h
+HEADERS += lcddevice.h mythstorage.h remotefile.h
HEADERS += mythcorecontext.h mythsystem.h mythlocale.h storagegroup.h
HEADERS += mythcoreutil.h mythdownloadmanager.h mythtranslation.h
HEADERS += unzip.h unzip_p.h zipentry_p.h iso639.h iso3166.h mythmedia.h
@@ -27,7 +27,7 @@ SOURCES += mythsocket.cpp mythsocketthread.cpp msocketdevice.cpp
SOURCES += mythdbcon.cpp mythdb.cpp oldsettings.cpp mythverbose.cpp
SOURCES += mythobservable.cpp mythevent.cpp httpcomms.cpp mcodecs.cpp
SOURCES += mythdirs.cpp mythsignalingtimer.cpp
-SOURCES += lcddevice.cpp mythstorage.cpp remotefile.cpp decodeencode.cpp
+SOURCES += lcddevice.cpp mythstorage.cpp remotefile.cpp
SOURCES += mythcorecontext.cpp mythsystem.cpp mythlocale.cpp storagegroup.cpp
SOURCES += mythcoreutil.cpp mythdownloadmanager.cpp mythtranslation.cpp
SOURCES += unzip.cpp iso639.cpp iso3166.cpp mythmedia.cpp util.cpp
@@ -6,7 +6,6 @@ using namespace std;
#include "mythconfig.h"
#include "mythdb.h"
#include "remotefile.h"
-#include "decodeencode.h"
#include "mythcorecontext.h"
#include "mythsocket.h"
#include "compat.h"
@@ -128,15 +127,15 @@ MythSocket *RemoteFile::openSocket(bool control)
strlist.push_back("invalid response");
}
- if (strlist.size() >= 4)
+ if (strlist.size() >= 3)
{
it = strlist.begin(); ++it;
recordernum = (*it).toInt(); ++it;
- filesize = decodeLongLong(strlist, it);
+ filesize = (*(it)).toLongLong(); ++it;
for (; it != strlist.end(); ++it)
auxfiles << *it;
}
- else if (0 < strlist.size() && strlist.size() < 4 &&
+ else if (0 < strlist.size() && strlist.size() < 3 &&
strlist[0] != "ERROR")
{
VERBOSE(VB_IMPORTANT, loc_err +
@@ -373,18 +372,18 @@ long long RemoteFile::Seek(long long pos, int whence, long long curpos)
QStringList strlist( QString(query).arg(recordernum) );
strlist << "SEEK";
- encodeLongLong(strlist, pos);
+ strlist << QString::number(pos);
strlist << QString::number(whence);
if (curpos > 0)
- encodeLongLong(strlist, curpos);
+ strlist << QString::number(curpos);
else
- encodeLongLong(strlist, readposition);
+ strlist << QString::number(readposition);
controlSock->writeStringList(strlist);
controlSock->readStringList(strlist);
lock.unlock();
- long long retval = decodeLongLong(strlist, 0);
+ long long retval = strlist[0].toLongLong();
readposition = retval;
Reset();
@@ -44,7 +44,6 @@ using namespace std;
#include "fifowriter.h"
#include "filtermanager.h"
#include "util.h"
-#include "decodeencode.h"
#include "livetvchain.h"
#include "decoderbase.h"
#include "nuppeldecoder.h"
@@ -28,7 +28,6 @@
#include "remotefile.h"
#include "storagegroup.h"
#include "util.h"
-#include "decodeencode.h"
#include "playercontext.h"
#include "mythdirs.h"
#include "mythverbose.h"
@@ -341,7 +340,7 @@ bool PreviewGenerator::RemotePreviewRun(void)
strlist.push_back(token);
programInfo.ToStringList(strlist);
strlist.push_back(timeInSeconds ? "s" : "f");
- encodeLongLong(strlist, captureTime);
+ strlist.push_back(QString::number(captureTime));
if (outFileName.isEmpty())
{
strlist.push_back("<EMPTY>");
@@ -5,7 +5,6 @@
#include "remoteencoder.h"
#include "programinfo.h"
#include "util.h"
-#include "decodeencode.h"
#include "mythcorecontext.h"
#include "signalmonitor.h"
#include "videooutbase.h"
@@ -206,21 +205,13 @@ long long RemoteEncoder::GetFramesWritten(void)
QStringList strlist( QString("QUERY_RECORDER %1").arg(recordernum));
strlist << "GET_FRAMES_WRITTEN";
- if (!SendReceiveStringList(strlist, 2))
+ if (!SendReceiveStringList(strlist, 1))
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "GetFramesWritten() -- network error");
return -1;
}
- if (1 == strlist.size())
- {
- VERBOSE(VB_IMPORTANT, LOC_ERR +
- QString("GetFramesWritten() -- server ret: %1")
- .arg(strlist[0]));
- return -1;
- }
-
- cachedFramesWritten = decodeLongLong(strlist, 0);
+ cachedFramesWritten = strlist[0].toLongLong();
return cachedFramesWritten;
}
@@ -235,8 +226,8 @@ long long RemoteEncoder::GetFilePosition(void)
QStringList strlist( QString("QUERY_RECORDER %1").arg(recordernum));
strlist << "GET_FILE_POSITION";
- if (SendReceiveStringList(strlist, 2))
- return decodeLongLong(strlist, 0);
+ if (SendReceiveStringList(strlist, 1))
+ return strlist[0].toLongLong();
return -1;
}
@@ -250,8 +241,8 @@ long long RemoteEncoder::GetMaxBitrate(void)
QStringList strlist( QString("QUERY_RECORDER %1").arg(recordernum));
strlist << "GET_MAX_BITRATE";
- if (SendReceiveStringList(strlist, 2))
- return decodeLongLong(strlist, 0);
+ if (SendReceiveStringList(strlist, 1))
+ return strlist[0].toLongLong();
return 20200000LL; // Peek bit rate for HD-PVR
}
@@ -267,10 +258,10 @@ int64_t RemoteEncoder::GetKeyframePosition(uint64_t desired)
{
QStringList strlist( QString("QUERY_RECORDER %1").arg(recordernum) );
strlist << "GET_KEYFRAME_POS";
- encodeLongLong(strlist, desired);
+ strlist << QString::number(desired);
- if (SendReceiveStringList(strlist, 2))
- return decodeLongLong(strlist, 0);
+ if (SendReceiveStringList(strlist, 1))
+ return strlist[0].toLongLong();
return -1;
}
@@ -7,7 +7,6 @@
#include "inputinfo.h"
#include "programinfo.h"
#include "mythcorecontext.h"
-#include "decodeencode.h"
#include "remoteencoder.h"
#include "tv_rec.h"
@@ -707,8 +707,7 @@ void AutoExpire::ExpireEpisodesOverMax(void)
(!episodeParts.contains(episodeKey)) &&
(found > *maxIter))
{
- long long spaceFreed =
- query.value(5).toLongLong() >> 20;
+ long long spaceFreed = query.value(5).toLongLong() >> 20;
QString msg =
QString("Expiring %1 MBytes for %2 at %3 => %4. Too "
"many episodes, we only want to keep %5.")
@@ -26,7 +26,6 @@
#include "mythcorecontext.h"
#include "mythversion.h"
-#include "decodeencode.h"
#include "mythdbcon.h"
#include "compat.h"
#include "mythconfig.h"
@@ -454,8 +453,8 @@ void HttpStatus::FillStatusXML( QDomDocument *pDoc )
fsID = *(sit++);
sit++; // ignore dirID
sit++; // ignore blocksize
- iTotal = decodeLongLong(strlist, sit);
- iUsed = decodeLongLong(strlist, sit);
+ iTotal = (*(sit++)).toLongLong();
+ iUsed = (*(sit++)).toLongLong();;
iAvail = iTotal - iUsed;
if (fsID == "-2")
Oops, something went wrong. Retry.

2 comments on commit 1508085

@NigelPearson
Member

If your make does something like this:

cd mythcommflag/ && make -f Makefile
make[2]: *** No rule to make target ../../libs/libmythbase/decodeencode.h', needed byBlankFrameDetector.o'. Stop.
make[1]: *** [sub-mythcommflag-make_default] Error 2
make: *** [programs] Error 2
Do something like:

find programs -name *.pro -exec touch {} ;

make

@Beirdo
Member
Beirdo commented on 1508085 May 28, 2011
Please sign in to comment.