diff src/alsa/audio.c @ 879:c7daa70ffe7e trunk

[svn] alsa output plugin: use snd_pcm_wait in place of raw polls to handle device readyness; this allows to use alsa plugins such as jackplug; requires testing
author giacomo
date Mon, 19 Mar 2007 13:18:28 -0700
parents 279846578fdc
children 1d8d643134db
line wrap: on
line diff
--- a/src/alsa/audio.c	Mon Mar 19 13:15:52 2007 -0700
+++ b/src/alsa/audio.c	Mon Mar 19 13:18:28 2007 -0700
@@ -824,15 +824,12 @@
 static void *alsa_loop(void *arg)
 {
 	int npfds = snd_pcm_poll_descriptors_count(alsa_pcm);
-	struct pollfd *pfds;
-	unsigned short *revents;
 
 	g_mutex_lock(alsa_mutex);
 
 	if (npfds <= 0)
 		goto _error;
-	pfds = alloca(sizeof(*pfds) * npfds);
-	revents = alloca(sizeof(*revents) * npfds);
+
 	while (going && alsa_pcm)
 	{
 		if (get_thread_buffer_filled() > prebuffer_size)
@@ -840,23 +837,9 @@
 		if (!paused && !prebuffer &&
 		    get_thread_buffer_filled() > hw_period_size_in)
 		{
-			snd_pcm_poll_descriptors(alsa_pcm, pfds, npfds);
-			if (poll(pfds, npfds, 10) > 0)
+			if (snd_pcm_wait(alsa_pcm, 10) > 0)
 			{
-				/*
-				 * need to check revents.  poll() with
-				 * dmix returns a postive value even
-				 * if no data is available
-				 */
-				int i;
-				snd_pcm_poll_descriptors_revents(alsa_pcm, pfds,
-								 npfds, revents);
-				for (i = 0; i < npfds; i++)
-					if (revents[i] & POLLOUT)
-					{
-						alsa_write_out_thread_data();
-						break;
-					}
+				alsa_write_out_thread_data();
 			}
 		}
 		else