mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-12 07:13:23 +00:00
Added a skeleton plugin for sndio. Also updated build script stuff to not include ALSA for FreeBSD.
This commit is contained in:
parent
e2f247669a
commit
402008e148
@ -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
|
||||
|
@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
7
src/plugins/sndioout/CMakeLists.txt
Normal file
7
src/plugins/sndioout/CMakeLists.txt
Normal 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})
|
100
src/plugins/sndioout/SndioOut.cpp
Normal file
100
src/plugins/sndioout/SndioOut.cpp
Normal 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;
|
||||
}
|
71
src/plugins/sndioout/SndioOut.h
Normal file
71
src/plugins/sndioout/SndioOut.h
Normal 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;
|
||||
};
|
58
src/plugins/sndioout/plugin.cpp
Normal file
58
src/plugins/sndioout/plugin.cpp
Normal 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();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user