title: Video playback from Android internal storage eventually hangs/crashes
body: <p>I'm having an issue playing an mp4 video that involves the video freezing at a random but consistent point during playback (random in that it seems to differ from device to device, but consistent in that it seems to be the same place on a given device). The video in question is downloaded to the device from a remote url and saved to the internal device storage. Since the native VideoView class doesn't support video playback from the internal storage, I've created a modified version of VideoView with a new method that accepts a file descriptor pointing to the video file in question. The class has also been modified to set the media player's data source to this file descriptor. This results in the video being played from the internal device storage, albeit with the freezing issue described above.</p>
  
  <p>Judging by the logcat output pasted below, there seems to be an issue with the mediaserver crashing, possibly involving a segfault. I've seen stack traces of similar crashes elsewhere on the 'net but they seem to be related to camera usage rather than video playback. I've tested this on three different handsets, two running Android 2.2.1 and the third running Android 2.1. Can anybody indicate to me what might be causing this issue and how I can fix or circumvent it?</p>
  
  <blockquote>
    <p>WARN/InputManagerService(103): [ 01-25 14:55:48.791  9274:0x27db F/MPEG4Extractor ]<br>
    WARN/InputManagerService(103): frameworks/base/media/libstagefright/MPEG4Extractor.cpp:1595   srcOffset + mNALLengthSize &lt;= size<br>
    INFO/DEBUG(55): <strong>* <em></strong> *</em>* <strong>* <em></strong> *</em>* <strong>* <em></strong> *</em>* <strong>* <em></strong> *</em>* <strong>* <em></strong> *</em>* **<br>
    INFO/DEBUG(55): Build fingerprint: 'vodafone/vfpioneer/sapphire/sapphire:2.2.1/FRG83D/75603:user/release-keys'<br>
    INFO/DEBUG(55): pid: 9274, tid: 10203  <strong>>>> /system/bin/mediaserver &lt;&lt;&lt;</strong><br>
    INFO/DEBUG(55): <strong>signal 11 (SIGSEGV), fault addr deadbaad</strong><br>
    INFO/DEBUG(55):  r0 00000000  r1 0000000c  r2 00000027  r3 00000000<br>
    INFO/DEBUG(55):  r4 00000000  r5 deadbaad  r6 00001728  r7 fffde6df<br>
    INFO/DEBUG(55):  r8 00100000  r9 a340a1f1  10 4050a000  fp 00016db8<br>
    INFO/DEBUG(55):  ip ffffffff  sp 40609908  lr afd154c5  pc afd11dc4  cpsr 40000030<br>
    WARN/AACDecoder(9274): AAC decoder returned error 1, substituting silence<br>
    ...<br>
    WARN/AACDecoder(9274): AAC decoder returned error 1, substituting silence<br>
    INFO/DEBUG(55):          #00  pc 00011dc4  /system/lib/libc.so<br>
    INFO/DEBUG(55):          #01  pc 0000135c  /system/lib/liblog.so<br>
    INFO/DEBUG(55): code around pc:<br>
    INFO/DEBUG(55): afd11da4 1c2bd00b 2d00682d e026d1fb 2b0068db<br>
    INFO/DEBUG(55): afd11db4 4e17d003 51a02001 4d164798 24002227<br>
    INFO/DEBUG(55): afd11dc4 f7fb702a 2106ee14 ef10f7fc 05592380<br>
    WARN/AACDecoder(9274): AAC decoder returned error 1, substituting silence<br>
    INFO/DEBUG(55): afd11dd4 6091aa01 1c116054 94012006 eab6f7fc<br>
    INFO/DEBUG(55): afd11de4 2200a905 f7fc2002 f7fbeac2 2106ee00<br>
    INFO/DEBUG(55): code around lr:<br>
    INFO/DEBUG(55): afd154a4 b0834a0d 589c447b 26009001 686768a5<br>
    INFO/DEBUG(55): afd154b4 220ce008 2b005eab 1c28d003 47889901<br>
    INFO/DEBUG(55): afd154c4 35544306 d5f43f01 2c006824 b003d1ee<br>
    INFO/DEBUG(55): afd154d4 bdf01c30 0002ae7c 000000d4 1c0fb5f0<br>
    INFO/DEBUG(55): afd154e4 43551c3d a904b087 1c16ac01 604d9004<br>
    INFO/DEBUG(55): stack:<br>
    INFO/DEBUG(55):     406098c8  00000000<br>
    INFO/DEBUG(55):     406098cc  000003a0<br>
    INFO/DEBUG(55):     406098d0  afd40498  /system/lib/libc.so<br>
    INFO/DEBUG(55):     406098d4  afd41b6c  /system/lib/libc.so<br>
    INFO/DEBUG(55):     406098d8  00000000<br>
    INFO/DEBUG(55):     406098dc  afd154c5  /system/lib/libc.so<br>
    WARN/AACDecoder(9274): AAC decoder returned error 1, substituting silence<br>
    INFO/DEBUG(55):     406098e0  00000009<br>
    INFO/DEBUG(55):     406098e4  afd1450d  /system/lib/libc.so<br>
    INFO/DEBUG(55):     406098e8  0000005f<br>
    INFO/DEBUG(55):     406098ec  afd40328  /system/lib/libc.so<br>
    INFO/DEBUG(55):     406098f0  00000000<br>
    INFO/DEBUG(55):     406098f4  00001728<br>
    INFO/DEBUG(55):     406098f8  fffde6df<br>
    INFO/DEBUG(55):     406098fc  afd147ab  /system/lib/libc.so<br>
    INFO/DEBUG(55):     40609900  df002777<br>
    INFO/DEBUG(55):     40609904  e3a070ad<br>
    INFO/DEBUG(55): #00 40609908  40609904<br>
    INFO/DEBUG(55):     4060990c  00000001<br>
    INFO/DEBUG(55):     40609910  a2f89987  /system/lib/libstagefright.so<br>
    INFO/DEBUG(55):     40609914  0000000f<br>
    INFO/DEBUG(55):     40609918  4060993c<br>
    INFO/DEBUG(55):     4060991c  fffffbdf<br>
    INFO/DEBUG(55):     40609920  4060993c<br>
    INFO/DEBUG(55):     40609924  a2f89987  /system/lib/libstagefright.so<br>
    INFO/DEBUG(55):     40609928  a2fab2a8  /system/lib/libstagefright.so<br>
    INFO/DEBUG(55):     4060992c  afa0135f  /system/lib/liblog.so<br>
    INFO/DEBUG(55): #01 40609930  4060993c<br>
    INFO/DEBUG(55):     40609934  afa0135f  /system/lib/liblog.so<br>
    WARN/AACDecoder(9274): AAC decoder returned error 1, substituting silence<br>
    WARN/AACDecoder(9274): AAC decoder returned error 1, substituting silence<br>
    INFO/DEBUG(55):     40609938  40609d54<br>
    INFO/DEBUG(55):     4060993c  6d617266<br>
    INFO/DEBUG(55):     40609940  726f7765<br>
    INFO/DEBUG(55):     40609944  622f736b<br>
    INFO/DEBUG(55):     40609948  2f657361<br>
    INFO/DEBUG(55):     4060994c  6964656d<br>
    INFO/DEBUG(55):     40609950  696c2f61<br>
    INFO/DEBUG(55):     40609954  61747362<br>
    INFO/DEBUG(55):     40609958  72666567<br>
    INFO/DEBUG(55):     4060995c  74686769<br>
    INFO/DEBUG(55):     40609960  45504d2f<br>
    INFO/DEBUG(55):     40609964  78453447<br>
    INFO/DEBUG(55):     40609968  63617274<br>
    INFO/DEBUG(55):     4060996c  2e726f74<br>
    INFO/DEBUG(55):     40609970  3a707063<br>
    INFO/DEBUG(55):     40609974  35393531<br>
    WARN/AACDecoder(9274): AAC decoder returned error 1, substituting silence<br>
    ...<br>
    WARN/AACDecoder(9274): AAC decoder returned error 1, substituting silence<br>
    INFO/ServiceManager(52): service 'media.audio_flinger' died<br>
    INFO/ServiceManager(52): service 'media.player' died<br>
    INFO/ServiceManager(52): service 'media.camera' died<br>
    INFO/ServiceManager(52): service 'media.audio_policy' died<br>
    WARN/IMediaDeathNotifier(10181): media server died<br>
    ERROR/MediaPlayer(10181): error (100, 0)<br>
    ERROR/MediaPlayer(10181): Error (100,0)<br>
    DEBUG/VideoView(10181): Error: 100,0<br>
    WARN/AudioSystem(103): AudioFlinger server died!<br>
    WARN/AudioSystem(103): AudioPolicyService server died!<br>
    INFO/BootReceiver(103): Copying /data/tombstones/tombstone_03 to DropBox  (SYSTEM_TOMBSTONE)  </p>
  </blockquote>