Re: rate plugin issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

Takashi Iwai wrote:
I committed your patch now on HG tree, as it's likely OK from the
possible breakage on other apps, too.
OK, first I have to apologize for
not providing a test-case - its still
in my todo if you need it. There are
still a few things unclear, like, for
example, how it fixes the portaudio,
if, as you say, such an apps are not
touching the code in question.

Anyway... as I said already, there are
few more problems that were hidden
before and are not any more. (I really
tried to warn you :)
For example, mpg123 will now consume
100% of CPU because of the nasty loop
in snd_pcm_write_areas()...
I am using something like the attached
patch, but maybe you can come up with
the better solution.
Quick summary: mpg123 sets avail_min=1,
so the loop spins without any rest.
Before, the value was "adjusted", so
it didn't spin that nasty way.

Anyway, I swear that I'll never read any mails during my next
vacation.  That was so exhausting to be dragged to a lengthy
discussion for band-aiding a badly designed compoment... :)
But now, unfortunately, you won't get
away from that. :)
The hack used to cover more problems...

--- pcm.c.old	2007-11-04 17:57:01.000000000 +0300
+++ pcm.c	2007-11-07 21:34:59.000000000 +0300
@@ -6465,19 +6465,35 @@
 			goto _end;
 		}
 		if ((state == SND_PCM_STATE_RUNNING &&
-		     (snd_pcm_uframes_t)avail < pcm->avail_min &&
 		     size > (snd_pcm_uframes_t)avail) ||
 		    (size >= pcm->xfer_align &&
 		     (snd_pcm_uframes_t)avail < pcm->xfer_align)) {
+			snd_pcm_sframes_t avail_min, orig_avail_min;
+			snd_pcm_sw_params_t params;
 
 			if (pcm->mode & SND_PCM_NONBLOCK) {
 				err = -EAGAIN;
 				goto _end;
 			}
 
+			avail_min = (size < pcm->period_size ?
+				size : pcm->period_size);
+			orig_avail_min = pcm->avail_min;
+			if (avail_min != pcm->avail_min) {
+				snd_pcm_sw_params_current(pcm, &params);
+				params.avail_min = avail_min;
+				snd_pcm_sw_params(pcm, &params);
+			}
+
 			err = snd_pcm_wait(pcm, -1);
 			if (err < 0)
 				break;
+
+			if (orig_avail_min != pcm->avail_min) {
+				params.avail_min = orig_avail_min;
+				snd_pcm_sw_params(pcm, &params);
+			}
+
 			goto _again;			
 		}
 		if ((snd_pcm_uframes_t) avail > pcm->xfer_align)
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux