Skip to content

Commit

Permalink
Don't include all of the standard namespace. (libmythtv/recorders)
Browse files Browse the repository at this point in the history
Including all of the standard namespace is considered bad practice. It
defeats the purpose of namespaces, and pollutes the global name table.
  • Loading branch information
linuxdude42 committed Oct 2, 2020
1 parent b0f4c3d commit 91b3102
Show file tree
Hide file tree
Showing 53 changed files with 124 additions and 167 deletions.
13 changes: 6 additions & 7 deletions mythtv/libs/libmythtv/recorders/DeviceReadBuffer.cpp
@@ -1,5 +1,4 @@
#include <algorithm>
using namespace std;

#include "DeviceReadBuffer.h"
#include "mythcorecontext.h"
Expand Down Expand Up @@ -70,10 +69,10 @@ bool DeviceReadBuffer::Setup(const QString &streamName, int streamfd,
m_used = 0;
m_devReadSize = m_readQuanta * (m_usingPoll ? 256 : 48);
m_devReadSize = (deviceBufferSize) ?
min(m_devReadSize, (size_t)deviceBufferSize) : m_devReadSize;
std::min(m_devReadSize, (size_t)deviceBufferSize) : m_devReadSize;
m_readThreshold = m_readQuanta * 128;

m_buffer = new (nothrow) unsigned char[m_size + m_devReadSize];
m_buffer = new (std::nothrow) unsigned char[m_size + m_devReadSize];
m_readPtr = m_buffer;
m_writePtr = m_buffer;

Expand Down Expand Up @@ -346,7 +345,7 @@ void DeviceReadBuffer::run(void)
{
// Limit read size for faster return from read
auto unused = static_cast<size_t>(WaitForUnused(m_readQuanta));
size_t read_size = min(m_devReadSize, unused);
size_t read_size = std::min(m_devReadSize, unused);

// if read_size > 0 do the read...
if (read_size)
Expand Down Expand Up @@ -447,7 +446,7 @@ bool DeviceReadBuffer::Poll(void) const
timeout = 10;
else if (m_pollTimeoutIsError)
// subtract a bit to allow processing time.
timeout = max((int)m_maxPollWait - timer.elapsed() - 15, 10);
timeout = std::max((int)m_maxPollWait - timer.elapsed() - 15, 10);

int ret = poll(polls.data(), poll_cnt, timeout);

Expand Down Expand Up @@ -614,8 +613,8 @@ bool DeviceReadBuffer::CheckForErrors(
*/
uint DeviceReadBuffer::Read(unsigned char *buf, const uint count)
{
uint avail = WaitForUsed(min(count, (uint)m_readThreshold), 20);
size_t cnt = min(count, avail);
uint avail = WaitForUsed(std::min(count, (uint)m_readThreshold), 20);
size_t cnt = std::min(count, avail);

if (!cnt)
return 0;
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/recorders/ExternalChannel.h
Expand Up @@ -6,7 +6,6 @@
#include <cstdint>
#include <utility>
#include <vector>
using namespace std;

// Qt headers
#include <QString>
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/recorders/ExternalStreamHandler.cpp
Expand Up @@ -410,7 +410,7 @@ void ExternIO::Fork(void)
{
std::cerr << "ExternIO: "
<< "setpgid() failed: "
<< strerror(errno) << endl;
<< strerror(errno) << std::endl;
}

/* run command */
Expand All @@ -431,13 +431,13 @@ void ExternIO::Fork(void)
// Can't use LOG due to locking fun.
std::cerr << "ExternIO: "
<< "execv() failed: "
<< strerror(errno) << endl;
<< strerror(errno) << std::endl;
}
else
{
std::cerr << "ExternIO: "
<< "execv() should not be here?: "
<< strerror(errno) << endl;
<< strerror(errno) << std::endl;
}

#endif // !defined( USING_MINGW ) && !defined( _MSC_VER )
Expand Down Expand Up @@ -866,7 +866,7 @@ bool ExternalStreamHandler::SetAPIVersion(void)

if (tokens.size() > 1)
m_apiVersion = tokens[1].toUInt();
m_apiVersion = min(m_apiVersion, static_cast<int>(MAX_API_VERSION));
m_apiVersion = std::min(m_apiVersion, static_cast<int>(MAX_API_VERSION));
if (m_apiVersion < 1)
{
LOG(VB_RECORD, LOG_ERR, LOC +
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/recorders/ExternalStreamHandler.h
Expand Up @@ -5,7 +5,6 @@

#include <cstdint>
#include <vector>
using namespace std;

#include <QString>
#include <QAtomicInt>
Expand Down
9 changes: 4 additions & 5 deletions mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp
Expand Up @@ -18,7 +18,6 @@
#include <QStringList>

#include <iostream>
using namespace std;

#include "mythmiscutil.h"
#include "mythcontext.h"
Expand Down Expand Up @@ -86,7 +85,7 @@ NuppelVideoRecorder::NuppelVideoRecorder(TVRec *rec, ChannelBase *channel) :
V4LRecorder(rec)
{
m_channelObj = channel;
m_seekTable = new vector<struct seektable_entry>;
m_seekTable = new std::vector<struct seektable_entry>;
m_ccd = new CC608Decoder(this);

SetPositionMapType(MARK_KEYFRAME);
Expand Down Expand Up @@ -2059,7 +2058,7 @@ void NuppelVideoRecorder::WriteSeekTable(void)
}

void NuppelVideoRecorder::WriteKeyFrameAdjustTable(
const vector<struct kfatable_entry> &kfa_table)
const std::vector<struct kfatable_entry> &kfa_table)
{
int numentries = kfa_table.size();

Expand Down Expand Up @@ -2248,7 +2247,7 @@ void NuppelVideoRecorder::doAudioThread(void)
(like we used to.) Measure to see how much stuff is in there,
and correct for it when calculating the timestamp */
gettimeofday(&anow, &m_tzone);
int bytes_read = max(m_audioDevice->GetNumReadyBytes(), 0);
int bytes_read = std::max(m_audioDevice->GetNumReadyBytes(), 0);

int act = m_actAudioBuffer;

Expand Down Expand Up @@ -2436,7 +2435,7 @@ void NuppelVideoRecorder::FormatTT(struct VBIData *vbidata)
break;
memcpy(outpos, &st, sizeof(st));
outpos += sizeof(st);
int count = max(st.len, static_cast<uint8_t>(41));
int count = std::max(st.len, static_cast<uint8_t>(41));
std::copy(linebuf.cbegin(), linebuf.cbegin() + count, outpos);
outpos += count;
*outpos = 0;
Expand Down
13 changes: 6 additions & 7 deletions mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.h
Expand Up @@ -23,7 +23,6 @@ extern "C" {
#include <cstdint>
#include <ctime>
#include <vector>
using namespace std;

// Qt headers
#include <QString>
Expand Down Expand Up @@ -111,7 +110,7 @@ class MTV_PUBLIC NuppelVideoRecorder : public V4LRecorder, public CC608Input
void WriteHeader(void);
void WriteSeekTable(void);
void WriteKeyFrameAdjustTable(
const vector<struct kfatable_entry> &kfa_table);
const std::vector<struct kfatable_entry> &kfa_table);
void UpdateSeekTable(int frame_num, long offset = 0);

bool SetupAVCodecVideo(void);
Expand Down Expand Up @@ -190,14 +189,14 @@ class MTV_PUBLIC NuppelVideoRecorder : public V4LRecorder, public CC608Input
RTjpeg *m_rtjc {nullptr};

#define OUT_LEN (1024*1024 + 1024*1024 / 64 + 16 + 3)
array<lzo_byte,OUT_LEN> m_out {};
std::array<lzo_byte,OUT_LEN> m_out {};
#define HEAP_ALLOC(var,size) \
std::array<long,((size) + (sizeof(long) - 1)) / sizeof(long)> __LZO_MMODEL var
HEAP_ALLOC(wrkmem, LZO1X_1_MEM_COMPRESS) {};

vector<struct vidbuffertype *> m_videoBuffer;
vector<struct audbuffertype *> m_audioBuffer;
vector<struct txtbuffertype *> m_textBuffer;
std::vector<struct vidbuffertype *> m_videoBuffer;
std::vector<struct audbuffertype *> m_audioBuffer;
std::vector<struct txtbuffertype *> m_textBuffer;

int m_actVideoEncode {0};
int m_actVideoBuffer {0};
Expand Down Expand Up @@ -226,7 +225,7 @@ class MTV_PUBLIC NuppelVideoRecorder : public V4LRecorder, public CC608Input
bool m_recording {false};

int m_keyframeDist {KEYFRAMEDIST};
vector<struct seektable_entry> *m_seekTable {nullptr};
std::vector<struct seektable_entry> *m_seekTable {nullptr};
long long m_lastPositionMapPos {0};

long long m_extendedDataOffset {0};
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythtv/recorders/asichannel.h
Expand Up @@ -4,7 +4,6 @@
#define ASI_CHANNEL_H

#include <vector>
using namespace std;

// Qt headers
#include <QString>
Expand Down Expand Up @@ -34,13 +33,13 @@ class ASIChannel : public DTVChannel
{ return m_isOpen; }
QString GetDevice(void) const override // ChannelBase
{ return m_device; }
vector<DTVTunerType> GetTunerTypes(void) const override // DTVChannel
std::vector<DTVTunerType> GetTunerTypes(void) const override // DTVChannel
{ return m_tunerTypes; }
bool IsPIDTuningSupported(void) const override // DTVChannel
{ return true; }

private:
vector<DTVTunerType> m_tunerTypes;
std::vector<DTVTunerType> m_tunerTypes;
QString m_device;
bool m_isOpen {false};
};
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/recorders/asistreamhandler.h
Expand Up @@ -4,7 +4,6 @@
#define ASISTREAMHANDLER_H

#include <vector>
using namespace std;

#include <QString>
#include <QMutex>
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/recorders/avcinfo.cpp
Expand Up @@ -45,8 +45,8 @@ bool AVCInfo::GetSubunitInfo(void)

for (uint i = 0; i < 8; i++)
{
vector<uint8_t> cmd;
vector<uint8_t> ret;
std::vector<uint8_t> cmd;
std::vector<uint8_t> ret;

cmd.push_back(FirewireDevice::kAVCStatusInquiryCommand);
cmd.push_back(FirewireDevice::kAVCSubunitTypeUnit |
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythtv/recorders/avcinfo.h
Expand Up @@ -5,7 +5,6 @@
#include <array>
#include <cstdint>
#include <vector>
using namespace std;

// Qt headers
#include <QString>
Expand All @@ -29,8 +28,8 @@ class AVCInfo
virtual ~AVCInfo() = default;

virtual bool SendAVCCommand(
const vector<uint8_t> &/*cmd*/,
vector<uint8_t> &/*result*/,
const std::vector<uint8_t> &/*cmd*/,
std::vector<uint8_t> &/*result*/,
int /*retry_cnt*/)
{
return false;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/recorders/cetonchannel.h
Expand Up @@ -37,7 +37,7 @@ class CetonChannel : public DTVChannel
bool IsOpen(void) const override; // ChannelBase
QString GetDevice(void) const override // ChannelBase
{ return m_deviceId; }
vector<DTVTunerType> GetTunerTypes(void) const override // DTVChannel
std::vector<DTVTunerType> GetTunerTypes(void) const override // DTVChannel
{ return m_tunerTypes; }

// Sets
Expand All @@ -53,7 +53,7 @@ class CetonChannel : public DTVChannel
private:
QString m_deviceId;
CetonStreamHandler *m_streamHandler {nullptr};
vector<DTVTunerType> m_tunerTypes;
std::vector<DTVTunerType> m_tunerTypes;
};

#endif
3 changes: 1 addition & 2 deletions mythtv/libs/libmythtv/recorders/channelbase.cpp
Expand Up @@ -11,7 +11,6 @@
// C++ headers
#include <iostream>
#include <algorithm>
using namespace std;

// Qt headers
#include <QCoreApplication>
Expand Down Expand Up @@ -236,7 +235,7 @@ bool ChannelBase::IsInputAvailable(
mplexid_restriction = 0;
chanid_restriction = 0;

vector<uint> inputids = CardUtil::GetConflictingInputs(m_inputId);
std::vector<uint> inputids = CardUtil::GetConflictingInputs(m_inputId);
for (uint inputid : inputids)
{
if (RemoteIsBusy(inputid, info))
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythtv/recorders/darwinavcinfo.cpp
Expand Up @@ -6,7 +6,6 @@

// Std C++ headers
#include <vector>
using namespace std;

// MythTV headers
#include "darwinfirewiredevice.h"
Expand Down Expand Up @@ -114,8 +113,8 @@ void DarwinAVCInfo::Update(uint64_t _guid, DarwinFirewireDevice *dev,
}

bool DarwinAVCInfo::SendAVCCommand(
const vector<uint8_t> &cmd,
vector<uint8_t> &result,
const std::vector<uint8_t> &cmd,
std::vector<uint8_t> &result,
int /*retry_cnt*/)
{
result.clear();
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythtv/recorders/darwinavcinfo.h
Expand Up @@ -5,7 +5,6 @@

// C++ headers
#include <vector>
using namespace std;

// OS X headers
#undef always_inline
Expand Down Expand Up @@ -42,8 +41,8 @@ class DarwinAVCInfo : public AVCInfo
void CloseDeviceInterface(void);

bool SendAVCCommand(
const vector<uint8_t> &cmd,
vector<uint8_t> &result,
const std::vector<uint8_t> &cmd,
std::vector<uint8_t> &result,
int retry_cnt) override; // AVCInfo

bool GetDeviceNodes(int &local_node, int &remote_node);
Expand Down
15 changes: 7 additions & 8 deletions mythtv/libs/libmythtv/recorders/darwinfirewiredevice.cpp
Expand Up @@ -22,7 +22,6 @@
// Std C++ headers
#include <algorithm>
#include <vector>
using namespace std;

// MythTV headers
#include "darwinfirewiredevice.h"
Expand Down Expand Up @@ -329,7 +328,7 @@ bool DarwinFirewireDevice::OpenAVStream(void)
int max_speed = GetMaxSpeed();
LOG(VB_GENERAL, LOG_INFO, LOC + QString("Max Speed: %1, Our speed: %2")
.arg(max_speed).arg(m_speed));
m_speed = min((uint)max_speed, m_speed);
m_speed = std::min((uint)max_speed, m_speed);

uint fwchan = 0;
bool streaming = IsSTBStreaming(&fwchan);
Expand Down Expand Up @@ -499,8 +498,8 @@ bool DarwinFirewireDevice::StopStreaming(void)
return true;
}

bool DarwinFirewireDevice::SendAVCCommand(const vector<uint8_t> &cmd,
vector<uint8_t> &result,
bool DarwinFirewireDevice::SendAVCCommand(const std::vector<uint8_t> &cmd,
std::vector<uint8_t> &result,
int retry_cnt)
{
return GetInfoPtr()->SendAVCCommand(cmd, result, retry_cnt);
Expand Down Expand Up @@ -606,9 +605,9 @@ void DarwinFirewireDevice::ProcessStreamingMessage(
}
}

vector<AVCInfo> DarwinFirewireDevice::GetSTBList(void)
std::vector<AVCInfo> DarwinFirewireDevice::GetSTBList(void)
{
vector<AVCInfo> list;
std::vector<AVCInfo> list;

{
DarwinFirewireDevice dev(0,0,0);
Expand All @@ -627,7 +626,7 @@ vector<AVCInfo> DarwinFirewireDevice::GetSTBList(void)
return list;
}

vector<AVCInfo> DarwinFirewireDevice::GetSTBListPrivate(void)
std::vector<AVCInfo> DarwinFirewireDevice::GetSTBListPrivate(void)
{
#if 0
LOG(VB_GENERAL, LOG_DEBUG, LOC + "GetSTBListPrivate -- begin");
Expand All @@ -637,7 +636,7 @@ vector<AVCInfo> DarwinFirewireDevice::GetSTBListPrivate(void)
LOG(VB_GENERAL, LOG_DEBUG, LOC + "GetSTBListPrivate -- got lock");
#endif

vector<AVCInfo> list;
std::vector<AVCInfo> list;

for (auto dev : qAsConst(m_priv->m_devices))
{
Expand Down

0 comments on commit 91b3102

Please sign in to comment.