* <http://www.gnu.org/licenses/>.
*
*/
+
//#define DEBUG_VERBOSE 1
#include "system.h"
#if defined(TARGET_ANDROID)
YUVBUFFER &buf = m_buffers[idx];
- SAFE_RELEASE(m_buffers[idx].mediacodec);
+ SAFE_RELEASE(buf.mediacodec);
#endif
}
}
else if (m_renderMethod & RENDER_MEDIACODEC)
{
- RenderMediaCodec(index, m_currentField);
+ RenderSurfaceTexture(index, m_currentField);
}
else
{
#endif
}
-void CLinuxRendererGLES::RenderMediaCodec(int index, int field)
+void CLinuxRendererGLES::RenderSurfaceTexture(int index, int field)
{
#if defined(TARGET_ANDROID)
#ifdef DEBUG_VERBOSE
void CLinuxRendererGLES::UploadSurfaceTexture(int index)
{
#if defined(TARGET_ANDROID)
- if (m_buffers[index].mediacodec)
+#ifdef DEBUG_VERBOSE
+ unsigned int time = XbmcThreads::SystemClockMillis();
+#endif
+
+ int mindex = -1;
+ YUVBUFFER &buf = m_buffers[index];
+
+ if (buf.mediacodec)
{
- m_buffers[index].fields[0][0].id = m_buffers[index].mediacodec->GetTextureID();
- m_buffers[index].mediacodec->ReleaseOutputBuffer(true);
- m_buffers[index].mediacodec->UpdateTexImage();
- m_buffers[index].mediacodec->GetTransformMatrix(m_textureMatrix);
- SAFE_RELEASE(m_buffers[index].mediacodec);
+ mindex = buf.mediacodec->GetIndex();
+ buf.fields[0][0].id = buf.mediacodec->GetTextureID();
+ buf.mediacodec->UpdateTexImage();
+ buf.mediacodec->GetTransformMatrix(m_textureMatrix);
+ SAFE_RELEASE(buf.mediacodec);
}
+#ifdef DEBUG_VERBOSE
+ CLog::Log(LOGDEBUG, "UploadSurfaceTexture %d: img: %d tm:%d", index, mindex, XbmcThreads::SystemClockMillis() - time);
+#endif
#endif
}
void CLinuxRendererGLES::DeleteSurfaceTexture(int index)
unsigned int time = XbmcThreads::SystemClockMillis();
#endif
+ int mindex = -1;
YUVBUFFER &buf = m_buffers[index];
if (mediacodec)
+ {
buf.mediacodec = mediacodec->Retain();
+ mindex = buf.mediacodec->GetIndex();
+ // releaseOutputBuffer must be in same thread as
+ // dequeueOutputBuffer. We are in DVDPlayerVideo
+ // thread here, so we are safe.
+ buf.mediacodec->ReleaseOutputBuffer(true);
+ }
#ifdef DEBUG_VERBOSE
- CLog::Log(LOGDEBUG, "AddProcessor %d: img:%d: tm:%d\n", index, buf.mediacodec->GetTexture(), XbmcThreads::SystemClockMillis() - time);
+ CLog::Log(LOGDEBUG, "AddProcessor %d: img:%d tm:%d", index, mindex, XbmcThreads::SystemClockMillis() - time);
#endif
}
#endif
m_frameready->Reset();
m_codec->releaseOutputBuffer(m_index, render);
+
if (xbmc_jnienv()->ExceptionOccurred())
{
CLog::Log(LOGERROR, "CDVDMediaCodecInfo::ReleaseOutputBuffer "
xbmc_jnienv()->ExceptionDescribe();
xbmc_jnienv()->ExceptionClear();
}
+}
- // this is key, after calling releaseOutputBuffer, we must
- // wait a little for MediaCodec to render to the surface.
- // Then we can updateTexImage without delay. If we do not
- // wait, then video playback gets jerky. To optomize this,
- // we hook the SurfaceTexture OnFrameAvailable callback
- // using CJNISurfaceTextureOnFrameAvailableListener and wait
- // on a CEvent to fire. 20ms seems to be a good max fallback.
- if (render)
- m_frameready->WaitMSec(20);
+int CDVDMediaCodecInfo::GetIndex() const
+{
+ CSingleLock lock(m_section);
+
+ return m_index;
}
int CDVDMediaCodecInfo::GetTextureID() const
if (!m_valid)
return;
+ // updateTexImage will check and spew any prior gl errors,
+ // clear them before we call updateTexImage.
+ glGetError();
+
+ // this is key, after calling releaseOutputBuffer, we must
+ // wait a little for MediaCodec to render to the surface.
+ // Then we can updateTexImage without delay. If we do not
+ // wait, then video playback gets jerky. To optomize this,
+ // we hook the SurfaceTexture OnFrameAvailable callback
+ // using CJNISurfaceTextureOnFrameAvailableListener and wait
+ // on a CEvent to fire. 20ms seems to be a good max fallback.
+ m_frameready->WaitMSec(20);
+
m_surfacetexture->updateTexImage();
if (xbmc_jnienv()->ExceptionOccurred())
{