title: ACodec call to OMX_GetExtensionIndex fails, during playback of an m3u8 file
body: <p>This is somewhat a follow-up to question:</p>
  
  <p><a href="https://stackoverflow.com/questions/15760953/m3u8-file-not-playing-in-android-emulator">m3u8 file not playing in Android Emulator</a></p>
  
  <p>I have a very similar issue to the one asked over there, but with a real device where JB has been ported to (project details at: <a href="http://groups.google.com/group/renesas-emev-osp/topics" rel="nofollow noreferrer">http://groups.google.com/group/renesas-emev-osp/topics</a>):</p>
  
  <pre><code>V/MediaPlayerJNI( 1064): setDataSource: path http://rai-i.akamaihd.net/i/20140610/tg1notte-100620141.00.00_REPLAY_,400,600,800,.mp4.csmil/master.m3u8
  V/MediaPlayer( 1064): setDataSource(http://rai-i.akamaihd.net/i/20140610/tg1notte-100620141.00.00_REPLAY_,400,600,800,.mp4.csmil/master.m3u8)
  V/MediaPlayer( 1064): setVideoSurfaceTexture
  V/MediaPlayerJNI( 1064): setAudioStreamType: 3
  ...
  D/MediaPlayer( 1064): getMetadata
  E/MediaPlayerService(   74): getMetadata failed -38
  V/MediaPlayerJNI( 1064): start
  V/MediaPlayer( 1064): start
  ...
  V/MediaPlayer( 1064): start
  I/avc_utils(   74): found AVC codec config (700 x 394, Main-profile level 3.1)
  V/ACodec  (   74): Now uninitialized
  V/ACodec  (   74): onAllocateComponent
  I/ESQueue (   74): found AAC codec config (44100 Hz, 2 channels)
  I/EV2OMXPlugin(   74): ***run OMFPlugin ------- makeComponentInstance !!!!!!!!
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] Now Loaded
  V/ACodec  (   74): onConfigureComponent - msg: AMessage(what = 'setu', target = 14) = {
  V/ACodec  (   74):    string mime = "video/avc"
  V/ACodec  (   74):    int32_t width = 700
  V/ACodec  (   74):    int32_t height = 394
  V/ACodec  (   74):    ABuffer *csd-0 = 0x2a06af40
  V/ACodec  (   74):    ABuffer *csd-1 = 0x2a0722b0
  V/ACodec  (   74):    RefBase *native-window = 0x2a026e88
  V/ACodec  (   74):  }
  V/ACodec  (   74): initNativeWindow
  E/OMXNodeInstance(   74): OMX_GetExtensionIndex (index:'7fffffff') failed
  F/ACodec  (   74): frameworks/av/media/libstagefright/ACodec.cpp:3107 CHECK_EQ( (status_t)OK,mCodec-&gt;initNativeWindow()) failed: 0 vs. -2147483648
  F/libc    (   74): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 1490 (NuPlayerDecoder)
  ...
  </code></pre>
  
  <p>As for the emulator case above, the OMX_GetExtensionIndex call fails, as the vendor OMX implementation doesn't include the NativeBuffer-related functions:</p>
  
  <p><a href="https://github.com/Renesas-EMEV2/Renesas-device_emev/blob/emev-4.1/omf/OMF_Extension.h" rel="nofollow noreferrer">https://github.com/Renesas-EMEV2/Renesas-device_emev/blob/emev-4.1/omf/OMF_Extension.h</a></p>
  
  <p>In the OMXCodec (used by the AwesomePlayer to succesfully play mp4 files) initNativeWindow() isn't invoked at all (as per debug logs I've captured).</p>
  
  <p>Also, our JB porting included this additional check for componentName, in the OMXCodec creation:</p>
  
  <pre><code>OMXCodec::OMXCodec(
      const sp&lt;IOMX&gt; &amp;omx, IOMX::node_id node,
      uint32_t quirks, uint32_t flags,
      bool isEncoder,
      const char *mime,
      const char *componentName,
      const sp&lt;MediaSource&gt; &amp;source,
      const sp&lt;ANativeWindow&gt; &amp;nativeWindow)
  : mOMX(omx),
  ...
      mNativeWindow(
          (!strncmp(componentName, "OMX.google.", 11)
          || !strncmp(componentName, "OMX.RENESAS.", 12)
          || !strcmp(componentName, "OMX.Nvidia.mpeg2v.decode"))
                  ? NULL : nativeWindow) {
  ...
  </code></pre>
  
  <p>So, looks like mNativeWindow is nullified in our case (OMX.RENESAS.) and that makes a bunch of logic being skipped, including initNativeWindow of course.</p>
  
  <p>Adding this same check, not to call the InitNativeWindow logic, in ACodec::onConfgureComponent:</p>
  
  <pre><code>if (msg-&gt;findObject("native-window", &amp;obj)
          &amp;&amp; strncmp("OMX.google.", mCodec-&gt;mComponentName.c_str(), 11)
      &amp;&amp; strncmp("OMX.RENESAS.", mCodec-&gt;mComponentName.c_str(), 12)) {
          ...
      CHECK_EQ((status_t)OK, mCodec-&gt;initNativeWindow());
  }
  </code></pre>
  
  <p>NuPlayer isn't crashing anymore on the m3u8 playback, but screen remains black on m3u8 playback, while audio goes on!</p>
  
  <p>Comparing logs from the OMXCodec (mp4 - OK) vs ACodec (m3u8 - black outout) I can see similar calls repeating:</p>
  
  <pre><code>V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] allocating 2 buffers of size 1048576 on input port
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] allocated buffer 0x2a04b020 on input port
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] allocated buffer 0x2a065ca8 on input port
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] allocating 5 buffers of size 3133440 on output port
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] allocated buffer 0x2a065dd0 on output port
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] allocated buffer 0x2a061de0 on output port
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] allocated buffer 0x2a061ec0 on output port
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] allocated buffer 0x2a061fc0 on output port
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] allocated buffer 0x2a0620a0 on output port
  ...
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] EMPTY_BUFFER_DONE(buffer: 0x2a04b020)
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] Calling emptyBuffer on buffer 0x2a04b020 (length 18339), timestamp 40000 us (0.04 
  ...
  V/OMXCodec(   74): [OMX.RENESAS.VIDEO.DECODER.H264] FILL_BUFFER_DONE(buffer: 0x2a065dd0, size: 449280, flags: 0x00000010, timestamp: 40000 us (0.04 secs))
  ...
  
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] Now Loaded-&gt;Idle
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] Allocating 2 buffers of size 1048576 on input port
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] Allocating 5 buffers of size 3133440 on output port
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] Now Idle-&gt;Executing
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling fillBuffer 0x2a068970
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling fillBuffer 0x2a056fd0
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling fillBuffer 0x2a0570e8
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling fillBuffer 0x2a057228
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling fillBuffer 0x2a0572f8
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] Now Executing
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling emptyBuffer 0x2a054898 w/ codec specific data
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] onOMXEmptyBufferDone 0x2a054898
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling emptyBuffer 0x2a03cb88 w/ codec specific data
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling emptyBuffer 0x2a054898 w/ time 0 us
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] onOMXEmptyBufferDone 0x2a03cb88
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] onOMXEmptyBufferDone 0x2a054898
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling emptyBuffer 0x2a03cb88 w/ time 40000 us
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] onOMXEmptyBufferDone 0x2a03cb88
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling emptyBuffer 0x2a054898 w/ time 80000 us
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] calling emptyBuffer 0x2a03cb88 w/ time 120000 us
  V/ACodec  (   74): [OMX.RENESAS.VIDEO.DECODER.H264] onOMXFillBufferDone 0x2a068970 time 0 us, flags = 0x00000010
  </code></pre>
  
  <p>...</p>
  
  <p>but looks like something else is still missing...</p>
  
  <p>Any suggestion?</p>