Skip to contentSkip to conversation

Apparent bug in sound/oss/via82cxxx_audio.c GETOPTR ioctl

PATCH Jeremy White 1 participant 1 message Mar 1, 2005

lore
Share & tools
lore
#0 lore raw

Hi,

In trying to fix Wine's dsound implementation which uses mmap and DSP_SND_GETOPTR to write data out to the driver, I uncovered what appears to be a bug in the via82cxx_audio.c driver.

Specifically, via_sg_offset appears to return the number of bytes not yet consumed within the current block; we use it to adjust from blocks to a precise block count. However, it appears as though it returns 0 to indicate that no bytes have been consumed.

I was seeing results where I would get an OPTR return along the lines of 0x1c00, 0x1e00, 0x2800, and then 0x2100. Needless to say, having info.ptr go backwards causes Wine's code to have a serious hissy fit.

The attached patch fixes the problem for me, but I would appreciate review by an expert on this.

Cheers,

Jeremy

via82cxxx_audio.c.orig renamed from via82cxxx_audio.c +0 -2
@@ -2831,8 +2831,6 @@
 		unsigned long extra;
 		info.ptr = atomic_read (&chan->hw_ptr) * chan->frag_size;
 		extra = chan->frag_size - via_sg_offset(chan);
-                if (extra == chan->frag_size)
-                    extra = 0;
 		info.ptr += extra;
 		info.bytes += extra;
 	} else {