Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AESinkFactory: Adjust Sndio #13183

Merged
merged 1 commit into from Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/modules/FindSndio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ find_package_handle_standard_args(Sndio
if(SNDIO_FOUND)
set(SNDIO_INCLUDE_DIRS ${SNDIO_INCLUDE_DIR})
set(SNDIO_LIBRARIES ${SNDIO_LIBRARY})
set(SNDIO_DEFINITIONS -DHAVE_SNDIO=1)
set(SNDIO_DEFINITIONS -DHAS_SNDIO=1)

if(NOT TARGET Sndio::Sndio)
add_library(Sndio::Sndio UNKNOWN IMPORTED)
set_target_properties(Sndio::Sndio PROPERTIES
IMPORTED_LOCATION "${SNDIO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SNDIO_INCLUDE_DIR}")
set_target_properties(Sndio::Sndio PROPERTIES
INTERFACE_COMPILE_DEFINITIONS -DHAVE_SNDIO=1)
INTERFACE_COMPILE_DEFINITIONS -DHAS_SNDIO=1)
endif()
endif()

Expand Down
20 changes: 20 additions & 0 deletions xbmc/cores/AudioEngine/Sinks/AESinkSNDIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "system.h"
#ifdef HAS_SNDIO
#include "AESinkSNDIO.h"
#include "cores/AudioEngine/AESinkFactory.h"
#include "cores/AudioEngine/Utils/AEUtil.h"
#include "utils/log.h"

Expand Down Expand Up @@ -158,6 +159,25 @@ CAESinkSNDIO::~CAESinkSNDIO()
Deinitialize();
}

void CAESinkSNDIO::Register()
{
AE::AESinkRegEntry entry;
entry.sinkName = "SNDIO";
entry.createFunc = CAESinkSNDIO::Create;
entry.enumerateFunc = CAESinkSNDIO::EnumerateDevicesEx;
AE::CAESinkFactory::RegisterSink(entry);
}

IAESink* CAESinkSNDIO::Create(std::string &device, AEAudioFormat& desiredFormat)
{
IAESink* sink = new CAESinkSNDIO();
if (sink->Initialize(desiredFormat, device))
return sink;

delete sink;
return nullptr;
}

bool CAESinkSNDIO::Initialize(AEAudioFormat &format, std::string &device)
{
if ((m_hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0)) == nullptr)
Expand Down
5 changes: 4 additions & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkSNDIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class CAESinkSNDIO : public IAESink
CAESinkSNDIO();
~CAESinkSNDIO() override;

static void Register();
static IAESink* Create(std::string &device, AEAudioFormat &desiredFormat);
static void EnumerateDevicesEx(AEDeviceInfoList &list, bool force = false);

bool Initialize(AEAudioFormat &format, std::string &device) override;
void Deinitialize() override;

Expand All @@ -43,7 +47,6 @@ class CAESinkSNDIO : public IAESink
double GetCacheTotal() override { return 0.0; }
unsigned int AddPackets(uint8_t **data, unsigned int frames, unsigned int offset) override;
void Drain() override;
static void EnumerateDevicesEx(AEDeviceInfoList &list, bool force = false);
private:
void AudioFormatToPar(AEAudioFormat& format);
bool ParToAudioFormat(AEAudioFormat& format);
Expand Down
3 changes: 0 additions & 3 deletions xbmc/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@
#ifdef HAVE_LIRC
#define HAS_LIRC
#endif
#ifdef HAVE_SNDIO
#define HAS_SNDIO
#endif
#endif

#ifdef HAVE_LIBSSH
Expand Down
18 changes: 18 additions & 0 deletions xbmc/windowing/X11/OptionalsReg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,21 @@ bool X11::PulseAudioRegister()
return false;
}
#endif

//-----------------------------------------------------------------------------
// sndio
//-----------------------------------------------------------------------------

#ifdef HAS_SNDIO
#include "cores/AudioEngine/Sinks/AESinkSNDIO.h"
bool X11::SndioRegister()
{
CAESinkSNDIO::Register();
return true;
}
#else
bool X11::SndioRegister()
{
return false;
}
#endif
9 changes: 9 additions & 0 deletions xbmc/windowing/X11/OptionalsReg.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ namespace X11
{
bool PulseAudioRegister();
}

//-----------------------------------------------------------------------------
// sndio
//-----------------------------------------------------------------------------

namespace X11
{
bool SndioRegister();
}
9 changes: 8 additions & 1 deletion xbmc/windowing/X11/WinSystemX11GLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,18 @@ CWinSystemX11GLContext::CWinSystemX11GLContext()
{
X11::PulseAudioRegister();
}
else if (StringUtils::EqualsNoCase(envSink, "SNDIO"))
{
X11::SndioRegister();
}
else
{
if (!X11::PulseAudioRegister())
{
X11::ALSARegister();
if (!X11::ALSARegister())

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

{
X11::SndioRegister();
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions xbmc/windowing/gbm/OptionalsReg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,21 @@ bool GBM::PulseAudioRegister()
return false;
}
#endif

//-----------------------------------------------------------------------------
// sndio
//-----------------------------------------------------------------------------

#ifdef HAS_SNDIO
#include "cores/AudioEngine/Sinks/AESinkSNDIO.h"
bool GBM::SndioRegister()
{
CAESinkSNDIO::Register();
return true;
}
#else
bool GBM::SndioRegister()
{
return false;
}
#endif
9 changes: 9 additions & 0 deletions xbmc/windowing/gbm/OptionalsReg.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,12 @@ namespace GBM
{
bool PulseAudioRegister();
}

//-----------------------------------------------------------------------------
// sndio
//-----------------------------------------------------------------------------

namespace GBM
{
bool SndioRegister();
}
11 changes: 9 additions & 2 deletions xbmc/windowing/gbm/WinSystemGbm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@ CWinSystemGbm::CWinSystemGbm() :
}
else if (StringUtils::EqualsNoCase(envSink, "PULSE"))
{
GBM::PulseAudioRegister();
GBM::PulseAudioRegister();
}
else if (StringUtils::EqualsNoCase(envSink, "SNDIO"))
{
GBM::SndioRegister();
}
else
{
if (!GBM::PulseAudioRegister())
{
GBM::ALSARegister();
if (!GBM::ALSARegister())
{
GBM::SndioRegister();
}
}
}

Expand Down
18 changes: 18 additions & 0 deletions xbmc/windowing/wayland/OptionalsReg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,21 @@ bool WAYLAND::PulseAudioRegister()
return false;
}
#endif

//-----------------------------------------------------------------------------
// sndio
//-----------------------------------------------------------------------------

#ifdef HAS_SNDIO
#include "cores/AudioEngine/Sinks/AESinkSNDIO.h"
bool WAYLAND::SndioRegister()
{
CAESinkSNDIO::Register();
return true;
}
#else
bool WAYLAND::SndioRegister()
{
return false;
}
#endif
9 changes: 9 additions & 0 deletions xbmc/windowing/wayland/OptionalsReg.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ namespace WAYLAND
{
bool PulseAudioRegister();
}

//-----------------------------------------------------------------------------
// sndio
//-----------------------------------------------------------------------------

namespace WAYLAND
{
bool SndioRegister();
}
9 changes: 8 additions & 1 deletion xbmc/windowing/wayland/WinSystemWayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,18 @@ CWinSystemWayland::CWinSystemWayland()
{
::WAYLAND::PulseAudioRegister();
}
else if (StringUtils::EqualsNoCase(envSink, "SNDIO"))
{
::WAYLAND::SndioRegister();
}
else
{
if (!::WAYLAND::PulseAudioRegister())
{
::WAYLAND::ALSARegister();
if (!::WAYLAND::ALSARegister())
{
::WAYLAND::SndioRegister();
}
}
}
m_winEvents.reset(new CWinEventsWayland());
Expand Down