Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
OpenHome Sample Players (https://github.com/openhome/ohPlayer) for Mac
OpenHome Sample Player (https://github.com/openhome/ohPlayer) for Mac
Windows, Linux and Raspberry Pi.

=========================================
Only the Linux tree is under development.
=========================================


Repository and source setup
===========================

Expand Down
1 change: 0 additions & 1 deletion linux/ConfigGTKKeyStore.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <OpenHome/Private/Converter.h>
#include <OpenHome/Private/Printer.h>

#include <string>
#include <vector>

#include <sys/stat.h>
Expand Down
4 changes: 3 additions & 1 deletion linux/ConfigGTKKeyStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

#include <glib.h>

#include <OpenHome/Configuration/BufferPtrCmp.h>
#include <OpenHome/Buffer.h>
#include <OpenHome/Configuration/IStore.h>
#include <OpenHome/Private/Thread.h>

#include <string>

namespace OpenHome {
namespace Configuration {

Expand Down
33 changes: 26 additions & 7 deletions linux/DriverAlsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class PcmProcessorBase : public IPcmProcessor
protected:
PcmProcessorBase(IDataSink& aDataSink, Bwx& aBuffer);
public: // IPcmProcessor
virtual void BeginBlock();
virtual void BeginBlock() override;
void ProcessFragment(const Brx& aData, TUint aNumChannels, TUint aSubsampleBytes) override;
void ProcessSilence(const Brx& aData, TUint aNumChannels, TUint aSubsampleBytes) override;
virtual void EndBlock();
virtual void Flush();
virtual void EndBlock() override;
virtual void Flush() override;
public:
void SetDuplicateChannel(TBool duplicateChannel);
void SetBitDepth(TUint bitDepth);
Expand Down Expand Up @@ -993,14 +993,30 @@ TUint DriverAlsa::PipelineAnimatorDelayJiffies(AudioFormat aFormat,
return iPimpl->DriverDelayJiffies(aSampleRate);
}

TUint DriverAlsa::PipelineAnimatorDsdBlockSizeWords() const
TUint DriverAlsa::PipelineAnimatorMaxBitDepth() const
{
return 0;
return 0;
}

TUint DriverAlsa::PipelineAnimatorMaxBitDepth() const
void DriverAlsa::PipelineAnimatorDsdBlockConfiguration(TUint& aSampleBlockWords,
TUint& aPadBytesPerChunk) const
{
return 0;
aSampleBlockWords=0;
aPadBytesPerChunk=0;
}



void DriverAlsa::PipelineAnimatorGetMaxSampleRates(TUint& aPcm, TUint& aDsd) const
{
aPcm=0;
aDsd=0;
}

void DriverAlsa::PipelineAnimatorGetMaxSampleRates(TUint& aPcm, TUint& aDsd) const
{
aPcm = 192000;
aDsd = 5644800;
}

Msg* DriverAlsa::ProcessMsg(MsgHalt* aMsg)
Expand Down Expand Up @@ -1044,3 +1060,6 @@ Msg* DriverAlsa::ProcessMsg(MsgDrain* aMsg)

return aMsg;
}



6 changes: 5 additions & 1 deletion linux/DriverAlsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ class DriverAlsa : public PipelineElement, public IPipelineAnimator, private INo
TUint PipelineAnimatorBufferJiffies() const override;
TUint PipelineAnimatorDelayJiffies(AudioFormat aFormat, TUint aSampleRate,
TUint aBitDepth, TUint aNumChannels) const override;
TUint PipelineAnimatorDsdBlockSizeWords() const override;
TUint PipelineAnimatorMaxBitDepth() const override;

void PipelineAnimatorDsdBlockConfiguration(TUint& aSampleBlockWords,
TUint& aPadBytesPerChunk) const override;
void PipelineAnimatorGetMaxSampleRates(TUint& aPcm, TUint& aDsd) const override;

private:
class Pimpl;
Pimpl* iPimpl;
Expand Down
81 changes: 41 additions & 40 deletions linux/ExampleMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <OpenHome/Web/ConfigUi/ConfigUi.h>
#include <OpenHome/Private/Shell.h>
#include <OpenHome/Private/ShellCommandDebug.h>
#include <OpenHome/OAuth.h>

#include "ConfigGTKKeyStore.h"
#include "ControlPointProxy.h"
Expand All @@ -40,6 +41,9 @@ using namespace OpenHome::Web;
const Brn kPrefix("OpenHome");

const Brn ExampleMediaPlayer::kIconOpenHomeFileName("OpenHomeIcon");
const Brn ExampleMediaPlayer::kResourceDir(Brn("/usr/share/"
"openhome-player/res/"));
const Brn ExampleMediaPlayer::kPlayerName("Softplayer");

ExampleMediaPlayer::ExampleMediaPlayer(Net::DvStack& aDvStack,
Net::CpStack& aCpStack,
Expand Down Expand Up @@ -116,10 +120,12 @@ ExampleMediaPlayer::ExampleMediaPlayer(Net::DvStack& aDvStack,
iInitParams->SetGorgerDuration(iInitParams->DecodedReservoirJiffies());

// create MediaPlayer
auto mpInit = MediaPlayerInitParams::New(Brn(aRoom), Brn(aProductName), kPrefix);
iMediaPlayer = new MediaPlayer( aDvStack, aCpStack, *iDevice, *iRamStore,
iAudioTime = new AudioTimeCpu(aDvStack.Env());
auto mpInit = MediaPlayerInitParams::New(Brn(aRoom), Brn(aProductName), kPrefix);

iMediaPlayer = new MediaPlayer( aDvStack, aCpStack, *iDevice, *iRamStore,
*iConfigStore, iInitParams,
volumeInit, volumeProfile, *iInfoLogger,
*iAudioTime, volumeInit, volumeProfile, *iInfoLogger,
aUdn, mpInit);

#ifdef DEBUG
Expand Down Expand Up @@ -167,6 +173,7 @@ ExampleMediaPlayer::~ExampleMediaPlayer()
delete iDevice;
delete iDeviceUpnpAv;
delete iRamStore;
delete iAudioTime;
}

Environment& ExampleMediaPlayer::Env()
Expand Down Expand Up @@ -325,24 +332,31 @@ void ExampleMediaPlayer::RegisterPlugins(Environment& aEnv)

#ifdef ENABLE_TIDAL
// You must define your Tidal token
std::vector<OpenHome::OAuthAppDetails> aAppDetails;
aAppDetails.emplace_back(TildaAuthAppId, TildaAuthClientId, TildaAuthClientSecret);

iMediaPlayer->Add(ProtocolFactory::NewTidal(
aEnv,
Brn(TIDAL_TOKEN),
ssl,
TildaAuthClientId,
TildaAuthClientSecret,
aAppDetails,
*iMediaPlayer));
#endif // ENABLE_TIDAL

#ifdef ENABLE_QOBUZ
// You must define your QOBUZ appId and secret key
iMediaPlayer->Add(ProtocolFactory::NewQobuz(
Brn(QOBUZ_APPID),
Brn(QOBUZ_SECRET),
*iMediaPlayer));
QoubusAuthClientId,
QoubusAuthClientSecret,
*iMediaPlayer,
iUserAgent));
#endif // ENABLE_QOBUZ

#ifdef ENABLE_RADIO
// Radio is disabled by default as many stations depend on AAC
iMediaPlayer->Add(SourceFactory::NewRadio(*iMediaPlayer,
Brn(TUNEIN_PARTNER_ID)));
TuneinAuthPartnerId));
#endif // ENABLE_RADIO
}

Expand Down Expand Up @@ -380,12 +394,13 @@ void ExampleMediaPlayer::AddConfigApp()
iMediaPlayer->ConfigManager(),
iFileResourceHandlerFactory,
sourcesBufs,
Brn("Softplayer"),
Brn("/usr/share/"
"openhome-player/res/"),
30,
kPlayerName,
kResourceDir,
kMinWebUiResourceThreads,
kMaxUiTabs,
kUiSendQueueSize,
kUiMsgBufCount,
kUiMsgBufBytes,
iRebootHandler);

iAppFramework->Add(iConfigApp, // iAppFramework takes ownership
Expand Down Expand Up @@ -425,7 +440,7 @@ OpenHome::Net::Library* ExampleMediaPlayerInit::CreateLibrary(TIpAddress preferr
{
TUint index = 0;
InitialisationParams *initParams = InitialisationParams::Create();
TIpAddress lastSubnet = InitArgs::NO_SUBNET;
TIpAddress lastSubnet = TIpAddress();
const TChar *lastSubnetStr = "Subnet.LastUsed";

//initParams->SetDvEnableBonjour();
Expand All @@ -445,9 +460,11 @@ OpenHome::Net::Library* ExampleMediaPlayerInit::CreateLibrary(TIpAddress preferr
// Check the configuration store for the last subnet joined.
try
{
Bwn lastSubnetBuf = Bwn((TByte *)&lastSubnet, sizeof(lastSubnet));

configStore->Read(Brn(lastSubnetStr), lastSubnetBuf);
if(!TIpAddressUtils::IsZero(lastSubnet))
{
Bwn lastSubnetBuf = Bwn((TByte *)&lastSubnet, sizeof(lastSubnet));
configStore->Read(Brn(lastSubnetStr), lastSubnetBuf);
}
}
catch (StoreKeyNotFound&)
{
Expand All @@ -464,9 +481,10 @@ OpenHome::Net::Library* ExampleMediaPlayerInit::CreateLibrary(TIpAddress preferr
{
TIpAddress subnet = (*subnetList)[i]->Subnet();

// If the requested subnet is available, choose it.
const TBool isPreferredSubnet = preferredSubnet.iFamily == kFamilyV4 ? CompareIPv4Addrs(preferredSubnet, subnet)
: CompareIPv6Addrs(preferredSubnet, subnet);
// If the requested subnet is available, choose it

const TBool isPreferredSubnet = TIpAddressUtils::Equals(preferredSubnet, subnet);

if (isPreferredSubnet)
{
index = i;
Expand All @@ -475,8 +493,7 @@ OpenHome::Net::Library* ExampleMediaPlayerInit::CreateLibrary(TIpAddress preferr

// If the last used subnet is available, note it.
// We'll fall back to it if the requested subnet is not available.
const TBool isLastSubnet = lastSubnet.iFamily == kFamilyV4 ? CompareIPv4Addrs(lastSubnet, subnet)
: CompareIPv6Addrs(lastSubnet, subnet);
const TBool isLastSubnet = TIpAddressUtils::Equals(lastSubnet, subnet);

if (isLastSubnet)
{
Expand All @@ -494,25 +511,9 @@ OpenHome::Net::Library* ExampleMediaPlayerInit::CreateLibrary(TIpAddress preferr
configStore->Write(Brn(lastSubnetStr),
Brn((TByte *)&subnet, sizeof(subnet)));

if (subnet.iFamily == kFamilyV4)
{
Log::Print("Using Subnet %d.%d.%d.%d\n", subnet.iV4 & 0xff,
(subnet.iV4 >> 8) & 0xff,
(subnet.iV4 >> 16) & 0xff,
(subnet.iV4 >> 24) & 0xff);
}
else
{
Log::Print("Using Subnet: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
subnet.iV6[0], subnet.iV6[1],
subnet.iV6[2], subnet.iV6[3],
subnet.iV6[4], subnet.iV6[5],
subnet.iV6[6], subnet.iV6[7],
subnet.iV6[8], subnet.iV6[9],
subnet.iV6[10], subnet.iV6[11],
subnet.iV6[12], subnet.iV6[13],
subnet.iV6[14], subnet.iV6[15]);
}
Bws<TIpAddressUtils::kMaxAddressBytes> addressBuf;
TIpAddressUtils::ToString(subnet, addressBuf);
Log::Print("using subnet %.*s\n", PBUF(addressBuf));

return lib;
}
28 changes: 9 additions & 19 deletions linux/ExampleMediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,19 @@ namespace Av {
class RamStore;
class ControlPointProxy;

// Helpers
static TBool CompareIPv4Addrs(const TIpAddress addr1,
const TIpAddress addr2)
{
return addr1.iFamily == kFamilyV4
&& addr2.iFamily == kFamilyV4
&& addr1.iV4 == addr2.iV4;
}

static TBool CompareIPv6Addrs(const TIpAddress addr1,
const TIpAddress addr2)
{
return addr1.iFamily == kFamilyV6
&& addr2.iFamily == kFamilyV6
&& memcmp((TByte*)addr1.iV6[0], (TByte*)addr2.iV6[0], 16) == 0;
}



class ExampleMediaPlayer : private Net::IResourceManager
{
static const Brn kIconOpenHomeFileName;
static const TUint kMinWebUiResourceThreads = 30; //Resource handler count
static const TUint kMaxUiTabs = 4;
static const TUint kUiSendQueueSize = kMaxUiTabs * 200;
static const TUint kUiMsgBufCount = kUiSendQueueSize + ((kUiSendQueueSize + 1) / 2);
static const TUint kUiMsgBufBytes = 16;
static const TUint kMaxPinsDevice = 6;
static const TUint kShellPort = 2323;
static const Brn kResourceDir;
static const Brn kPlayerName;

public:
ExampleMediaPlayer(Net::DvStack& aDvStack, Net::CpStack& aCpStack,
const Brx& aUdn,
Expand Down Expand Up @@ -113,9 +101,11 @@ class ExampleMediaPlayer : private Net::IResourceManager
Semaphore iSemShutdown;
Web::WebAppFramework *iAppFramework;
RebootLogger iRebootHandler;

private:
Semaphore iDisabled;
Av::VolumeControl iVolume;
Media::AudioTimeCpu *iAudioTime;
ControlPointProxy *iCpProxy;
IOhmTimestamper *iTxTimestamper;
IOhmTimestamper *iRxTimestamper;
Expand Down
Loading