Added a skeleton plugin for sndio. Also updated build script stuff to not include ALSA for FreeBSD.

This commit is contained in:
casey langen 2017-12-21 09:08:21 +00:00
parent e2f247669a
commit 402008e148
6 changed files with 253 additions and 6 deletions

View File

@ -102,11 +102,14 @@ endif()
add_dependencies(taglibreader taglib)
if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_subdirectory(src/plugins/alsaout)
add_subdirectory(src/plugins/pulseout)
else()
add_subdirectory(src/plugins/coreaudioout) # macOS
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_subdirectory(src/plugins/sndioout)
add_subdirectory(src/plugins/pulseout)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(src/plugins/coreaudioout)
endif()
# install the binary
@ -119,12 +122,18 @@ install(
# install the plugins
if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(ADDITIONAL_OUTPUTS bin/plugins/libalsaout.so)
else()
set(ADDITIONAL_OUTPUTS bin/plugins/libsndioout.so)
endif()
if (${FFMPEG_DECODER} MATCHES "true")
install(
FILES
bin/plugins/libalsaout.so
bin/plugins/libpulseout.so
bin/plugins/libnullout.so
${ADDITIONAL_OUTPUTS}
bin/plugins/libffmpegdecoder.so
bin/plugins/libtaglibreader.so
bin/plugins/libserver.so
@ -134,9 +143,9 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
else()
install(
FILES
bin/plugins/libalsaout.so
bin/plugins/libpulseout.so
bin/plugins/libnullout.so
${ADDITIONAL_OUTPUTS}
bin/plugins/libflacdecoder.so
bin/plugins/libm4adecoder.so
bin/plugins/libnomaddecoder.so

View File

@ -53,6 +53,8 @@ using OutputList = std::vector<Output>;
static const std::string defaultOutput = "WASAPI";
#elif defined(__APPLE__)
static const std::string defaultOutput = "CoreAudio";
#elif defined(__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__DragonFly__)
static const std::string defaultOutput = "sndio";
#else
static const std::string defaultOutput = "PulseAudio";
#endif
@ -131,4 +133,4 @@ namespace musik {
}
}
}
}
}

View File

@ -0,0 +1,7 @@
set (sndioout_SOURCES
plugin.cpp
SndioOut.cpp
)
add_library(sndioout SHARED ${sndioout_SOURCES})
target_link_libraries(sndioout ${musikcube_LINK_LIBS})

View File

@ -0,0 +1,100 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2017 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "SndioOut.h"
#include <core/sdk/constants.h>
#include <core/sdk/IPreferences.h>
using namespace musik::core::sdk;
SndioOut::SndioOut() {
this->volume = 1.0f;
this->state = StateStopped;
}
SndioOut::~SndioOut() {
}
void SndioOut::Release() {
delete this;
}
void SndioOut::Pause() {
this->state = StatePaused;
}
void SndioOut::Resume() {
this->state = StatePlaying;
}
void SndioOut::SetVolume(double volume) {
this->volume = volume;
}
double SndioOut::GetVolume() {
return this->volume;
}
void SndioOut::Stop() {
this->state = StateStopped;
}
void SndioOut::Drain() {
}
IDeviceList* SndioOut::GetDeviceList() {
return nullptr;
}
bool SndioOut::SetDefaultDevice(const char* deviceId) {
return false;
}
IDevice* SndioOut::GetDefaultDevice() {
return nullptr;
}
int SndioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
if (this->state == StatePaused) {
return OutputInvalidState;
}
return OutputBufferWritten;
}
double SndioOut::Latency() {
return 0.0;
}

View File

@ -0,0 +1,71 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2017 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/sdk/IOutput.h>
using namespace musik::core::sdk;
class SndioOut : public IOutput {
public:
SndioOut();
~SndioOut();
/* IPlugin */
virtual const char* Name() override { return "sndio"; };
virtual void Release() override;
/* IOutput */
virtual void Pause() override;
virtual void Resume() override;
virtual void SetVolume(double volume) override;
virtual double GetVolume() override;
virtual void Stop() override;
virtual int Play(IBuffer *buffer, IBufferProvider *provider) override;
virtual double Latency() override;
virtual void Drain() override;
virtual IDeviceList* GetDeviceList() override;
virtual bool SetDefaultDevice(const char* deviceId) override;
virtual IDevice* GetDefaultDevice() override;
private:
enum State {
StateStopped,
StatePaused,
StatePlaying
};
State state;
double volume;
};

View File

@ -0,0 +1,58 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2017 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include <core/sdk/constants.h>
#include <core/sdk/IPlugin.h>
#include "SndioOut.h"
class SndioPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Release() { delete this; }
virtual const char* Name() { return "Sndio IOutput"; }
virtual const char* Version() { return "0.1.0"; }
virtual const char* Author() { return "clangen"; }
virtual const char* Guid() { return "13903ab8-b387-4de9-86e3-14ba22057dcd"; }
virtual bool Configurable() { return false; }
virtual void Configure() { }
virtual void Reload() { }
virtual int SdkVersion() { return musik::core::sdk::SdkVersion; }
};
extern "C" musik::core::sdk::IPlugin* GetPlugin() {
return new SndioPlugin();
}
extern "C" musik::core::sdk::IOutput* GetAudioOutput() {
return new SndioOut();
}