Author: snirkel
Update of /cvs/nonfree/rpms/sidplay/devel
In directory se02.es.rpmfusion.net:/tmp/cvs-serv18596
Modified Files:
sidplay.spec
Added Files:
sidplay-alsa.patch sidplay-autohell-fixes.patch
Log Message:
Patch from Bernie Innocenti to rebuild with exclusive
ALSA support.
sidplay-alsa.patch:
--- NEW FILE sidplay-alsa.patch ---
diff -Nrup sidplay-2.0.9.orig/configure.ac sidplay-2.0.9/configure.ac
--- sidplay-2.0.9.orig/configure.ac 2009-09-06 00:26:21.370889171 -0400
+++ sidplay-2.0.9/configure.ac 2009-09-06 00:26:38.631866724 -0400
@@ -24,6 +24,8 @@ AC_CHECK_HEADERS(sys/ioctl.h linux/sound
sys/soundcard.h soundcard.h sys/audio.h sun/audioio.h sun/dbriio.h sys/audioio.h \
audio.h dmedia/audio.h)
+AC_ARG_WITH(alsa,[ --with-alsa Use ALSA library for
sound],[WANT_ALSA=$withval],[WANT_ALSA=no])
+
AH_TOP(
[/* Define supported audio driver */
#undef HAVE_HARDSID
@@ -60,9 +62,17 @@ case "$host" in
AC_MSG_RESULT(irix)
AC_CHECK_LIB(audio, main, [AUDIO_LDADD=-laudio AC_SUBST(AUDIO_LDADD)])
;;
- *linux*) AC_DEFINE(HAVE_OSS)
- audiodrv_libadd="./audio/oss/liboss.a"
- AC_MSG_RESULT(oss)
+ *linux*)
+ if test "$WANT_ALSA" = "yes" ; then
+ AC_DEFINE(HAVE_ALSA)
+ audiodrv_libadd="./audio/alsa/libalsa.a"
+ AC_MSG_RESULT(alsa)
+ AC_CHECK_LIB(asound, main, [AUDIO_LDFLAGS=-lasound AC_SUBST(AUDIO_LDFLAGS)])
+ else
+ AC_DEFINE(HAVE_OSS)
+ audiodrv_libadd="./audio/oss/liboss.a"
+ AC_MSG_RESULT(oss)
+ fi
;;
*netbsd*) AC_DEFINE(HAVE_OSS)
audiodrv_libadd="./audio/oss/liboss.a"
diff -Nrup sidplay-2.0.9.orig/src/audio/alsa/audiodrv.cpp
sidplay-2.0.9/src/audio/alsa/audiodrv.cpp
--- sidplay-2.0.9.orig/src/audio/alsa/audiodrv.cpp 2009-09-06 00:26:21.372869292 -0400
+++ sidplay-2.0.9/src/audio/alsa/audiodrv.cpp 2009-09-06 00:26:38.633866542 -0400
@@ -2,6 +2,9 @@
// Advanced Linux Sound Architecture (ALSA) specific audio driver interface.
// --------------------------------------------------------------------------
/***************************************************************************
+ * 2005-07-12: Heikki Orsila <heikki.orsila(a)iki.fi>
+ * Fixed use of obsolete parts of ALSA API
+ *
* $Log: audiodrv.cpp,v $
* Revision 1.7 2002/03/04 19:07:48 s_a_white
* Fix C++ use of nothrow.
@@ -31,6 +34,7 @@
#include "audiodrv.h"
#ifdef HAVE_ALSA
+#include <iostream>
#include <stdio.h>
#ifdef HAVE_EXCEPTIONS
# include <new>
@@ -57,88 +61,86 @@ void Audio_ALSA::outOfOrder ()
void *Audio_ALSA::open (AudioConfig &cfg, const char *)
{
AudioConfig tmpCfg;
- int mask, wantedFormat, format;
- int rtn;
- int card = -1, dev = 0;
-
- if (_audioHandle != NULL)
- {
+ snd_pcm_uframes_t buffer_frames;
+ snd_pcm_hw_params_t *hw_params;
+
+ // Transfer input parameters to this object.
+ // May later be replaced with driver defaults.
+ tmpCfg = cfg;
+ unsigned int rate = tmpCfg.frequency;
+
+ if (_audioHandle != NULL) {
_errorString = "ERROR: Device already in use";
return NULL;
}
- if ((rtn = snd_pcm_open_preferred (&_audioHandle, &card, &dev,
SND_PCM_OPEN_PLAYBACK)))
- {
+ if (snd_pcm_open (&_audioHandle, "default", SND_PCM_STREAM_PLAYBACK,
0)) {
_errorString = "ERROR: Could not open audio device.";
goto open_error;
}
-
- // Transfer input parameters to this object.
- // May later be replaced with driver defaults.
- tmpCfg = cfg;
- snd_pcm_channel_params_t pp;
- snd_pcm_channel_setup_t setup;
-
- snd_pcm_channel_info_t pi;
-
- memset (&pi, 0, sizeof (pi));
- pi.channel = SND_PCM_CHANNEL_PLAYBACK;
- if ((rtn = snd_pcm_plugin_info (_audioHandle, &pi)))
- {
- _errorString = "ALSA: snd_pcm_plugin_info failed.";
- goto open_error;
+ if (snd_pcm_hw_params_malloc(&hw_params) < 0) {
+ _errorString = "ERROR: could not malloc hwparams.";
+ goto open_error;
}
-
- memset(&pp, 0, sizeof (pp));
-
- pp.mode = SND_PCM_MODE_BLOCK;
- pp.channel = SND_PCM_CHANNEL_PLAYBACK;
- pp.start_mode = SND_PCM_START_FULL;
- pp.stop_mode = SND_PCM_STOP_STOP;
-
- pp.buf.block.frag_size = pi.max_fragment_size;
-
- pp.buf.block.frags_max = 1;
- pp.buf.block.frags_min = 1;
-
- pp.format.interleave = 1;
- pp.format.rate = tmpCfg.frequency;
- pp.format.voices = tmpCfg.channels;
-
- // Set sample precision and type of encoding.
- if ( tmpCfg.precision == 8 )
- {
- tmpCfg.encoding = AUDIO_UNSIGNED_PCM;
- pp.format.format = SND_PCM_SFMT_U8;
+
+ if (snd_pcm_hw_params_any (_audioHandle, hw_params) < 0) {
+ _errorString = "ERROR: could not initialize hw params";
+ goto open_error;
}
- if ( tmpCfg.precision == 16 )
- {
- tmpCfg.encoding = AUDIO_SIGNED_PCM;
- pp.format.format = SND_PCM_SFMT_S16_LE;
+
+ if (snd_pcm_hw_params_set_access (_audioHandle, hw_params,
SND_PCM_ACCESS_RW_INTERLEAVED)) {
+ _errorString = "ERROR: could not set access type";
+ goto open_error;
}
- if ((rtn = snd_pcm_plugin_params (_audioHandle, &pp)) < 0)
- {
- _errorString = "ALSA: snd_pcm_plugin_params failed.";
- goto open_error;
+ snd_pcm_format_t alsamode;
+ switch (tmpCfg.precision) {
+ case 8:
+ tmpCfg.encoding = AUDIO_UNSIGNED_PCM;
+ alsamode = SND_PCM_FORMAT_U8;
+ break;
+ case 16:
+ tmpCfg.encoding = AUDIO_SIGNED_PCM;
+ alsamode = SND_PCM_FORMAT_S16;
+ break;
+ default:
+ _errorString = "ERROR: set desired number of bits for audio device.";
+ goto open_error;
}
-
- if ((rtn = snd_pcm_plugin_prepare (_audioHandle, SND_PCM_CHANNEL_PLAYBACK)) < 0)
- {
- _errorString = "ALSA: snd_pcm_plugin_prepare failed.";
- goto open_error;
+
+ if (snd_pcm_hw_params_set_format (_audioHandle, hw_params, alsamode)) {
+ _errorString = "ERROR: could not set sample format";
+ goto open_error;
}
-
- memset (&setup, 0, sizeof (setup));
- setup.channel = SND_PCM_CHANNEL_PLAYBACK;
- if ((rtn = snd_pcm_plugin_setup (_audioHandle, &setup)) < 0)
- {
- _errorString = "ALSA: snd_pcm_plugin_setup failed.";
- goto open_error;
+
+ if (snd_pcm_hw_params_set_channels (_audioHandle, hw_params, tmpCfg.channels)) {
+ _errorString = "ERROR: could not set channel count";
+ goto open_error;
}
- tmpCfg.bufSize = setup.buf.block.frag_size;
+ if (snd_pcm_hw_params_set_rate_near (_audioHandle, hw_params, &rate, 0)) {
+ _errorString = "ERROR: could not set sample rate";
+ goto open_error;
+ }
+
+ _alsa_to_frames_divisor = tmpCfg.channels * tmpCfg.precision / 8;
+ buffer_frames = 4096;
+ snd_pcm_hw_params_set_period_size_near(_audioHandle, hw_params, &buffer_frames,
0);
+
+ if (snd_pcm_hw_params (_audioHandle, hw_params)) {
+ _errorString = "ERROR: could not set hw parameters";
+ goto open_error;
+ }
+
+ snd_pcm_hw_params_free (hw_params);
+
+ if (snd_pcm_prepare (_audioHandle)) {
+ _errorString = "ERROR: could not prepare audio interface for use";
+ goto open_error;
+ }
+
+ tmpCfg.bufSize = buffer_frames * _alsa_to_frames_divisor;
#ifdef HAVE_EXCEPTIONS
_sampleBuffer = new(std::nothrow) int_least8_t[tmpCfg.bufSize];
#else
@@ -158,13 +160,11 @@ void *Audio_ALSA::open (AudioConfig &cfg
return _sampleBuffer;
open_error:
+ std::cerr << "ALSA open error: " << _errorString <<
std::endl;
if (_audioHandle != NULL)
- {
close ();
- }
-
perror ("ALSA");
-return NULL;
+ return NULL;
}
// Close an opened audio device, free any allocated buffers and
@@ -174,7 +174,7 @@ void Audio_ALSA::close ()
if (_audioHandle != NULL )
{
snd_pcm_close(_audioHandle);
- delete [] _sampleBuffer;
+ delete [] ((int_least8_t *) _sampleBuffer);
outOfOrder ();
}
}
@@ -192,7 +192,7 @@ void *Audio_ALSA::write ()
return NULL;
}
- snd_pcm_plugin_write (_audioHandle, _sampleBuffer, _settings.bufSize);
+ snd_pcm_writei (_audioHandle, _sampleBuffer, _settings.bufSize /
_alsa_to_frames_divisor);
return (void *) _sampleBuffer;
}
diff -Nrup sidplay-2.0.9.orig/src/audio/alsa/audiodrv.h
sidplay-2.0.9/src/audio/alsa/audiodrv.h
--- sidplay-2.0.9.orig/src/audio/alsa/audiodrv.h 2009-09-06 00:26:21.373888163 -0400
+++ sidplay-2.0.9/src/audio/alsa/audiodrv.h 2009-09-06 00:26:38.634867533 -0400
@@ -35,8 +35,7 @@
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/asoundlib.h>
+#include <alsa/asoundlib.h>
#include "../AudioBase.h"
@@ -44,6 +43,7 @@ class Audio_ALSA: public AudioBase
{
private: // ------------------------------------------------------- private
snd_pcm_t * _audioHandle;
+ int _alsa_to_frames_divisor;
void outOfOrder ();
sidplay-autohell-fixes.patch:
--- NEW FILE sidplay-autohell-fixes.patch ---
Author: Bernie Innocenti <bernie(a)codewiz.org>
Fix the build harness for contemporary versions of the autoshite suite.
We can't invoke libtool from within configure because it's not yet there;
but we don't need libtool if we use pkg-config to detect libraries.
This change opens the possibility to drop a bunch of macros from
unix/sidplay2.m4 and simplify other things, but this patch doesn't
bother to.
--- sidplay-2.0.9.old/configure.ac 2009-09-06 16:11:38.362313298 -0400
+++ sidplay-2.0.9/configure.ac 2009-09-06 16:15:34.224189943 -0400
@@ -1,6 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(Makefile.am)
AC_CONFIG_AUX_DIR(unix)
+AC_CONFIG_MACRO_DIR(unix)
AM_CONFIG_HEADER(unix/config.h)
dnl Setup library CURRENT, REVISION and AGE
@@ -114,16 +115,15 @@ MY_CHECK_IOS_BIN
MY_CHECK_IOS_OPENMODE
dnl Check for libraries
-SID2_LIB_CHECKS
-SID2_FIND_LIBSIDPLAY2
-SID2_FIND_LIBSIDUTILS
+PKG_CHECK_MODULES(LIBSIDPLAY2, libsidplay2)
+PKG_CHECK_MODULES(LIBSIDUTILS, libsidutils)
# Find sid builder emulations
SID2_FIND_BUILDERS
dnl Add absolute directory for header files
CXXFLAGS="$CXXFLAGS -I\$(top_srcdir)/include \
-\$(LIBSIDPLAY2_CXXFLAGS) \$(LIBSIDUTILS_CXXFLAGS)"
+\$(LIBSIDPLAY2_CFLAGS) \$(LIBSIDUTILS_CFLAGS)"
ACLOCAL_AMFLAGS="-I unix"
AC_SUBST(ACLOCAL_AMFLAGS)
diff -rup sidplay-2.0.9.old/src/Makefile.am sidplay-2.0.9/src/Makefile.am
--- sidplay-2.0.9.old/src/Makefile.am 2003-07-07 15:58:53.000000000 -0400
+++ sidplay-2.0.9/src/Makefile.am 2009-09-06 16:10:21.236220894 -0400
@@ -11,7 +11,7 @@ player.cpp player.h
sidplay2_LDADD = ./audio/null/libnull.a ./audio/wav/libwav.a \
$(AUDIO_DRV) $(AUDIO_LDFLAGS) \
-$(LIBSIDPLAY2_LDFLAGS) $(LIBSIDUTILS_LDFLAGS) \
+$(LIBSIDPLAY2_LIBS) $(LIBSIDUTILS_LIBS) \
$(BUILDERS_LDFLAGS)
# Remove bad default includes
--- sidplay-2.0.9/unix/my_macros.m4 2009-09-07 08:48:22.441381197 -0400
+++ sidplay-2.0.9.bernie/unix/my_macros.m4 2009-09-06 11:51:18.198661349 -0400
@@ -163,7 +163,7 @@ AC_DEFUN([MY_TRY_COMPILE],
CXXFLAGS="$CXXFLAGS $1"
LDFLAGS="$LDFLAGS $2"
- CXX="${SHELL-/bin/sh} ${srcdir}/libtool $CXX"
+ #CXX="${SHELL-/bin/sh} ${srcdir}/libtool $CXX"
AC_TRY_LINK(
[#include <$3>],
Index: sidplay.spec
===================================================================
RCS file: /cvs/nonfree/rpms/sidplay/devel/sidplay.spec,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- sidplay.spec 11 May 2009 20:10:35 -0000 1.6
+++ sidplay.spec 8 Sep 2009 22:38:16 -0000 1.7
@@ -3,7 +3,7 @@
Name: sidplay
Version: 2.0.9
-Release: 7%{?dist}
+Release: 8%{?dist}
Summary: A command-line tool for playing back SID files
URL:
http://sidplay2.sourceforge.net/
Group: Applications/Multimedia
@@ -12,6 +12,8 @@
#
http://packages.debian.org/unstable/oldlibs/sidplay
Patch0: sidplay_2.0.9-5.diff.gz
Patch1: gcc440.patch
+Patch2: sidplay-alsa.patch
+Patch3: sidplay-autohell-fixes.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
License: GPL
BuildRequires: libsidplay-devel
@@ -35,9 +37,12 @@
%setup -q
%patch0 -p1
%patch1 -p1
+%patch2 -p1
+%patch3 -p1
%build
-%configure --with-sidbuilders=%{_libdir}/sidplay/builders
+ACLOCAL='aclocal -I unix' autoreconf -v --force --install
+%configure --with-sidbuilders=%{_libdir}/sidplay/builders --with-alsa
make %{?_smp_mflags}
%install
@@ -54,6 +59,11 @@
%{_bindir}/*
%changelog
+* Mon Sep 07 2009 Bernie Innocenti <bernie(a)codewiz.org> 2.0.9-7
+- Add sidplay-alsa.patch, stolen from Gentoo
+- Add sidplay-autohell-fixes.patch, rolled in house
+- Rock!
+
* Mon May 11 2009 Linus Walleij <triad(a)df.lth.se> 2.0.9-6
- Located a suspect GCC 4.4.0 rebuild bug.