From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: emu10k1 bug and patch (0.9.0rc7) Date: Thu, 13 Feb 2003 13:03:07 +0100 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <20030210172112.GA12226@via.ecp.fr> Mime-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <20030210172112.GA12226@via.ecp.fr> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: Arnaud de Bossoreille de Ribou Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Mon, 10 Feb 2003 18:21:12 +0100, Arnaud de Bossoreille de Ribou wrote: > > Hi, I discovered a bug in the emu10k1 driver which I'll explain here: > > I was developing an application which uses the timestamps given in the > status of the device to send S/PDIF data to it. This app worked pretty > well except that sometimes I heard sound discontinuities and then a > constant time delay between the sound and the video. > > I finally found where was the problem, my results is based on the > emu10k1-debug.patch file attached. The "frame" argument is equal to 0 > when the app gets the status of the device. With this patch applied I > saw some output on the console exactly at the same time the bug occured. > Adding a "else" after the "if" to prevent sw_ready from being updated > fixed the problem and the output looked like > > ---------------- > plop 0 -1536 A B > plop 0 1536 B A > ---------------- > > where B == A - 1536 (1536 is the period_size). These two lines were > repeated a few times during playback. > > So the bug looks like a signedness problem since sw_ready is unsigned > and there is a while(sw_ready > 0), which explain the constant delay, > next in the "snd_emu10k1_fx8010_playback_transfer" function. this is because of the incorrect check of boundary-wrap. the comparison below must be <= instead of <. (or, it can be simply "diff < 0".) if there only two periods, the original code cannot detect the boundary-wrap. if (diff) { ==> if (diff < -(snd_pcm_sframes_t) (runtime->boundary / 2)) diff += runtime->boundary; pcm->sw_ready += diff; } sw_ready should be unsigned safely. please try the change above with the unsigned sw_ready. anyway, thanks for your bug report! ciao, Takashi ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf