All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [alsa-cvslog] CVS: alsa-kernel/core/oss pcm_oss.c,1.87,1.88
       [not found] <E1DbLgK-0000QR-5z@sc8-pr-cvs1.sourceforge.net>
@ 2005-05-27  8:40 ` Jaroslav Kysela
  2005-05-27  9:23   ` Clemens Ladisch
  0 siblings, 1 reply; 4+ messages in thread
From: Jaroslav Kysela @ 2005-05-27  8:40 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Takashi Iwai, ALSA development

On Thu, 26 May 2005, Clemens Ladisch wrote:

> Update of /cvsroot/alsa/alsa-kernel/core/oss
> In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1617
> 
> Modified Files:
> 	pcm_oss.c 
> Log Message:
> Summary: pcm_oss - fix SNDCTL_DSP_GETOPTR not working correctly
> 
> This patch changes snd_pcm_oss_bytes() by adding a local variable
> for the frames -> bytes conversion, which means that the frame count
> is no longer corrupted by this conversion.

It seems like a wrong patch to me. We cannot mix frames with bytes (see
last expression). I think that there is a overflow in the return
expression.

					Jaroslav

> 
> Signed-off-by: Roger Mach <bigmach@us.ibm.com>
> 
> Index: pcm_oss.c
> ===================================================================
> RCS file: /cvsroot/alsa/alsa-kernel/core/oss/pcm_oss.c,v
> retrieving revision 1.87
> retrieving revision 1.88
> diff -u -r1.87 -r1.88
> --- pcm_oss.c	12 Apr 2005 16:33:59 -0000	1.87
> +++ pcm_oss.c	26 May 2005 16:58:01 -0000	1.88
> @@ -124,11 +124,12 @@
>  
>  static long snd_pcm_oss_bytes(snd_pcm_substream_t *substream, long frames)
>  {
> +	long bytes = 0;
>  	snd_pcm_runtime_t *runtime = substream->runtime;
>  	snd_pcm_uframes_t buffer_size = snd_pcm_lib_buffer_bytes(substream);
> -	frames = frames_to_bytes(runtime, frames);
> +	bytes = frames_to_bytes(runtime, frames);
>  	if (buffer_size == runtime->oss.buffer_bytes)
> -		return frames;
> +		return bytes;
>  	return (runtime->oss.buffer_bytes * frames) / buffer_size;
>  }

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [alsa-cvslog] CVS: alsa-kernel/core/oss pcm_oss.c,1.87,1.88
  2005-05-27  8:40 ` [alsa-cvslog] CVS: alsa-kernel/core/oss pcm_oss.c,1.87,1.88 Jaroslav Kysela
@ 2005-05-27  9:23   ` Clemens Ladisch
  2005-05-27  9:32     ` Takashi Iwai
  2005-05-27 10:12     ` Jaroslav Kysela
  0 siblings, 2 replies; 4+ messages in thread
From: Clemens Ladisch @ 2005-05-27  9:23 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, ALSA development

Jaroslav Kysela wrote:
> On Thu, 26 May 2005, Clemens Ladisch wrote:
> > Modified Files:
> > 	pcm_oss.c
> > Log Message:
> > Summary: pcm_oss - fix SNDCTL_DSP_GETOPTR not working correctly
> >
> > This patch changes snd_pcm_oss_bytes() by adding a local variable
> > for the frames -> bytes conversion, which means that the frame count
> > is no longer corrupted by this conversion.
>
> It seems like a wrong patch to me. We cannot mix frames with bytes (see
> last expression).

I assumed that buffer_size would be in frames (due to its type), but
this is obviously wroung.

> This reverts the last patch which wrongly mixes bytes and frames.
> The real culprit might be the 32-bit overflow, so the return expression uses
> 64-bit values now in snd_pcm_oss_bytes().
>
>  static long snd_pcm_oss_bytes(snd_pcm_substream_t *substream, long frames)
>  {
> -     long bytes = 0;
>       snd_pcm_runtime_t *runtime = substream->runtime;
>       snd_pcm_uframes_t buffer_size = snd_pcm_lib_buffer_bytes(substream);
> -     bytes = frames_to_bytes(runtime, frames);
> +     frames = frames_to_bytes(runtime, frames);
>       if (buffer_size == runtime->oss.buffer_bytes)
> -             return bytes;
> -     return (runtime->oss.buffer_bytes * frames) / buffer_size;
> +             return frames;
> +     return (long)(((int64_t)runtime->oss.buffer_bytes * (int64_t)frames) / (int64_t)buffer_size);
>  }

This still uses a misleading type for buffer_size, and uses 'frames'
for a value not measure in frames.  I think I'd better rename these.
Any objections?


Regards,
Clemens



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [alsa-cvslog] CVS: alsa-kernel/core/oss pcm_oss.c,1.87,1.88
  2005-05-27  9:23   ` Clemens Ladisch
@ 2005-05-27  9:32     ` Takashi Iwai
  2005-05-27 10:12     ` Jaroslav Kysela
  1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2005-05-27  9:32 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Jaroslav Kysela, ALSA development

At Fri, 27 May 2005 11:23:17 +0200 (METDST),
Clemens Ladisch wrote:
> 
> > This reverts the last patch which wrongly mixes bytes and frames.
> > The real culprit might be the 32-bit overflow, so the return expression uses
> > 64-bit values now in snd_pcm_oss_bytes().
> >
> >  static long snd_pcm_oss_bytes(snd_pcm_substream_t *substream, long frames)
> >  {
> > -     long bytes = 0;
> >       snd_pcm_runtime_t *runtime = substream->runtime;
> >       snd_pcm_uframes_t buffer_size = snd_pcm_lib_buffer_bytes(substream);
> > -     bytes = frames_to_bytes(runtime, frames);
> > +     frames = frames_to_bytes(runtime, frames);
> >       if (buffer_size == runtime->oss.buffer_bytes)
> > -             return bytes;
> > -     return (runtime->oss.buffer_bytes * frames) / buffer_size;
> > +             return frames;
> > +     return (long)(((int64_t)runtime->oss.buffer_bytes * (int64_t)frames) / (int64_t)buffer_size);
> >  }
> 
> This still uses a misleading type for buffer_size, and uses 'frames'
> for a value not measure in frames.  I think I'd better rename these.
> Any objections?

I second.


Takashi


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [alsa-cvslog] CVS: alsa-kernel/core/oss pcm_oss.c,1.87,1.88
  2005-05-27  9:23   ` Clemens Ladisch
  2005-05-27  9:32     ` Takashi Iwai
@ 2005-05-27 10:12     ` Jaroslav Kysela
  1 sibling, 0 replies; 4+ messages in thread
From: Jaroslav Kysela @ 2005-05-27 10:12 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Takashi Iwai, ALSA development

On Fri, 27 May 2005, Clemens Ladisch wrote:

> This still uses a misleading type for buffer_size, and uses 'frames'
> for a value not measure in frames.  I think I'd better rename these.
> Any objections?

Done.

						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-05-27 10:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1DbLgK-0000QR-5z@sc8-pr-cvs1.sourceforge.net>
2005-05-27  8:40 ` [alsa-cvslog] CVS: alsa-kernel/core/oss pcm_oss.c,1.87,1.88 Jaroslav Kysela
2005-05-27  9:23   ` Clemens Ladisch
2005-05-27  9:32     ` Takashi Iwai
2005-05-27 10:12     ` Jaroslav Kysela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.