rpms/wildmidi/devel wildmidi-0.2.2-pulseaudio.patch, NONE, 1.1 wildmidi.spec, 1.4, 1.5
Hans de Goede (jwrdegoede)
fedora-extras-commits at redhat.com
Sat Feb 9 14:04:00 UTC 2008
Author: jwrdegoede
Update of /cvs/extras/rpms/wildmidi/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv7858
Modified Files:
wildmidi.spec
Added Files:
wildmidi-0.2.2-pulseaudio.patch
Log Message:
* Sat Feb 9 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 0.2.2-4
- Change alsa output code to use regular write mode instead of mmap to make
it work with pulseaudio (bz 431846)
wildmidi-0.2.2-pulseaudio.patch:
--- NEW FILE wildmidi-0.2.2-pulseaudio.patch ---
diff -up wildmidi-0.2.2/src/wildmidi.c.pa wildmidi-0.2.2/src/wildmidi.c
--- wildmidi-0.2.2/src/wildmidi.c.pa 2004-01-28 19:13:46.000000000 +0100
+++ wildmidi-0.2.2/src/wildmidi.c 2008-02-09 14:54:58.000000000 +0100
@@ -402,12 +402,8 @@ close_mm_output ( void ) {
#else
#ifdef HAVE_ALSA
-void *buffer;
-int bps;
int alsa_first_time = 1;
static snd_pcm_t *pcm;
-static snd_pcm_uframes_t alsa_period_size;
-static snd_pcm_channel_area_t *areas;
int write_alsa_output (char * output_data, int output_size);
void close_alsa_output ( void );
@@ -417,9 +413,8 @@ open_alsa_output(void) {
snd_pcm_hw_params_t *hw;
snd_pcm_sw_params_t *sw;
int err;
- int alsa_buffer_time, bits_per_sample;
+ int alsa_buffer_time;
unsigned int alsa_period_time;
- snd_pcm_uframes_t alsa_buffer_size;
if (!pcmname)
pcmname = "default";
@@ -437,7 +432,7 @@ open_alsa_output(void) {
return -1;
}
- if ((err = snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) {
+ if ((err = snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
printf("Cannot set mmap'ed mode: %s.\n", snd_strerror(-err));
return -1;
}
@@ -491,28 +486,6 @@ open_alsa_output(void) {
return -1;
}
-#ifdef ALSA_NEW
- if ((err = snd_pcm_hw_params_get_buffer_size(hw, &alsa_buffer_size)) < 0)
-#else
- if ((err = snd_pcm_hw_params_get_buffer_size(hw)) < 0)
-#endif
- {
- printf ("snd_pcm_hw_params_get_buffer_size() failed: %s\n", snd_strerror(-err));
- return -1;
- }
-#ifdef ALSA_NEW
- if ((err = snd_pcm_hw_params_get_period_size(hw, &alsa_period_size, 0)) < 0)
-#else
- alsa_buffer_size = err;
- if ((err = snd_pcm_hw_params_get_period_size(hw, 0)) < 0)
-#endif
- {
- printf ("snd_pcm_hw_params_get_period_size() failed: %s\n", snd_strerror(-err));
- return -1;
- }
-#ifndef ALSA_NEW
- alsa_period_size = err;
-#endif
snd_pcm_sw_params_alloca(&sw);
snd_pcm_sw_params_current(pcm, sw);
if (snd_pcm_sw_params(pcm, sw) < 0)
@@ -521,19 +494,6 @@ open_alsa_output(void) {
return -1;
}
- bits_per_sample = snd_pcm_format_physical_width(SND_PCM_FORMAT_S16);
- bps = (rate * bits_per_sample * 2) / 8000;
-
- buffer = malloc(alsa_period_size * bits_per_sample / 8 * 2);
- areas = malloc(2 * sizeof(snd_pcm_channel_area_t));
-
- areas[0].addr = buffer;
- areas[0].first = 0;
- areas[0].step = 2 * bits_per_sample;
- areas[1].addr = buffer;
- areas[1].first = bits_per_sample;
- areas[1].step = 2 * bits_per_sample;
-
send_output = write_alsa_output;
close_output = close_alsa_output;
return 0;
@@ -541,45 +501,23 @@ open_alsa_output(void) {
int
write_alsa_output (char * output_data, int output_size) {
- int cnt = 0, err;
- snd_pcm_uframes_t offset, frames;
- snd_pcm_sframes_t avail;
- const snd_pcm_channel_area_t *chan_areas = areas;
+ int err;
+ snd_pcm_uframes_t frames;
while (output_size > 0) {
- avail = snd_pcm_avail_update(pcm);
- if (avail == -EPIPE) {
- if (snd_pcm_state(pcm) == SND_PCM_STATE_XRUN) {
- if ((err = snd_pcm_prepare(pcm)) < 0)
- printf("snd_pcm_prepare() failed.\n");
- alsa_first_time = 1;
- }
- } else if (avail < 0) {
- printf("snd_pcm_avail_update() failed: %s\n", snd_strerror(-avail));
- avail = 0;
- }
- if (avail < alsa_period_size) {
- usleep(500);
- continue;
- }
frames = snd_pcm_bytes_to_frames(pcm, output_size);
- if ((err = snd_pcm_mmap_begin(pcm, &chan_areas, &offset, &frames)) < 0) {
- printf("snd_pcm_mmap_begin() failed: %s\n", snd_strerror(-err));
- }
- cnt = snd_pcm_frames_to_bytes(pcm, frames);
- memcpy((char*) chan_areas[0].addr + snd_pcm_frames_to_bytes(pcm, offset), output_data, cnt);
- if ((err = snd_pcm_mmap_commit(pcm, offset, frames)) < 0) {
+ if ((err = snd_pcm_writei(pcm, output_data, frames)) < 0) {
if (snd_pcm_state(pcm) == SND_PCM_STATE_XRUN) {
if ((err = snd_pcm_prepare(pcm)) < 0)
printf("snd_pcm_prepare() failed.\n");
alsa_first_time = 1;
+ continue;
}
+ return err;
}
- if (err != frames)
- printf("snd_pcm_mmap_commit returned %d, expected %d\n", err, (int)frames);
- output_size -= cnt;
- output_data += cnt;
+ output_size -= snd_pcm_frames_to_bytes(pcm, err);
+ output_data += snd_pcm_frames_to_bytes(pcm, err);
if (alsa_first_time) {
alsa_first_time = 0;
snd_pcm_start(pcm);
@@ -591,8 +529,6 @@ write_alsa_output (char * output_data, i
void
close_alsa_output ( void ) {
snd_pcm_close (pcm);
- free(areas);
- free(buffer);
}
#else
Index: wildmidi.spec
===================================================================
RCS file: /cvs/extras/rpms/wildmidi/devel/wildmidi.spec,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- wildmidi.spec 14 Oct 2007 19:49:23 -0000 1.4
+++ wildmidi.spec 9 Feb 2008 14:03:23 -0000 1.5
@@ -1,6 +1,6 @@
Name: wildmidi
Version: 0.2.2
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: WildMidi softsynth midi player
Group: Applications/Multimedia
License: GPLv2+
@@ -8,6 +8,7 @@
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Patch0: wildmidi-0.2.2-opt.patch
Patch1: wildmidi-0.2.2-cfg-abs-path.patch
+Patch2: wildmidi-0.2.2-pulseaudio.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: alsa-lib-devel libtool
Requires: %{name}-libs = %{version}-%{release}
@@ -45,6 +46,7 @@
%setup -q
%patch0 -p1 -z .opt
%patch1 -p1 -z .abs
+%patch2 -p1 -z .pa
sed -i 's/\r//g' COPYING
# we need to update libtool to fix compilation on systems which have lib64
autoreconf -i -f
@@ -86,6 +88,10 @@
%changelog
+* Sat Feb 9 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 0.2.2-4
+- Change alsa output code to use regular write mode instead of mmap to make
+ it work with pulseaudio (bz 431846)
+
* Sun Oct 14 2007 Hans de Goede <j.w.r.degoede at hhs.nl> 0.2.2-3
- Require timidity++-patches instead of timidity++ itself so that we don't
drag in arts and through arts, qt and boost.
More information about the fedora-extras-commits
mailing list