[MPlayer-advusers] PATCH: FPE in demux_audio.c

Andrew A. Gill superluser at frontiernet.net
Thu Jul 28 04:27:21 CEST 2005


On Thu, 28 Jul 2005, Ivo wrote:
>
> Why use a switch statement? You can also do:

I thought that switches were more efficient.  Brief googling
informs me that in this case, they are not.  I shall change the
patch, recompile and send it along.

OK.  It works and is attached.

> Same for the other switch. It's a lot shorter and also has no cosmetic
> changes (which are mostly forbidden, see DOCS/tech/patches.txt).

Well, you're going to need cosmetic changes to get rid of the
goto statements eventually.  ;-P

> BTW It's better if you post your patches to mplayer-dev-eng.

I would, but I figured that this list would be better to ask
about code efficiency and exception handling.  Most coders
couldn't care less about efficiency or exceptions.

-- 
|Andrew A. Gill                       |I posted to Silent-Tristero and|
|<superluser at frontiernet.net>         |all I got was this stupid sig! |
|alt.tv.simpsons CBG-FAQ author       |                               |
|                          (Report all obscene mail to Le Maitre Pots)|
|Yet: <http://www.needsfoodbadly.com>                 Temporary sig: --

Why do you have those goto statements?
-------------- next part --------------
--- main/libmpdemux/demux_audio.c	2005-07-27 22:11:53.000000000 -0400
+++ main/libmpdemux/demux_audio.c	2005-07-27 22:15:19.000000000 -0400
@@ -415,7 +415,8 @@
     l = 65535;
     dp = new_demux_packet(l);
     l = stream_read(s,dp->buffer,l);
-    priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + l/(float)sh_audio->i_bps;
+    if (sh_audio->i_bps) {priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + l/(float)sh_audio->i_bps;}
+    else priv->last_pts = 0;
     break;
   }
   default:
@@ -424,8 +425,9 @@
   }
 
   resize_demux_packet(dp, l);
-  ds->pts = priv->last_pts - (ds_tell_pts(demux->audio) -
-              sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
+  if (sh_audio->i_bps) {ds->pts = priv->last_pts - (ds_tell_pts(demux->audio) -
+              sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;}
+  else priv->last_pts = 0;
   ds_add_packet(ds, dp);
   return 1;
 }


More information about the MPlayer-advusers mailing list