8 changes: 4 additions & 4 deletions mythtv/libs/libmythupnp/upnptaskcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class SSDPCacheTask : public Task
{
protected:

int m_nInterval; // Number of ms between executing.
int m_nExecuteCount; // Used for debugging.
std::chrono::milliseconds m_nInterval {30s}; // Number of ms between executing.
int m_nExecuteCount {0}; // Used for debugging.

// Destructor protected to force use of Release Method

Expand All @@ -42,8 +42,8 @@ class SSDPCacheTask : public Task
SSDPCacheTask() : Task("SSDPCacheTask")
{
m_nExecuteCount = 0;
m_nInterval = 1000 *
UPnp::GetConfiguration()->GetValue("UPnP/SSDP/CacheInterval", 30);
m_nInterval =
UPnp::GetConfiguration()->GetDuration<std::chrono::seconds>("UPnP/SSDP/CacheInterval", 30s);
}

QString Name() override // Task
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythupnp/upnptasknotify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ UPnpNotifyTask::UPnpNotifyTask( int nServicePort ) :
{
m_nServicePort = nServicePort;

m_nMaxAge = UPnp::GetConfiguration()->GetValue( "UPnP/SSDP/MaxAge" , 3600 );
m_nMaxAge = UPnp::GetConfiguration()->GetDuration<std::chrono::seconds>( "UPnP/SSDP/MaxAge" , 1h );
}

/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -73,7 +73,7 @@ void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
.arg( GetNTSString() )
.arg( sNT )
.arg( sUSN )
.arg( m_nMaxAge );
.arg( m_nMaxAge.count() );

LOG(VB_UPNP, LOG_INFO,
QString("UPnpNotifyTask::SendNotifyMsg : %1:%2 : %3 : %4")
Expand Down Expand Up @@ -164,7 +164,7 @@ void UPnpNotifyTask::Execute( TaskQueue *pQueue )
m_mutex.lock();

if (m_eNTS == NTS_alive)
pQueue->AddTask( (m_nMaxAge / 2) * 1000, (Task *)this );
pQueue->AddTask( (m_nMaxAge / 2), (Task *)this );

m_mutex.unlock();

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythupnp/upnptasknotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class UPnpNotifyTask : public Task

QString m_sMasterIP;
int m_nServicePort;
int m_nMaxAge {3600};
std::chrono::seconds m_nMaxAge {1h};

UPnpNotifyNTS m_eNTS {NTS_alive};

Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythupnp/upnptasksearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ UPnpSearchTask::UPnpSearchTask( int nServicePort,
m_sST = std::move(sST);
m_sUDN = std::move(sUDN);
m_nServicePort= nServicePort;
m_nMaxAge = UPnp::GetConfiguration()->GetValue( "UPnP/SSDP/MaxAge" , 3600 );
m_nMaxAge = UPnp::GetConfiguration()->GetDuration<std::chrono::seconds>( "UPnP/SSDP/MaxAge" , 1h );

}

Expand Down Expand Up @@ -81,7 +81,7 @@ void UPnpSearchTask::SendMsg( MSocketDevice *pSocket,
"ST: %4\r\n"
"USN: %5\r\n"
"Content-Length: 0\r\n\r\n" )
.arg( m_nMaxAge )
.arg( m_nMaxAge.count() )
.arg( sDate )
.arg( HttpServer::GetServerVersion() )
.arg( sST )
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythupnp/upnptasksearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UPnpSearchTask : public Task

QList<QHostAddress> m_addressList;
int m_nServicePort;
int m_nMaxAge {3600};
std::chrono::seconds m_nMaxAge {1h};

QHostAddress m_peerAddress;
int m_nPeerPort;
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythupnp/upnputil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ bool operator== ( TaskTime t1, TaskTime t2 )
//
/////////////////////////////////////////////////////////////////////////////

void AddMicroSecToTaskTime( TaskTime &t, suseconds_t uSecs )
void AddMicroSecToTaskTime( TaskTime &t, std::chrono::microseconds uSecs )
{
uSecs += t.tv_usec;
uSecs += std::chrono::microseconds(t.tv_usec);

t.tv_sec += (uSecs / 1000000);
t.tv_usec = (uSecs % 1000000);
t.tv_sec += (uSecs.count() / 1000000);
t.tv_usec = (uSecs.count() % 1000000);
}

/////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythupnp/upnputil.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ QString LookupUDN ( const QString &sDeviceType );
bool operator< ( TaskTime t1, TaskTime t2 );
bool operator== ( TaskTime t1, TaskTime t2 );

void AddMicroSecToTaskTime( TaskTime &t, suseconds_t uSecs );
void AddMicroSecToTaskTime( TaskTime &t, std::chrono::microseconds uSecs );
void AddSecondsToTaskTime ( TaskTime &t, long nSecs );

UPNP_PUBLIC QStringList GetSourceProtocolInfos ();
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythupnp/websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void WebSocketWorker::CleanupSocket()
.arg(m_socket->error()));
}

int writeTimeout = 5000; // 5 Seconds
std::chrono::milliseconds writeTimeout = 5s;
// Make sure any data in the buffer is flushed before the socket is closed
while (m_webSocketServer.IsRunning() &&
m_socket->isValid() &&
Expand All @@ -251,13 +251,13 @@ void WebSocketWorker::CleanupSocket()
// streaming. We should create a new server extension or adjust the
// timeout according to the User-Agent, instead of increasing the
// standard timeout. However we should ALWAYS have a timeout.
if (!m_socket->waitForBytesWritten(writeTimeout))
if (!m_socket->waitForBytesWritten(writeTimeout.count()))
{
LOG(VB_GENERAL, LOG_WARNING, QString("WebSocketWorker(%1): "
"Timed out waiting to write bytes to "
"the socket, waited %2 seconds")
.arg(m_socketFD)
.arg(writeTimeout / 1000));
.arg(writeTimeout.count() / 1000));
break;
}
}
Expand Down