rpms/ClanLib/devel ClanLib-0.8.0-alsa.patch, NONE, 1.1 ClanLib.spec, 1.14, 1.15 ClanLib-0.8.0-gcc41.patch, 1.1, NONE ClanLib-0.8.0-grave_key.patch, 1.1, NONE

Hans de Goede (jwrdegoede) fedora-extras-commits at redhat.com
Sun Mar 2 12:06:19 UTC 2008


Author: jwrdegoede

Update of /cvs/extras/rpms/ClanLib/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1404

Modified Files:
	ClanLib.spec 
Added Files:
	ClanLib-0.8.0-alsa.patch 
Removed Files:
	ClanLib-0.8.0-gcc41.patch ClanLib-0.8.0-grave_key.patch 
Log Message:
* Sun Mar  2 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 0.8.0-10
- Add support for audio output through alsa (original ClanLib only supports
  OSS??), this also adds support for using pulseaudio through alsa


ClanLib-0.8.0-alsa.patch:

--- NEW FILE ClanLib-0.8.0-alsa.patch ---
diff -up ClanLib-0.8.0/Sources/Sound/Makefile.am.alsa ClanLib-0.8.0/Sources/Sound/Makefile.am
--- ClanLib-0.8.0/Sources/Sound/Makefile.am.alsa	2008-03-02 10:43:33.000000000 +0100
+++ ClanLib-0.8.0/Sources/Sound/Makefile.am	2008-03-02 10:54:51.000000000 +0100
@@ -38,12 +38,15 @@ else
 libclanSound_la_SOURCES += \
 Unix/soundoutput_oss.cpp \
 Unix/soundoutput_oss.h \
+Unix/soundoutput_alsa.cpp \
+Unix/soundoutput_alsa.h \
 SoundProviders/Unix/soundprovider_recorder_oss.cpp \
 SoundProviders/Unix/soundprovider_recorder_oss.h
 endif
 
 libclanSound_la_LDFLAGS = \
   -release $(LT_RELEASE) \
-  -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+  -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+  -lasound
 
 # EOF #
diff -up ClanLib-0.8.0/Sources/Sound/soundoutput.cpp.alsa ClanLib-0.8.0/Sources/Sound/soundoutput.cpp
--- ClanLib-0.8.0/Sources/Sound/soundoutput.cpp.alsa	2005-10-25 12:39:25.000000000 +0200
+++ ClanLib-0.8.0/Sources/Sound/soundoutput.cpp	2008-03-02 10:48:33.000000000 +0100
@@ -40,6 +40,7 @@
 #ifdef __APPLE__
 #include "MacOSX/soundoutput_macosx.h"
 #else
+#include "Unix/soundoutput_alsa.h"
 #include "Unix/soundoutput_oss.h"
 #endif
 #endif
@@ -66,6 +67,15 @@ CL_SoundOutput::CL_SoundOutput(const CL_
 #ifdef __APPLE__
 	impl = new CL_SoundOutput_MacOSX(desc.get_mixing_frequency());
 #else
+#ifdef __linux__
+	CL_SoundOutput_alsa *alsa_impl;
+	alsa_impl = new CL_SoundOutput_alsa(desc.get_mixing_frequency());
+	if (alsa_impl->handle)
+		impl = alsa_impl;
+	else
+		delete alsa_impl;
+	if (!impl)
+#endif
 	impl = new CL_SoundOutput_OSS(desc.get_mixing_frequency());
 #endif
 #endif
diff -up ClanLib-0.8.0/Sources/Sound/Unix/soundoutput_alsa.cpp.alsa ClanLib-0.8.0/Sources/Sound/Unix/soundoutput_alsa.cpp
--- ClanLib-0.8.0/Sources/Sound/Unix/soundoutput_alsa.cpp.alsa	2008-03-02 10:49:14.000000000 +0100
+++ ClanLib-0.8.0/Sources/Sound/Unix/soundoutput_alsa.cpp	2008-03-02 11:03:43.000000000 +0100
@@ -0,0 +1,161 @@
+/*
+**  ClanLib SDK
+**  Copyright (c) 1997-2008 The ClanLib Team
+**
+**  This software is provided 'as-is', without any express or implied
+**  warranty.  In no event will the authors be held liable for any damages
+**  arising from the use of this software.
+**
+**  Permission is granted to anyone to use this software for any purpose,
+**  including commercial applications, and to alter it and redistribute it
+**  freely, subject to the following restrictions:
+**
+**  1. The origin of this software must not be misrepresented; you must not
+**     claim that you wrote the original software. If you use this software
+**     in a product, an acknowledgment in the product documentation would be
+**     appreciated but is not required.
+**  2. Altered source versions must be plainly marked as such, and must not be
+**     misrepresented as being the original software.
+**  3. This notice may not be removed or altered from any source distribution.
+**
+**  Note: Some of the libraries ClanLib may link to may have additional
+**  requirements or restrictions.
+**
+**  File Author(s):
+**
+**    Magnus Norddahl
+**    Hans de Goede
+**    (if your name is missing here, please add it)
+*/
+
+#include "Sound/precomp.h"
+#include "soundoutput_alsa.h"
+#include "API/Core/System/error.h"
+#include "API/Core/System/cl_assert.h"
+#include "API/Core/System/system.h"
+#include "API/Core/System/log.h"
+
+#ifdef __linux__
+
+/////////////////////////////////////////////////////////////////////////////
+// CL_SoundOutput_alsa construction:
+
+CL_SoundOutput_alsa::CL_SoundOutput_alsa(int mixing_frequency) :
+	CL_SoundOutput_Generic(mixing_frequency), frames_in_buffer(4096),
+	frames_in_period(1024)
+{
+	int rc;
+	snd_pcm_hw_params_t *hwparams;
+	
+	rc = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0);
+	if (rc < 0)
+	{
+		CL_Log::log("warn", "ClanSound: Couldn't open sound device, disabling sound");
+		handle = NULL;
+		return;
+	}
+
+	snd_pcm_hw_params_alloca(&hwparams);
+	snd_pcm_hw_params_any(handle, hwparams);
+	snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
+	snd_pcm_hw_params_set_format(handle, hwparams, SND_PCM_FORMAT_S16);
+	snd_pcm_hw_params_set_channels(handle, hwparams, 2);
+	snd_pcm_hw_params_set_rate_near(handle, hwparams,
+				(unsigned int *)&this->mixing_frequency, 0);
+	snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &frames_in_buffer);
+	frames_in_period = frames_in_buffer / 4;
+	snd_pcm_hw_params_set_period_size_near(handle, hwparams, &frames_in_period, 0);
+	
+	rc = snd_pcm_hw_params(handle, hwparams);
+	if (rc < 0)
+	{
+		CL_Log::log("warn", "ClanSound: Couldn't initialize sound device, disabling sound");
+		snd_pcm_close(handle);
+		handle = NULL;
+		return;
+	}
+	
+	snd_pcm_hw_params_get_period_size(hwparams, &frames_in_period, 0);
+
+	start_mixer_thread();
+}
+
+CL_SoundOutput_alsa::~CL_SoundOutput_alsa()
+{
+	stop_mixer_thread();
+	if (handle) {
+		snd_pcm_close(handle);
+		handle = NULL;
+	}
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CL_SoundOutput_alsa operations:
+
+void CL_SoundOutput_alsa::silence()
+{
+	/* Note: not supported by all hardware! */
+	if (handle)
+		snd_pcm_pause(handle, 1);
+}
+
+bool CL_SoundOutput_alsa::is_full()
+{
+	int rc;
+	snd_pcm_sframes_t delay;
+	
+	if (handle == NULL) return false;
+	
+	rc = snd_pcm_delay(handle, &delay);
+	if (rc < 0) {
+		CL_Log::log("debug", "ClanSound: snd_pcm_delay() failed!?");
+		return false;
+	}
+
+	/* See if there is more then one period free in the buffer */
+	return delay > (snd_pcm_sframes_t)(frames_in_buffer - frames_in_period);
+}
+
+int CL_SoundOutput_alsa::get_fragment_size()
+{
+	return frames_in_period;
+}
+
+void CL_SoundOutput_alsa::write_fragment(short *data)
+{
+	snd_pcm_sframes_t rc;
+
+	if (handle == NULL) return;
+
+	switch(snd_pcm_state(handle)) {
+		case SND_PCM_STATE_XRUN:
+		case SND_PCM_STATE_SUSPENDED:
+			snd_pcm_prepare(handle);
+			break;
+		case SND_PCM_STATE_PAUSED:
+			snd_pcm_pause(handle, 0);
+			break;
+		default:
+			break;
+	}
+
+	rc = snd_pcm_writei(handle, data, frames_in_period);
+	if (rc < 0)
+		CL_Log::log("debug", "ClanSound: snd_pcm_writei() failed!");
+}
+
+void CL_SoundOutput_alsa::wait()
+{
+	if(handle == NULL)
+	{
+		CL_System::sleep(100);
+		return;
+	}
+	/* wait upto 1 second */
+	snd_pcm_wait(handle, 1000);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CL_SoundOutput_alsa implementation:
+
+#endif
diff -up ClanLib-0.8.0/Sources/Sound/Unix/soundoutput_alsa.h.alsa ClanLib-0.8.0/Sources/Sound/Unix/soundoutput_alsa.h
--- ClanLib-0.8.0/Sources/Sound/Unix/soundoutput_alsa.h.alsa	2008-03-02 10:49:20.000000000 +0100
+++ ClanLib-0.8.0/Sources/Sound/Unix/soundoutput_alsa.h	2008-03-02 10:43:09.000000000 +0100
@@ -0,0 +1,76 @@
+/*
+**  ClanLib SDK
+**  Copyright (c) 1997-2008 The ClanLib Team
+**
+**  This software is provided 'as-is', without any express or implied
+**  warranty.  In no event will the authors be held liable for any damages
+**  arising from the use of this software.
+**
+**  Permission is granted to anyone to use this software for any purpose,
+**  including commercial applications, and to alter it and redistribute it
+**  freely, subject to the following restrictions:
+**
+**  1. The origin of this software must not be misrepresented; you must not
+**     claim that you wrote the original software. If you use this software
+**     in a product, an acknowledgment in the product documentation would be
+**     appreciated but is not required.
+**  2. Altered source versions must be plainly marked as such, and must not be
+**     misrepresented as being the original software.
+**  3. This notice may not be removed or altered from any source distribution.
+**
+**  Note: Some of the libraries ClanLib may link to may have additional
+**  requirements or restrictions.
+**
+**  File Author(s):
+**
+**    Magnus Norddahl
+**    Hans de Goede
+**    (if your name is missing here, please add it)
+*/
+
+#ifndef header_soundoutput_alsa
+#define header_soundoutput_alsa
+
+#ifdef __linux__
+
+#include "../soundoutput_generic.h"
+#include <alsa/asoundlib.h> 
+
+class CL_SoundOutput_alsa : public CL_SoundOutput_Generic
+{
+//! Construction:
+public:
+	CL_SoundOutput_alsa(int mixing_frequency);
+	
+	~CL_SoundOutput_alsa();
+
+//! Attributes:
+public:
+	snd_pcm_t *handle;
+	snd_pcm_uframes_t frames_in_period;
+	snd_pcm_uframes_t frames_in_buffer;
+
+//! Operations:
+public:
+	//: Called when we have no samples to play - and wants to tell the soundcard
+	//: about this possible event.
+	virtual void silence();
+
+	//: Returns true if all fragments are filled with data.
+	virtual bool is_full();
+
+	//: Returns the buffer size used by device (returned as num [stereo] samples).
+	virtual int get_fragment_size();
+
+	//: Writes a fragment to the soundcard.
+	virtual void write_fragment(short *data);
+
+	//: Waits until output source isn't full anymore.
+	virtual void wait();
+
+//! Implementation:
+private:
+};
+
+#endif
+#endif
diff -up ClanLib-0.8.0/Sources/Sound/Makefile.in.alsa ClanLib-0.8.0/Sources/Sound/Makefile.in
--- ClanLib-0.8.0/Sources/Sound/Makefile.in.alsa	2008-03-02 10:43:38.000000000 +0100
+++ ClanLib-0.8.0/Sources/Sound/Makefile.in	2008-03-02 10:54:53.000000000 +0100
@@ -46,6 +46,8 @@ target_triplet = @target@
 @WIN32_FALSE at am__append_2 = \
 @WIN32_FALSE at Unix/soundoutput_oss.cpp \
 @WIN32_FALSE at Unix/soundoutput_oss.h \
+ at WIN32_FALSE@Unix/soundoutput_alsa.cpp \
+ at WIN32_FALSE@Unix/soundoutput_alsa.h \
 @WIN32_FALSE at SoundProviders/Unix/soundprovider_recorder_oss.cpp \
 @WIN32_FALSE at SoundProviders/Unix/soundprovider_recorder_oss.h
 
@@ -90,12 +92,13 @@ am__libclanSound_la_SOURCES_DIST =  \
 	SoundProviders/Win32/soundprovider_recorder_directsound.cpp \
 	SoundProviders/Win32/soundprovider_recorder_directsound.h \
 	Unix/soundoutput_oss.cpp Unix/soundoutput_oss.h \
+	Unix/soundoutput_alsa.cpp Unix/soundoutput_alsa.h \
 	SoundProviders/Unix/soundprovider_recorder_oss.cpp \
 	SoundProviders/Unix/soundprovider_recorder_oss.h
 am__dirstamp = $(am__leading_dot)dirstamp
 @WIN32_TRUE at am__objects_1 = Win32/soundoutput_directsound.lo \
 @WIN32_TRUE@	SoundProviders/Win32/soundprovider_recorder_directsound.lo
- at WIN32_FALSE@am__objects_2 = Unix/soundoutput_oss.lo \
+ at WIN32_FALSE@am__objects_2 = Unix/soundoutput_oss.lo Unix/soundoutput_alsa.lo \
 @WIN32_FALSE@	SoundProviders/Unix/soundprovider_recorder_oss.lo
 am_libclanSound_la_OBJECTS = SoundFilters/echofilter_generic.lo \
 	SoundFilters/fadefilter_generic.lo \
@@ -324,7 +327,8 @@ libclanSound_la_SOURCES = SoundFilters/e
 	soundprovider_session.cpp $(am__append_1) $(am__append_2)
 libclanSound_la_LDFLAGS = \
   -release $(LT_RELEASE) \
-  -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+  -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+  -lasound
 
 all: all-am
 
@@ -448,6 +452,8 @@ Unix/$(DEPDIR)/$(am__dirstamp):
 	@: > Unix/$(DEPDIR)/$(am__dirstamp)
 Unix/soundoutput_oss.lo: Unix/$(am__dirstamp) \
 	Unix/$(DEPDIR)/$(am__dirstamp)
+Unix/soundoutput_alsa.lo: Unix/$(am__dirstamp) \
+	Unix/$(DEPDIR)/$(am__dirstamp)
 SoundProviders/Unix/$(am__dirstamp):
 	@$(mkdir_p) SoundProviders/Unix
 	@: > SoundProviders/Unix/$(am__dirstamp)
@@ -488,6 +494,8 @@ mostlyclean-compile:
 	-rm -f SoundProviders/soundprovider_wave_session.lo
 	-rm -f Unix/soundoutput_oss.$(OBJEXT)
 	-rm -f Unix/soundoutput_oss.lo
+	-rm -f Unix/soundoutput_alsa.$(OBJEXT)
+	-rm -f Unix/soundoutput_alsa.lo
 	-rm -f Win32/soundoutput_directsound.$(OBJEXT)
 	-rm -f Win32/soundoutput_directsound.lo
 
@@ -522,6 +530,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at SoundProviders/Unix/$(DEPDIR)/soundprovider_recorder_oss.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at SoundProviders/Win32/$(DEPDIR)/soundprovider_recorder_directsound.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at Unix/$(DEPDIR)/soundoutput_oss.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at Unix/$(DEPDIR)/soundoutput_alsa.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at Win32/$(DEPDIR)/soundoutput_directsound.Plo at am__quote@
 
 .cpp.o:


Index: ClanLib.spec
===================================================================
RCS file: /cvs/extras/rpms/ClanLib/devel/ClanLib.spec,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ClanLib.spec	19 Feb 2008 07:38:23 -0000	1.14
+++ ClanLib.spec	2 Mar 2008 12:05:44 -0000	1.15
@@ -1,7 +1,7 @@
 Summary:        Cross platform C++ game library
 Name:           ClanLib
 Version:        0.8.0
-Release:        9%{?dist}
+Release:        10%{?dist}
 Group:          System Environment/Libraries
 License:        zlib
 URL:            http://www.clanlib.org/
@@ -14,6 +14,7 @@
 Patch0:         ClanLib-0.8.0-fullscreen.patch
 Patch1:         ClanLib-0.8.0-tex-format.patch
 Patch2:         ClanLib-0.8.0-gcc43.patch
+Patch3:         ClanLib-0.8.0-alsa.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires:  libX11-devel libXi-devel libXmu-devel libGLU-devel libICE-devel
 BuildRequires:  libXext-devel libXxf86vm-devel libXt-devel xorg-x11-proto-devel
@@ -41,6 +42,7 @@
 %patch0 -p1 -z .fs
 %patch1 -p1 -z .texfmt
 %patch2 -p1 -z .gcc43
+%patch3 -p1 -z .alsa
 # fixup pc files
 sed -i 's|libdir=${exec_prefix}/lib|libdir=@libdir@|' pkgconfig/clan*.pc.in
 sed -i 's|Libs:   -L${libdir}|Libs:   -L${libdir}/%{name}-0.8|' \
@@ -90,6 +92,10 @@
 
 
 %changelog
+* Sun Mar  2 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 0.8.0-10
+- Add support for audio output through alsa (original ClanLib only supports
+  OSS??), this also adds support for using pulseaudio through alsa
+
 * Tue Feb 19 2008 Fedora Release Engineering <rel-eng at fedoraproject.org> - 0.8.0-9
 - Autorebuild for GCC 4.3
 


--- ClanLib-0.8.0-gcc41.patch DELETED ---


--- ClanLib-0.8.0-grave_key.patch DELETED ---




More information about the fedora-extras-commits mailing list