title: Recording with MediaRecorder doesn't work
body: <p>I'm trying to record video using the MediaRecorder class and I have tried many examples but all of them have the same problem, they record for a few seconds, then the preview stops for a few second, this happens a few times and after that the preview gets stuck entirely and then I get the following output:</p>
  
  <pre><code>04-05 15:53:59.257 26730-26730/? D/dalvikvm: Late-enabling CheckJNI
  04-05 15:54:01.312 26730-26730/com.example.sition.videopoc D/libEGL: loaded /system/lib/egl/libEGL_MRVL.so
  04-05 15:54:01.351 26730-26730/com.example.sition.videopoc D/libEGL: loaded /system/lib/egl/libGLESv1_CM_MRVL.so
  04-05 15:54:01.359 26730-26730/com.example.sition.videopoc D/libEGL: loaded /system/lib/egl/libGLESv2_MRVL.so
  04-05 15:54:01.375 26730-26730/com.example.sition.videopoc D/GC: &lt;tid=26730&gt; OES20 ===&gt; GC Version   : GC Ver SS_rls_pxa988_JB42_R1_RC2_GC13.16
  04-05 15:54:01.421 26730-26730/com.example.sition.videopoc D/OpenGLRenderer: Enabling debug mode 0
  04-05 15:54:01.437 26730-26730/com.example.sition.videopoc I/MediaRecorderJNI: prepare: surface=0x5ac59450 (identity=2933)
  04-05 15:54:01.531 26730-26730/com.example.sition.videopoc D/v_gal: [tid=26730] gralloc_register_buffer: ===&gt;Width = 800, Height = 480, surface = 0x5ac75c38
  04-05 15:54:01.585 26730-26730/com.example.sition.videopoc D/v_gal: [tid=26730] gralloc_register_buffer: ===&gt;Width = 800, Height = 480, surface = 0x5ac44360
  04-05 15:54:02.789 26730-26730/com.example.sition.videopoc D/v_gal: [tid=26730] gralloc_unregister_buffer: ===&gt;Width = 800, Height = 480, surface = 0x5ac75c38
  04-05 15:54:02.789 26730-26730/com.example.sition.videopoc D/v_gal: [tid=26730] gralloc_unregister_buffer: ===&gt;Width = 800, Height = 480, surface = 0x5ac44360
  04-05 15:54:03.546 26730-26730/com.example.sition.videopoc W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
  04-05 15:54:06.609 26730-26730/com.example.sition.videopoc I/MediaRecorderJNI: prepare: surface=0x5ac59450 (identity=2947)
  04-05 15:54:06.656 26730-26730/com.example.sition.videopoc D/v_gal: [tid=26730] gralloc_register_buffer: ===&gt;Width = 800, Height = 480, surface = 0x5ac75c38
  04-05 15:54:06.765 26730-26730/com.example.sition.videopoc D/v_gal: [tid=26730] gralloc_register_buffer: ===&gt;Width = 800, Height = 480, surface = 0x5ac44360
  04-05 15:54:23.382 26730-26766/com.example.sition.videopoc W/Camera: Camera server died!
  04-05 15:54:23.382 26730-26766/com.example.sition.videopoc W/IMediaDeathNotifier: media server died
  04-05 15:54:25.382 26730-26730/com.example.sition.videopoc D/v_gal: [tid=26730] gralloc_unregister_buffer: ===&gt;Width = 800, Height = 480, surface = 0x5ac75c38
  04-05 15:54:25.382 26730-26730/com.example.sition.videopoc D/v_gal: [tid=26730] gralloc_unregister_buffer: ===&gt;Width = 800, Height = 480, surface = 0x5ac44360
  </code></pre>
  
  <p>This is the Activity where this happens:</p>
  
  <pre><code>public class MainActivity extends Activity implements View.OnClickListener, SurfaceHolder.Callback {
      MediaRecorder recorder;
      SurfaceHolder holder;
      boolean recording = false;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                  WindowManager.LayoutParams.FLAG_FULLSCREEN);
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  
          recorder = new MediaRecorder();
          initRecorder();
          setContentView(R.layout.activity_main);
  
          SurfaceView cameraView = (SurfaceView) findViewById(R.id.cameraView);
          holder = cameraView.getHolder();
          holder.addCallback(this);
          holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  
          cameraView.setClickable(true);
          cameraView.setOnClickListener(this);
      }
  
      private void initRecorder() {
          recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
          recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
  
          CamcorderProfile cpHigh = CamcorderProfile
                  .get(CamcorderProfile.QUALITY_HIGH);
          recorder.setProfile(cpHigh);
          recorder.setOutputFile("/sdcard/videocapture_example.mp4");
          recorder.setMaxDuration(50000); // 50 seconds
          recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
      }
  
      private void prepareRecorder() {
          recorder.setPreviewDisplay(holder.getSurface());
  
          try {
              recorder.prepare();
          } catch (IllegalStateException e) {
              e.printStackTrace();
              finish();
          } catch (IOException e) {
              e.printStackTrace();
              finish();
          }
      }
  
      public void onClick(View v) {
          if (recording) {
              recorder.stop();
              recording = false;
  
              // Let's initRecorder so we can record again
              initRecorder();
              prepareRecorder();
          } else {
              recording = true;
              recorder.start();
          }
      }
  
      public void surfaceCreated(SurfaceHolder holder) {
          prepareRecorder();
      }
  
      public void surfaceChanged(SurfaceHolder holder, int format, int width,
                                 int height) {
      }
  
      public void surfaceDestroyed(SurfaceHolder holder) {
          if (recording) {
              recorder.stop();
              recording = false;
          }
          recorder.release();
          finish();
      }
  }
  </code></pre>
  
  <p>And this is the layout file:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
  
      &lt;SurfaceView
          android:id="@+id/cameraView"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I can't even open the files created by this application (but they do contain data).</p>