Skip to content

Commit

Permalink
Fix AirPlay compilation if RAOP isn't compiled in.
Browse files Browse the repository at this point in the history
  • Loading branch information
jyavenard committed Jun 16, 2012
1 parent f60a706 commit 604b4f7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
20 changes: 18 additions & 2 deletions mythtv/libs/libmythtv/AirPlay/mythairplayserver.cpp
Expand Up @@ -19,7 +19,6 @@

#include "bonjourregister.h"
#include "mythairplayserver.h"
#include "mythraopdevice.h"

MythAirplayServer* MythAirplayServer::gMythAirplayServer = NULL;
MThread* MythAirplayServer::gMythAirplayServerThread = NULL;
Expand Down Expand Up @@ -108,6 +107,23 @@ QMutex* MythAirplayServer::gMythAirplayServerMutex = new QMutex(QMute
"</dict>\r\n"\
"</plist>\r\n")

QString AirPlayHardwareId()
{
QString key = "AirPlayId";
QString id = gCoreContext->GetSetting(key);
int size = id.size();
if (size == 12)
return id;

QByteArray ba;
for (int i = 0; i < AIRPLAY_HARDWARE_ID_SIZE; i++)
ba.append((random() % 80) + 33);
id = ba.toHex();

gCoreContext->SaveSetting(key, id);
return id;
}

class APHTTPRequest
{
public:
Expand Down Expand Up @@ -825,7 +841,7 @@ void MythAirplayServer::GetPlayerStatus(bool &playing, float &speed,

QString MythAirplayServer::GetMacAddress()
{
QString id = MythRAOPDevice::HardwareId();
QString id = AirPlayHardwareId();

QString res;
for (int i = 1; i <= id.size(); i++)
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/AirPlay/mythairplayserver.h
Expand Up @@ -12,6 +12,8 @@ class MThread;
class BonjourRegister;

#define AIRPLAY_PORT_RANGE 100
#define AIRPLAY_HARDWARE_ID_SIZE 6
QString AirPlayHardwareId();

enum AirplayEvent
{
Expand Down
5 changes: 3 additions & 2 deletions mythtv/libs/libmythtv/AirPlay/mythraopconnection.cpp
Expand Up @@ -12,6 +12,7 @@

#include "mythraopdevice.h"
#include "mythraopconnection.h"
#include "mythairplayserver.h"

#define LOC QString("RAOP Conn: ")
#define MAX_PACKET_SIZE 2048
Expand Down Expand Up @@ -915,8 +916,8 @@ void MythRAOPConnection::ProcessRequest(const QStringList &header,
i += 16;
}
}
memcpy(from + i, m_hardwareId.constData(), RAOP_HARDWARE_ID_SIZE);
i += RAOP_HARDWARE_ID_SIZE;
memcpy(from + i, m_hardwareId.constData(), AIRPLAY_HARDWARE_ID_SIZE);
i += AIRPLAY_HARDWARE_ID_SIZE;

int pad = 32 - i;
if (pad > 0)
Expand Down
20 changes: 2 additions & 18 deletions mythtv/libs/libmythtv/AirPlay/mythraopdevice.cpp
Expand Up @@ -9,6 +9,7 @@
#include "bonjourregister.h"
#include "mythraopconnection.h"
#include "mythraopdevice.h"
#include "mythairplayserver.h"

MythRAOPDevice* MythRAOPDevice::gMythRAOPDevice = NULL;
MThread* MythRAOPDevice::gMythRAOPDeviceThread = NULL;
Expand Down Expand Up @@ -60,23 +61,6 @@ bool MythRAOPDevice::Create(void)
return true;
}

QString MythRAOPDevice::HardwareId()
{
QString key = "AirPlayId";
QString id = gCoreContext->GetSetting(key);
int size = id.size();
if (size == 12)
return id;

QByteArray ba;
for (int i = 0; i < RAOP_HARDWARE_ID_SIZE; i++)
ba.append((random() % 80) + 33);
id = ba.toHex();

gCoreContext->SaveSetting(key, id);
return id;
}

void MythRAOPDevice::Cleanup(void)
{
LOG(VB_GENERAL, LOG_INFO, LOC + "Cleaning up.");
Expand All @@ -101,7 +85,7 @@ MythRAOPDevice::MythRAOPDevice()
: ServerPool(), m_name(QString("MythTV")), m_bonjour(NULL), m_valid(false),
m_lock(new QMutex(QMutex::Recursive)), m_setupPort(5000)
{
m_hardwareId = QByteArray::fromHex(HardwareId().toAscii());
m_hardwareId = QByteArray::fromHex(AirPlayHardwareId().toAscii());
}

MythRAOPDevice::~MythRAOPDevice()
Expand Down
2 changes: 0 additions & 2 deletions mythtv/libs/libmythtv/AirPlay/mythraopdevice.h
Expand Up @@ -12,7 +12,6 @@ class BonjourRegister;
class MythRAOPConnection;

#define RAOP_PORT_RANGE 100
#define RAOP_HARDWARE_ID_SIZE 6

class MTV_PUBLIC MythRAOPDevice : public ServerPool
{
Expand All @@ -24,7 +23,6 @@ class MTV_PUBLIC MythRAOPDevice : public ServerPool

MythRAOPDevice();
bool NextInAudioQueue(MythRAOPConnection* conn);
static QString HardwareId();

private slots:
void Start();
Expand Down

0 comments on commit 604b4f7

Please sign in to comment.