rpms/audacious-plugins/devel audacious-plugins-2.1-alsa-ng.patch, NONE, 1.1 audacious-plugins-2.1-underruns.patch, NONE, 1.1 audacious-plugins.spec, 1.50, 1.51 audacious-plugins-2.1-keep-mixer-open.patch, 1.1, NONE
Michael Schwendt
mschwendt at fedoraproject.org
Mon Sep 21 10:30:06 UTC 2009
Author: mschwendt
Update of /cvs/pkgs/rpms/audacious-plugins/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv32209
Modified Files:
audacious-plugins.spec
Added Files:
audacious-plugins-2.1-alsa-ng.patch
audacious-plugins-2.1-underruns.patch
Removed Files:
audacious-plugins-2.1-keep-mixer-open.patch
Log Message:
* Sun Sep 20 2009 Michael Schwendt <mschwendt at fedoraproject.org> - 2.1-4
- Patch alsa-ng plugin with some buffer prefilling to fight underruns.
- Merge minor changes from 2.2-alpha1 alsa-ng plugin.
audacious-plugins-2.1-alsa-ng.patch:
alsa-configure.c | 60 +++++++++++++++++-------------------------
alsa-core.c | 78 +++++++++++++++++++++++++++++++++++--------------------
2 files changed, 76 insertions(+), 62 deletions(-)
--- NEW FILE audacious-plugins-2.1-alsa-ng.patch ---
diff -Nur audacious-plugins-fedora-2.1-orig/src/alsa-ng/alsa-configure.c audacious-plugins-fedora-2.1/src/alsa-ng/alsa-configure.c
--- audacious-plugins-fedora-2.1-orig/src/alsa-ng/alsa-configure.c 2009-07-07 00:40:36.000000000 +0200
+++ audacious-plugins-fedora-2.1/src/alsa-ng/alsa-configure.c 2009-09-16 00:57:07.000000000 +0200
@@ -245,8 +245,7 @@
void alsaplug_configure(void)
{
- GtkWidget *vbox, *notebook;
- GtkWidget *dev_vbox, *adevice_frame, *adevice_box;
+ GtkWidget * vbox, * adevice_frame, * adevice_box;
GtkWidget *mixer_frame, *mixer_box, *mixer_table, *mixer_card_om;
GtkWidget *mixer_card_label, *mixer_device_label;
GtkWidget *bbox, *ok, *cancel;
@@ -259,31 +258,25 @@
return;
}
- configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_signal_connect(GTK_OBJECT(configure_win), "destroy",
- GTK_SIGNAL_FUNC(gtk_widget_destroyed),
- &configure_win);
- gtk_window_set_title(GTK_WINDOW(configure_win),
- _("ALSA Driver configuration"));
- gtk_window_set_policy(GTK_WINDOW(configure_win),
- FALSE, TRUE, FALSE);
- gtk_container_border_width(GTK_CONTAINER(configure_win), 10);
-
- vbox = gtk_vbox_new(FALSE, 10);
- gtk_container_add(GTK_CONTAINER(configure_win), vbox);
-
- notebook = gtk_notebook_new();
- gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
-
- dev_vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(dev_vbox), 5);
-
- adevice_frame = gtk_frame_new(_("Audio device:"));
- gtk_box_pack_start(GTK_BOX(dev_vbox), adevice_frame, FALSE, FALSE, 0);
-
- adevice_box = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(adevice_box), 5);
- gtk_container_add(GTK_CONTAINER(adevice_frame), adevice_box);
+ configure_win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title ((GtkWindow *) configure_win, _("ALSA Output "
+ "Plugin Preferences"));
+ gtk_window_set_type_hint ((GtkWindow *) configure_win,
+ GDK_WINDOW_TYPE_HINT_DIALOG);
+ gtk_window_set_resizable ((GtkWindow *) configure_win, FALSE);
+ gtk_container_set_border_width ((GtkContainer *) configure_win, 6);
+ g_signal_connect ((GObject *) configure_win, "destroy", (GCallback)
+ gtk_widget_destroyed, & configure_win);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_add ((GtkContainer *) configure_win, vbox);
+
+ adevice_frame = gtk_frame_new (_("Device:"));
+ gtk_box_pack_start ((GtkBox *) vbox, adevice_frame, FALSE, FALSE, 0);
+
+ adevice_box = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width ((GtkContainer *) adevice_box, 6);
+ gtk_container_add ((GtkContainer *) adevice_frame, adevice_box);
devices_combo = gtk_combo_new();
gtk_box_pack_start(GTK_BOX(adevice_box), devices_combo,
@@ -292,12 +285,12 @@
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(devices_combo)->entry),
alsaplug_cfg.pcm_device);
- mixer_frame = gtk_frame_new(_("Mixer:"));
- gtk_box_pack_start(GTK_BOX(dev_vbox), mixer_frame, FALSE, FALSE, 0);
+ mixer_frame = gtk_frame_new (_("Mixer:"));
+ gtk_box_pack_start ((GtkBox *) vbox, mixer_frame, FALSE, FALSE, 0);
- mixer_box = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(mixer_box), 5);
- gtk_container_add(GTK_CONTAINER(mixer_frame), mixer_box);
+ mixer_box = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width ((GtkContainer *) mixer_box, 6);
+ gtk_container_add ((GtkContainer *) mixer_frame, mixer_box);
mixer_table = gtk_table_new(2, 2, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(mixer_table), 5);
@@ -331,9 +324,6 @@
gtk_table_attach(GTK_TABLE(mixer_table), mixer_devices_combo,
1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dev_vbox,
- gtk_label_new(_("Device settings")));
-
bbox = gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
diff -Nur audacious-plugins-fedora-2.1-orig/src/alsa-ng/alsa-core.c audacious-plugins-fedora-2.1/src/alsa-ng/alsa-core.c
--- audacious-plugins-fedora-2.1-orig/src/alsa-ng/alsa-core.c 2009-07-07 00:40:36.000000000 +0200
+++ audacious-plugins-fedora-2.1/src/alsa-ng/alsa-core.c 2009-09-16 00:57:07.000000000 +0200
@@ -222,10 +222,14 @@
else
{
gint err = snd_pcm_recover(pcm_handle, wr_frames, 1);
- if (err < 0)
- _ERROR("(write) snd_pcm_recover: %s", snd_strerror(err));
- return;
+ _DEBUG ("snd_pcm_writei error: %s", snd_strerror (wr_frames));
+
+ if (err < 0)
+ {
+ _ERROR ("snd_pcm_recover error: %s", snd_strerror (err));
+ return;
+ }
}
}
}
@@ -299,13 +303,40 @@
if (alsaplug_cfg.mixer_card == NULL)
alsaplug_cfg.mixer_card = g_strdup("default");
+ if (!alsaplug_mixer_new(&amixer))
+ mixer_ready = TRUE;
+
return OUTPUT_PLUGIN_INIT_FOUND_DEVICES;
}
+static void alsaplug_cleanup(void)
+{
+ if (mixer_ready == TRUE)
+ {
+ snd_mixer_detach(amixer, alsaplug_cfg.mixer_card);
+ snd_mixer_close(amixer);
+
+ amixer = NULL;
+ mixer_ready = FALSE;
+ }
+}
+
+#define CHECK_FAIL(expression, name) \
+{ \
+ gint error = expression; \
+ if (error) \
+ { \
+ _ERROR (name " failed: %s.\n", snd_strerror (error)); \
+ snd_pcm_close (pcm_handle); \
+ pcm_handle = NULL; \
+ return -1; \
+ } \
+}
+
static gint
alsaplug_open_audio(AFormat fmt, gint rate, gint nch)
{
- gint err, bitwidth, ringbuf_size;
+ gint err, bitwidth, ringbuf_size, buf_size;
snd_pcm_format_t afmt;
snd_pcm_hw_params_t *hwparams = NULL;
@@ -316,9 +347,6 @@
return -1;
}
- if (!alsaplug_mixer_new(&amixer))
- mixer_ready = TRUE;
-
if ((err = snd_pcm_open(&pcm_handle, alsaplug_cfg.pcm_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
{
_ERROR("snd_pcm_open: %s", snd_strerror(err));
@@ -328,27 +356,31 @@
snd_pcm_hw_params_alloca(&hwparams);
snd_pcm_hw_params_any(pcm_handle, hwparams);
- snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
- snd_pcm_hw_params_set_format(pcm_handle, hwparams, afmt);
- snd_pcm_hw_params_set_channels(pcm_handle, hwparams, nch);
- snd_pcm_hw_params_set_rate(pcm_handle, hwparams, rate, 0);
- err = snd_pcm_hw_params(pcm_handle, hwparams);
- if (err < 0)
- {
- _ERROR("snd_pcm_hw_params failed: %s", snd_strerror(err));
- return -1;
- }
+ CHECK_FAIL (snd_pcm_hw_params_set_access (pcm_handle, hwparams,
+ SND_PCM_ACCESS_RW_INTERLEAVED), "snd_pcm_hw_params_set_access");
+ CHECK_FAIL (snd_pcm_hw_params_set_format (pcm_handle, hwparams, afmt),
+ "snd_pcm_hw_params_set_format");
+ CHECK_FAIL (snd_pcm_hw_params_set_channels (pcm_handle, hwparams, nch),
+ "snd_pcm_hw_params_set_channels");
+ CHECK_FAIL (snd_pcm_hw_params_set_rate (pcm_handle, hwparams, rate, 0),
+ "snd_pcm_hw_params_set_rate");
+ CHECK_FAIL (snd_pcm_hw_params (pcm_handle, hwparams), "snd_pcm_hw_params");
bitwidth = snd_pcm_format_physical_width(afmt);
bps = (rate * bitwidth * nch) >> 3;
- ringbuf_size = aud_cfg->output_buffer_size * bps / 1000;
+
+ buf_size = MAX(aud_cfg->output_buffer_size, 100);
+ ringbuf_size = buf_size * bps / 1000;
+
if (alsaplug_ringbuffer_init(&pcm_ringbuf, ringbuf_size) == -1) {
_ERROR("alsaplug_ringbuffer_init failed");
return -1;
}
+
pcm_going = TRUE;
flush_request = -1;
+ paused = FALSE;
audio_thread = g_thread_create(alsaplug_loop, NULL, TRUE, NULL);
return 1;
@@ -371,15 +403,6 @@
g_thread_join(audio_thread);
audio_thread = NULL;
-
- if (mixer_ready == TRUE)
- {
- snd_mixer_detach(amixer, alsaplug_cfg.mixer_card);
- snd_mixer_close(amixer);
-
- amixer = NULL;
- mixer_ready = FALSE;
- }
}
static void
@@ -500,6 +523,7 @@
.description = "ALSA Output Plugin (-ng)",
.probe_priority = 1,
.init = alsaplug_init,
+ .cleanup = alsaplug_cleanup,
.open_audio = alsaplug_open_audio,
.close_audio = alsaplug_close_audio,
.write_audio = alsaplug_write_audio,
audacious-plugins-2.1-underruns.patch:
alsa-core.c | 38 ++++++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
--- NEW FILE audacious-plugins-2.1-underruns.patch ---
diff -Nur audacious-plugins-fedora-2.1/src/alsa-ng/alsa-core.c audacious-plugins-fedora-2.1-underruns/src/alsa-ng/alsa-core.c
--- audacious-plugins-fedora-2.1/src/alsa-ng/alsa-core.c 2009-09-16 00:57:07.000000000 +0200
+++ audacious-plugins-fedora-2.1-underruns/src/alsa-ng/alsa-core.c 2009-09-19 17:38:22.574485456 +0200
@@ -27,6 +27,10 @@
static gboolean pcm_going = FALSE;
static GThread *audio_thread = NULL;
static gint bps;
+static gint loopbufsize = 384000;
+static gint looppostsize = 2048;
+static gint looppresize;
+static gboolean prefill = TRUE;
static gsize wr_total = 0;
static gsize wr_hwframes = 0;
@@ -221,6 +225,9 @@
}
else
{
+ if (wr_frames == -EPIPE) {
+ prefill = TRUE;
+ }
gint err = snd_pcm_recover(pcm_handle, wr_frames, 1);
_DEBUG ("snd_pcm_writei error: %s", snd_strerror (wr_frames));
@@ -237,7 +244,7 @@
static gpointer
alsaplug_loop(gpointer unused)
{
- guchar buf[2048];
+ guchar buf[loopbufsize];
int size;
while (pcm_going)
@@ -247,6 +254,7 @@
if (flush_request != -1)
{
alsaplug_ringbuffer_reset (& pcm_ringbuf);
+ prefill = TRUE;
snd_pcm_drop(pcm_handle);
snd_pcm_prepare(pcm_handle);
wr_total = flush_request * (long long) bps / 1000;
@@ -264,12 +272,26 @@
continue;
}
- if (size > sizeof buf)
- size = sizeof buf;
+ if (prefill) {
+ if (size > loopbufsize)
+ size = loopbufsize;
+
+ if (size >= looppresize) {
+ alsaplug_ringbuffer_read (& pcm_ringbuf, buf, size);
+ prefill = FALSE;
+ }
+ }
+ else {
+ if (size > looppostsize)
+ size = looppostsize;
alsaplug_ringbuffer_read (& pcm_ringbuf, buf, size);
+ alsaplug_ringbuffer_read (& pcm_ringbuf, buf, size);
+ }
g_mutex_unlock (pcm_state_mutex);
- alsaplug_write_buffer (buf, size);
+ if (!prefill) {
+ alsaplug_write_buffer (buf, size);
+ }
}
snd_pcm_drain(pcm_handle);
@@ -377,6 +399,13 @@
_ERROR("alsaplug_ringbuffer_init failed");
return -1;
}
+ if (loopbufsize >= ringbuf_size) {
+ looppresize = ringbuf_size/2;
+ }
+ else {
+ looppresize = loopbufsize;
+ }
+ prefill = TRUE;
pcm_going = TRUE;
flush_request = -1;
@@ -511,6 +540,7 @@
{
g_mutex_lock (pcm_state_mutex);
paused = p;
+ prefill = !paused;
g_cond_broadcast (pcm_state_cond);
g_mutex_unlock (pcm_state_mutex);
}
Index: audacious-plugins.spec
===================================================================
RCS file: /cvs/pkgs/rpms/audacious-plugins/devel/audacious-plugins.spec,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -p -r1.50 -r1.51
--- audacious-plugins.spec 30 Jul 2009 10:32:38 -0000 1.50
+++ audacious-plugins.spec 21 Sep 2009 10:30:06 -0000 1.51
@@ -5,7 +5,7 @@
Name: audacious-plugins
Version: 2.1
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: Plugins for the Audacious media player
Group: Applications/Multimedia
URL: http://audacious-media-player.org/
@@ -24,7 +24,8 @@ Source0: audacious-plugins-fedora-%{vers
Patch1: audacious-plugins-1.5.1-timidity-cfg.patch
Patch2: audacious-plugins-2.0.1-xmms-skindir.patch
-Patch3: audacious-plugins-2.1-keep-mixer-open.patch
+Patch3: audacious-plugins-2.1-alsa-ng.patch
+Patch4: audacious-plugins-2.1-underruns.patch
BuildRequires: audacious-devel >= %{aud_ver}
BuildRequires: jack-audio-connection-kit-devel libsamplerate-devel
@@ -147,7 +148,8 @@ vortex compressed files.
%patch1 -p1 -b .timidity-cfg
%patch2 -p1 -b .xmms-skindir
-%patch3 -p1 -b .keep-mixer-open
+%patch3 -p1 -b .alsa-ng
+%patch4 -p1 -b .underruns
sed -i '\,^.SILENT:,d' buildsys.mk.in
@@ -231,6 +233,10 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Sun Sep 20 2009 Michael Schwendt <mschwendt at fedoraproject.org> - 2.1-4
+- Patch alsa-ng plugin with some buffer prefilling to fight underruns.
+- Merge minor changes from 2.2-alpha1 alsa-ng plugin.
+
* Thu Jul 30 2009 Michael Schwendt <mschwendt at fedoraproject.org> - 2.1-3
- Keep mixer open and not start at only %50 volume.
--- audacious-plugins-2.1-keep-mixer-open.patch DELETED ---
More information about the fedora-extras-commits
mailing list