612 changes: 263 additions & 349 deletions mythplugins/mytharchive/mytharchivehelper/main.cpp

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions mythplugins/mytharchive/mythburn/scripts/mythburn.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def getMysqlDBParameters():

f = tempfile.NamedTemporaryFile();
result = os.spawnlp(os.P_WAIT, 'mytharchivehelper','mytharchivehelper',
'-p', f.name)
'--getdbparameters', '--outfile', f.name)
if result <> 0:
write("Failed to run mytharchivehelper to get mysql database parameters! "
"Exit code: %d" % result)
Expand Down Expand Up @@ -1929,7 +1929,7 @@ def multiplexMPEGStream(video, audio1, audio2, destination, syncOffset):
def getStreamInformation(filename, xmlFilename, lenMethod):
"""create a stream.xml file for filename"""
filename = quoteFilename(filename)
command = "mytharchivehelper -i %s %s %d" % (filename, xmlFilename, lenMethod)
command = "mytharchivehelper --getfileinfo --infile %s --outfile %s --method %d" % (filename, xmlFilename, lenMethod)

result = runCommand(command)

Expand Down Expand Up @@ -2081,7 +2081,7 @@ def runProjectX(chanid, starttime, folder, usecutlist, file):
os.path.exists(os.path.join(folder, "stream.sup.IFO"))):
write("Found DVB subtitles converting to DVD subtitles")
command = "mytharchivehelper --sup2dast "
command += " %s %s 0" % (os.path.join(folder, "stream.sup"), os.path.join(folder, "stream.sup.IFO"))
command += " --infile %s --ifofile %s --delay 0" % (os.path.join(folder, "stream.sup"), os.path.join(folder, "stream.sup.IFO"))

result = runCommand(command)

Expand Down Expand Up @@ -2289,7 +2289,7 @@ def extractVideoFrame(source, destination, seconds):

source = quoteFilename(source)

command = "mytharchivehelper -t %s '%s' %s" % (source, seconds, destination)
command = "mytharchivehelper --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (source, seconds, destination)
result = runCommand(command)
if result <> 0:
fatalError("Failed while running mytharchivehelper to get thumbnails.\n"
Expand All @@ -2314,7 +2314,7 @@ def extractVideoFrames(source, destination, thumbList):

source = quoteFilename(source)

command = "mytharchivehelper -v important -t %s '%s' %s" % (source, thumbList, destination)
command = "mytharchivehelper -v important --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (source, thumbList, destination)
result = runCommand(command)
if result <> 0:
fatalError("Failed while running mytharchivehelper to get thumbnails")
Expand Down Expand Up @@ -3501,7 +3501,7 @@ def generateVideoPreview(videoitem, itemonthispage, menuitem, starttime, menulen
height = getScaledAttribute(node, "h")
frames = int(secondsToFrames(menulength))

command = "mytharchivehelper -t %s '%s' '%s' %d" % (inputfile, starttime, outputfile, frames)
command = "mytharchivehelper --createthumbnail --infile %s --thumblist '%s' --outfile '%s' --framecount %d" % (inputfile, starttime, outputfile, frames)
result = runCommand(command)
if (result != 0):
write( "mytharchivehelper failed with code %d. Command = %s" % (result, command) )
Expand Down Expand Up @@ -5091,7 +5091,7 @@ def copyRemote(files, tmpPath):
tmpfile = node.attributes["filename"].value
filename = os.path.basename(tmpfile)

res = runCommand("mytharchivehelper -r " + quoteFilename(tmpfile))
res = runCommand("mytharchivehelper --isremote --infile " + quoteFilename(tmpfile))
if res == 2:
# file is on a remote filesystem so copy it to a local file
write("Copying file from " + tmpfile)
Expand Down
8 changes: 5 additions & 3 deletions mythplugins/mythgallery/mythgallery/glsingleview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ using namespace std;
#include <mythcontext.h>
#include <util.h>
#include <mythuihelper.h>
#include "mythlogging.h"

// MythGallery headers
#include "config.h"
Expand Down Expand Up @@ -626,7 +627,7 @@ void GLSingleView::Load(void)
ThumbItem *item = m_itemList.at(m_pos);
if (!item)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "No item at "<<m_pos);
VERBOSE(VB_IMPORTANT, LOC_ERR + QString("No item at %1").arg(m_pos));
return;
}

Expand Down Expand Up @@ -1532,10 +1533,11 @@ void KenBurnsImageLoader::Initialize(int pos)

void KenBurnsImageLoader::run()
{
threadRegister("KenBurnsImageLoader");
ThumbItem *item = m_itemList.at(m_pos);
if (!item)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "No item at "<<m_pos);
VERBOSE(VB_IMPORTANT, LOC_ERR + QString("No item at %1").arg(m_pos));
return;
}
QImage image(item->GetPath());
Expand All @@ -1544,5 +1546,5 @@ void KenBurnsImageLoader::run()

m_singleView->LoadImage(QGLWidget::convertToGLFormat(image.scaled(m_texSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)), image.size());
m_singleView->Ready();

threadDeregister();
}
5 changes: 5 additions & 0 deletions mythplugins/mythgallery/mythgallery/iconview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ using namespace std;
#include <mythmainwindow.h>
#include <mythprogressdialog.h>
#include <mythmediamonitor.h>
#include "mythlogging.h"

// MythGallery headers
#include "galleryutil.h"
Expand Down Expand Up @@ -83,6 +84,7 @@ void FileCopyThread::run()
QFileInfo fi;
QFileInfo dest;

threadRegister("FileCopy");
m_progress = 0;

for (it = m_parent->m_itemMarked.begin(); it != m_parent->m_itemMarked.end(); it++)
Expand All @@ -95,6 +97,7 @@ void FileCopyThread::run()

m_progress++;
}
threadDeregister();
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1481,6 +1484,7 @@ void ChildCountThread::cancel()

void ChildCountThread::run()
{
threadRegister("ChildCount");
while (moreWork())
{
QString file;
Expand All @@ -1502,6 +1506,7 @@ void ChildCountThread::run()
// inform parent we have got a count ready for it
QApplication::postEvent(m_parent, new ChildCountEvent(ccd));
}
threadDeregister();
}

bool ChildCountThread::moreWork()
Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mythgallery/mythgallery/singleview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ void SingleView::Load(void)
ThumbItem *item = m_itemList.at(m_pos);
if (!item)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "No item at " << m_pos);
VERBOSE(VB_IMPORTANT, LOC_ERR + QString("No item at %1").arg(m_pos));
return;
}

Expand Down
4 changes: 3 additions & 1 deletion mythplugins/mythgallery/mythgallery/thumbgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "galleryutil.h"
#include "mythsystem.h"
#include "exitcodes.h"
#include "mythlogging.h"

#ifdef EXIF_SUPPORT
#include <libexif/exif-data.h>
Expand Down Expand Up @@ -94,7 +95,7 @@ void ThumbGenerator::cancel()

void ThumbGenerator::run()
{

threadRegister("ThumbGenerator");
while (moreWork())
{

Expand Down Expand Up @@ -179,6 +180,7 @@ void ThumbGenerator::run()
}
}
}
threadDeregister();
}

bool ThumbGenerator::moreWork()
Expand Down
3 changes: 3 additions & 0 deletions mythplugins/mythmusic/mythmusic/avfdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <mythcontext.h>
#include <audiooutput.h>
#include <mythverbose.h>
#include "mythlogging.h"

using namespace std;

Expand Down Expand Up @@ -371,6 +372,7 @@ void avfDecoder::run()
if (!inited)
return;

threadRegister("avfDecoder");
AVPacket pkt, tmp_pkt;
char *s;
int data_size, dec_len;
Expand Down Expand Up @@ -491,6 +493,7 @@ void avfDecoder::run()
}

deinit();
threadDeregister();
}

MetaIO* avfDecoder::doCreateTagger(void)
Expand Down
3 changes: 3 additions & 0 deletions mythplugins/mythmusic/mythmusic/cddecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern "C" {
#include "cddecoder.h"
#include "constants.h"
#include "metadata.h"
#include "mythlogging.h"

CdDecoder::CdDecoder(const QString &file, DecoderFactory *d, QIODevice *i,
AudioOutput *o) :
Expand Down Expand Up @@ -189,6 +190,7 @@ void CdDecoder::run()
if (!inited)
return;

threadRegister("CdDecoder");
stat = DecoderEvent::Decoding;
{
DecoderEvent e((DecoderEvent::Type) stat);
Expand Down Expand Up @@ -281,6 +283,7 @@ void CdDecoder::run()
}

deinit();
threadDeregister();
}

void CdDecoder::setCDSpeed(int speed)
Expand Down
8 changes: 8 additions & 0 deletions mythplugins/mythmusic/mythmusic/cdrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ using namespace std;
#include "flacencoder.h"
#include "genres.h"
#include "editmetadata.h"
#include "mythlogging.h"

QEvent::Type RipStatusEvent::kTrackTextEvent =
(QEvent::Type) QEvent::registerEventType();
Expand Down Expand Up @@ -89,7 +90,9 @@ CDScannerThread::CDScannerThread(Ripper *ripper)

void CDScannerThread::run()
{
threadRegister("CDScanner");
m_parent->scanCD();
threadDeregister();
}

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -101,7 +104,9 @@ CDEjectorThread::CDEjectorThread(Ripper *ripper)

void CDEjectorThread::run()
{
threadRegister("CDEjector");
m_parent->ejectCD();
threadDeregister();
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -174,6 +179,7 @@ void CDRipperThread::run(void)
if (!m_tracks->size() > 0)
return;

threadRegister("CDRipper");
Metadata *track = m_tracks->at(0)->metadata;
QString tots;

Expand Down Expand Up @@ -331,6 +337,8 @@ void CDRipperThread::run(void)

QApplication::postEvent(
m_parent, new RipStatusEvent(RipStatusEvent::kFinishedEvent, ""));

threadDeregister();
}

int CDRipperThread::ripTrack(QString &cddevice, Encoder *encoder, int tracknum)
Expand Down
3 changes: 3 additions & 0 deletions mythplugins/mythmusic/mythmusic/databasebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using namespace std;
#include <mythmediamonitor.h>
#include <mythsystem.h>
#include <exitcodes.h>
#include "mythlogging.h"

// mythmusic
#include "metadata.h"
Expand Down Expand Up @@ -1276,6 +1277,7 @@ ReadCDThread::ReadCDThread(const QString &dev)
void ReadCDThread::run()
{
#ifndef USING_MINGW
threadRegister("ReadCD");
// lock all_music and cd_status_changed while running thread
QMutexLocker locker(getLock());

Expand Down Expand Up @@ -1363,6 +1365,7 @@ void ReadCDThread::run()
}

delete decoder;
threadDeregister();
#endif // USING_MINGW
}

3 changes: 3 additions & 0 deletions mythplugins/mythmusic/mythmusic/importmusic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <mythuibuttonlist.h>
#include <mythprogressdialog.h>
#include <mythuifilebrowser.h>
#include "mythlogging.h"

static bool copyFile(const QString &src, const QString &dst)
{
Expand Down Expand Up @@ -68,7 +69,9 @@ FileScannerThread::FileScannerThread(ImportMusicDialog *parent)

void FileScannerThread::run()
{
threadRegister("FileScanner");
m_parent->doScan();
threadDeregister();
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions mythplugins/mythmusic/mythmusic/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "treebuilders.h"
#include "playlist.h"
#include "playlistcontainer.h"
#include "mythlogging.h"


// this is the global MusicData object shared thoughout MythMusic
Expand Down Expand Up @@ -939,9 +940,11 @@ MetadataLoadingThread::MetadataLoadingThread(AllMusic *parent_ptr)

void MetadataLoadingThread::run()
{
threadRegister("MetadataLoading");
//if you want to simulate a big music collection load
//sleep(3);
parent->resync();
threadDeregister();
}

AllMusic::AllMusic(QString path_assignment, QString a_startdir)
Expand Down
3 changes: 3 additions & 0 deletions mythplugins/mythmusic/mythmusic/playlistcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <compat.h>

#include "playlistcontainer.h"
#include "mythlogging.h"

PlaylistLoadingThread::PlaylistLoadingThread(PlaylistContainer *parent_ptr,
AllMusic *all_music_ptr)
Expand All @@ -13,11 +14,13 @@ PlaylistLoadingThread::PlaylistLoadingThread(PlaylistContainer *parent_ptr,

void PlaylistLoadingThread::run()
{
threadRegister("PlaylistLoading");
while(!all_music->doneLoading())
{
sleep(1);
}
parent->load();
threadDeregister();
}

#define LOC QString("PlaylistContainer: ")
Expand Down
153 changes: 102 additions & 51 deletions mythplugins/mythnetvision/mythfillnetvision/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,68 +21,95 @@ using namespace std;
#include <mythconfig.h>
#include <netgrabbermanager.h>
#include <mythrssmanager.h>
#include <mythcommandlineparser.h>
#include <mythlogging.h>

GrabberDownloadThread *gdt = 0;
RSSManager *rssMan = 0;

class MPUBLIC MythFillNVCommandLineParser : public MythCommandLineParser
{
public:
MythFillNVCommandLineParser();
void LoadArguments(void);
};

MythFillNVCommandLineParser::MythFillNVCommandLineParser() :
MythCommandLineParser("mythfillnetvision")
{ LoadArguments(); }

void MythFillNVCommandLineParser::LoadArguments(void)
{
addHelp();
addVersion();
addVerbose();
addLogging();

add("--refresh-all", "refresh-all", false,
"Refresh ALL configured and installed tree grabbers", "");
add("--refresh-rss", "refresh-rss", false,
"Refresh RSS feeds only", "");
add("--refresh-tree", "refresh-tree", false,
"Refresh trees only", "");
}



int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
int argpos = 1;
bool refreshall = false;
bool refreshrss = true;
bool refreshtree = true;
MythFillNVCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
{
cmdline.PrintHelp();
return GENERIC_EXIT_INVALID_CMDLINE;
}

myth_nice(19);
if (cmdline.toBool("showversion"))
{
cmdline.PrintVersion();
return GENERIC_EXIT_OK;
}

while (argpos < a.argc())
if (cmdline.toBool("showhelp"))
{
// The manual and update flags should be mutually exclusive.
if (!strcmp(a.argv()[argpos], "--refresh-all"))
{
cout << "###\n";
cout << "### Refreshing ALL configured and installed tree grabbers.\n";
cout << "###\n";
refreshall = true;
}
else if (!strcmp(a.argv()[argpos], "--refresh-rss"))
{
cout << "###\n";
cout << "### Refreshing RSS Only.\n";
cout << "###\n";
refreshtree = false;
}
else if (!strcmp(a.argv()[argpos], "--refresh-tree"))
{
cout << "###\n";
cout << "### Refreshing Trees Only.\n";
cout << "###\n";
refreshrss = false;
}
else if (!strcmp(a.argv()[argpos], "-h") ||
!strcmp(a.argv()[argpos], "--help"))
{
cout << "usage:\n";
cout << "--refresh-all\n";
cout << " Refresh all tree views and RSS feeds, regardless of whether they need it.\n";
cout << "--refresh-rss\n";
cout << " Refresh RSS feeds only.\n";
cout << "--refresh-tree\n";
cout << " Refresh Tree views only.\n";
cout << "\n";
cout << "Run with no options to only update trees which need update.\n";
cmdline.PrintHelp();
return GENERIC_EXIT_OK;
}

QCoreApplication a(argc, argv);

QCoreApplication::setApplicationName("mythfillnetvision");

if (cmdline.toBool("verbose"))
if (parse_verbose_arg(cmdline.toString("verbose")) ==
GENERIC_EXIT_INVALID_CMDLINE)
return GENERIC_EXIT_INVALID_CMDLINE;
}
else

int quiet;
if (cmdline.toBool("quiet"))
{
quiet = cmdline.toUInt("quiet");
if (quiet > 1)
{
fprintf(stderr, "illegal option: '%s' (use --help)\n",
a.argv()[argpos]);
return GENERIC_EXIT_INVALID_CMDLINE;
print_verbose_messages = VB_NONE;
parse_verbose_arg("none");
}

++argpos;
}

int facility = cmdline.GetSyslogFacility();
bool dblog = !cmdline.toBool("nodblog");

///////////////////////////////////////////////////////////////////////
// Don't listen to console input
close(0);

VERBOSE(VB_IMPORTANT, QString("%1 version: %2 [%3] www.mythtv.org")
.arg("mythfillnetvision").arg(MYTH_SOURCE_PATH)
.arg(MYTH_SOURCE_VERSION));

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
{
Expand All @@ -91,10 +118,34 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_NO_MYTHCONTEXT;
}

MythTranslation::load("mythfrontend");
bool refreshall = cmdline.toBool("refresh-all");
bool refreshrss = cmdline.toBool("refresh-rss");
bool refreshtree = cmdline.toBool("refresh-tree");

gCoreContext->LogEntry("mythfillnetvision", LP_INFO,
"Online Source Listing Download Started", "");
if (refreshall && (refreshrss || refreshtree))
{
VERBOSE(VB_IMPORTANT, "--refresh-all must not be accompanied by "
"--refresh-rss or --refresh-tree");
return GENERIC_EXIT_INVALID_CMDLINE;
}

if (refreshrss && refreshtree)
{
VERBOSE(VB_IMPORTANT, "--refresh-rss and --refresh-tree are mutually "
"exclusive options");
return GENERIC_EXIT_INVALID_CMDLINE;
}

if (!refreshall && !refreshrss && !refreshtree)
{
// Default is to do rss & tree, but not all
refreshtree = true;
refreshrss = true;
}

myth_nice(19);

MythTranslation::load("mythfrontend");

if (refreshtree)
{
Expand Down
8 changes: 5 additions & 3 deletions mythplugins/mythweather/mythweather/sourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ bool SourceManager::connectScreen(uint id, WeatherScreen *screen)
if (!screen)
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
"Cannot connect nonexistent screen "<<screen);
QString("Cannot connect nonexistent screen 0x%1")
.arg((uint64_t)screen,0,16));

return false;
}
Expand All @@ -347,7 +348,8 @@ bool SourceManager::disconnectScreen(WeatherScreen *screen)
if (!screen)
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
"Cannot disconnect nonexistent screen "<<screen);
QString("Cannot disconnect nonexistent screen 0x%1")
.arg((uint64_t)screen,0,16));

return false;
}
Expand All @@ -356,7 +358,7 @@ bool SourceManager::disconnectScreen(WeatherScreen *screen)
if (it == m_sourcemap.end())
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
"Cannot disconnect nonexistent source "<<screen->getId());
QString("Cannot disconnect nonexistent source %1").arg(screen->getId()));

return false;
}
Expand Down
1 change: 0 additions & 1 deletion mythtv/html/setup/general.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<li><a href="/Config/General?__group__=backend_wakeup_settings"><span>Backend Wakeup</span></a></li>
<li><a href="/Config/General?__group__=backend_control"><span>Backend Control</span></a></li>
<li><a href="/Config/General?__group__=upnp_server_settings"><span>UPNP</span></a></li>
<li><a href="/Config/General?__group__=database_logging"><span>Logging</span></a></li>
<li><a href="/Config/General?__group__=program_schedule_downloading_options"><span>Guide Data</span></a></li>
</ul>
</div>
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmyth/audio/audiooutputbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "SoundTouch.h"
#include "freesurround.h"
#include "spdifencoder.h"
#include "mythlogging.h"

#define LOC QString("AO: ")
#define LOC_ERR QString("AO, ERROR: ")
Expand Down Expand Up @@ -1691,9 +1692,11 @@ void AudioOutputBase::Drain()
*/
void AudioOutputBase::run(void)
{
threadRegister("AudioOutputBase");
VBAUDIO(QString("kickoffOutputAudioLoop: pid = %1").arg(getpid()));
OutputAudioLoop();
VBAUDIO("kickoffOutputAudioLoop exiting");
threadDeregister();
}

int AudioOutputBase::readOutputData(unsigned char*, int)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/libmyth.pro
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ inc.files += remoteutil.h filesysteminfo.h
inc.files += programinfo.h hardwareprofile.h
inc.files += programtypes.h recordingtypes.h
inc.files += mythrssmanager.h netgrabbermanager.h
inc.files += rssparse.h netutils.h
inc.files += rssparse.h netutils.h mythcommandlineparser.h

# remove when everything is switched to mythui
inc.files += virtualkeyboard_qt.h
Expand Down
2,002 changes: 1,253 additions & 749 deletions mythtv/libs/libmyth/mythcommandlineparser.cpp

Large diffs are not rendered by default.

383 changes: 253 additions & 130 deletions mythtv/libs/libmyth/mythcommandlineparser.h

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions mythtv/libs/libmyth/mythconfiggroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ void StackedConfigurationGroup::raise(Configurable* child)
}
}

VERBOSE(VB_IMPORTANT, "BUG: StackedConfigurationGroup::raise(): "
"unrecognized child " << child << " "
<<QString("on setting %1/%2").arg(getName()).arg(getLabel()));
VERBOSE(VB_IMPORTANT, QString("BUG: StackedConfigurationGroup::raise(): "
"unrecognized child 0x%1 on setting %2/%3")
.arg((uint64_t)child,0,16).arg(getName()).arg(getLabel()));
}

void StackedConfigurationGroup::Save(void)
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmyth/mythcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ using namespace std;
#include "mythimage.h"
#include "mythxmlclient.h"
#include "upnp.h"
#include "mythlogging.h"

#ifdef USING_MINGW
#include <unistd.h>
Expand Down Expand Up @@ -1098,6 +1099,7 @@ MythContext::~MythContext()
"~MythContext waiting for threads to exit.");
}
QThreadPool::globalInstance()->waitForDone();
logStop();

delete gCoreContext;
gCoreContext = NULL;
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmyth/mythmediamonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using namespace std;
#include "mythdialogbox.h"
#include "mythverbose.h"
#include "util.h"
#include "mythlogging.h"

#ifdef USING_DARWIN_DA
#include "mediamonitor-darwin.h"
Expand All @@ -45,11 +46,13 @@ MonitorThread::MonitorThread(MediaMonitor* pMon, unsigned long interval)
// loop and check it's devices.
void MonitorThread::run(void)
{
threadRegister("Monitor");
while (m_Monitor && m_Monitor->IsActive())
{
m_Monitor->CheckDevices();
msleep(m_Interval);
}
threadDeregister();
}

////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmyth/mythwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,9 @@ void MythRemoteLineEdit::updateCycle(QString current_choice, QString set)
if (index < 0 || index > length)
{
VERBOSE(VB_IMPORTANT,
"MythRemoteLineEdit passed a choice of \""
<< current_choice << "\" which is not in set \""
<< set << "\"");
QString("MythRemoteLineEdit passed a choice of \"%1"
"\" which is not in set \"%2"
"\"").arg(current_choice).arg(set));
setText("????");
return;
}
Expand Down
6 changes: 6 additions & 0 deletions mythtv/libs/libmyth/netgrabbermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "mythsystem.h"
#include "exitcodes.h"
#include "util.h"
#include "mythlogging.h"

#include "netgrabbermanager.h"
#include "netutils.h"
Expand Down Expand Up @@ -46,6 +47,7 @@ GrabberScript::~GrabberScript()

void GrabberScript::run()
{
threadRegister("GrabberScript");
QMutexLocker locker(&m_lock);

QString commandline = m_commandline;
Expand Down Expand Up @@ -85,6 +87,7 @@ void GrabberScript::run()
"%1 crashed while grabbing tree.").arg(m_title));

emit finished();
threadDeregister();
}

void GrabberScript::parseDBTree(const QString &feedtitle, const QString &path,
Expand Down Expand Up @@ -212,6 +215,7 @@ void GrabberDownloadThread::refreshAll()

void GrabberDownloadThread::run()
{
threadRegister("GrabberDownload");
m_scripts = findAllDBTreeGrabbers();
uint updateFreq = gCoreContext->GetNumSetting(
"netsite.updateFreq", 24);
Expand All @@ -230,6 +234,8 @@ void GrabberDownloadThread::run()
emit finished();
if (m_parent)
QCoreApplication::postEvent(m_parent, new GrabberUpdateEvent());

threadDeregister();
}

Search::Search()
Expand Down
104 changes: 65 additions & 39 deletions mythtv/libs/libmyth/programinfoupdater.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "programinfoupdater.h"
#include "remoteutil.h"
#include "compat.h"
#include "mythlogging.h"

uint qHash(const PIKey &k)
{
Expand Down Expand Up @@ -31,61 +32,86 @@ void ProgramInfoUpdater::insert(

// Start a new run() if one isn't already running..
// The lock prevents anything from getting stuck on a queue.
if (!isQueued)
if (!isRunning)
{
isQueued = true;
isRunning = true;
QThreadPool::globalInstance()->start(this);
}
else
moreWork.wakeAll();
}

void ProgramInfoUpdater::run(void)
{
// we don't need instant updates allow a few to queue up
// if they come in quick succession, this allows multiple
// updates to be consolidated into one update...
usleep(50 * 1000);
bool workDone;
QMutex mutex;

QMutexLocker locker(&lock);
isQueued = false;
threadRegister("ProgramInfoUpdater");

// send adds and deletes in the order they were queued
vector<PIKeyAction>::iterator ita = needsAddDelete.begin();
for (; ita != needsAddDelete.end(); ++ita)
{
if (kPIAdd != (*ita).action && kPIDelete != (*ita).action)
continue;
do {
workDone = false;

QString type = (kPIAdd == (*ita).action) ? "ADD" : "DELETE";
QString msg = QString("RECORDING_LIST_CHANGE %1 %2 %3")
.arg(type).arg((*ita).chanid)
.arg((*ita).recstartts.toString(Qt::ISODate));
// we don't need instant updates allow a few to queue up
// if they come in quick succession, this allows multiple
// updates to be consolidated into one update...
usleep(50 * 1000);

RemoteSendMessage(msg);
}
needsAddDelete.clear();
QMutexLocker locker(&lock);

// Send updates in any old order, we just need
// one per updated ProgramInfo.
QHash<PIKey,PIKeyData>::iterator itu = needsUpdate.begin();
for (; itu != needsUpdate.end(); ++itu)
{
QString msg;
// send adds and deletes in the order they were queued
vector<PIKeyAction>::iterator ita = needsAddDelete.begin();
for (; ita != needsAddDelete.end(); ++ita)
{
if (kPIAdd != (*ita).action && kPIDelete != (*ita).action)
continue;

QString type = (kPIAdd == (*ita).action) ? "ADD" : "DELETE";
QString msg = QString("RECORDING_LIST_CHANGE %1 %2 %3")
.arg(type).arg((*ita).chanid)
.arg((*ita).recstartts.toString(Qt::ISODate));

if (kPIUpdateFileSize == (*itu).action)
workDone = true;
RemoteSendMessage(msg);
}
needsAddDelete.clear();

// Send updates in any old order, we just need
// one per updated ProgramInfo.
QHash<PIKey,PIKeyData>::iterator itu = needsUpdate.begin();
for (; itu != needsUpdate.end(); ++itu)
{
msg = QString("UPDATE_FILE_SIZE %1 %2 %3")
.arg(itu.key().chanid)
.arg(itu.key().recstartts.toString(Qt::ISODate))
.arg((*itu).filesize);
QString msg;

if (kPIUpdateFileSize == (*itu).action)
{
msg = QString("UPDATE_FILE_SIZE %1 %2 %3")
.arg(itu.key().chanid)
.arg(itu.key().recstartts.toString(Qt::ISODate))
.arg((*itu).filesize);
}
else
{
msg = QString("MASTER_UPDATE_PROG_INFO %1 %2")
.arg(itu.key().chanid)
.arg(itu.key().recstartts.toString(Qt::ISODate));
}

workDone = true;
RemoteSendMessage(msg);
}
else
needsUpdate.clear();

if ( workDone )
{
msg = QString("MASTER_UPDATE_PROG_INFO %1 %2")
.arg(itu.key().chanid)
.arg(itu.key().recstartts.toString(Qt::ISODate));
QMutexLocker mlock(&mutex);
moreWork.wait(&mutex, 1000);
}
} while( workDone );

RemoteSendMessage(msg);
}
needsUpdate.clear();
threadDeregister();
isRunning = false;
}

/*
* vim:ts=4:sw=4:ai:et:si:sts=4
*/
6 changes: 4 additions & 2 deletions mythtv/libs/libmyth/programinfoupdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using namespace std;
#include <QDateTime>
#include <QMutex>
#include <QHash>
#include <QWaitCondition>

typedef enum PIAction {
kPIAdd,
Expand Down Expand Up @@ -57,15 +58,16 @@ class PIKeyData
class ProgramInfoUpdater : public QRunnable
{
public:
ProgramInfoUpdater() : isQueued(false) { setAutoDelete(false); }
ProgramInfoUpdater() : isRunning(false) { setAutoDelete(false); }

void insert(uint chanid, const QDateTime &recstartts,
PIAction action, uint64_t filesize = 0ULL);
void run(void);

private:
QMutex lock;
bool isQueued;
QWaitCondition moreWork;
bool isRunning;
vector<PIKeyAction> needsAddDelete;
QHash<PIKey,PIKeyData> needsUpdate;
};
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ void SelectSetting::setValue(int which)
{
if ((which >= ((int) values.size())) || (which < 0))
{
VERBOSE(VB_IMPORTANT, "SelectSetting::setValue(): "
"invalid index: " << which << " size: "<<values.size());
VERBOSE(VB_IMPORTANT, QString("SelectSetting::setValue(): "
"invalid index: %1 size: ").arg(which).arg(values.size()));
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions mythtv/libs/libmyth/uitypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,14 @@ void UIImageType::LoadImage()

if (!GetMythUI()->FindThemeFile(file))
{
VERBOSE(VB_IMPORTANT, "UIImageType::LoadImage() - Cannot find image: "
<< m_filename);
VERBOSE(VB_IMPORTANT, "UIImageType::LoadImage() - Cannot find image: " +
m_filename);
m_show = false;
return;
}

if (m_debug == true)
VERBOSE(VB_GENERAL, " -Filename: " << file);
VERBOSE(VB_GENERAL, QString(" -Filename: %1").arg(file));

if (m_hmult == 1 && m_wmult == 1 && m_force_x == -1 && m_force_y == -1)
{
Expand All @@ -767,13 +767,13 @@ void UIImageType::LoadImage()
{
doX = m_force_x;
if (m_debug == true)
VERBOSE(VB_GENERAL, " +Force X: " << doX);
VERBOSE(VB_GENERAL, QString(" +Force X: %1").arg(doX));
}
if (m_force_y != -1)
{
doY = m_force_y;
if (m_debug == true)
VERBOSE(VB_GENERAL, " +Force Y: " << doY);
VERBOSE(VB_GENERAL, QString(" +Force Y: %1").arg(doY));
}

scalerImg = sourceImg->scaled((int)(doX * m_wmult),
Expand All @@ -783,13 +783,13 @@ void UIImageType::LoadImage()
m_show = true;
img = QPixmap::fromImage(scalerImg);
if (m_debug == true)
VERBOSE(VB_GENERAL, " -Image: " << file << " loaded.");
VERBOSE(VB_GENERAL, QString(" -Image: %1 loaded.").arg(file));
}
else
{
m_show = false;
if (m_debug == true)
VERBOSE(VB_GENERAL, " -Image: " << file << " failed to load.");
VERBOSE(VB_GENERAL, QString(" -Image: %1 failed to load.").arg(file));
}
delete sourceImg;
}
Expand Down
28 changes: 28 additions & 0 deletions mythtv/libs/libmythbase/dbutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,34 @@ int DBUtil::CountClients(void)
return count;
}

/**
* \brief Checks whether table exists
*
* \param table The name of the table to check (without schema name)
* \return true if table exists in schema or false if not
*/
bool DBUtil::TableExists(const QString &table)
{
bool result = false;
MSqlQuery query(MSqlQuery::InitCon());
if (query.isConnected())
{
QString sql = "SELECT INFORMATION_SCHEMA.TABLES.TABLE_NAME "
" FROM INFORMATION_SCHEMA.TABLES "
" WHERE INFORMATION_SCHEMA.TABLES.TABLE_SCHEMA = "
" DATABASE() "
" AND INFORMATION_SCHEMA.TABLES.TABLE_NAME = "
" :TABLENAME ;";
if (query.prepare(sql))
{
query.bindValue(":TABLENAME", table);
if (query.exec() && query.next())
result = true;
}
}
return result;
}

/**
* \brief Try to get a lock on the table schemalock.
*
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythbase/dbutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class MBASE_PUBLIC DBUtil
static bool IsNewDatabase(void);
static bool IsBackupInProgress(void);
static int CountClients(void);
static bool TableExists(const QString &table);

static bool lockSchema(MSqlQuery &);
static void unlockSchema(MSqlQuery &);
Expand Down
9 changes: 5 additions & 4 deletions mythtv/libs/libmythbase/libmythbase.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ 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
HEADERS += util.h mythhdd.h mythcdrom.h autodeletedeque.h dbutil.h
HEADERS += mythhttppool.h mythhttphandler.h mythdeque.h version.h
HEADERS += mythbaseutil.h referencecounter.h
HEADERS += mythhttppool.h mythhttphandler.h mythdeque.h mythlogging.h
HEADERS += mythbaseutil.h referencecounter.h version.h

SOURCES += mythsocket.cpp mythsocketthread.cpp msocketdevice.cpp
SOURCES += mythdbcon.cpp mythdb.cpp oldsettings.cpp mythverbose.cpp
Expand All @@ -32,7 +32,8 @@ 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
SOURCES += mythhdd.cpp mythcdrom.cpp dbutil.cpp
SOURCES += mythhttppool.cpp mythhttphandler.cpp referencecounter.cpp
SOURCES += mythhttppool.cpp mythhttphandler.cpp mythlogging.cpp
SOURCES += referencecounter.cpp

win32:SOURCES += msocketdevice_win.cpp
unix {
Expand All @@ -52,7 +53,7 @@ inc.files = mythverbose.h mythdbcon.h mythdbparams.h mythbaseexp.h mythdb.h
inc.files += compat.h mythversion.h mythconfig.h mythconfig.mak version.h
inc.files += mythobservable.h mythevent.h httpcomms.h mcodecs.h
inc.files += mythtimer.h lcddevice.h exitcodes.h mythdirs.h mythstorage.h
inc.files += mythsocket.h mythsocket_cb.h msocketdevice.h
inc.files += mythsocket.h mythsocket_cb.h msocketdevice.h mythlogging.h
inc.files += mythcorecontext.h mythsystem.h storagegroup.h
inc.files += mythcoreutil.h mythlocale.h mythdownloadmanager.h
inc.files += mythtranslation.h iso639.h iso3166.h mythmedia.h util.h
Expand Down
121 changes: 3 additions & 118 deletions mythtv/libs/libmythbase/mythcorecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using namespace std;
#include "mythsocket.h"
#include "mythsystem.h"
#include "exitcodes.h"
#include "mythlogging.h"

#include "mythversion.h"

Expand All @@ -45,8 +46,6 @@ class MythCoreContextPrivate : public QObject

bool WaitForWOL(int timeout_ms = INT_MAX);

void LoadLogSettings(void);

public:
MythCoreContext *m_parent;
QObject *m_GUIcontext;
Expand All @@ -61,12 +60,6 @@ class MythCoreContextPrivate : public QObject
MythSocket *m_serverSock; ///< socket for sending MythProto requests
MythSocket *m_eventSock; ///< socket events arrive on

int m_logenable;
int m_logmaxcount;
int m_logprintlevel;
QMap<QString,int> m_lastLogCounts;
QMap<QString,QString> m_lastLogStrings;

QMutex m_WOLInProgressLock;
QWaitCondition m_WOLInProgressWaitCondition;
bool m_WOLInProgress;
Expand All @@ -91,13 +84,13 @@ MythCoreContextPrivate::MythCoreContextPrivate(MythCoreContext *lparent,
m_masterHostname(QString::null),
m_sockLock(QMutex::NonRecursive),
m_serverSock(NULL), m_eventSock(NULL),
m_logenable(-1), m_logmaxcount(-1), m_logprintlevel(-1),
m_WOLInProgress(false),
m_backend(false),
m_database(GetMythDB()),
m_UIThread(QThread::currentThread()),
m_locale(NULL)
{
threadRegister("CoreContext");
}

MythCoreContextPrivate::~MythCoreContextPrivate()
Expand All @@ -122,6 +115,7 @@ MythCoreContextPrivate::~MythCoreContextPrivate()
DestroyMythDB();
m_database = NULL;
}
threadDeregister();
}

/// If another thread has already started WOL process, wait on them...
Expand All @@ -143,13 +137,6 @@ bool MythCoreContextPrivate::WaitForWOL(int timeout_in_ms)
return !m_WOLInProgress;
}

void MythCoreContextPrivate::LoadLogSettings(void)
{
m_logenable = m_parent->GetNumSetting("LogEnabled", 0);
m_logmaxcount = m_parent->GetNumSetting("LogMaxCount", 0);
m_logprintlevel = m_parent->GetNumSetting("LogPrintLevel", LP_ERROR);
}

MythCoreContext::MythCoreContext(const QString &binversion,
QObject *guiContext)
: d(NULL)
Expand Down Expand Up @@ -694,11 +681,6 @@ QString MythCoreContext::GetFilePrefix(void)
return GetSetting("RecordFilePrefix");
}

void MythCoreContext::RefreshBackendConfig(void)
{
d->LoadLogSettings();
}

void MythCoreContext::GetResolutionSetting(const QString &type,
int &width, int &height,
double &forced_aspect,
Expand Down Expand Up @@ -1018,103 +1000,6 @@ bool MythCoreContext::CheckProtoVersion(MythSocket *socket, uint timeout_ms,
return false;
}

void MythCoreContext::LogEntry(const QString &module, int priority,
const QString &message, const QString &details)
{
unsigned int logid;
int howmany;

if (IsDatabaseIgnored())
return;

if (d->m_logenable == -1) // Haven't grabbed the settings yet
d->LoadLogSettings();
if (d->m_logenable == 1)
{
QString fullMsg = message;
if (!details.isEmpty())
fullMsg += ": " + details;

if (message.left(21) != "Last message repeated")
{
if (fullMsg == d->m_lastLogStrings[module])
{
d->m_lastLogCounts[module] += 1;
return;
}
else
{
if (0 < d->m_lastLogCounts[module])
{
LogEntry(module, priority,
QString("Last message repeated %1 times")
.arg(d->m_lastLogCounts[module]),
d->m_lastLogStrings[module]);
}

d->m_lastLogCounts[module] = 0;
d->m_lastLogStrings[module] = fullMsg;
}
}


MSqlQuery query(MSqlQuery::InitCon());
query.prepare("INSERT INTO mythlog (module, priority, "
"logdate, host, message, details) "
"values (:MODULE, :PRIORITY, now(), :HOSTNAME, "
":MESSAGE, :DETAILS );");

query.bindValue(":MODULE", module);
query.bindValue(":PRIORITY", priority);
query.bindValue(":HOSTNAME", d->m_localHostname);
query.bindValue(":MESSAGE", message);
query.bindValue(":DETAILS", details);

if (!query.exec() || !query.isActive())
MythDB::DBError("LogEntry", query);

if (d->m_logmaxcount > 0)
{
query.prepare("SELECT logid FROM mythlog WHERE "
"module= :MODULE ORDER BY logdate ASC ;");
query.bindValue(":MODULE", module);
if (!query.exec() || !query.isActive())
{
MythDB::DBError("DelLogEntry#1", query);
}
else
{
howmany = query.size();
if (howmany > d->m_logmaxcount)
{
MSqlQuery delquery(MSqlQuery::InitCon());
while (howmany > d->m_logmaxcount)
{
query.next();
logid = query.value(0).toUInt();
delquery.prepare("DELETE FROM mythlog WHERE "
"logid= :LOGID ;");
delquery.bindValue(":LOGID", logid);

if (!delquery.exec() || !delquery.isActive())
{
MythDB::DBError("DelLogEntry#2", delquery);
}
howmany--;
}
}
}
}

if (priority <= d->m_logprintlevel)
{
QByteArray tmp =
QString("%1: %2").arg(module).arg(fullMsg).toUtf8();
VERBOSE(VB_IMPORTANT, tmp.constData());
}
}
}

void MythCoreContext::dispatch(const MythEvent &event)
{
VERBOSE(VB_NETWORK, QString("MythEvent: %1").arg(event.Message()));
Expand Down
5 changes: 0 additions & 5 deletions mythtv/libs/libmythbase/mythcorecontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ class MBASE_PUBLIC MythCoreContext : public MythObservable, public MythSocketCBs
QString GetHostName(void);
QString GetFilePrefix(void);

void RefreshBackendConfig(void);

bool IsConnectedToMaster(void);
void SetBackend(bool backend);
bool IsBackend(void); ///< is this process a backend process
Expand Down Expand Up @@ -155,9 +153,6 @@ class MBASE_PUBLIC MythCoreContext : public MythObservable, public MythSocketCBs
void dispatch(const MythEvent &event);
void dispatchNow(const MythEvent &event) MDEPRECATED;

void LogEntry(const QString &module, int priority,
const QString &message, const QString &details);

void InitLocale(void);
const MythLocale *GetLocale(void);
void SaveLocaleDefaults(void);
Expand Down
6 changes: 6 additions & 0 deletions mythtv/libs/libmythbase/mythdownloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "remotefile.h"

#include "mythdownloadmanager.h"
#include "mythlogging.h"

using namespace std;

Expand Down Expand Up @@ -99,6 +100,7 @@ class RemoteFileDownloadThread : public QRunnable
{
bool ok = false;

threadRegister("RemoteFileDownload");
RemoteFile *rf = new RemoteFile(m_dlInfo->m_url, false, false, 0);
ok = rf->SaveAs(m_dlInfo->m_privData);
delete rf;
Expand All @@ -107,6 +109,7 @@ class RemoteFileDownloadThread : public QRunnable
m_dlInfo->m_errorCode = QNetworkReply::UnknownNetworkError;

m_parent->downloadFinished(m_dlInfo);
threadDeregister();
}

private:
Expand Down Expand Up @@ -188,6 +191,8 @@ void MythDownloadManager::run(void)
bool itemsInQueue = false;
bool waitAnyway = false;

threadRegister("DownloadManager");

m_queueThread = currentThread();

while (!m_runThread)
Expand Down Expand Up @@ -259,6 +264,7 @@ void MythDownloadManager::run(void)
m_infoLock->unlock();
}
m_isRunning = false;
threadDeregister();
}

/** \fn MythDownloadManager::queueItem(const QString &url, QNetworkRequest *req,
Expand Down
740 changes: 740 additions & 0 deletions mythtv/libs/libmythbase/mythlogging.cpp

Large diffs are not rendered by default.

201 changes: 201 additions & 0 deletions mythtv/libs/libmythbase/mythlogging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
#ifndef MYTHLOGGING_H_
#define MYTHLOGGING_H_

#ifdef __cplusplus
#include <QString>
#include <QThread>
#include <QQueue>
#include <QMutex>
#include <QMutexLocker>
#endif
#include <stdint.h>
#include <time.h>
#include "mythbaseexp.h" // MBASE_PUBLIC , etc.

#define LOGLINE_MAX 2048

typedef enum
{
LOG_EMERG = 0,
LOG_ALERT,
LOG_CRIT,
LOG_ERR,
LOG_WARNING,
LOG_NOTICE,
LOG_INFO,
LOG_DEBUG,
LOG_UNKNOWN
} LogLevel_t;

#ifdef _LogLevelNames_
const char *LogLevelNames[] =
{
"LOG_EMERG",
"LOG_ALERT",
"LOG_CRIT",
"LOG_ERR",
"LOG_WARNING",
"LOG_NOTICE",
"LOG_INFO",
"LOG_DEBUG",
"LOG_UNKNOWN"
};
int LogLevelNameCount = sizeof(LogLevelNames)/sizeof(LogLevelNames[0]);
#else
extern MBASE_PUBLIC char *LogLevelNames[];
extern MBASE_PUBLIC int LogLevelNameCount;
#endif
extern MBASE_PUBLIC LogLevel_t LogLevel;

typedef struct
{
LogLevel_t level;
uint64_t threadId;
const char *file;
int line;
const char *function;
struct tm tm;
uint32_t usec;
char *message;
char *threadName;
int registering;
int deregistering;
int refcount;
void *refmutex;
} LoggingItem_t;


#ifdef __cplusplus
extern "C" {
#endif

#define LogPrintQString(mask, level, string) \
LogPrintLine(mask, (LogLevel_t)level, __FILE__, __LINE__, __FUNCTION__, \
QString(string).toLocal8Bit().constData())

#define LogPrint(mask, level, format, ...) \
LogPrintLine(mask, (LogLevel_t)level, __FILE__, __LINE__, __FUNCTION__, \
(const char *)format, ##__VA_ARGS__)

/* Define the external prototype */
MBASE_PUBLIC void LogPrintLine( uint32_t mask, LogLevel_t level,
const char *file, int line,
const char *function, const char *format, ... );

#ifdef __cplusplus
}

MBASE_PUBLIC void logStart(QString logfile, int quiet = 0, int facility = 0,
bool dblog = true);
MBASE_PUBLIC void logStop(void);
MBASE_PUBLIC void threadRegister(QString name);
MBASE_PUBLIC void threadDeregister(void);
MBASE_PUBLIC int syslogGetFacility(QString facility);

void LogTimeStamp( time_t *epoch, uint32_t *usec );

typedef union {
char *string;
int number;
} LoggerHandle_t;


class LoggerBase : public QObject {
Q_OBJECT

public:
LoggerBase(char *string, int number);
~LoggerBase();
virtual bool logmsg(LoggingItem_t *item) = 0;
virtual void reopen(void) = 0;
protected:
LoggerHandle_t m_handle;
bool m_string;
};

class FileLogger : public LoggerBase {
public:
FileLogger(char *filename);
~FileLogger();
bool logmsg(LoggingItem_t *item);
void reopen(void);
private:
bool m_opened;
int m_fd;
};

class SyslogLogger : public LoggerBase {
public:
SyslogLogger(int facility);
~SyslogLogger();
bool logmsg(LoggingItem_t *item);
void reopen(void) { };
private:
char *m_application;
bool m_opened;
};

class DBLoggerThread;

class DatabaseLogger : public LoggerBase {
friend class DBLoggerThread;
public:
DatabaseLogger(char *table);
~DatabaseLogger();
bool logmsg(LoggingItem_t *item);
void reopen(void) { };
protected:
bool logqmsg(LoggingItem_t *item);
private:
bool isDatabaseReady();

DBLoggerThread *m_thread;
char *m_host;
char *m_application;
char *m_query;
pid_t m_pid;
bool m_opened;
bool m_loggingTableExists;
};

class LoggerThread : public QThread {
Q_OBJECT

public:
LoggerThread();
~LoggerThread();
void run(void);
void stop(void) { aborted = true; };
private:
bool aborted;
};

class DBLoggerThread : public QThread {
Q_OBJECT

public:
DBLoggerThread(DatabaseLogger *logger) : m_logger(logger),
m_queue(new QQueue<LoggingItem_t *>) {}
~DBLoggerThread() { delete m_queue; }
void run(void);
void stop(void) { aborted = true; }
bool enqueue(LoggingItem_t *item)
{
QMutexLocker qLock(&m_queueMutex);
m_queue->enqueue(item);
return true;
}
private:
DatabaseLogger *m_logger;
QMutex m_queueMutex;
QQueue<LoggingItem_t *> *m_queue;
bool aborted;
};
#endif


#endif

/*
* vim:ts=4:sw=4:ai:et:si:sts=4
*/
4 changes: 4 additions & 0 deletions mythtv/libs/libmythbase/mythsignalingtimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "mythsignalingtimer.h"
#include "mythlogging.h"

MythSignalingTimer::MythSignalingTimer(
QObject *parent, const char *slot) :
Expand Down Expand Up @@ -67,6 +68,8 @@ void MythSignalingTimer::stop(void)

void MythSignalingTimer::run(void)
{
threadRegister("SignalingTimer");

running = true;
while (dorun)
{
Expand All @@ -75,4 +78,5 @@ void MythSignalingTimer::run(void)
emit timeout();
}
running = false;
threadDeregister();
}
3 changes: 3 additions & 0 deletions mythtv/libs/libmythbase/mythsocketthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "mythsocketthread.h"
#include "mythbaseutil.h"
#include "mythverbose.h"
#include "mythlogging.h"
#include "mythsocket.h"

#define SLOC(a) QString("MythSocketThread(sock 0x%1:%2): ")\
Expand Down Expand Up @@ -187,6 +188,7 @@ void MythSocketThread::ProcessAddRemoveQueues(void)

void MythSocketThread::run(void)
{
threadRegister("Socket");
VERBOSE(VB_SOCKET, "MythSocketThread: readyread thread start");

QMutexLocker locker(&m_readyread_lock);
Expand Down Expand Up @@ -373,4 +375,5 @@ void MythSocketThread::run(void)
}

VERBOSE(VB_SOCKET, "MythSocketThread: readyread thread exit");
threadDeregister();
}
59 changes: 32 additions & 27 deletions mythtv/libs/libmythbase/mythverbose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@ unsigned int userDefaultValueInt = verboseDefaultInt;
QString userDefaultValueStr = QString(verboseDefaultStr);
bool haveUserDefaultValues = false;

#define VERBOSE_ARG_HELP(ARG_ENUM, ARG_VALUE, ARG_STR, ARG_ADDITIVE, ARG_HELP) \
QString(" %1").arg(ARG_STR).leftJustified(15, ' ', true) << \
" - " << ARG_HELP << "\n" <<

#define VERBOSE_ARG_CHECKS(ARG_ENUM, ARG_VALUE, ARG_STR, ARG_ADDITIVE, ARG_HELP) \
else if (option == ARG_STR) \
{ \
if (reverseOption) \
{ \
print_verbose_messages &= ~(ARG_VALUE); \
verboseString = verboseString + " no" + ARG_STR; \
} \
else \
{ \
if (ARG_ADDITIVE) \
{ \
print_verbose_messages |= ARG_VALUE; \
verboseString = verboseString + ' ' + ARG_STR; \
} \
else \
{ \
print_verbose_messages = ARG_VALUE; \
verboseString = ARG_STR; \
} \
} \
}

int parse_verbose_arg(QString arg)
{
QString option;
Expand Down Expand Up @@ -55,10 +82,6 @@ int parse_verbose_arg(QString arg)
"Verbose debug levels.\n" <<
"Accepts any combination (separated by comma) of:\n\n" <<

#define VERBOSE_ARG_HELP(ARG_ENUM, ARG_VALUE, ARG_STR, ARG_ADDITIVE, ARG_HELP) \
QString(" %1").arg(ARG_STR).leftJustified(15, ' ', true) << \
" - " << ARG_HELP << "\n" <<

VERBOSE_MAP(VERBOSE_ARG_HELP)

"\n" <<
Expand Down Expand Up @@ -93,29 +116,7 @@ int parse_verbose_arg(QString arg)
}
}

#define VERBOSE_ARG_CHECKS(ARG_ENUM, ARG_VALUE, ARG_STR, ARG_ADDITIVE, ARG_HELP) \
else if (option == ARG_STR) \
{ \
if (reverseOption) \
{ \
print_verbose_messages &= ~(ARG_VALUE); \
verboseString = verboseString + " no" + ARG_STR; \
} \
else \
{ \
if (ARG_ADDITIVE) \
{ \
print_verbose_messages |= ARG_VALUE; \
verboseString = verboseString + ' ' + ARG_STR; \
} \
else \
{ \
print_verbose_messages = ARG_VALUE; \
verboseString = ARG_STR; \
} \
} \
}

// Essentially a pile of else if {} blocks
VERBOSE_MAP(VERBOSE_ARG_CHECKS)

else
Expand Down Expand Up @@ -146,3 +147,7 @@ QString safe_eno_to_string(int errnum)
return QString("%1 (%2)").arg(strerror(errnum)).arg(errnum);
}

/*
* vim:ts=4:sw=4:ai:et:si:sts=4
*/

113 changes: 19 additions & 94 deletions mythtv/libs/libmythbase/mythverbose.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#endif

#include "mythbaseexp.h" // MBASE_PUBLIC , et c.
#include "mythlogging.h"

/// This MAP is for the various VERBOSITY flags, used to select which
/// messages we want printed to the console.
Expand Down Expand Up @@ -103,10 +104,11 @@
F(VB_NONE, 0x00000000, "none", \
0, "NO debug output")

enum VerboseMask
{
#define VERBOSE_ENUM(ARG_ENUM, ARG_VALUE, ARG_STRING, ARG_ADDITIVE, ARG_HELP)\
ARG_ENUM = ARG_VALUE ,

enum VerboseMask
{
VERBOSE_MAP(VERBOSE_ENUM)
VB_UNUSED_END // keep at end
};
Expand All @@ -122,96 +124,19 @@ extern MBASE_PUBLIC unsigned int print_verbose_messages;
#define VERBOSE_LEVEL_NONE (print_verbose_messages == 0)
#define VERBOSE_LEVEL_CHECK(mask) ((print_verbose_messages & (mask)) == (mask))

// 1. A non-locking one, used in C or Objective C src, or standalone libraries,
// 2. A mutex-locked one, which may deadlock, and
// 3. A mutex-locked one, which should be deadlock safe.
// If MYTHCONTEXT_H_ is not defined, we assume the first type,
// otherwise DEBUG determines the second or third


#ifndef MYTHCONTEXT_H_
#ifdef __cplusplus
#define VERBOSE(mask, ...) \
do { \
if (VERBOSE_LEVEL_CHECK(mask)) \
{ \
QDateTime dtmp = QDateTime::currentDateTime(); \
QString dtime = dtmp.toString("yyyy-MM-dd hh:mm:ss.zzz"); \
QString dargs(__VA_ARGS__); \
verbose_mutex.lock(); \
std::cout << dtime.toLocal8Bit().constData() << " " \
<< dargs.toLocal8Bit().constData() << std::endl; \
verbose_mutex.unlock(); \
} \
} while (0)
#else
#if HAVE_GETTIMEOFDAY
#define VERBOSEDATE \
{ \
struct tm *tp; \
struct timeval tv; \
gettimeofday(&tv, NULL); \
tp = localtime(&tv.tv_sec); \
printf("%4d-%02d-%02d %2d:%02d:%02d.%03d ", \
1900+tp->tm_year, 1+tp->tm_mon, \
tp->tm_mday, tp->tm_hour, tp->tm_min, \
tp->tm_sec, (int)(tv.tv_usec/10000)); \
}
#else
#define VERBOSEDATE ;
#endif
#define VERBOSE(mask, ...) \
do { \
if (VERBOSE_LEVEL_CHECK(mask)) \
{ \
VERBOSEDATE \
printf(__VA_ARGS__); \
putchar('\n'); \
} \
} while (0)
#endif

#elif defined(DEBUG) // && MYTHCONTEXT_H_

// The verbose_mutex lock is a recursive lock so it is possible (while
// not recommended) to use a VERBOSE macro within another VERBOSE macro.
// But waiting for another thread to do something is not safe within a
// VERBOSE macro, since those threads may wish to use the VERBOSE macro
// and this will cause a deadlock.

#define VERBOSE(mask, ...) \
do { \
if (VERBOSE_LEVEL_CHECK(mask)) \
{ \
QDateTime dtmp = QDateTime::currentDateTime(); \
QString dtime = dtmp.toString("yyyy-MM-dd hh:mm:ss.zzz"); \
verbose_mutex.lock(); \
std::cout << dtime.toLocal8Bit().constData() << " " \
<< QString(__VA_ARGS__).toLocal8Bit().constData() << std::endl; \
verbose_mutex.unlock(); \
} \
} while (0)

#else // MYTHCONTEXT_H_ && !DEBUG

// use a slower non-deadlockable version in release builds

#define VERBOSE(mask, ...) \
do { \
if (VERBOSE_LEVEL_CHECK(mask)) \
{ \
QDateTime dtmp = QDateTime::currentDateTime(); \
QString dtime = dtmp.toString("yyyy-MM-dd hh:mm:ss.zzz"); \
QTextStream ssMsg(&dtime); \
ssMsg << " " << __VA_ARGS__; \
verbose_mutex.lock(); \
std::cout << ssMsg.string()->toLocal8Bit().constData() << \
std::endl; \
verbose_mutex.unlock(); \
} \
} while (0)

#endif // MYTHCONTEXT_H_, DEBUG
// There are two VERBOSE macros now. One for use with Qt/C++, one for use
// without Qt.
//
// Neither of them will lock the calling thread, but rather put the log message
// onto a queue.

#ifdef __cplusplus
#define VERBOSE(mask, ...) \
LogPrintQString(mask, LOG_INFO, QString(__VA_ARGS__))
#else
#define VERBOSE(mask, ...) \
LogPrint(mask, LOG_INFO, __VA_ARGS__)
#endif


#ifdef __cplusplus
Expand All @@ -222,8 +147,8 @@ extern MBASE_PUBLIC unsigned int print_verbose_messages;

MBASE_PUBLIC int parse_verbose_arg(QString arg);

/// This can be appended to the VERBOSE args with either
/// "+" (with QStrings) or "<<" (with c strings). It uses
/// This can be appended to the VERBOSE args with
/// "+". Please do not use "<<". It uses
/// a thread safe version of strerror to produce the
/// string representation of errno and puts it on the
/// next line in the verbose output.
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.25.20110607-1"
#define MYTH_BINARY_VERSION "0.25.20110607-2"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand Down
9 changes: 8 additions & 1 deletion mythtv/libs/libmythbase/system-unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "mythevent.h"
#include "mythverbose.h"
#include "exitcodes.h"
#include "mythlogging.h"

#define CLOSE(x) \
if( (x) >= 0 ) { \
Expand Down Expand Up @@ -69,6 +70,7 @@ MythSystemIOHandler::MythSystemIOHandler(bool read) :

void MythSystemIOHandler::run(void)
{
threadRegister(QString("SystemIOHandler%1").arg(m_read ? "R" : "W"));
VERBOSE(VB_GENERAL|VB_SYSTEM, QString("Starting IO manager (%1)")
.arg(m_read ? "read" : "write"));

Expand Down Expand Up @@ -129,6 +131,7 @@ void MythSystemIOHandler::run(void)
m_pLock.unlock();
}
}
threadDeregister();
}

void MythSystemIOHandler::HandleRead(int fd, QBuffer *buff)
Expand Down Expand Up @@ -237,6 +240,7 @@ MythSystemManager::MythSystemManager() : QThread()

void MythSystemManager::run(void)
{
threadRegister("SystemManager");
VERBOSE(VB_GENERAL|VB_SYSTEM, "Starting process manager");

// gCoreContext is set to NULL during shutdown, and we need this thread to
Expand Down Expand Up @@ -377,6 +381,7 @@ void MythSystemManager::run(void)
// kick to allow them to close themselves cleanly
readThread->wake();
writeThread->wake();
threadDeregister();
}

void MythSystemManager::append(MythSystemUnix *ms)
Expand Down Expand Up @@ -424,6 +429,7 @@ MythSystemSignalManager::MythSystemSignalManager() : QThread()

void MythSystemSignalManager::run(void)
{
threadRegister("SystemSignalManager");
VERBOSE(VB_GENERAL|VB_SYSTEM, "Starting process signal handler");
while( gCoreContext )
{
Expand Down Expand Up @@ -473,6 +479,7 @@ void MythSystemSignalManager::run(void)
ms->deleteLater();
}
}
threadDeregister();
}

/*******************************
Expand Down Expand Up @@ -653,7 +660,7 @@ void MythSystemUnix::Fork(time_t timeout)
m_pid = child;
SetStatus( GENERIC_EXIT_RUNNING );

VERBOSE(VB_SYSTEM|VB_EXTRA,
VERBOSE(VB_SYSTEM,
QString("Managed child (PID: %1) has started! "
"%2%3 command=%4, timeout=%5")
.arg(m_pid) .arg(GetSetting("UseShell") ? "*" : "")
Expand Down
9 changes: 8 additions & 1 deletion mythtv/libs/libmythbase/system-windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "mythevent.h"
#include "mythverbose.h"
#include "exitcodes.h"
#include "mythlogging.h"

// Windows headers
#include <windows.h>
Expand Down Expand Up @@ -72,6 +73,7 @@ MythSystemIOHandler::MythSystemIOHandler(bool read) :

void MythSystemIOHandler::run(void)
{
threadRegister(QString("SystemIOHandler%1").arg(m_read ? "R" : "W"));
VERBOSE(VB_GENERAL|VB_SYSTEM, QString("Starting IO manager (%1)")
.arg(m_read ? "read" : "write"));

Expand Down Expand Up @@ -115,6 +117,7 @@ void MythSystemIOHandler::run(void)
}
}
}
threadDeregister();
}

bool MythSystemIOHandler::HandleRead(HANDLE h, QBuffer *buff)
Expand Down Expand Up @@ -217,6 +220,7 @@ MythSystemManager::~MythSystemManager()

void MythSystemManager::run(void)
{
threadRegister("SystemManager");
VERBOSE(VB_GENERAL|VB_SYSTEM, "Starting process manager");

// gCoreContext is set to NULL during shutdown, and we need this thread to
Expand Down Expand Up @@ -323,6 +327,7 @@ void MythSystemManager::run(void)
// kick to allow them to close themselves cleanly
readThread->wake();
writeThread->wake();
threadDeregister();
}

// NOTE: This is only to be run while m_mapLock is locked!!!
Expand Down Expand Up @@ -394,6 +399,7 @@ MythSystemSignalManager::MythSystemSignalManager() : QThread()

void MythSystemSignalManager::run(void)
{
threadRegister("SystemSignalManager");
VERBOSE(VB_GENERAL|VB_SYSTEM, "Starting process signal handler");
while( gCoreContext )
{
Expand Down Expand Up @@ -437,6 +443,7 @@ void MythSystemSignalManager::run(void)
delete ms;
}
}
threadDeregister();
}

/*******************************
Expand Down Expand Up @@ -659,7 +666,7 @@ void MythSystemWindows::Fork(time_t timeout)
m_child = pi.hProcess;
SetStatus( GENERIC_EXIT_RUNNING );

VERBOSE(VB_SYSTEM|VB_EXTRA,
VERBOSE(VB_SYSTEM,
QString("Managed child (Handle: %1) has started! "
"%2%3 command=%4, timeout=%5")
.arg((long long)m_child)
Expand Down
44 changes: 44 additions & 0 deletions mythtv/libs/libmythbase/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,4 +1476,48 @@ bool MythRemoveDirectory(QDir &aDir)
VERBOSE(VB_NETWORK, LOC + "failed to find a network proxy");
}

MBASE_PUBLIC void wrapList(QStringList &list, int width)
{
int i;

for(i = 0; i < list.size(); i++)
{
QString string = list.at(i);

if( string.size() <= width )
continue;

QString left = string.left(width);
bool inserted = false;

while( !inserted && left.right(1) != " " )
{
if( string.mid(left.size(), 1) == " " )
{
list.replace(i, left);
list.insert(i+1, string.mid(left.size()).trimmed());
inserted = true;
}
else
{
left.chop(1);
if( !left.contains(" ") )
{
// Line is too long, just hyphenate it
list.replace(i, left + "-");
list.insert(i+1, string.mid(left.size()));
inserted = true;
}
}
}

if( !inserted )
{
left.chop(1);
list.replace(i, left);
list.insert(i+1, string.mid(left.size()).trimmed());
}
}
}

/* vim: set expandtab tabstop=4 shiftwidth=4: */
3 changes: 3 additions & 0 deletions mythtv/libs/libmythbase/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class QFile;
MBASE_PUBLIC void sendPlaybackStart();
MBASE_PUBLIC void sendPlaybackEnd();

MBASE_PUBLIC void wrapList(QStringList &list, int width);


inline float clamp(float val, float minimum, float maximum)
{
return min(max(val, minimum), maximum);
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythmetadata/metadatadownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "mythsystem.h"
#include "metadatadownload.h"
#include "util.h"
#include "mythlogging.h"

QEvent::Type MetadataLookupEvent::kEventType =
(QEvent::Type) QEvent::registerEventType();
Expand Down Expand Up @@ -61,6 +62,7 @@ void MetadataDownload::cancel()
void MetadataDownload::run()
{
MetadataLookup* lookup;
threadRegister("MetadataDownload");
while ((lookup = moreWork()) != NULL)
{
MetadataLookupList list;
Expand Down Expand Up @@ -116,6 +118,7 @@ void MetadataDownload::run()
new MetadataLookupFailure(list));
}
}
threadDeregister();
}

MetadataLookup* MetadataDownload::moreWork()
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythmetadata/metadataimagedownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "metadataimagedownload.h"
#include "remotefile.h"
#include "mythdownloadmanager.h"
#include "mythlogging.h"

QEvent::Type ImageDLEvent::kEventType =
(QEvent::Type) QEvent::registerEventType();
Expand Down Expand Up @@ -73,6 +74,7 @@ void MetadataImageDownload::run()
{
// Always handle thumbnails first, they're higher priority.
ThumbnailData *thumb;
threadRegister("MetadataImageDownload");
while ((thumb = moreThumbs()) != NULL)
{
QString sFilename = getDownloadFilename(thumb->title, thumb->url);
Expand Down Expand Up @@ -241,6 +243,7 @@ void MetadataImageDownload::run()
lookup->SetDownloads(downloaded);
QCoreApplication::postEvent(m_parent, new ImageDLEvent(lookup));
}
threadDeregister();
}

ThumbnailData* MetadataImageDownload::moreThumbs()
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythmetadata/videoscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "videoscan.h"
#include "videoutils.h"
#include "remoteutil.h"
#include "mythlogging.h"

namespace
{
Expand Down Expand Up @@ -92,6 +93,7 @@ class VideoScannerThread : public QThread

void run()
{
threadRegister("VideoScanner");
QList<QByteArray> image_types = QImageReader::supportedImageFormats();
QStringList imageExtensions;
for (QList<QByteArray>::const_iterator p = image_types.begin();
Expand Down Expand Up @@ -134,6 +136,7 @@ class VideoScannerThread : public QThread
m_DBDataChanged = updateDB(fs_files, db_remove);
if (m_DBDataChanged)
RemoteSendMessage("VIDEO_LIST_CHANGE");
threadDeregister();
}

void SetDirs(const QStringList &dirs)
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythprotoserver/mythsocketmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using namespace std;
#include "mythconfig.h"
#include "mythverbose.h"
#include "mythversion.h"
#include "mythlogging.h"

#define LOC QString("MythSocketManager: ")
#define LOC_WARN QString("MythSocketManager, Warning: ")
Expand Down Expand Up @@ -53,6 +54,7 @@ class ProcessRequestThread : public QThread

virtual void run(void)
{
threadRegister("ProcessRequest");
QMutexLocker locker(&m_lock);
m_threadlives = true;
m_waitCond.wakeAll(); // Signal to creating thread
Expand All @@ -76,6 +78,7 @@ class ProcessRequestThread : public QThread
m_socket = NULL;
m_parent->MarkUnused(this);
}
threadDeregister();
}

QMutex m_lock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ using namespace std;
#include "mythverbose.h"
#include "requesthandler/deletethread.h"
#include "mythcorecontext.h"
#include "mythlogging.h"

/*
Rather than attempt to calculate a delete speed from tuner card information
Expand All @@ -35,6 +36,7 @@ DeleteThread::DeleteThread(void) :

void DeleteThread::run(void)
{
threadRegister("Delete");
while (gCoreContext && m_run)
{
// loop through any stored files every half second
Expand All @@ -54,6 +56,7 @@ void DeleteThread::run(void)
delete (*i);
}
}
threadDeregister();
}

bool DeleteThread::AddFile(QString path)
Expand Down
4 changes: 4 additions & 0 deletions mythtv/libs/libmythtv/DeviceReadBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using namespace std;
#include "mythverbose.h"
#include "tspacket.h"
#include "compat.h"
#include "mythlogging.h"

#ifndef USING_MINGW
#include <sys/poll.h>
Expand Down Expand Up @@ -317,6 +318,7 @@ void DeviceReadBuffer::run(void)
{
uint errcnt = 0;

threadRegister("DeviceReadBuffer");
lock.lock();
dorun = true;
running = true;
Expand Down Expand Up @@ -377,6 +379,8 @@ void DeviceReadBuffer::run(void)
running = false;
eof = true;
lock.unlock();

threadDeregister();
}

bool DeviceReadBuffer::HandlePausing(void)
Expand Down
5 changes: 5 additions & 0 deletions mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ using namespace std;
#include "tv_rec.h"
#include "tv_play.h"
#include "audioinput.h"
#include "mythlogging.h"
#include "vbitext/cc.h"
#include "vbitext/vbi.h"

Expand Down Expand Up @@ -70,12 +71,16 @@ extern "C" {

void NVRWriteThread::run(void)
{
threadRegister("NVRWrite");
m_parent->doWriteThread();
threadDeregister();
}

void NVRAudioThread::run(void)
{
threadRegister("NVRAudio");
m_parent->doAudioThread();
threadDeregister();
}

NuppelVideoRecorder::NuppelVideoRecorder(TVRec *rec, ChannelBase *channel) :
Expand Down
6 changes: 6 additions & 0 deletions mythtv/libs/libmythtv/ThreadedFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,29 @@
// MythTV headers
#include "ThreadedFileWriter.h"
#include "mythverbose.h"
#include "mythlogging.h"

#include "mythtimer.h"
#include "compat.h"

/// \brief Runs ThreadedFileWriter::DiskLoop(void)
void TFWWriteThread::run(void)
{
threadRegister("TFWWrite");
#ifndef USING_MINGW
// don't exit program if file gets larger than quota limit..
signal(SIGXFSZ, SIG_IGN);
#endif
m_parent->DiskLoop();
threadDeregister();
}

/// \brief Runs ThreadedFileWriter::SyncLoop(void)
void TFWSyncThread::run(void)
{
threadRegister("TFWSync");
m_parent->SyncLoop();
threadDeregister();
}

const uint ThreadedFileWriter::kMaxBufferSize = 128 * 1024 * 1024;
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/audioplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,17 @@ bool AudioPlayer::SetMuted(bool mute)
if (m_audioOutput && !m_no_audio_out && !is_muted && mute &&
(kMuteAll == SetMuteState(kMuteAll)))
{
VERBOSE(VB_AUDIO, "muting sound " <<IsMuted());
VERBOSE(VB_AUDIO, QString("muting sound %1").arg(IsMuted()));
return true;
}
else if (m_audioOutput && !m_no_audio_out && is_muted && !mute &&
(kMuteOff == SetMuteState(kMuteOff)))
{
VERBOSE(VB_AUDIO, "unmuting sound "<<IsMuted());
VERBOSE(VB_AUDIO, QString("unmuting sound %1").arg(IsMuted()));
return true;
}

VERBOSE(VB_AUDIO, "not changing sound mute state "<<IsMuted());
VERBOSE(VB_AUDIO, QString("not changing sound mute state %1").arg(IsMuted()));

return false;
}
Expand Down
85 changes: 45 additions & 40 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,8 @@ long long AvFormatDecoder::GetChapter(int chapter)

bool AvFormatDecoder::DoRewind(long long desiredFrame, bool discardFrames)
{
VERBOSE(VB_PLAYBACK, LOC + "DoRewind("
<<desiredFrame<<", "
<<( discardFrames ? "do" : "don't" )<<" discard frames)");
VERBOSE(VB_PLAYBACK, LOC + QString("DoRewind(%1, %2 discard frames)")
.arg(desiredFrame).arg( discardFrames ? "do" : "don't" ));

if (recordingHasPositionMap || livetv)
return DecoderBase::DoRewind(desiredFrame, discardFrames);
Expand Down Expand Up @@ -580,8 +579,8 @@ bool AvFormatDecoder::DoFastForward(long long desiredFrame, bool discardFrames)

if (av_seek_frame(ic, -1, ts, flags) < 0)
{
VERBOSE(VB_IMPORTANT, LOC_ERR
<<"av_seek_frame(ic, -1, "<<ts<<", 0) -- error");
VERBOSE(VB_IMPORTANT, LOC_ERR + QString("av_seek_frame(ic, -1, %1"
", 0) -- error").arg(ts));
return false;
}

Expand Down Expand Up @@ -828,8 +827,9 @@ extern "C" void HandleStreamChange(void* data)
AvFormatDecoder* decoder = (AvFormatDecoder*) data;
int cnt = decoder->ic->nb_streams;

VERBOSE(VB_PLAYBACK, LOC + "HandleStreamChange(): "
"streams_changed "<<data<<" -- stream count "<<cnt);
VERBOSE(VB_PLAYBACK, LOC + QString("HandleStreamChange(): "
"streams_changed 0x%1 -- stream count %2")
.arg((uint64_t)data,0,16).arg(cnt));

QMutexLocker locker(avcodeclock);
decoder->SeekReset(0, 0, true, true);
Expand All @@ -841,8 +841,9 @@ extern "C" void HandleDVDStreamChange(void* data)
AvFormatDecoder* decoder = (AvFormatDecoder*) data;
int cnt = decoder->ic->nb_streams;

VERBOSE(VB_PLAYBACK, LOC + "HandleDVDStreamChange(): "
"streams_changed "<<data<<" -- stream count "<<cnt);
VERBOSE(VB_PLAYBACK, LOC + QString("HandleDVDStreamChange(): "
"streams_changed 0x%1 -- stream count %2")
.arg((uint64_t)data,0,16).arg(cnt));

QMutexLocker locker(avcodeclock);
//decoder->SeekReset(0, 0, true, true);
Expand Down Expand Up @@ -931,8 +932,8 @@ int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,
int err = av_open_input_stream(&ic, ic->pb, filename, fmt, &params);
if (err < 0)
{
VERBOSE(VB_IMPORTANT, LOC_ERR
<<"avformat err("<<err<<") on av_open_input_file call.");
VERBOSE(VB_IMPORTANT, LOC_ERR +
QString("avformat err(%1) on av_open_input_file call.").arg(err));
return -1;
}

Expand Down Expand Up @@ -1222,11 +1223,11 @@ static bool IS_DR1_PIX_FMT(const enum PixelFormat fmt)
void AvFormatDecoder::InitVideoCodec(AVStream *stream, AVCodecContext *enc,
bool selectedStream)
{
VERBOSE(VB_PLAYBACK, LOC
<<"InitVideoCodec() "<<enc<<" "
<<"id("<<ff_codec_id_string(enc->codec_id)
<<") type ("<<ff_codec_type_string(enc->codec_type)
<<").");
VERBOSE(VB_PLAYBACK, LOC +
QString("InitVideoCodec() 0x%1 id(%2) type (%3).")
.arg((uint64_t)enc,0,16)
.arg(ff_codec_id_string(enc->codec_id))
.arg(ff_codec_type_string(enc->codec_type)));

if (ringBuffer && ringBuffer->IsDVD())
directrendering = false;
Expand Down Expand Up @@ -1724,12 +1725,11 @@ int AvFormatDecoder::ScanStreams(bool novideo)
AVCodecContext *enc = ic->streams[i]->codec;
VERBOSE(VB_PLAYBACK, LOC +
QString("Stream #%1, has id 0x%2 codec id %3, "
"type %4, bitrate %5 at ")
.arg(i).arg((int)ic->streams[i]->id, 0, 16)
"type %4, bitrate %5 at 0x%6")
.arg(i).arg((uint64_t)ic->streams[i]->id,0,16)
.arg(ff_codec_id_string(enc->codec_id))
.arg(ff_codec_type_string(enc->codec_type))
.arg(enc->bit_rate)
<<((void*)ic->streams[i]));
.arg(enc->bit_rate).arg((uint64_t)ic->streams[i],0,16));

switch (enc->codec_type)
{
Expand Down Expand Up @@ -1841,11 +1841,12 @@ int AvFormatDecoder::ScanStreams(bool novideo)

if (enc->codec)
{
VERBOSE(VB_IMPORTANT, LOC
<<"Warning, video codec "<<enc<<" "
<<"id("<<ff_codec_id_string(enc->codec_id)
<<") type ("<<ff_codec_type_string(enc->codec_type)
<<") already open.");
VERBOSE(VB_IMPORTANT, LOC +
QString("Warning, video codec 0x%1 id(%2) type (%3"
") already open.")
.arg((uint64_t)enc,0,16)
.arg(ff_codec_id_string(enc->codec_id))
.arg(ff_codec_type_string(enc->codec_type)));
}

// Set the default stream to the stream
Expand Down Expand Up @@ -1887,11 +1888,12 @@ int AvFormatDecoder::ScanStreams(bool novideo)
{
if (enc->codec)
{
VERBOSE(VB_IMPORTANT, LOC
<<"Warning, audio codec "<<enc
<<" id("<<ff_codec_id_string(enc->codec_id)
<<") type ("<<ff_codec_type_string(enc->codec_type)
<<") already open, leaving it alone.");
VERBOSE(VB_IMPORTANT, LOC +
QString("Warning, audio codec 0x%1 id(%2) "
"type (%3) already open, leaving it alone.")
.arg((uint64_t)enc,0,16)
.arg(ff_codec_id_string(enc->codec_id))
.arg(ff_codec_type_string(enc->codec_type)));
}
//assert(enc->codec_id);
VERBOSE(VB_GENERAL, LOC + QString("codec %1 has %2 channels")
Expand Down Expand Up @@ -2008,21 +2010,24 @@ int AvFormatDecoder::ScanStreams(bool novideo)
int open_val = avcodec_open(enc, codec);
if (open_val < 0)
{
VERBOSE(VB_IMPORTANT, LOC_ERR
<<"Could not open codec "<<enc<<", "
<<"id("<<ff_codec_id_string(enc->codec_id)<<") "
<<"type("<<ff_codec_type_string(enc->codec_type)<<") "
<<"aborting. reason "<<open_val);
VERBOSE(VB_IMPORTANT, LOC_ERR +
QString("Could not open codec 0x%1, id(%2) type(%3) "
"aborting. reason %4").arg((uint64_t)enc,0,16)
.arg(ff_codec_id_string(enc->codec_id))
.arg(ff_codec_type_string(enc->codec_type))
.arg(open_val));
//av_close_input_file(ic); // causes segfault
ic = NULL;
scanerror = -1;
break;
}
else
{
VERBOSE(VB_GENERAL, LOC + "Opened codec "<<enc<<", "
<<"id("<<ff_codec_id_string(enc->codec_id)<<") "
<<"type("<<ff_codec_type_string(enc->codec_type)<<")");
VERBOSE(VB_GENERAL, LOC +
QString("Opened codec 0x%1, id(%2) type(%3)")
.arg((uint64_t)enc,0,16)
.arg(ff_codec_id_string(enc->codec_id))
.arg(ff_codec_type_string(enc->codec_type)));
}
}

Expand Down Expand Up @@ -2177,8 +2182,8 @@ void AvFormatDecoder::SetupAudioStreamSubIndexes(int streamIndex)
if (current == tracks[kTrackTypeAudio].end())
{
VERBOSE(VB_IMPORTANT, LOC_WARN +
"Invalid stream index passed to "
"SetupAudioStreamSubIndexes: "<<streamIndex);
QString("Invalid stream index passed to "
"SetupAudioStreamSubIndexes: %1").arg(streamIndex));

return;
}
Expand Down
21 changes: 11 additions & 10 deletions mythtv/libs/libmythtv/cc608decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1252,8 +1252,8 @@ bool CC608Decoder::XDSPacketParseProgram(
{
xds_rating_systems[cf] |= kHasCanEnglish;
xds_rating[cf][kRatingCanEnglish] = tv_rating;
VERBOSE(VB_VBI, loc + "VChip "
<< GetRatingString(kRatingCanEnglish, future));
VERBOSE(VB_VBI, loc + QString("VChip %1")
.arg(GetRatingString(kRatingCanEnglish, future)));
}
}
else if (sel == 7)
Expand All @@ -1263,8 +1263,8 @@ bool CC608Decoder::XDSPacketParseProgram(
{
xds_rating_systems[cf] |= kHasCanFrench;
xds_rating[cf][kRatingCanFrench] = tv_rating;
VERBOSE(VB_VBI, loc + "VChip "
<< GetRatingString(kRatingCanFrench, future));
VERBOSE(VB_VBI, loc + QString("VChip %1")
.arg(GetRatingString(kRatingCanFrench, future)));
}
}
else if (sel == 0x13 || sel == 0x1f)
Expand All @@ -1277,8 +1277,8 @@ bool CC608Decoder::XDSPacketParseProgram(
uint f = ((xds_buf[0]<<3) & 0x80) | ((xds_buf[1]<<1) & 0x70);
xds_rating_systems[cf] |= kHasTPG;
xds_rating[cf][kRatingTPG] = tv_rating | f;
VERBOSE(VB_VBI, loc + "VChip "
<< GetRatingString(kRatingTPG, future));
VERBOSE(VB_VBI, loc + QString("VChip %1")
.arg(GetRatingString(kRatingTPG, future)));
}
}
else if (rating_system == 0)
Expand All @@ -1288,14 +1288,15 @@ bool CC608Decoder::XDSPacketParseProgram(
{
xds_rating_systems[cf] |= kHasMPAA;
xds_rating[cf][kRatingMPAA] = movie_rating;
VERBOSE(VB_VBI, loc + "VChip "
<< GetRatingString(kRatingMPAA, future));
VERBOSE(VB_VBI, loc + QString("VChip %1")
.arg(GetRatingString(kRatingMPAA, future)));
}
}
else
{
VERBOSE(VB_VBI, loc + "VChip Unhandled -- rs("<<rating_system
<<") rating("<<tv_rating<<":"<<movie_rating<<")");
VERBOSE(VB_VBI, loc +
QString("VChip Unhandled -- rs(%1) rating(%2:%3)")
.arg(rating_system).arg(tv_rating).arg(movie_rating));
}
}
#if 0
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/channelbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// POSIX headers
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>

Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ using namespace std;
#include "cardutil.h"
#include "sourceutil.h"
#include "mythdb.h"
#include "mythlogging.h"

// MythTV includes - DTV
#include "dtvsignalmonitor.h"
Expand All @@ -67,7 +68,9 @@ using namespace std;
*/
void ScannerThread::run(void)
{
threadRegister("Scanner");
m_parent->RunScanner();
threadDeregister();
}

/// SDT's should be sent every 2 seconds and NIT's every
Expand Down
10 changes: 6 additions & 4 deletions mythtv/libs/libmythtv/channelscan/channelscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ void ChannelScanner::Scan(
(ScanTypeSetting::FullScan_Analog == scantype))
{
VERBOSE(VB_CHANSCAN, LOC +
"ScanTransports("<<freq_std<<", "<<mod<<", "<<tbl<<")");
QString("ScanTransports(%1, %2, %3)")
.arg(freq_std).arg(mod).arg(tbl));

// HACK HACK HACK -- begin
// if using QAM we may need additional time... (at least with HD-3000)
Expand All @@ -167,7 +168,8 @@ void ChannelScanner::Scan(
}
else if (ScanTypeSetting::FullTransportScan == scantype)
{
VERBOSE(VB_CHANSCAN, LOC + "ScanExistingTransports("<<sourceid<<")");
VERBOSE(VB_CHANSCAN, LOC + QString("ScanExistingTransports(%1)")
.arg(sourceid));

ok = sigmonScanner->ScanExistingTransports(sourceid, do_follow_nit);
if (ok)
Expand All @@ -184,7 +186,7 @@ void ChannelScanner::Scan(
{
ok = true;

VERBOSE(VB_CHANSCAN, LOC + "ScanForChannels("<<sourceid<<")");
VERBOSE(VB_CHANSCAN, LOC + QString("ScanForChannels(%1)").arg(sourceid));

QString card_type = CardUtil::GetRawCardType(cardid);
QString sub_type = card_type;
Expand Down Expand Up @@ -214,7 +216,7 @@ void ChannelScanner::Scan(
}
else if (ScanTypeSetting::TransportScan == scantype)
{
VERBOSE(VB_CHANSCAN, LOC + "ScanTransport("<<mplexid<<")");
VERBOSE(VB_CHANSCAN, LOC + QString("ScanTransport(%1)").arg(mplexid));

ok = sigmonScanner->ScanTransport(mplexid, do_follow_nit);
}
Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmythtv/darwinfirewiredevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ using namespace std;
#include "darwinfirewiredevice.h"
#include "darwinavcinfo.h"
#include "mythverbose.h"
#include "mythlogging.h"

// Apple Firewire example headers
#include <AVCVideoServices/StringLogger.h>
Expand Down Expand Up @@ -877,8 +878,9 @@ void DarwinFirewireDevice::HandleDeviceChange(uint messageType)

void *dfd_controller_thunk(void *param)
{
threadRegister("DarwinController");
((DarwinFirewireDevice*)param)->RunController();
return NULL;
threadDeregister();
}

void dfd_update_device_list_item(
Expand Down
38 changes: 19 additions & 19 deletions mythtv/libs/libmythtv/datadirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,8 @@ int DataDirectProcessor::UpdateChannelsSafe(
if (!SourceUtil::GetConnectionCount(sourceid))
{
VERBOSE(VB_IMPORTANT, LOC +
"Not inserting channels into disconnected source "
<<sourceid<<".");
QString("Not inserting channels into disconnected source %1.")
.arg(sourceid));
return -1;
}

Expand Down Expand Up @@ -1015,7 +1015,7 @@ bool DataDirectProcessor::DDPost(
#endif

if (SHOW_WGET_OUTPUT)
VERBOSE(VB_GENERAL, "command: "<<command<<endl);
VERBOSE(VB_GENERAL, "command: " + command);

err_txt = "Returned failure";
if (myth_system(command, kMSAnonLog) != GENERIC_EXIT_OK)
Expand Down Expand Up @@ -1099,7 +1099,7 @@ bool DataDirectProcessor::GrabNextSuggestedTime(void)
}

if (SHOW_WGET_OUTPUT)
VERBOSE(VB_GENERAL, "command: "<<command<<endl);
VERBOSE(VB_GENERAL, "command: " + command);
#ifndef USING_MINGW
else
command += " 2> /dev/null ";
Expand Down Expand Up @@ -1163,7 +1163,7 @@ bool DataDirectProcessor::GrabData(const QDateTime pstartDate,
const QDateTime pendDate)
{
QString msg = (pstartDate.addSecs(1) == pendDate) ? "channel" : "listing";
VERBOSE(VB_GENERAL, "Grabbing " << msg << " data");
VERBOSE(VB_GENERAL, "Grabbing " + msg + " data");

QString err = "";
QString ddurl = providers[listings_provider].webServiceURL;
Expand Down Expand Up @@ -1450,22 +1450,22 @@ QDateTime DataDirectProcessor::GetLineupCacheAge(const QString &lineupid) const
QFile lfile(get_cache_filename(lineupid));
if (!lfile.exists())
{
VERBOSE(VB_GENERAL, "GrabLineupCacheAge("<<lineupid<<") failed -- "
<<QString("file '%1' doesn't exist")
VERBOSE(VB_GENERAL, "GrabLineupCacheAge("+lineupid+") failed -- " +
QString("file '%1' doesn't exist")
.arg(get_cache_filename(lineupid)));
return cache_dt;
}
if (lfile.size() < 8)
{
VERBOSE(VB_IMPORTANT, "GrabLineupCacheAge("<<lineupid<<") failed -- "
<<QString("file '%1' size %2 too small")
VERBOSE(VB_IMPORTANT, "GrabLineupCacheAge("+lineupid+") failed -- " +
QString("file '%1' size %2 too small")
.arg(get_cache_filename(lineupid)).arg(lfile.size()));
return cache_dt;
}
if (!lfile.open(QIODevice::ReadOnly))
{
VERBOSE(VB_IMPORTANT, "GrabLineupCacheAge("<<lineupid<<") failed -- "
<<QString("cannot open file '%1'")
VERBOSE(VB_IMPORTANT, "GrabLineupCacheAge("+lineupid+") failed -- " +
QString("cannot open file '%1'")
.arg(get_cache_filename(lineupid)));
return cache_dt;
}
Expand All @@ -1475,8 +1475,8 @@ QDateTime DataDirectProcessor::GetLineupCacheAge(const QString &lineupid) const
io >> tmp;
cache_dt = QDateTime::fromString(tmp, Qt::ISODate);

VERBOSE(VB_GENERAL, "GrabLineupCacheAge("<<lineupid<<") -> "
<<cache_dt.toString(Qt::ISODate));
VERBOSE(VB_GENERAL, "GrabLineupCacheAge("+lineupid+") -> " +
cache_dt.toString(Qt::ISODate));

return cache_dt;
}
Expand All @@ -1486,7 +1486,7 @@ bool DataDirectProcessor::GrabLineupsFromCache(const QString &lineupid)
QFile lfile(get_cache_filename(lineupid));
if (!lfile.exists() || (lfile.size() < 8) || !lfile.open(QIODevice::ReadOnly))
{
VERBOSE(VB_IMPORTANT, "GrabLineupFromCache("<<lineupid<<") -- failed");
VERBOSE(VB_IMPORTANT, "GrabLineupFromCache("+lineupid+") -- failed");
return false;
}

Expand Down Expand Up @@ -1535,7 +1535,7 @@ bool DataDirectProcessor::GrabLineupsFromCache(const QString &lineupid)
stations[station.stationid] = station;
}

VERBOSE(VB_GENERAL, "GrabLineupFromCache("<<lineupid<<") -- success");
VERBOSE(VB_GENERAL, "GrabLineupFromCache("+lineupid+") -- success");

return true;
}
Expand All @@ -1547,7 +1547,7 @@ bool DataDirectProcessor::SaveLineupToCache(const QString &lineupid) const
QFile lfile(fna.constData());
if (!lfile.open(QIODevice::WriteOnly))
{
VERBOSE(VB_IMPORTANT, "SaveLineupToCache("<<lineupid<<") -- failed");
VERBOSE(VB_IMPORTANT, "SaveLineupToCache("+lineupid+") -- failed");
return false;
}

Expand Down Expand Up @@ -1590,7 +1590,7 @@ bool DataDirectProcessor::SaveLineupToCache(const QString &lineupid) const
}
io << flush;

VERBOSE(VB_GENERAL, "SaveLineupToCache("<<lineupid<<") -- success");
VERBOSE(VB_GENERAL, "SaveLineupToCache("+lineupid+") -- success");

makeFileAccessible(fna.constData()); // Let anybody update it

Expand Down Expand Up @@ -1919,7 +1919,7 @@ bool DataDirectProcessor::Post(QString url, const PostList &list,
#endif

if (SHOW_WGET_OUTPUT)
VERBOSE(VB_GENERAL, "command: "<<command<<endl);
VERBOSE(VB_GENERAL, "command: " + command);
else
{
command += (documentFile.isEmpty()) ? "&> " : "2> ";
Expand Down Expand Up @@ -2354,7 +2354,7 @@ static void set_lineup_type(const QString &lineupid, const QString &type)
tmptype.detach();
srcid_to_type[srcid] = tmptype;

VERBOSE(VB_GENERAL, "sourceid "<<srcid<<" has lineup type: "<<type);
VERBOSE(VB_GENERAL, QString("sourceid %1 has lineup type: %2").arg(srcid).arg(type));
}
}

Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/decoderbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ unsigned long DecoderBase::GetPositionMapSize(void) const
*/
bool DecoderBase::SyncPositionMap(void)
{
VERBOSE(VB_PLAYBACK, LOC + "Resyncing position map. posmapStarted = "
<< (int) posmapStarted << " livetv(" << livetv << ") "
<< "watchingRec(" << watchingrecording << ")");
VERBOSE(VB_PLAYBACK, LOC + QString("Resyncing position map. posmapStarted = %1"
" livetv(%2) watchingRec(%3)")
.arg((int) posmapStarted).arg(livetv).arg(watchingrecording));

if (dontSyncPositionMap)
return false;
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/dtvconfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ void DTVConfParser::AddChannel(const DTVMultiplex &mux, DTVChannelInfo &chan)
{
channels[i].channels.push_back(chan);

VERBOSE(VB_IMPORTANT, "Imported channel: "<<chan.toString()
<<" on "<<mux.toString());
VERBOSE(VB_IMPORTANT, "Imported channel: " + chan.toString() +
" on " + mux.toString());
return;
}
}

channels.push_back(mux);
channels.back().channels.push_back(chan);

VERBOSE(VB_IMPORTANT, "Imported channel: "<<chan.toString()
<<" on "<<mux.toString());
VERBOSE(VB_IMPORTANT, "Imported channel: " + chan.toString() +
" on " + mux.toString());
}
5 changes: 3 additions & 2 deletions mythtv/libs/libmythtv/dtvrecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ bool DTVRecorder::FindOtherKeyframes(const TSPacket *tspacket)
// documented in recorderbase.h
void DTVRecorder::SetNextRecording(const ProgramInfo *progInf, RingBuffer *rb)
{
VERBOSE(VB_RECORD, LOC + "SetNextRecord("<<progInf<<", "<<rb<<")");
VERBOSE(VB_RECORD, LOC + QString("SetNextRecord(0x%1, 0x%2)")
.arg((uint64_t)progInf,0,16).arg((uint64_t)rb,0,16));
// First we do some of the time consuming stuff we can do now
SavePositionMap(true);
if (ringBuffer)
Expand Down Expand Up @@ -953,7 +954,7 @@ void DTVRecorder::HandlePMT(uint progNum, const ProgramMapTable *_pmt)

if ((int)progNum == _stream_data->DesiredProgram())
{
VERBOSE(VB_RECORD, LOC + "SetPMT("<<progNum<<")");
VERBOSE(VB_RECORD, LOC + QString("SetPMT(%1)").arg(progNum));
ProgramMapTable *oldpmt = _input_pmt;
_input_pmt = new ProgramMapTable(*_pmt);

Expand Down
27 changes: 15 additions & 12 deletions mythtv/libs/libmythtv/dtvsignalmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#undef DBG_SM
#define DBG_SM(FUNC, MSG) VERBOSE(VB_CHANNEL, \
"DTVSM("<<channel->GetDevice()<<")::"<<FUNC<<": "<<MSG);
QString("DTVSM(%1)::%2: %3").arg(channel->GetDevice()).arg(FUNC).arg(MSG))

#define LOC QString("DTVSM(%1): ").arg(channel->GetDevice())
#define LOC_ERR QString("DTVSM(%1) Error: ").arg(channel->GetDevice())
Expand Down Expand Up @@ -83,8 +83,9 @@ QStringList DTVSignalMonitor::GetStatusList(bool kick)
if ((seenGood != (int)seenPMT.IsGood()) ||
(matchingGood != (int)matchingPMT.IsGood()))
{
DBG_SM("GetStatusList", "WaitForPMT seen("<<seenPMT.IsGood()
<<") matching("<<matchingPMT.IsGood()<<")");
DBG_SM("GetStatusList", QString("WaitForPMT seen(%1) matching(%2)")
.arg(seenPMT.IsGood())
.arg(matchingPMT.IsGood()));
seenGood = (int)seenPMT.IsGood();
matchingGood = (int)matchingPMT.IsGood();
}
Expand Down Expand Up @@ -299,7 +300,7 @@ void DTVSignalMonitor::HandlePAT(const ProgramAssociationTable *pat)
last_pat_crc = pat->CRC();
QString errStr = QString("Program #%1 not found in PAT!")
.arg(programNumber);
VERBOSE(VB_IMPORTANT, errStr<<endl<<pat->toString());
VERBOSE(VB_IMPORTANT, errStr + "\n" + pat->toString());
}
if (pat->ProgramCount() == 1)
{
Expand Down Expand Up @@ -362,7 +363,8 @@ void DTVSignalMonitor::HandlePMT(uint, const ProgramMapTable *pmt)

void DTVSignalMonitor::HandleSTT(const SystemTimeTable*)
{
VERBOSE(VB_CHANNEL+VB_EXTRA, LOC + "Time Offset: "<<GetStreamData()->TimeOffset());
VERBOSE(VB_CHANNEL+VB_EXTRA, LOC + QString("Time Offset: %1")
.arg(GetStreamData()->TimeOffset()));
}

void DTVSignalMonitor::HandleMGT(const MasterGuideTable* mgt)
Expand Down Expand Up @@ -394,9 +396,9 @@ void DTVSignalMonitor::HandleTVCT(

if (idx < 0)
{
VERBOSE(VB_IMPORTANT, "Could not find channel "
<<majorChannel<<"_"<<minorChannel<<" in TVCT");
VERBOSE(VB_IMPORTANT, endl<<tvct->toString());
VERBOSE(VB_IMPORTANT, QString("Could not find channel %1_%2 in TVCT")
.arg(majorChannel).arg(minorChannel));
VERBOSE(VB_IMPORTANT, "\n" + tvct->toString());
GetATSCStreamData()->SetVersionTVCT(tvct->TransportStreamID(),-1);
return;
}
Expand All @@ -415,9 +417,9 @@ void DTVSignalMonitor::HandleCVCT(uint, const CableVirtualChannelTable* cvct)

if (idx < 0)
{
VERBOSE(VB_IMPORTANT, "Could not find channel "
<<majorChannel<<"_"<<minorChannel<<" in CVCT");
VERBOSE(VB_IMPORTANT, endl<<cvct->toString());
VERBOSE(VB_IMPORTANT, QString("Could not find channel %1_%2 in CVCT")
.arg(majorChannel).arg(minorChannel));
VERBOSE(VB_IMPORTANT, "\n" + cvct->toString());
GetATSCStreamData()->SetVersionCVCT(cvct->TransportStreamID(),-1);
return;
}
Expand All @@ -431,7 +433,8 @@ void DTVSignalMonitor::HandleCVCT(uint, const CableVirtualChannelTable* cvct)

void DTVSignalMonitor::HandleTDT(const TimeDateTable*)
{
VERBOSE(VB_CHANNEL+VB_EXTRA, LOC + "Time Offset: "<<GetStreamData()->TimeOffset());
VERBOSE(VB_CHANNEL+VB_EXTRA, LOC + QString("Time Offset: %1")
.arg(GetStreamData()->TimeOffset()));
}

void DTVSignalMonitor::HandleNIT(const NetworkInformationTable *nit)
Expand Down
7 changes: 5 additions & 2 deletions mythtv/libs/libmythtv/dvbcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ using namespace std;
#include "dvbcam.h"
#include "dvbchannel.h"
#include "dvbrecorder.h"
#include "mythlogging.h"

#define LOC_ERR QString("DVB#%1 CA Error: ").arg(device)
#define LOC QString("DVB#%1 CA: ").arg(device)

void DVBCamThread::run(void)
{
threadRegister("DVBCam");
m_parent->CiHandlerLoop();
threadDeregister();
}

DVBCam::DVBCam(const QString &aDevice)
Expand Down Expand Up @@ -363,8 +366,8 @@ void DVBCam::SendPMT(const ProgramMapTable &pmt, uint cplm)
continue;
}

VERBOSE(VB_DVBCAM, LOC + "Creating CA_PMT, ServiceID = "
<< pmt.ProgramNumber());
VERBOSE(VB_DVBCAM, LOC + QString("Creating CA_PMT, ServiceID = %1")
.arg(pmt.ProgramNumber()));

cCiCaPmt capmt = CreateCAPMT(pmt, casids, cplm);

Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/dvbrecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "dvbrecorder.h"
#include "dvbchannel.h"
#include "tv_rec.h"
#include "mythverbose.h"

#define LOC QString("DVBRec(%1:%2): ") \
.arg(tvrec->GetCaptureCardNum()).arg(videodevice)
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/dvbsignalmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ void DVBSignalMonitor::UpdateValues(void)
// Debug output
if (wasLocked != isLocked)
{
VERBOSE(VB_CHANNEL, LOC + "UpdateValues -- Signal "
<<(isLocked ? "Locked" : "Lost"));
VERBOSE(VB_CHANNEL, LOC + "UpdateValues -- Signal " +
(isLocked ? "Locked" : "Lost"));
}

EmitStatus();
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythtv/dvbstreamhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "cardutil.h"
#include "dvbtypes.h" // for pid filtering
#include "diseqc.h" // for rotor retune
#include "mythlogging.h"

#define LOC QString("DVBSH(%1): ").arg(_device)
#define LOC_WARN QString("DVBSH(%1) Warning: ").arg(_device)
Expand Down Expand Up @@ -104,6 +105,7 @@ void DVBStreamHandler::SetRunningDesired(bool desired)

void DVBStreamHandler::run(void)
{
threadRegister("DVBRead");
VERBOSE(VB_RECORD, LOC + "run(): begin");

if (!SupportsTSMonitoring() && _allow_section_reader)
Expand All @@ -112,6 +114,7 @@ void DVBStreamHandler::run(void)
RunTS();

VERBOSE(VB_RECORD, LOC + "run(): end");
threadDeregister();
}

/** \fn DVBStreamHandler::RunTS(void)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/eitcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ bool EITCache::IsNewEIT(uint chanid, uint tableid, uint version,

if (accessCnt % 500000 == 50000)
{
VERBOSE(VB_EIT, endl << GetStatistics());
VERBOSE(VB_EIT, "\n" + GetStatistics());
WriteToDB();
}

Expand Down
7 changes: 5 additions & 2 deletions mythtv/libs/libmythtv/eitscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "util.h"
#include "mythdb.h"
#include "mythverbose.h"
#include "mythlogging.h"

#define LOC QString("EITScanner: ")
#define LOC_ID QString("EITScanner (%1): ").arg(cardnum)
Expand All @@ -27,7 +28,9 @@
*/
void EITThread::run(void)
{
threadRegister("EIT");
scanner->RunEventLoop();
threadDeregister();
}

/** \class EITScanner
Expand Down Expand Up @@ -118,7 +121,7 @@ void EITScanner::RunEventLoop(void)
// seen any in a while, tell scheduler to run.
if (eitCount && (t.elapsed() > 60 * 1000))
{
VERBOSE(VB_EIT, LOC_ID + "Added "<<eitCount<<" EIT Events");
VERBOSE(VB_EIT, LOC_ID + QString("Added %1 EIT Events").arg(eitCount));
eitCount = 0;
RescheduleRecordings();
}
Expand All @@ -128,7 +131,7 @@ void EITScanner::RunEventLoop(void)
// if there have been any new events, tell scheduler to run.
if (eitCount)
{
VERBOSE(VB_EIT, LOC_ID + "Added "<<eitCount<<" EIT Events");
VERBOSE(VB_EIT, LOC_ID + QString("Added %1 EIT Events").arg(eitCount));
eitCount = 0;
RescheduleRecordings();
}
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythtv/fifowriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "fifowriter.h"
#include "compat.h"
#include "mythverbose.h"
#include "mythlogging.h"

#include "mythconfig.h"
#if CONFIG_DARWIN
Expand Down Expand Up @@ -137,7 +138,9 @@ void FIFOThread::run(void)
if (!m_parent || m_id == -1)
return;

threadRegister(QString("FIFOWrite%1").arg(m_id));
m_parent->FIFOWriteThread(m_id);
threadDeregister();
}

void FIFOWriter::FIFOWriteThread(int id)
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/filtermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ bool FilterManager::LoadFilterLib(const QString &path)
QByteArray libname = path.toAscii();
newFilter->libname = strdup(libname.constData());
filters[newFilter->name] = newFilter;
VERBOSE(VB_PLAYBACK+VB_EXTRA, LOC + QString("filters[%1] = ")
.arg(newFilter->name) << newFilter);
VERBOSE(VB_PLAYBACK+VB_EXTRA, LOC + QString("filters[%1] = 0x%2")
.arg(newFilter->name).arg((uint64_t)newFilter,0,16));
}
return true;
}
Expand All @@ -189,7 +189,7 @@ const FilterInfo *FilterManager::GetFilterInfo(const QString &name) const
finfo = it->second;

VERBOSE(VB_PLAYBACK, LOC + QString("GetFilterInfo(%1)").arg(name) +
" returning: "<<finfo);
QString(" returning: 0x%1").arg((uint64_t)finfo,0,16));

return finfo;
}
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/firewiredevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void FirewireDevice::AddListener(TSDataListener *listener)
m_listeners.push_back(listener);
}

VERBOSE(VB_RECORD, LOC + "AddListener() "<<m_listeners.size());
VERBOSE(VB_RECORD, LOC + QString("AddListener() %1").arg(m_listeners.size()));
}

void FirewireDevice::RemoveListener(TSDataListener *listener)
Expand All @@ -63,7 +63,7 @@ void FirewireDevice::RemoveListener(TSDataListener *listener)
}
while (it != m_listeners.end());

VERBOSE(VB_RECORD, LOC + "RemoveListener() "<<m_listeners.size());
VERBOSE(VB_RECORD, LOC + QString("RemoveListener() %1").arg(m_listeners.size()));
}

bool FirewireDevice::SetPowerState(bool on)
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythtv/firewirerecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ bool FirewireRecorder::PauseAndWait(int timeout)
QMutexLocker locker(&pauseLock);
if (request_pause)
{
VERBOSE(VB_RECORD, LOC + "PauseAndWait("<<timeout<<") -- pause");
VERBOSE(VB_RECORD, LOC + QString("PauseAndWait(%1) -- pause").arg(timeout));
if (!IsPaused(true))
{
StopStreaming();
Expand All @@ -208,8 +208,7 @@ bool FirewireRecorder::PauseAndWait(int timeout)

if (!request_pause && IsPaused(true))
{
paused = false;
VERBOSE(VB_RECORD, LOC + "PauseAndWait("<<timeout<<") -- unpause");
VERBOSE(VB_RECORD, LOC + QString("PauseAndWait(%1) -- unpause").arg(timeout));
StartStreaming();
unpauseWait.wakeAll();
}
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythtv/firewiresignalmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
#include "atsctables.h"
#include "firewirechannel.h"
#include "firewiresignalmonitor.h"
#include "mythlogging.h"

#define LOC QString("FireSM(%1): ").arg(channel->GetDevice())
#define LOC_WARN QString("FireSM(%1), Warning: ").arg(channel->GetDevice())
#define LOC_ERR QString("FireSM(%1), Error: ").arg(channel->GetDevice())

void FirewireTableMonitorThread::run(void)
{
threadRegister("FirewireTableMonitor");
m_parent->RunTableMonitor();
threadDeregister();
}

const uint FirewireSignalMonitor::kPowerTimeout = 3000; /* ms */
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/hdhrrecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "hdhrrecorder.h"
#include "hdhrchannel.h"
#include "tv_rec.h"
#include "mythverbose.h"

#define LOC QString("HDHRRec(%1): ").arg(tvrec->GetCaptureCardNum())
#define LOC_WARN QString("HDHRRec(%1), Warning: ") \
Expand Down
5 changes: 5 additions & 0 deletions mythtv/libs/libmythtv/hdhrstreamhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "streamlisteners.h"
#include "mpegstreamdata.h"
#include "cardutil.h"
#include "mythverbose.h"
#include "mythlogging.h"

#define LOC QString("HDHRSH(%1): ").arg(_device)
#define LOC_WARN QString("HDHRSH(%1) Warning: ").arg(_device)
Expand Down Expand Up @@ -107,12 +109,14 @@ HDHRStreamHandler::HDHRStreamHandler(const QString &device) :
*/
void HDHRStreamHandler::run(void)
{
threadRegister("HDHRStreamHandler");
/* Create TS socket. */
if (!hdhomerun_device_stream_start(_hdhomerun_device))
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
"Starting recording (set target failed). Aborting.");
_error = true;
threadDeregister();
return;
}
hdhomerun_device_stream_flush(_hdhomerun_device);
Expand Down Expand Up @@ -178,6 +182,7 @@ void HDHRStreamHandler::run(void)
VERBOSE(VB_RECORD, LOC + "RunTS(): " + "end");

SetRunning(false, false, false);
threadDeregister();
}

static QString filt_str(uint pid)
Expand Down
7 changes: 5 additions & 2 deletions mythtv/libs/libmythtv/iptv/iptvchannelfetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "channelutil.h"
#include "iptvchannelfetcher.h"
#include "scanmonitor.h"
#include "mythlogging.h"

#define LOC QString("IPTVChanFetch: ")
#define LOC_ERR QString("IPTVChanFetch, Error: ")
Expand All @@ -35,7 +36,9 @@ static bool parse_extinf(const QString &data,
*/
void IPTVChannelFetcherThread::run(void)
{
threadRegister("IPTVChannelFetcher");
iptvfetcher->RunScan();
threadDeregister();
}

IPTVChannelFetcher::IPTVChannelFetcher(
Expand Down Expand Up @@ -303,8 +306,8 @@ fbox_chan_map_t IPTVChannelFetcher::ParsePlaylist(
uint num_channels = estimate_number_of_channels(rawdata);
fetcher->SetTotalNumChannels(num_channels);

VERBOSE(VB_CHANNEL, "Estimating there are "<<num_channels
<<" channels in playlist");
VERBOSE(VB_CHANNEL, QString("Estimating there are %1"
" channels in playlist").arg(num_channels));
}

// Parse each channel
Expand Down
Loading