Skip to content

Commit

Permalink
SatIP code cleanup
Browse files Browse the repository at this point in the history
More descriptive function names and a bit of comment added.
No functional changes.
  • Loading branch information
kmdewaal committed Dec 8, 2021
1 parent 1423951 commit 32a8bd1
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 165 deletions.
25 changes: 20 additions & 5 deletions mythtv/libs/libmythtv/recorders/satipchannel.cpp
Expand Up @@ -39,7 +39,9 @@ bool SatIPChannel::Open(void)
LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Open(%1)").arg(m_device));

if (IsOpen())
{
return true;
}

QMutexLocker locker(&m_tuneLock);

Expand Down Expand Up @@ -71,7 +73,7 @@ void SatIPChannel::Close(void)
{
m_streamHandler->RemoveListener(m_streamData);
}
SatIPStreamHandler::Return(m_streamHandler, m_inputId);
SatIPStreamHandler::Return(m_streamHandler, GetInputID());
}
}

Expand All @@ -86,15 +88,28 @@ bool SatIPChannel::Tune(const QString &channum)
return false;
}

bool SatIPChannel::Tune(const DTVMultiplex &tuning)
bool SatIPChannel::EnterPowerSavingMode(void)
{
LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Tune(frequency=%1)").arg(tuning.m_frequency));
m_streamHandler->Tune(tuning);
return true;
}

bool SatIPChannel::IsOpen(void) const
{
QMutexLocker locker(&m_streamLock);
return m_streamHandler != nullptr;
bool result = m_streamHandler != nullptr;
LOG(VB_CHANNEL, LOG_DEBUG, LOC + QString("< %1 IsOpen:%2").arg(__func__).arg(result));
return result;
}

bool SatIPChannel::Tune(const DTVMultiplex &tuning)
{
LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Tune(frequency=%1)").arg(tuning.m_frequency));

if (m_streamHandler->Tune(tuning))
{
SetSIStandard(tuning.m_sistandard);
return true;
}
LOG(VB_GENERAL, LOG_ERR, LOC + QString("Tune failed"));
return false;
}
7 changes: 4 additions & 3 deletions mythtv/libs/libmythtv/recorders/satipchannel.h
@@ -1,5 +1,5 @@
#ifndef _SATIP_CHANNEL_H_
#define _SATIP_CHANNEL_H_
#ifndef SATIPCHANNEL_H
#define SATIPCHANNEL_H

// Qt headers
#include <QString>
Expand All @@ -18,6 +18,7 @@ class SatIPChannel : public DTVChannel
// Commands
bool Open(void) override; // ChannelBase
void Close(void) override; // ChannelBase
bool EnterPowerSavingMode(void) override; // DTVChannel

using DTVChannel::Tune;
bool Tune(const DTVMultiplex& tuning) override; // DTVChannel
Expand All @@ -41,4 +42,4 @@ class SatIPChannel : public DTVChannel
MPEGStreamData *m_streamData {nullptr};
};

#endif // _SATIP_CHANNEL_H_
#endif // SATIPCHANNEL_H
5 changes: 3 additions & 2 deletions mythtv/libs/libmythtv/recorders/satiprecorder.cpp
Expand Up @@ -18,6 +18,7 @@ SatIPRecorder::SatIPRecorder(TVRec *rec, SatIPChannel *channel)
, m_channel(channel)
, m_inputId(rec->GetInputId())
{
LOG(VB_RECORD, LOG_INFO, LOC + QString("ctor %1").arg(m_channel->GetDevice()));
}

bool SatIPRecorder::Open(void)
Expand All @@ -32,7 +33,7 @@ bool SatIPRecorder::Open(void)

if (m_channel->GetFormat().compare("MPTS") == 0)
{
// MPTS only. Use TSStreamData to write out unfiltered data.
// MPTS only. Use TSStreamData to write out unfiltered data.
LOG(VB_RECORD, LOG_INFO, LOC + "Using TSStreamData");
SetStreamData(new TSStreamData(m_inputId));
m_recordMptsOnly = true;
Expand Down Expand Up @@ -73,7 +74,6 @@ void SatIPRecorder::run(void)
{
LOG(VB_RECORD, LOG_INFO, LOC + "run -- begin");

/* Create video socket. */
if (!Open())
{
m_error = "Failed to open SatIPRecorder device";
Expand Down Expand Up @@ -148,6 +148,7 @@ void SatIPRecorder::run(void)
m_recordingWait.wakeAll();

LOG(VB_RECORD, LOG_INFO, LOC + "run -- end");
LOG(VB_GENERAL, LOG_INFO, LOC + QString("< %1").arg(__func__));
}

bool SatIPRecorder::PauseAndWait(std::chrono::milliseconds timeout)
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/recorders/satiprecorder.h
@@ -1,5 +1,5 @@
#ifndef SATIPRECORDER_H_
#define SATIPRECORDER_H_
#ifndef SATIPRECORDER_H
#define SATIPRECORDER_H

// Qt includes
#include <QString>
Expand Down Expand Up @@ -33,4 +33,4 @@ class SatIPRecorder : public DTVRecorder
int m_inputId {0};
};

#endif // SATIPRECORDER_H_
#endif // SATIPRECORDER_H

0 comments on commit 32a8bd1

Please sign in to comment.