sndio for akode
ok ratchov
This commit is contained in:
parent
7e86a9aa5f
commit
aa4e53b6ed
@ -1,9 +1,9 @@
|
||||
# $OpenBSD: Makefile,v 1.16 2009/07/19 22:49:12 sthen Exp $
|
||||
# $OpenBSD: Makefile,v 1.17 2009/12/14 00:02:17 jakemsr Exp $
|
||||
|
||||
COMMENT= decoding library for KDE Multimedia
|
||||
|
||||
DISTNAME= akode-2.0.2
|
||||
PKGNAME= ${DISTNAME}p9
|
||||
PKGNAME= ${DISTNAME}p10
|
||||
SHARED_LIBS += akode 2.1 # .2.0
|
||||
|
||||
CATEGORIES= audio multimedia x11/kde
|
||||
@ -29,14 +29,18 @@ LIB_DEPENDS= FLAC.>=8::audio/flac \
|
||||
jack::audio/jack
|
||||
|
||||
WANTLIB= a52 bz2 c faac faad samplerate m mp3lame ogg pthread \
|
||||
oil-0.3 schroedinger-1.0 stdc++ theora x264 z
|
||||
oil-0.3 schroedinger-1.0 sndio stdc++ theora x264 z
|
||||
|
||||
USE_X11= Yes
|
||||
USE_GMAKE= Yes
|
||||
USE_LIBTOOL= Yes
|
||||
|
||||
CONFIGURE_STYLE= autoconf
|
||||
BUILD_DEPENDS= ${MODGNU_AUTOCONF_DEPENDS} \
|
||||
${MODGNU_AUTOMAKE_DEPENDS}
|
||||
|
||||
CONFIGURE_STYLE= gnu
|
||||
AUTOCONF_VERSION= 2.60
|
||||
AUTOMAKE_VERSION= 1.9
|
||||
CONFIGURE= /bin/sh ${WRKDIST}/admin/cvs.sh configure
|
||||
CONFIGURE_ENV= PTHREAD_LIBS=-pthread
|
||||
CONFIGURE_ARGS+= --with-extra-includes=${LOCALBASE}/include \
|
||||
@ -45,4 +49,14 @@ CONFIGURE_ARGS+= --with-extra-includes=${LOCALBASE}/include \
|
||||
--without-polyaudio \
|
||||
--without-oss
|
||||
|
||||
post-extract:
|
||||
mkdir -p ${WRKSRC}/akode/plugins/sndio_sink
|
||||
cp ${FILESDIR}/{Makefile.am,sndio_sink.*} ${WRKSRC}/akode/plugins/sndio_sink
|
||||
|
||||
pre-configure:
|
||||
cd ${WRKSRC} && \
|
||||
AUTOCONF_VERSION=${AUTOCONF_VERSION} \
|
||||
AUTOMAKE_VERSION=${AUTOMAKE_VERSION} \
|
||||
autoreconf -i
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
7
audio/akode/files/Makefile.am
Normal file
7
audio/akode/files/Makefile.am
Normal file
@ -0,0 +1,7 @@
|
||||
INCLUDES = -I$(top_srcdir)/akode/lib -I$(top_builddir)/akode/lib $(all_includes)
|
||||
|
||||
lib_LTLIBRARIES = libakode_sndio_sink.la
|
||||
|
||||
libakode_sndio_sink_la_SOURCES = sndio_sink.cpp
|
||||
libakode_sndio_sink_la_LDFLAGS = -module -avoid-version -no-undefined
|
||||
libakode_sndio_sink_la_LIBADD = ../../lib/libakode.la $(LIBSNDIO)
|
172
audio/akode/files/sndio_sink.cpp
Normal file
172
audio/akode/files/sndio_sink.cpp
Normal file
@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Jacob Meuser <jakemsr@sdf.lonestar.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <sndio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <audioframe.h>
|
||||
#include "sndio_sink.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace aKode {
|
||||
|
||||
extern "C" { SndioSinkPlugin sndio_sink; }
|
||||
|
||||
struct SndioSink::private_data
|
||||
{
|
||||
private_data() : hdl(0), valid(false) {};
|
||||
struct sio_hdl *hdl;
|
||||
struct sio_par par;
|
||||
|
||||
AudioConfiguration config;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
SndioSink::SndioSink()
|
||||
{
|
||||
d = new private_data;
|
||||
}
|
||||
|
||||
SndioSink::~SndioSink()
|
||||
{
|
||||
close();
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool
|
||||
SndioSink::open()
|
||||
{
|
||||
d->hdl = ::sio_open(NULL, SIO_PLAY, 0);
|
||||
|
||||
if (d->hdl == NULL) {
|
||||
std::cerr << "akode: could not open sndio device\n";
|
||||
goto failed;
|
||||
}
|
||||
if (!sio_start(d->hdl)) {
|
||||
std::cerr << "akode: could not start sndio device\n";
|
||||
goto failed;
|
||||
}
|
||||
d->valid = true;
|
||||
return true;
|
||||
|
||||
failed:
|
||||
d->valid = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
SndioSink::close() {
|
||||
if (d->hdl != NULL)
|
||||
::sio_close(d->hdl);
|
||||
d->hdl = NULL;
|
||||
d->valid = false;
|
||||
}
|
||||
|
||||
int
|
||||
SndioSink::setAudioConfiguration(const AudioConfiguration* config)
|
||||
{
|
||||
d->config = *config;
|
||||
|
||||
if (d->valid)
|
||||
sio_stop(d->hdl);
|
||||
|
||||
sio_initpar(&d->par);
|
||||
|
||||
if (config->sample_width < 0) {
|
||||
d->par.bits = 16;
|
||||
d->par.sig = 1;
|
||||
} else {
|
||||
d->par.bits = config->sample_width;
|
||||
if (d->par.bits == 8)
|
||||
d->par.sig = 0;
|
||||
else
|
||||
d->par.sig = 1;
|
||||
}
|
||||
d->par.pchan = config->channels;
|
||||
d->par.rate = config->sample_rate;
|
||||
|
||||
if (!sio_setpar(d->hdl, &d->par)) {
|
||||
d->valid = false;
|
||||
return -1;
|
||||
}
|
||||
if (!sio_getpar(d->hdl, &d->par)) {
|
||||
d->valid = false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
d->config.sample_width = d->par.bits;
|
||||
d->config.sample_rate = d->par.rate;
|
||||
d->config.channels = d->par.pchan;
|
||||
if (d->config.channels <= 2)
|
||||
d->config.channel_config = MonoStereo;
|
||||
|
||||
if (!sio_start(d->hdl)) {
|
||||
std::cerr << "akode: could not restart sndio device\n";
|
||||
d->valid = false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (d->config == *config)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
const AudioConfiguration*
|
||||
SndioSink::audioConfiguration() const
|
||||
{
|
||||
return &d->config;
|
||||
}
|
||||
|
||||
bool
|
||||
SndioSink::writeFrame(AudioFrame* frame)
|
||||
{
|
||||
if (!d->valid)
|
||||
return false;
|
||||
|
||||
if (frame->sample_width != d->config.sample_width ||
|
||||
frame->channels != d->config.channels ) {
|
||||
if (setAudioConfiguration(frame) < 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
int channels = d->config.channels;
|
||||
int length = frame->length;
|
||||
|
||||
int16_t *buffer = (int16_t*)alloca(length*channels*2);
|
||||
int16_t** data = (int16_t**)frame->data;
|
||||
for (int i = 0; i < length; i++)
|
||||
for (int j = 0; j < channels; j++)
|
||||
buffer[i * channels + j] = data[j][i];
|
||||
|
||||
// std::cerr << "Writing frame\n";
|
||||
int status = 0;
|
||||
do {
|
||||
status = ::sio_write(d->hdl, buffer, channels * length * 2);
|
||||
if (status == 0) {
|
||||
return false;
|
||||
}
|
||||
} while(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
55
audio/akode/files/sndio_sink.h
Normal file
55
audio/akode/files/sndio_sink.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Jacob Meuser <jakemsr@sdf.lonestar.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _AKODE_SNDIO_SINK_H
|
||||
#define _AKODE_SNDIO_SINK_H
|
||||
|
||||
#include "sink.h"
|
||||
|
||||
#include "akode_export.h"
|
||||
|
||||
namespace aKode {
|
||||
|
||||
class AudioConfiguration;
|
||||
class AudioFrame;
|
||||
|
||||
class SndioSink : public Sink {
|
||||
public:
|
||||
SndioSink();
|
||||
~SndioSink();
|
||||
bool open();
|
||||
void close();
|
||||
int setAudioConfiguration(const AudioConfiguration *config);
|
||||
const AudioConfiguration* audioConfiguration() const;
|
||||
bool writeFrame(AudioFrame *frame);
|
||||
struct private_data;
|
||||
private:
|
||||
template<class T> void _writeFrame(AudioFrame *frame);
|
||||
private_data *d;
|
||||
};
|
||||
|
||||
class SndioSinkPlugin : public SinkPlugin {
|
||||
public:
|
||||
virtual SndioSink* openSink() {
|
||||
return new SndioSink();
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" AKODE_EXPORT SndioSinkPlugin sndio_sink;
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
12
audio/akode/patches/patch-akode_lib_auto_sink_cpp
Normal file
12
audio/akode/patches/patch-akode_lib_auto_sink_cpp
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-akode_lib_auto_sink_cpp,v 1.1 2009/12/14 00:02:17 jakemsr Exp $
|
||||
--- akode/lib/auto_sink.cpp.orig Wed Dec 9 22:27:49 2009
|
||||
+++ akode/lib/auto_sink.cpp Wed Dec 9 22:29:23 2009
|
||||
@@ -66,6 +66,8 @@ bool AutoSink::open()
|
||||
// Try Polypaudio
|
||||
if (getenv("POLYP_SERVER"))
|
||||
if (m_data->tryOpen("polyp")) return true;
|
||||
+ // Try sndio
|
||||
+ if (m_data->tryOpen("sndio")) return true;
|
||||
// Try Jack
|
||||
if (m_data->tryOpen("jack")) return true;
|
||||
// Try ALSA
|
21
audio/akode/patches/patch-akode_plugins_Makefile_am
Normal file
21
audio/akode/patches/patch-akode_plugins_Makefile_am
Normal file
@ -0,0 +1,21 @@
|
||||
$OpenBSD: patch-akode_plugins_Makefile_am,v 1.1 2009/12/14 00:02:17 jakemsr Exp $
|
||||
--- akode/plugins/Makefile.am.orig Wed Dec 9 21:37:22 2009
|
||||
+++ akode/plugins/Makefile.am Wed Dec 9 21:38:15 2009
|
||||
@@ -28,6 +28,10 @@ if include_sun_sink
|
||||
AKODE_SUN_SINK=sun_sink
|
||||
endif
|
||||
|
||||
+if include_sndio_sink
|
||||
+AKODE_SNDIO_SINK=sndio_sink
|
||||
+endif
|
||||
+
|
||||
if include_jack_sink
|
||||
AKODE_JACK_SINK=jack_sink
|
||||
endif
|
||||
@@ -39,5 +43,5 @@ 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_SNDIO_SINK) $(AKODE_JACK_SINK) $(AKODE_POLYP_SINK) \
|
||||
$(AKODE_SRC_RESAMPLER)
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-configure_in,v 1.2 2007/05/08 15:16:37 naddy Exp $
|
||||
--- configure.in.orig Fri Apr 6 15:23:11 2007
|
||||
+++ configure.in Sat May 5 17:10:46 2007
|
||||
$OpenBSD: patch-configure_in,v 1.3 2009/12/14 00:02:17 jakemsr Exp $
|
||||
--- configure.in.orig Fri Apr 6 06:23:11 2007
|
||||
+++ configure.in Wed Dec 9 22:06:10 2009
|
||||
@@ -120,7 +120,7 @@ AC_DEFUN([AC_CHECK_LIBFLAC],
|
||||
|
||||
])
|
||||
@ -55,7 +55,23 @@ $OpenBSD: patch-configure_in,v 1.2 2007/05/08 15:16:37 naddy Exp $
|
||||
VORBISFILE_LIBS="-lvorbisfile"
|
||||
|
||||
# for akode/plugins/xiph_decoder/
|
||||
@@ -257,8 +257,8 @@ kde_save_akode_libs="$LIBS"
|
||||
@@ -228,6 +228,15 @@ AC_DEFUN([KDE_CHECK_SUN],
|
||||
AC_CHECK_HEADERS([sys/audioio.h], [have_sun=yes])
|
||||
])
|
||||
|
||||
+AC_DEFUN([KDE_CHECK_SNDIO],
|
||||
+[
|
||||
+ have_sndio=no
|
||||
+
|
||||
+ AC_CHECK_HEADERS([sndio.h], [have_sndio=yes])
|
||||
+ AC_CHECK_LIB(sndio, sio_open, [LIBSNDIO="-lsndio"])
|
||||
+ AC_SUBST(LIBSNDIO)
|
||||
+])
|
||||
+
|
||||
AC_DEFUN([KDE_CHECK_ALSA],
|
||||
[
|
||||
PKG_CHECK_MODULES([ALSA], [alsa >= 0.9], [have_alsa=yes], [have_alsa=no])
|
||||
@@ -257,8 +266,8 @@ kde_save_akode_libs="$LIBS"
|
||||
LIBS="$all_libraries $USER_LDFLAGS"
|
||||
CFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
|
||||
AC_TRY_COMPILE([
|
||||
@ -66,7 +82,7 @@ $OpenBSD: patch-configure_in,v 1.2 2007/05/08 15:16:37 naddy Exp $
|
||||
#include <ogg/ogg.h>
|
||||
],[
|
||||
],[
|
||||
@@ -267,7 +267,7 @@ AC_TRY_COMPILE([
|
||||
@@ -267,7 +276,7 @@ AC_TRY_COMPILE([
|
||||
AC_MSG_RESULT($have_libspeex)
|
||||
if test x$have_libspeex = xyes; then
|
||||
KDE_CHECK_LIB(speex,speex_decoder_ctl,,
|
||||
@ -75,7 +91,7 @@ $OpenBSD: patch-configure_in,v 1.2 2007/05/08 15:16:37 naddy Exp $
|
||||
fi
|
||||
CFLAGS="$kde_save_akode_cflags"
|
||||
LIBS="$kde_save_akode_libs"
|
||||
@@ -278,10 +278,10 @@ kde_save_akode_libs="$LIBS"
|
||||
@@ -278,10 +287,10 @@ kde_save_akode_libs="$LIBS"
|
||||
LIBS="$all_libraries $USER_LDFLAGS"
|
||||
CFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
|
||||
AC_TRY_COMPILE([
|
||||
@ -90,7 +106,7 @@ $OpenBSD: patch-configure_in,v 1.2 2007/05/08 15:16:37 naddy Exp $
|
||||
#include <ogg/ogg.h>
|
||||
],[
|
||||
],[
|
||||
@@ -290,12 +290,12 @@ AC_TRY_COMPILE([
|
||||
@@ -290,12 +299,12 @@ AC_TRY_COMPILE([
|
||||
AC_MSG_RESULT($have_libspeex11)
|
||||
if test x$have_libspeex11 = xyes; then
|
||||
KDE_CHECK_LIB(speex,speex_decode_int,,
|
||||
@ -105,3 +121,39 @@ $OpenBSD: patch-configure_in,v 1.2 2007/05/08 15:16:37 naddy Exp $
|
||||
fi
|
||||
CFLAGS="$kde_save_akode_cflags"
|
||||
LIBS="$kde_save_akode_libs"
|
||||
@@ -548,6 +557,19 @@ if test "x$with_sun" != xno; then
|
||||
fi
|
||||
fi
|
||||
|
||||
+AC_ARG_WITH(sndio,
|
||||
+ [AS_HELP_STRING(--with-sndio,
|
||||
+ [enable support for sndio output @<:@default=check@:>@])],
|
||||
+ [], with_sndio=check)
|
||||
+
|
||||
+if test "x$with_sndio" != xno; then
|
||||
+ KDE_CHECK_SNDIO
|
||||
+
|
||||
+ if test "x$with_sndio" != xcheck && test "x$have_sndio" != xyes; then
|
||||
+ AC_MSG_FAILURE([--with-sndio was given, but test for sndio failed])
|
||||
+ fi
|
||||
+fi
|
||||
+
|
||||
AC_ARG_WITH(alsa,
|
||||
[AS_HELP_STRING(--with-alsa,
|
||||
[enable support for ALSA output @<:@default=check@:>@])],
|
||||
@@ -586,6 +608,7 @@ AM_CONDITIONAL(include_src_resampler, test x$have_libs
|
||||
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_sndio_sink, test x$have_sndio = xyes)
|
||||
AM_CONDITIONAL(include_jack_sink, test x$have_jack = xyes)
|
||||
AM_CONDITIONAL(include_polyp_sink, test x$have_polyp = xyes)
|
||||
AM_CONDITIONAL(include_ffmpeg_decoder, test x$have_ffmpeg = xyes)
|
||||
@@ -623,6 +646,7 @@ AC_CONFIG_FILES([ akode/plugins/oss_sink/Makefile ])
|
||||
AC_CONFIG_FILES([ akode/plugins/polyp_sink/Makefile ])
|
||||
AC_CONFIG_FILES([ akode/plugins/src_resampler/Makefile ])
|
||||
AC_CONFIG_FILES([ akode/plugins/sun_sink/Makefile ])
|
||||
+AC_CONFIG_FILES([ akode/plugins/sndio_sink/Makefile ])
|
||||
AC_CONFIG_FILES([ akode/plugins/xiph_decoder/Makefile ])
|
||||
AC_CONFIG_FILES([ akode/akode-config ])
|
||||
AC_OUTPUT
|
||||
|
@ -1,9 +1,10 @@
|
||||
@comment $OpenBSD: PFRAG.shared,v 1.5 2009/01/12 11:43:43 ajacoutot Exp $
|
||||
@comment $OpenBSD: PFRAG.shared,v 1.6 2009/12/14 00:02:17 jakemsr Exp $
|
||||
@lib lib/libakode.so.${LIBakode_VERSION}
|
||||
lib/libakode_ffmpeg_decoder.so
|
||||
lib/libakode_jack_sink.so
|
||||
lib/libakode_mpc_decoder.so
|
||||
lib/libakode_mpeg_decoder.so
|
||||
lib/libakode_sndio_sink.so
|
||||
lib/libakode_src_resampler.so
|
||||
lib/libakode_sun_sink.so
|
||||
lib/libakode_xiph_decoder.so
|
||||
|
@ -1,4 +1,4 @@
|
||||
@comment $OpenBSD: PLIST,v 1.7 2009/01/12 11:43:43 ajacoutot Exp $
|
||||
@comment $OpenBSD: PLIST,v 1.8 2009/12/14 00:02:17 jakemsr Exp $
|
||||
%%SHARED%%
|
||||
bin/akode-config
|
||||
@bin bin/akodeplay
|
||||
@ -38,6 +38,8 @@ lib/libakode.la
|
||||
@comment lib/libakode_mpc_decoder.la
|
||||
@comment lib/libakode_mpeg_decoder.a
|
||||
@comment lib/libakode_mpeg_decoder.la
|
||||
@comment lib/libakode_sndio_sink.a
|
||||
@comment lib/libakode_sndio_sink.la
|
||||
@comment lib/libakode_src_resampler.a
|
||||
@comment lib/libakode_src_resampler.la
|
||||
@comment lib/libakode_sun_sink.a
|
||||
|
Loading…
Reference in New Issue
Block a user