Commit 9574d11d authored by Max Kellermann's avatar Max Kellermann

output/sles: new output plugin for Android

parent 3d468975
......@@ -1078,6 +1078,17 @@ liboutput_plugins_a_SOURCES += \
libmixer_plugins_a_SOURCES += src/mixer/plugins/AlsaMixerPlugin.cxx
endif
if ANDROID
liboutput_plugins_a_SOURCES += \
src/output/plugins/sles/Object.hxx \
src/output/plugins/sles/Engine.hxx \
src/output/plugins/sles/Play.hxx \
src/output/plugins/sles/AndroidSimpleBufferQueue.hxx \
src/output/plugins/sles/SlesOutputPlugin.cxx \
src/output/plugins/sles/SlesOutputPlugin.hxx
OUTPUT_LIBS += -lOpenSLES
endif
if HAVE_ROAR
liboutput_plugins_a_SOURCES += \
src/output/plugins/RoarOutputPlugin.cxx \
......
......@@ -34,6 +34,7 @@
#include "plugins/RecorderOutputPlugin.hxx"
#include "plugins/RoarOutputPlugin.hxx"
#include "plugins/ShoutOutputPlugin.hxx"
#include "plugins/sles/SlesOutputPlugin.hxx"
#include "plugins/SolarisOutputPlugin.hxx"
#include "plugins/WinmmOutputPlugin.hxx"
......@@ -44,6 +45,9 @@ const AudioOutputPlugin *const audio_output_plugins[] = {
&shout_output_plugin,
#endif
&null_output_plugin,
#ifdef ANDROID
&sles_output_plugin,
#endif
#ifdef HAVE_FIFO
&fifo_output_plugin,
#endif
......
/*
* Copyright (C) 2011-2012 Max Kellermann <max@duempel.org>
*
* 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.
*
* 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
* FOUNDATION 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.
*/
#ifndef SLES_ANDROID_SIMPLE_BUFFER_QUEUE_HPP
#define SLES_ANDROID_SIMPLE_BUFFER_QUEUE_HPP
#include <SLES/OpenSLES_Android.h>
namespace SLES {
/**
* OO wrapper for an OpenSL/ES SLAndroidSimpleBufferQueueItf
* variable.
*/
class AndroidSimpleBufferQueue {
SLAndroidSimpleBufferQueueItf queue;
public:
AndroidSimpleBufferQueue() = default;
explicit AndroidSimpleBufferQueue(SLAndroidSimpleBufferQueueItf _queue)
:queue(_queue) {}
SLresult Enqueue(const void *pBuffer, SLuint32 size) {
return (*queue)->Enqueue(queue, pBuffer, size);
}
SLresult Clear() {
return (*queue)->Clear(queue);
}
SLresult GetState(SLAndroidSimpleBufferQueueState *pState) {
return (*queue)->GetState(queue, pState);
}
SLresult RegisterCallback(slAndroidSimpleBufferQueueCallback callback,
void *pContext) {
return (*queue)->RegisterCallback(queue, callback, pContext);
}
};
}
#endif
/*
* Copyright (C) 2011-2012 Max Kellermann <max@duempel.org>
*
* 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.
*
* 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
* FOUNDATION 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.
*/
#ifndef SLES_ENGINE_HPP
#define SLES_ENGINE_HPP
#include <SLES/OpenSLES.h>
namespace SLES {
/**
* OO wrapper for an OpenSL/ES SLEngineItf variable.
*/
class Engine {
SLEngineItf engine;
public:
Engine() = default;
explicit Engine(SLEngineItf _engine):engine(_engine) {}
SLresult CreateAudioPlayer(SLObjectItf *pPlayer,
SLDataSource *pAudioSrc, SLDataSink *pAudioSnk,
SLuint32 numInterfaces,
const SLInterfaceID *pInterfaceIds,
const SLboolean *pInterfaceRequired) {
return (*engine)->CreateAudioPlayer(engine, pPlayer,
pAudioSrc, pAudioSnk,
numInterfaces, pInterfaceIds,
pInterfaceRequired);
}
SLresult CreateOutputMix(SLObjectItf *pMix,
SLuint32 numInterfaces,
const SLInterfaceID *pInterfaceIds,
const SLboolean *pInterfaceRequired) {
return (*engine)->CreateOutputMix(engine, pMix,
numInterfaces, pInterfaceIds,
pInterfaceRequired);
}
};
}
#endif
/*
* Copyright (C) 2011-2012 Max Kellermann <max@duempel.org>
*
* 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.
*
* 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
* FOUNDATION 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.
*/
#ifndef SLES_OBJECT_HPP
#define SLES_OBJECT_HPP
#include <SLES/OpenSLES.h>
namespace SLES {
/**
* OO wrapper for an OpenSL/ES SLObjectItf variable.
*/
class Object {
SLObjectItf object;
public:
Object() = default;
explicit Object(SLObjectItf _object):object(_object) {}
operator SLObjectItf() {
return object;
}
SLresult Realize(bool async) {
return (*object)->Realize(object, async);
}
void Destroy() {
(*object)->Destroy(object);
}
SLresult GetInterface(const SLInterfaceID iid, void *pInterface) {
return (*object)->GetInterface(object, iid, pInterface);
}
};
}
#endif
/*
* Copyright (C) 2011-2012 Max Kellermann <max@duempel.org>
*
* 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.
*
* 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
* FOUNDATION 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.
*/
#ifndef SLES_PLAY_HPP
#define SLES_PLAY_HPP
#include <SLES/OpenSLES.h>
namespace SLES {
/**
* OO wrapper for an OpenSL/ES SLPlayItf variable.
*/
class Play {
SLPlayItf play;
public:
Play() = default;
explicit Play(SLPlayItf _play):play(_play) {}
SLresult SetPlayState(SLuint32 state) {
return (*play)->SetPlayState(play, state);
}
};
}
#endif
/*
* Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_SLES_OUTPUT_PLUGIN_HXX
#define MPD_SLES_OUTPUT_PLUGIN_HXX
extern const struct AudioOutputPlugin sles_output_plugin;
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment