Skip to content

Commit

Permalink
Some more libmythupnp changes to std::chrono. (44)
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdude42 committed Jan 25, 2021
1 parent 28903d0 commit 41d960e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythupnp/bufferedsocketdevice.cpp
Expand Up @@ -419,7 +419,7 @@ qulonglong BufferedSocketDevice::WaitForMore(

msecs = 1s;

nBytes = m_pSocket->waitForMore( msecs.count(), &bTimeout );
nBytes = m_pSocket->waitForMore( msecs, &bTimeout );

if (pTimeout != nullptr)
*pTimeout = bTimeout;
Expand Down
6 changes: 5 additions & 1 deletion mythtv/libs/libmythupnp/msocketdevice.h
Expand Up @@ -44,11 +44,15 @@
#ifndef MSOCKETDEVICE_H
#define MSOCKETDEVICE_H

#include <chrono>

#include <QIODevice>
#include <QHostAddress> // int->QHostAddress conversion

#include "upnpexp.h"

using namespace std::chrono_literals;

class MSocketDevicePrivate;

class UPNP_PUBLIC MSocketDevice: public QIODevice
Expand Down Expand Up @@ -111,7 +115,7 @@ class UPNP_PUBLIC MSocketDevice: public QIODevice
virtual int accept();

qint64 bytesAvailable() const override; // QIODevice
qint64 waitForMore(int msecs, bool *timeout = nullptr) const;
qint64 waitForMore(std::chrono::milliseconds msecs, bool *timeout = nullptr) const;
virtual qint64 writeBlock(const char *data, quint64 len,
const QHostAddress & host, quint16 port);
inline qint64 writeBlock(const char *data, quint64 len)
Expand Down
10 changes: 5 additions & 5 deletions mythtv/libs/libmythupnp/msocketdevice_unix.cpp
Expand Up @@ -888,7 +888,7 @@ qint64 MSocketDevice::bytesAvailable() const
\sa bytesAvailable()
*/
qint64 MSocketDevice::waitForMore(int msecs, bool *timeout) const
qint64 MSocketDevice::waitForMore(std::chrono::milliseconds msecs, bool *timeout) const
{
if (!isValid())
return -1;
Expand All @@ -904,11 +904,11 @@ qint64 MSocketDevice::waitForMore(int msecs, bool *timeout) const

FD_SET(m_fd, &fds);

tv.tv_sec = msecs / 1000;
tv.tv_sec = msecs.count() / 1000;

tv.tv_usec = (msecs % 1000) * 1000;
tv.tv_usec = (msecs.count() % 1000) * 1000;

int rv = select(m_fd + 1, &fds, nullptr, nullptr, msecs < 0 ? nullptr : &tv);
int rv = select(m_fd + 1, &fds, nullptr, nullptr, msecs < 0ms ? nullptr : &tv);

if (rv < 0)
return -1;
Expand Down Expand Up @@ -1170,7 +1170,7 @@ qint64 MSocketDevice::writeData(const char *data, qint64 len)
break;
}
}
else if (waitForMore(0, &timeout) == 0)
else if (waitForMore(0ms, &timeout) == 0)
{
if (!timeout)
{
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythupnp/upnphelpers.cpp
Expand Up @@ -23,7 +23,7 @@ QString DurationFormat(std::chrono::milliseconds msec)
{
dayStr = QString("D%1").arg((msec % 24h).count());
}
QString timeStr = UPnPDateTime::TimeFormat(msec.count());
QString timeStr = UPnPDateTime::TimeFormat(msec);

return durationStr.arg(dayStr).arg(timeStr);
}
Expand All @@ -34,9 +34,9 @@ QString TimeFormat(const QTime time)
return timeStr;
}

QString TimeFormat(uint32_t msec)
QString TimeFormat(std::chrono::milliseconds msec)
{
QTime time = QTime::fromMSecsSinceStartOfDay(msec);
QTime time = QTime::fromMSecsSinceStartOfDay(msec.count());
return time.toString("HH:mm:ss");
}

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythupnp/upnphelpers.h
Expand Up @@ -84,7 +84,7 @@ namespace UPnPDateTime
* UPnP ContentDirectory Service 2008, 2013
* Appendix D.1 Date&Time Syntax
*/
UPNP_PUBLIC QString TimeFormat(uint32_t msec);
UPNP_PUBLIC QString TimeFormat(std::chrono::milliseconds msec);

/**
* Date-Time Format
Expand Down

0 comments on commit 41d960e

Please sign in to comment.