Skip to content

Commit

Permalink
Merge branch 'master' of github.com:/MythTV/mythtv
Browse files Browse the repository at this point in the history
  • Loading branch information
gigem committed Feb 17, 2012
2 parents c2cfcb1 + f7b7f61 commit d71adef
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 43 deletions.
2 changes: 1 addition & 1 deletion mythtv/bindings/python/MythTV/logging.py
Expand Up @@ -220,7 +220,7 @@ def __new__(cls, *args, **kwargs):
# abuse the __new__ constructor to set some immutable class attributes
# before the class is instantiated
cls._initlogger()
return super(MythLog, cls).__new__(cls, *args, **kwargs)
return super(MythLog, cls).__new__(cls)

def __init__(self, module='pythonbindings', db=None):
self.module = module
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/programinfo.cpp
Expand Up @@ -3665,7 +3665,7 @@ void ProgramInfo::SaveTotalFrames(int64_t frames)
query.bindValue(":DATA", (uint)(frames));

if (!query.exec())
MythDB::DBError("Frames insert", query);
MythDB::DBError("Total Frames insert", query);
}

/// \brief Store the Resolution at frame in the recordedmarkup table
Expand Down
12 changes: 9 additions & 3 deletions mythtv/libs/libmythbase/mythcorecontext.cpp
Expand Up @@ -846,10 +846,16 @@ QString MythCoreContext::GetMasterHostName(void)

if (d->m_masterHostname.isEmpty())
{
QStringList strlist("QUERY_HOSTNAME");

if (SendReceiveStringList(strlist))
d->m_masterHostname = strlist[0];
if (IsMasterBackend())
d->m_masterHostname = d->m_localHostname;
else
{
QStringList strlist("QUERY_HOSTNAME");

if (SendReceiveStringList(strlist))
d->m_masterHostname = strlist[0];
}
}

QString ret = d->m_masterHostname;
Expand Down
42 changes: 38 additions & 4 deletions mythtv/libs/libmythbase/system-unix.cpp
Expand Up @@ -783,8 +783,25 @@ void MythSystemUnix::Fork(time_t timeout)
}
else
{
/* We aren't sucking this down, close stdout */
close(1);
/* We aren't sucking this down, redirect stdout to /dev/null */
int fd = open("/dev/null", O_WRONLY);
if( fd >= 0 )
{
if( dup2(fd, 1) < 0)
{
cerr << locerr
<< "Cannot redirect standard output to /dev/null,"
"\n\t\t\tfailed to duplicate file descriptor: "
<< strerror(errno) << endl;
}
}
else
{
cerr << locerr
<< "Cannot redirect standard output to /dev/null, "
"failed to open: "
<< strerror(errno) << endl;
}
}

/* handle standard err */
Expand All @@ -801,8 +818,25 @@ void MythSystemUnix::Fork(time_t timeout)
}
else
{
/* We aren't sucking this down, close stderr */
close(2);
/* We aren't sucking this down, redirect stderr to /dev/null */
int fd = open("/dev/null", O_WRONLY);
if( fd >= 0 )
{
if( dup2(fd, 2) < 0)
{
cerr << locerr
<< "Cannot redirect standard error to /dev/null,"
"\n\t\t\tfailed to duplicate file descriptor: "
<< strerror(errno) << endl;
}
}
else
{
cerr << locerr
<< "Cannot redirect standard error to /dev/null, "
"failed to open: "
<< strerror(errno) << endl;
}
}

/* Close all open file descriptors except stdin/stdout/stderr */
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -1011,12 +1011,13 @@ int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,

// If watching pre-recorded television or video use the marked duration
// from the db if it exists, else ffmpeg duration
int64_t dur = 0;
int64_t dur = 0, frames = 0;

if (m_playbackinfo)
{
dur = m_playbackinfo->QueryTotalDuration();
dur /= 1000000;
frames = m_playbackinfo->QueryTotalFrames();
}

if (dur == 0)
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/mythcommflagplayer.cpp
Expand Up @@ -185,6 +185,7 @@ bool MythCommFlagPlayer::RebuildSeekTable(
cout << "\r \r" << flush;

SaveTotalDuration();
SaveTotalFrames();

SetPlaying(false);
killdecoder = true;
Expand Down
8 changes: 8 additions & 0 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -5003,6 +5003,14 @@ void MythPlayer::ResetTotalDuration(void)
decoder->ResetTotalDuration();
}

void MythPlayer::SaveTotalFrames(void)
{
if (!decoder)
return;

decoder->SaveTotalFrames();
}

static unsigned dbg_ident(const MythPlayer *player)
{
static QMutex dbg_lock;
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -339,6 +339,8 @@ class MTV_PUBLIC MythPlayer
static const int kNightModeBrightenssAdjustment;
static const int kNightModeContrastAdjustment;

void SaveTotalFrames(void);

protected:
// Initialization
void OpenDummy(void);
Expand Down
5 changes: 5 additions & 0 deletions mythtv/libs/libmythtv/recorderbase.cpp
Expand Up @@ -474,6 +474,11 @@ void RecorderBase::SetDuration(uint64_t duration)
curRecording->SaveTotalDuration(duration);
}

void RecorderBase::SetTotalFrames(uint64_t total_frames)
{
if (curRecording)
curRecording->SaveTotalFrames(total_frames);
}


RecorderBase *RecorderBase::CreateRecorder(
Expand Down
4 changes: 4 additions & 0 deletions mythtv/libs/libmythtv/recorderbase.h
Expand Up @@ -254,6 +254,10 @@ class MTV_PUBLIC RecorderBase : public QRunnable
*/
void SetDuration(uint64_t duration);

/** \brief Note the total frames in the recordedmark table
*/
void SetTotalFrames(uint64_t total_frames);

TVRec *tvrec;
RingBuffer *ringBuffer;
bool weMadeBuffer;
Expand Down
20 changes: 13 additions & 7 deletions mythtv/libs/libmythtv/subtitlescreen.cpp
Expand Up @@ -11,10 +11,13 @@

#define LOC QString("Subtitles: ")
#define LOC_WARN QString("Subtitles Warning: ")
#define PAD_WIDTH 0.20
#define PAD_HEIGHT 0.04
static const float PAD_WIDTH = 0.20;
static const float PAD_HEIGHT = 0.04;

static const float LINE_SPACING = 1.1765f;
// Normal font height is designed to be 1/20 of safe area height, with
// extra blank space between lines to make 17 lines within the safe
// area.
static const float LINE_SPACING = (20.0 / 17.0);

SubtitleScreen::SubtitleScreen(MythPlayer *player, const char * name,
int fontStretch) :
Expand Down Expand Up @@ -1132,9 +1135,9 @@ void FormattedTextSubtitle::Layout(void)
int anchor_height = 0;
for (int i = 0; i < m_lines.size(); i++)
{
QSize sz = m_lines[i].CalcSize();
QSize sz = m_lines[i].CalcSize(LINE_SPACING);
anchor_width = max(anchor_width, sz.width());
anchor_height += sz.height() * LINE_SPACING;
anchor_height += sz.height();
}

// Adjust the anchor point according to actual width and height
Expand All @@ -1159,7 +1162,7 @@ void FormattedTextSubtitle::Layout(void)
m_lines[i].x_indent = anchor_x;
if (m_lines[i].y_indent < 0)
m_lines[i].y_indent = y;
y += m_lines[i].CalcSize().height() * LINE_SPACING;
y += m_lines[i].CalcSize(LINE_SPACING).height();
// Prune leading all-whitespace chunks.
while (!m_lines[i].chunks.isEmpty() &&
m_lines[i].chunks.first().text.trimmed().isEmpty())
Expand Down Expand Up @@ -1325,12 +1328,15 @@ void SubtitleScreen::SetFontSizes(int nSmall, int nMedium, int nLarge)
}

QSize SubtitleScreen::CalcTextSize(const QString &text,
const CC708CharacterAttribute &format) const
const CC708CharacterAttribute &format,
float layoutSpacing) const
{
QFont *font = Get708Font(format)->GetFace();
QFontMetrics fm(*font);
int width = fm.width(text) + fm.maxWidth() * PAD_WIDTH;
int height = fm.height() * (1 + PAD_HEIGHT);
if (layoutSpacing > 0 && !text.trimmed().isEmpty())
height = max(height, (int)(font->pixelSize() * layoutSpacing));
return QSize(width, height);
}

Expand Down
11 changes: 6 additions & 5 deletions mythtv/libs/libmythtv/subtitlescreen.h
Expand Up @@ -40,7 +40,8 @@ class SubtitleScreen : public MythScreenType
void DisplayDVDButton(AVSubtitle* dvdButton, QRect &buttonPos);

QSize CalcTextSize(const QString &text,
const CC708CharacterAttribute &format) const;
const CC708CharacterAttribute &format,
float layoutSpacing) const;

void RegisterExpiration(MythUIType *shape, long long endTime)
{
Expand Down Expand Up @@ -114,9 +115,9 @@ class FormattedTextChunk
}
FormattedTextChunk(void) : parent(NULL) {}

QSize CalcSize(void) const
QSize CalcSize(float layoutSpacing = 0.0f) const
{
return parent->CalcTextSize(text, format);
return parent->CalcTextSize(text, format, layoutSpacing);
}
bool Split(FormattedTextChunk &newChunk);
QString ToLogString(void) const;
Expand All @@ -132,13 +133,13 @@ class FormattedTextLine
FormattedTextLine(int x = -1, int y = -1, int o_x = -1, int o_y = -1)
: x_indent(x), y_indent(y), orig_x(o_x), orig_y(o_y) {}

QSize CalcSize(void) const
QSize CalcSize(float layoutSpacing = 0.0f) const
{
int height = 0, width = 0;
QList<FormattedTextChunk>::const_iterator it;
for (it = chunks.constBegin(); it != chunks.constEnd(); ++it)
{
QSize tmp = (*it).CalcSize();
QSize tmp = (*it).CalcSize(layoutSpacing);
height = max(height, tmp.height());
width += tmp.width();
}
Expand Down
24 changes: 17 additions & 7 deletions mythtv/libs/libmythui/mythuitext.cpp
Expand Up @@ -527,14 +527,24 @@ bool MythUIText::Layout(QString & paragraph, QTextLayout *layout, bool final,
*/
QFontMetrics fm(GetFontProperties()->face());
int bearing;
int position;

bearing = fm.leftBearing(m_CutMessage[last_line]);
if (m_leftBearing > bearing)
m_leftBearing = bearing;
bearing = fm.rightBearing
(m_CutMessage[last_line + line.textLength() - 1]);
if (m_rightBearing > bearing)
m_rightBearing = bearing;
position = last_line;
if (m_CutMessage.length() > position)
{
bearing = fm.leftBearing(m_CutMessage[position]);
if (m_leftBearing > bearing)
m_leftBearing = bearing;
}

position = (last_line + line.textLength() - 1);
if (m_CutMessage.length() > position && position >= 0)
{
bearing = fm.rightBearing
(m_CutMessage[position]);
if (m_rightBearing > bearing)
m_rightBearing = bearing;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythbackend/mainserver.cpp
Expand Up @@ -1370,7 +1370,7 @@ void MainServer::HandleAnnounce(QStringList &slist, QStringList commands,
gCoreContext->SendSystemEvent(
QString("CLIENT_CONNECTED HOSTNAME %1").arg(commands[2]));
}
if (commands[1] == "MediaServer")
else if (commands[1] == "MediaServer")
{
if (commands.size() < 3)
{
Expand Down
5 changes: 4 additions & 1 deletion mythtv/programs/mythcommflag/ClassicCommDetector.cpp
Expand Up @@ -1805,7 +1805,10 @@ void ClassicCommDetector::BuildAllMethodsCommList(void)
.arg((framesProcessed - breakStart - 1)));

commBreakMap[breakStart] = MARK_COMM_START;
commBreakMap[framesProcessed - (int)(2 * fps) - 2] = MARK_COMM_END;
// Create what is essentially an open-ended final skip region
// by setting the end point 10 seconds past the end of the
// recording.
commBreakMap[framesProcessed + (10 * fps)] = MARK_COMM_END;
}

// include/exclude blanks from comm breaks
Expand Down
4 changes: 2 additions & 2 deletions mythtv/programs/scripts/hardwareprofile/getLink.py
Expand Up @@ -23,7 +23,7 @@
from optparse import OptionParser
from urlparse import urljoin
import urlgrabber.grabber
import simplejson
import json

sys.path.append('/usr/share/smolt/client')

Expand Down Expand Up @@ -76,7 +76,7 @@ def main():
pub_uuid_str = pub_uuid_fli.read()
try:
try:
pub_uuid_obj = simplejson.loads(pub_uuid_str)
pub_uuid_obj = json.loads(pub_uuid_str)
print _('To view your profile visit: %s') % smolt.get_profile_link(opts.smoonURL, pub_uuid_obj["pub_uuid"])
except ValueError, e:
error(_('Something went wrong fetching the public UUID'))
Expand Down
6 changes: 3 additions & 3 deletions mythtv/programs/scripts/hardwareprofile/scan.py
Expand Up @@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

import smolt
import simplejson, urllib
import json, urllib
from i18n import _
from smolt_config import get_config_attr

Expand All @@ -27,7 +27,7 @@ def rating(profile, smoonURL, gate):
print _("Current rating for vendor/model.")
print ""
scanURL='%s/client/host_rating?vendor=%s&system=%s' % (smoonURL, urllib.quote(profile.host.systemVendor), urllib.quote(profile.host.systemModel))
r = simplejson.load(urllib.urlopen(scanURL))['ratings']
r = json.load(urllib.urlopen(scanURL))['ratings']
rating_system = { '0' : _('Unrated/Unknown'),
'1' : _('Non-working'),
'2' : _('Partially-working'),
Expand Down Expand Up @@ -57,7 +57,7 @@ def scan(profile, smoonURL, gate):
scanURL='%s/smolt-w/api.php' % smoonURL
scanData = 'action=query&titles=%s&format=json' % searchDevices
try:
r = simplejson.load(urllib.urlopen(scanURL, scanData))
r = json.load(urllib.urlopen(scanURL, scanData))
except ValueError:
print "Could not wiki for errata!"
return
Expand Down

0 comments on commit d71adef

Please sign in to comment.