# HG changeset patch
# User Simon Farnsworth <simon.farnsworth@onelan.co.uk>
# Date 1217261681 -3600
# Node ID d48b28d89d229458b2068e047f00cc56de4f4c2f
# Parent  eeb73d0eab24590e2654cd2c6cfd7e4edbeacef8
Preallocate after we know how large the frames will be (fixes a buffer overrun)

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@ xine-lib (1.1.15) 2008-??-??
   * Xv deinterlacing didn't take the size of the deinterlaced image into
     account; on some chipsets, this would cause image corruption, while on
     others, there would be no problem.
+  * V4L changes:
+    - Delay preallocating video frames until we know how large they'll be
 
 xine-lib (1.1.14) 2008-06-29
   * DVB changes:
diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c
--- a/src/input/input_v4l.c
+++ b/src/input/input_v4l.c
@@ -892,10 +892,6 @@ static int open_video_capture_device(v4l
   _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1);
   _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1);
   
-  /* Pre-allocate some frames for audio and video so it doesn't have to be 
-   * done during capture */
-  allocate_frames(this, 1);
-  
   /* Unmute audio off video capture device */
   unmute_audio(this);
   
@@ -1004,7 +1000,11 @@ static int open_video_capture_device(v4l
   
   xine_set_param(this->stream, XINE_PARAM_VO_ZOOM_X, 103);
   xine_set_param(this->stream, XINE_PARAM_VO_ZOOM_Y, 103);
-  
+
+  /* Pre-allocate some frames for audio and video so it doesn't have to be 
+   * done during capture */
+  allocate_frames(this, 1);
+
   /* If we made it here, everything went ok */ 
   this->audio_only = 0;
   if (tuner_found)
