ANativeWindow, SurfaceTexture 분석하려고 찾아본 부분들
--------------------------------------------------------------------------------------------
AwesonePlayer => OMXCodec 호출
OMXCodec 를 생성할 때 IOMX를 하나 넣게 되어 있는데
static sp<MediaSource> Create(
const sp<IOMX> &omx,
const sp<MetaData> &meta, bool createEncoder,
const sp<MediaSource> &source,
const char *matchComponentName = NULL,
uint32_t flags = 0,
const sp<ANativeWindow> &nativeWindow = NULL);
이때 첫번째 인자로 IOMX가 들어간다.
이 IOMX는 AwesomPlayer 의 OMXClient 의 멤버이다.
OMXClient를 추적하면 AwesomPlayer 가 생성될때 만들어지는데 이놈은 바인더로 OMX 인터페이스를 가져오는 놈이다.
--------------------------------------------------------------------------------------------
struct OMXMaster : public OMXPluginBase
--------------------------------------------------------------------------------------------
class OMX : public BnOMX,
public IBinder::DeathRecipient {
OMX 클래스에서 OMXMaster 구조체 사용함
OMX 클래스에서 OMXNodeInstance 사용함
OMX 에서 OMXMaster를 호출
OMX::OMX()
: mMaster(new OMXMaster),
mNodeCounter(0) {
}
그리고
status_t OMX::allocateNode(
const char *name, const sp<IOMXObserver> &observer, node_id *node) {
Mutex::Autolock autoLock(mLock);
*node = 0;
OMXNodeInstance *instance = new OMXNodeInstance(this, observer);
OMX_COMPONENTTYPE *handle;
OMX_ERRORTYPE err = mMaster->makeComponentInstance(
name, &OMXNodeInstance::kCallbacks,
instance, &handle);
--------------------------------------------------------------------------------------------
ACodec 은 뭘까?
struct ACodec : public AHierarchicalStateMachine
--------------------------------------------------------------------------------------------
status_t SurfaceTextureLayer::queueBuffer(int buf, int64_t timestamp,
uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
status_t res = SurfaceTexture::queueBuffer(buf, timestamp,
outWidth, outHeight, outTransform);
sp<Layer> layer(mLayer.promote());
if (layer != NULL) {
*outTransform = layer->getTransformHint();
}
return res;
}
--------------------------------------------------------------------------------------------
int FramebufferNativeWindow::queueBuffer(ANativeWindow* window,
ANativeWindowBuffer* buffer)
{
FramebufferNativeWindow* self = getSelf(window);
Mutex::Autolock _l(self->mutex);
framebuffer_device_t* fb = self->fbDev;
buffer_handle_t handle = static_cast<NativeBuffer*>(buffer)->handle;
const int index = self->mCurrentBufferIndex;
GraphicLog& logger(GraphicLog::getInstance());
logger.log(GraphicLog::SF_FB_POST_BEFORE, index);
int res = fb->post(fb, handle);
logger.log(GraphicLog::SF_FB_POST_AFTER, index);
self->front = static_cast<NativeBuffer*>(buffer);
self->mNumFreeBuffers++;
self->mCondition.broadcast();
return res;
}
FramebufferNativeWindow::FramebufferNativeWindow()
: BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false)
{
hw_module_t const* module;
if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
int stride;
int err;
int i;
err = framebuffer_open(module, &fbDev);
ALOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err));
err = gralloc_open(module, &grDev);
ALOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err));
// bail out if we can't initialize the modules
if (!fbDev || !grDev)
return;
mUpdateOnDemand = (fbDev->setUpdateRect != 0);
// initialize the buffer FIFO
mNumBuffers = NUM_FRAME_BUFFERS;
mNumFreeBuffers = NUM_FRAME_BUFFERS;
mBufferHead = mNumBuffers-1;
for (i = 0; i < mNumBuffers; i++)
{
buffers[i] = new NativeBuffer(
fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB);
}
for (i = 0; i < mNumBuffers; i++)
{
err = grDev->alloc(grDev,
fbDev->width, fbDev->height, fbDev->format,
GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride);
ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s",
i, fbDev->width, fbDev->height, strerror(-err));
if (err)
{
mNumBuffers = i;
mNumFreeBuffers = i;
mBufferHead = mNumBuffers-1;
break;
}
}
const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags;
const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi;
const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi;
const_cast<int&>(ANativeWindow::minSwapInterval) =
fbDev->minSwapInterval;
const_cast<int&>(ANativeWindow::maxSwapInterval) =
fbDev->maxSwapInterval;
} else {
ALOGE("Couldn't get gralloc module");
}
ANativeWindow::setSwapInterval = setSwapInterval;
ANativeWindow::dequeueBuffer = dequeueBuffer;
ANativeWindow::lockBuffer = lockBuffer;
ANativeWindow::queueBuffer = queueBuffer;
ANativeWindow::query = query;
ANativeWindow::perform = perform;
}
'Android' 카테고리의 다른 글
ICS SurfaceFlinger 구조도 (0) | 2012.05.09 |
---|---|
android OMX Plug-in 추적 (0) | 2012.04.23 |
ICS Video Render 과정 (0) | 2012.04.20 |