commit b4697bcfd6567f704e01927fdaf77f3ab5b9112b Author: Slávek Banko Date: Thu Oct 15 04:46:45 2015 +0200 Rename completely from polyp to pulse Signed-off-by: Slávek Banko diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 635db2e..838fb28 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -116,7 +116,7 @@ if( WITH_OSS_SINK ) endif( WITH_OSS_SINK ) -##### check polyp support ####################### +##### check pulse support ####################### if( WITH_PULSE_SINK ) diff --git a/PACKAGING b/PACKAGING index da75139..8cbd9f1 100644 --- a/PACKAGING +++ b/PACKAGING @@ -7,9 +7,9 @@ Take especially note of the following: - If you wish to install plugins in a non-standard place, you can change the AKODE_SEARCHDIR definition in lib/pluginhandler.cpp. - You SHOULD not install sinks for backends you don't use. Thus jack_sink - should only be installed when jackd is available, polyp_sink only when - the polypaudio server is used and alsa_sink only when using a Linux kernel + should only be installed when jackd is available, pulse_sink only when + the PulseAudio server is used and alsa_sink only when using a Linux kernel with ALSA drivers. When using direct aKode playback sinks will be autodetected by loading and - probing plugins in this order: polyp, jack, alsa, oss + probing plugins in this order: pulse, jack, alsa, oss diff --git a/akode/PACKAGING b/akode/PACKAGING index da75139..8cbd9f1 100644 --- a/akode/PACKAGING +++ b/akode/PACKAGING @@ -7,9 +7,9 @@ Take especially note of the following: - If you wish to install plugins in a non-standard place, you can change the AKODE_SEARCHDIR definition in lib/pluginhandler.cpp. - You SHOULD not install sinks for backends you don't use. Thus jack_sink - should only be installed when jackd is available, polyp_sink only when - the polypaudio server is used and alsa_sink only when using a Linux kernel + should only be installed when jackd is available, pulse_sink only when + the PulseAudio server is used and alsa_sink only when using a Linux kernel with ALSA drivers. When using direct aKode playback sinks will be autodetected by loading and - probing plugins in this order: polyp, jack, alsa, oss + probing plugins in this order: pulse, jack, alsa, oss diff --git a/akode/configure.in.in b/akode/configure.in.in index 80338d5..80d0114 100644 --- a/akode/configure.in.in +++ b/akode/configure.in.in @@ -270,24 +270,24 @@ AC_SUBST(JACK_LIBADD) AC_SUBST(JACK_LDFLAGS) fi -AC_ARG_WITH(polypaudio,AC_HELP_STRING([--with-polypaudio],[Enable Polypaudio server support @<:@default=check@:>@]),[polypaudio_test="$withval"],[polypaudio_test="yes"]) - -if test "x$polypaudio_test" = "xyes" ; then -AC_MSG_CHECKING(for Polypaudio 0.7 or later) -if $PKG_CONFIG --atleast-version 0.7 polyplib-simple >/dev/null 2>&1 ; then - POLYP_CFLAGS="`$PKG_CONFIG --cflags polyplib-simple`" - POLYP_LIBADD="`$PKG_CONFIG --libs-only-l polyplib-simple`" - POLYP_LDFLAGS="`$PKG_CONFIG --libs-only-L polyplib-simple`" - have_polyp=yes +AC_ARG_WITH(pulseaudio,AC_HELP_STRING([--with-pulseaudio],[Enable PulseAudio server support @<:@default=check@:>@]),[pulseaudio_test="$withval"],[pulseaudio_test="yes"]) + +if test "x$pulseaudio_test" = "xyes" ; then +AC_MSG_CHECKING(for pulseaudio 0.9.2 or later) +if $PKG_CONFIG --atleast-version 0.9.2 libpulse-simple >/dev/null 2>&1 ; then + PULSE_CFLAGS="`$PKG_CONFIG --cflags libpulse-simple`" + PULSE_LIBADD="`$PKG_CONFIG --libs-only-l libpulse-simple`" + PULSE_LDFLAGS="`$PKG_CONFIG --libs-only-L libpulse-simple`" + have_pulse=yes AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_LIBPOLYP, 1, - [Define if you have polyplib (required if you want Polypaudio server support)]) + AC_DEFINE(HAVE_LIBPULSE, 1, + [Define if you have libpulse (required if you want PulseAudio server support)]) else AC_MSG_RESULT(not installed) fi -AC_SUBST(POLYP_CFLAGS) -AC_SUBST(POLYP_LIBADD) -AC_SUBST(POLYP_LDFLAGS) +AC_SUBST(PULSE_CFLAGS) +AC_SUBST(PULSE_LIBADD) +AC_SUBST(PULSE_LDFLAGS) fi AC_ARG_WITH(ffmpeg,AC_HELP_STRING([--with-ffmpeg],[Enable experimental FFMPEG decoder support @<:@default=check@:>@]),[ffmpeg_test="$withval"],[ffmpeg_test="yes"]) @@ -482,7 +482,7 @@ AM_CONDITIONAL(include_alsa_sink, test x$have_alsa = xyes) AM_CONDITIONAL(include_oss_sink, test x$have_oss = xyes) AM_CONDITIONAL(include_sun_sink, test x$have_sun = xyes) AM_CONDITIONAL(include_jack_sink, test x$have_jack = xyes) -AM_CONDITIONAL(include_polyp_sink, test x$have_polyp = xyes) +AM_CONDITIONAL(include_pulse_sink, test x$have_pulse = xyes) AM_CONDITIONAL(include_ffmpeg_decoder, test x$have_ffmpeg = xyes) AC_MSG_CHECKING(for compilable aKode) diff --git a/akode/lib/auto_sink.cpp b/akode/lib/auto_sink.cpp index bcc1250..bee17b1 100644 --- a/akode/lib/auto_sink.cpp +++ b/akode/lib/auto_sink.cpp @@ -65,8 +65,8 @@ AutoSink::~AutoSink() bool AutoSink::open() { // Try Polypaudio - if (getenv("POLYP_SERVER")) - if (m_data->tryOpen("polyp")) return true; + if (getenv("PULSE_SERVER")) + if (m_data->tryOpen("pulse")) return true; // Try Jack if (m_data->tryOpen("jack")) return true; // Try ALSA diff --git a/akode/plugins/CMakeLists.txt b/akode/plugins/CMakeLists.txt index 6e11f1a..89bcfd1 100644 --- a/akode/plugins/CMakeLists.txt +++ b/akode/plugins/CMakeLists.txt @@ -15,7 +15,7 @@ tde_conditional_add_subdirectory( WITH_ALSA_SINK alsa_sink ) tde_conditional_add_subdirectory( WITH_JACK_SINK jack_sink ) tde_conditional_add_subdirectory( WITH_OSS_SINK oss_sink ) -tde_conditional_add_subdirectory( WITH_PULSE_SINK polyp_sink ) +tde_conditional_add_subdirectory( WITH_PULSE_SINK pulse_sink ) tde_conditional_add_subdirectory( WITH_SUN_SINK sun_sink ) tde_conditional_add_subdirectory( WITH_FFMPEG_DECODER ffmpeg_decoder ) diff --git a/akode/plugins/Makefile.am b/akode/plugins/Makefile.am index 74f27e5..4a13c85 100644 --- a/akode/plugins/Makefile.am +++ b/akode/plugins/Makefile.am @@ -32,12 +32,12 @@ if include_jack_sink AKODE_JACK_SINK=jack_sink endif -if include_polyp_sink -AKODE_POLYP_SINK=polyp_sink +if include_pulse_sink +AKODE_PULSE_SINK=pulse_sink endif SUBDIRS= $(AKODE_MPC_DECODER) $(AKODE_XIPH_DECODER) \ $(AKODE_MPEG_DECODER) $(AKODE_FFMPEG_DECODER) \ $(AKODE_ALSA_SINK) $(AKODE_OSS_SINK) $(AKODE_SUN_SINK) \ - $(AKODE_JACK_SINK) $(AKODE_POLYP_SINK) \ + $(AKODE_JACK_SINK) $(AKODE_PULSE_SINK) \ $(AKODE_SRC_RESAMPLER) diff --git a/akode/plugins/polyp_sink/CMakeLists.txt b/akode/plugins/polyp_sink/CMakeLists.txt deleted file mode 100644 index 28a940e..0000000 --- a/akode/plugins/polyp_sink/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -################################################# -# -# (C) 2015 Slávek Banko -# slavek (DOT) banko (AT) axis.cz -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/akode/lib - ${CMAKE_SOURCE_DIR}/akode/lib - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${PULSE_INCLUDE_DIRS} -) - - -##### library ################################### - -set( target libakode_polyp_sink ) - -tde_add_library( - ${target} MODULE - SOURCES polyp_sink.cpp - LINK akode-shared ${PULSE_LIBRARIES} - DESTINATION ${LIB_INSTALL_DIR} -) - diff --git a/akode/plugins/polyp_sink/Makefile.am b/akode/plugins/polyp_sink/Makefile.am deleted file mode 100644 index a58b04c..0000000 --- a/akode/plugins/polyp_sink/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -INCLUDES = -I$(top_srcdir)/akode/lib -I$(top_builddir)/akode/lib $(PULSE_CFLAGS) $(all_includes) - -lib_LTLIBRARIES = libakode_polyp_sink.la - -libakode_polyp_sink_la_SOURCES = polyp_sink.cpp -libakode_polyp_sink_la_LDFLAGS = -module -avoid-version -no-undefined $(PULSE_LDFLAGS) -libakode_polyp_sink_la_LIBADD = ../../lib/libakode.la $(PULSE_LIBADD) diff --git a/akode/plugins/polyp_sink/polyp_sink.cpp b/akode/plugins/polyp_sink/polyp_sink.cpp deleted file mode 100644 index b48b63e..0000000 --- a/akode/plugins/polyp_sink/polyp_sink.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* aKode: Polyp-Sink - - Copyright (C) 2004 Allan Sandfeld Jensen - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#ifdef HAVE_STDINT_H -#include -#elif defined(HAVE_INTTYPES_H) -#include -#endif -#include - -#include "audioframe.h" -#include "audiobuffer.h" -#include "polyp_sink.h" - -#include - -namespace aKode { - -extern "C" { PolypSinkPlugin polyp_sink; }; - -struct PolypSink::private_data -{ - private_data() : server(0), error(false) {}; - - pa_simple *server; - pa_sample_spec sample_spec; - - bool error; - - AudioConfiguration config; -}; - -PolypSink::PolypSink() -{ - m_data = new private_data; - m_data->sample_spec.rate = 44100; - m_data->sample_spec.channels = 2; - m_data->sample_spec.format = PA_SAMPLE_S16NE; -} - -bool PolypSink::open() { - int error = 0; - m_data->server = pa_simple_new(0, "akode-client", PA_STREAM_PLAYBACK, 0, "", &m_data->sample_spec, 0, 0, &error ); - if (!m_data->server || error != 0) { - m_data->error = true; - close(); - std::cout << "Cannot open client\n"; - return false; - } - - - return true; -} - -void PolypSink::close() { - if (m_data->server) { - pa_simple_free(m_data->server); - m_data->server = 0; - } -} - -PolypSink::~PolypSink() -{ - close(); - delete m_data; -} - -int PolypSink::setAudioConfiguration(const AudioConfiguration* config) -{ - if (m_data->error) return -1; - - int res = 0; - if (*config == m_data->config) return 0; - m_data->config = *config; - - if (config->channel_config != MonoStereo ) return -1; - m_data->sample_spec.channels = config->channels; - - if (config->sample_width != 16) { - res = 1; - m_data->config.sample_width = 16; - } - - m_data->sample_spec.rate = config->sample_rate; - - // create new connection - close(); - open(); - - return res; -} - -const AudioConfiguration* PolypSink::audioConfiguration() const -{ - return &m_data->config; -} - -bool PolypSink::writeFrame(AudioFrame* frame) -{ - if ( m_data->error ) return false; - - if ( frame->channels != m_data->config.channels || frame->sample_rate != m_data->config.sample_rate) - { - if (setAudioConfiguration(frame)!=0) - return false; - } - - int channels = m_data->config.channels; - int length = frame->length; - - int16_t *buffer = new int16_t[length*channels]; - int16_t** data = (int16_t**)frame->data; - for(int i = 0; iserver, buffer, channels*length*2, &error); - delete[] buffer; - - return (error == 0); -} - -} // namespace diff --git a/akode/plugins/polyp_sink/polyp_sink.h b/akode/plugins/polyp_sink/polyp_sink.h deleted file mode 100644 index e279ff6..0000000 --- a/akode/plugins/polyp_sink/polyp_sink.h +++ /dev/null @@ -1,60 +0,0 @@ -/* aKode: Polyp-Sink - - Copyright (C) 2004 Allan Sandfeld Jensen - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef _AKODE_POLYP_SINK_H -#define _AKODE_POLYP_SINK_H - -#include "sink.h" - -#include "akode_export.h" - -namespace aKode { - -class AudioConfiguration; -class AudioFrame; - -class PolypSink : public Sink { -public: - PolypSink(); - ~PolypSink(); - bool open(); - void close(); - int setAudioConfiguration(const AudioConfiguration *config); - const AudioConfiguration* audioConfiguration() const; - // Writes blocking - bool writeFrame(AudioFrame *frame); - - struct private_data; -private: - private_data *m_data; -}; - -class PolypSinkPlugin : public SinkPlugin { -public: - virtual PolypSink* openSink() { - return new PolypSink(); - } -}; - -extern "C" AKODE_EXPORT PolypSinkPlugin polyp_sink; - -} // namespace - -#endif diff --git a/akode/plugins/pulse_sink/CMakeLists.txt b/akode/plugins/pulse_sink/CMakeLists.txt new file mode 100644 index 0000000..04026d3 --- /dev/null +++ b/akode/plugins/pulse_sink/CMakeLists.txt @@ -0,0 +1,32 @@ +################################################# +# +# (C) 2015 Slávek Banko +# slavek (DOT) banko (AT) axis.cz +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/akode/lib + ${CMAKE_SOURCE_DIR}/akode/lib + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${PULSE_INCLUDE_DIRS} +) + + +##### library ################################### + +set( target libakode_pulse_sink ) + +tde_add_library( + ${target} MODULE + SOURCES pulse_sink.cpp + LINK akode-shared ${PULSE_LIBRARIES} + DESTINATION ${LIB_INSTALL_DIR} +) + diff --git a/akode/plugins/pulse_sink/Makefile.am b/akode/plugins/pulse_sink/Makefile.am new file mode 100644 index 0000000..9f38245 --- /dev/null +++ b/akode/plugins/pulse_sink/Makefile.am @@ -0,0 +1,7 @@ +INCLUDES = -I$(top_srcdir)/akode/lib -I$(top_builddir)/akode/lib $(PULSE_CFLAGS) $(all_includes) + +lib_LTLIBRARIES = libakode_pulse_sink.la + +libakode_pulse_sink_la_SOURCES = pulse_sink.cpp +libakode_pulse_sink_la_LDFLAGS = -module -avoid-version -no-undefined $(PULSE_LDFLAGS) +libakode_pulse_sink_la_LIBADD = ../../lib/libakode.la $(PULSE_LIBADD) diff --git a/akode/plugins/pulse_sink/pulse_sink.cpp b/akode/plugins/pulse_sink/pulse_sink.cpp new file mode 100644 index 0000000..395bfb3 --- /dev/null +++ b/akode/plugins/pulse_sink/pulse_sink.cpp @@ -0,0 +1,143 @@ +/* aKode: Pulse-Sink + + Copyright (C) 2004 Allan Sandfeld Jensen + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" + +#ifdef HAVE_STDINT_H +#include +#elif defined(HAVE_INTTYPES_H) +#include +#endif +#include + +#include "audioframe.h" +#include "audiobuffer.h" +#include "pulse_sink.h" + +#include + +namespace aKode { + +extern "C" { PulseSinkPlugin pulse_sink; }; + +struct PulseSink::private_data +{ + private_data() : server(0), error(false) {}; + + pa_simple *server; + pa_sample_spec sample_spec; + + bool error; + + AudioConfiguration config; +}; + +PulseSink::PulseSink() +{ + m_data = new private_data; + m_data->sample_spec.rate = 44100; + m_data->sample_spec.channels = 2; + m_data->sample_spec.format = PA_SAMPLE_S16NE; +} + +bool PulseSink::open() { + int error = 0; + m_data->server = pa_simple_new(0, "akode-client", PA_STREAM_PLAYBACK, 0, "", &m_data->sample_spec, 0, 0, &error ); + if (!m_data->server || error != 0) { + m_data->error = true; + close(); + std::cout << "Cannot open client\n"; + return false; + } + + + return true; +} + +void PulseSink::close() { + if (m_data->server) { + pa_simple_free(m_data->server); + m_data->server = 0; + } +} + +PulseSink::~PulseSink() +{ + close(); + delete m_data; +} + +int PulseSink::setAudioConfiguration(const AudioConfiguration* config) +{ + if (m_data->error) return -1; + + int res = 0; + if (*config == m_data->config) return 0; + m_data->config = *config; + + if (config->channel_config != MonoStereo ) return -1; + m_data->sample_spec.channels = config->channels; + + if (config->sample_width != 16) { + res = 1; + m_data->config.sample_width = 16; + } + + m_data->sample_spec.rate = config->sample_rate; + + // create new connection + close(); + open(); + + return res; +} + +const AudioConfiguration* PulseSink::audioConfiguration() const +{ + return &m_data->config; +} + +bool PulseSink::writeFrame(AudioFrame* frame) +{ + if ( m_data->error ) return false; + + if ( frame->channels != m_data->config.channels || frame->sample_rate != m_data->config.sample_rate) + { + if (setAudioConfiguration(frame)!=0) + return false; + } + + int channels = m_data->config.channels; + int length = frame->length; + + int16_t *buffer = new int16_t[length*channels]; + int16_t** data = (int16_t**)frame->data; + for(int i = 0; iserver, buffer, channels*length*2, &error); + delete[] buffer; + + return (error == 0); +} + +} // namespace diff --git a/akode/plugins/pulse_sink/pulse_sink.h b/akode/plugins/pulse_sink/pulse_sink.h new file mode 100644 index 0000000..e890e4a --- /dev/null +++ b/akode/plugins/pulse_sink/pulse_sink.h @@ -0,0 +1,60 @@ +/* aKode: Pulse-Sink + + Copyright (C) 2004 Allan Sandfeld Jensen + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _AKODE_PULSE_SINK_H +#define _AKODE_PULSE_SINK_H + +#include "sink.h" + +#include "akode_export.h" + +namespace aKode { + +class AudioConfiguration; +class AudioFrame; + +class PulseSink : public Sink { +public: + PulseSink(); + ~PulseSink(); + bool open(); + void close(); + int setAudioConfiguration(const AudioConfiguration *config); + const AudioConfiguration* audioConfiguration() const; + // Writes blocking + bool writeFrame(AudioFrame *frame); + + struct private_data; +private: + private_data *m_data; +}; + +class PulseSinkPlugin : public SinkPlugin { +public: + virtual PulseSink* openSink() { + return new PulseSink(); + } +}; + +extern "C" AKODE_EXPORT PulseSinkPlugin pulse_sink; + +} // namespace + +#endif