title: Min undequeued buffer count exceeded
body: <p>I am using a SurfaceTexture to get preview frames in the following way.</p>
  
  <p>First, I set a preview texture:</p>
  
  <pre><code>camera.setPreviewTexture(new SurfaceTexture(0));
  </code></pre>
  
  <p>Then, just before starting the preview and then each time <code>onPreviewFrame</code> is called, I set the callback buffer like this:</p>
  
  <pre><code>camera.addCallbackBuffer(buffer);
  camera.setPreviewCallbackWithBuffer(this);
  </code></pre>
  
  <p>It works. Sometimes, I take a picture using <code>camera.takePicture(null, null, callback)</code>, which results in calling <code>onPictureTaken</code> successfully. The image is saved. Since I want to restart the preview after the picture has been taken, I do the following:</p>
  
  <pre><code>try
  {
      camera.setPreviewTexture(new SurfaceTexture(0));
      camera.startPreview();
  }
  ...
  </code></pre>
  
  <p>The preview restarts and everything seems to be fine. But the following error is reported in my Logcat, seemingly after the preview has be restarted:</p>
  
  <pre><code>E/BufferQueue﹕ [unnamed-5682-5] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=5 undequeudCount=1)
  </code></pre>
  
  <p>Am I missing something? Should I release the old texture at some point?</p>
  
  <p><strong>Configuration:</strong> Samsung Galaxy S4, Samsung Galaxy S5, Nexus 5, running on Android KitKat.</p>
  
  <p><strong>EDIT:</strong> I am not sure wether it is linked or not, but after a while, my App does not take pictures anymore and the following messages appear continuously in my Logcat:</p>
  
  <pre><code>E/LocSvc_api_v02(  318): I/---&gt; locClientSendReq line 2332         QMI_LOC_INJECT_SENSOR_DATA_REQ_V02
  E/gsiff_dmn(  318): I/loc_api_resp_ind_callback: Received LocAPI Resp ind = 77
  E/LocSvc_api_v02(  318): D/loc_sync_process_ind:172]: loc_sync_array not in use 
  E/LocSvc_utils_q(  318): D/msg_q_rcv: Received message 0xB899D940 rv = 0
  E/gsiff_dmn(  318): I/gsiff_data_task: Handling message type = 4
  E/gsiff_dmn(  318): I/gsiff_daemon_inject_sensor_data_handler: Sending Sensor Data to     LocApi. opaque_id = 1226
  
  E/LocSvc_api_v02(  318): I/---&gt; locClientSendReq line 2332 QMI_LOC_INJECT_SENSOR_DATA_REQ_V02
  E/gsiff_dmn(  318): I/loc_api_resp_ind_callback: Received LocAPI Resp ind = 77
  E/LocSvc_api_v02(  318): D/loc_sync_process_ind:172]: loc_sync_array not in use 
  E/mm-camera(  284): [cpp_hardware_process_frame:997] Too many cpp frames dropped!!
  E/mm-camera(  284): cpp_thread_handle_process_buf_event:224] get buffer fail. drop frame id:1845 identity:0x20002
  
  W/QCamera2HWI(  269): [CHECK_BUF_LOCK] Too many preview buffer is locked by     surfaceflinger : 29
  E/mm-camera(  284): [cpp_hardware_process_frame:997] Too many cpp frames dropped!!
  E/mm-camera(  284): cpp_thread_handle_process_buf_event:224] get buffer fail. drop frame     id:1846 identity:0x20002
  </code></pre>
  
  <p><strong>EDIT 2:</strong> If, instead of a <code>new SurfaceTexture(0)</code>, I always use the same <code>SurfaceTexture</code> (that I keep as a member), then some errors disappear and the App continues to work. The <code>min undequeued buffer count exceeded</code> error and the <code>Too many preview buffer is locked by surfaceflinger</code> warning stay.</p>