Dear FrNd,

As an alternative, I am now using the surface object and getting its
"sp<ISurface>" by calling surface->getISurface(), I have managed to
get the iSurface object also.
Now I just want to register buffers to this surface and try posting
the buffer. So this what i am doing for it.


....

if(iSurface.get())
        {
                sp<MemoryHeapBase> mFrameheap = new  
MemoryHeapBase(OutputFrameSize
* MAX_FRAME_BUFFERS);
                 if (mFrameheap->heapID() < 0)
                 {
                              return RetVal;
                  }

                    /* create frame buffer heap and register with 
surfaceflinger */
                   ISurface::BufferHeap
buffers( Width,Height,Width,Height,PIXEL_FORMAT_RGB_565,mFrameheap);

                   if (isurface->registerBuffers(buffers) <
0 )                 //********** The Execution is Stopping here
************
                   {
                        LOGE("Cannot register frame buffer!");
                        mFrameheap.clear();
                        return RetVal;
                   }

                    LOGE("    After RegisterBuffers        ");
}

............

The problem now I am facing is that the execution is stopping at the
call of register buffers. At statement, "isurface-
>registerBuffers(buffers)".

Can u help me out to solve this.


Thanks and Regards
Sandeep Patil


On Jun 9, 12:37 am, Dianne Hackborn <hack...@android.com> wrote:
> sp<> and Surface are native APIs.  This code will break on various devices.
>
> The only supported way to do this is with the new extended native APIs in
> 2.3.
>
> On Tue, Jun 7, 2011 at 7:06 AM, Sandeep Patil
> <sandeep.patil2...@gmail.com>wrote:
>
>
>
>
>
>
>
>
>
> > Dear frndz,
>
> > I am facing a problem of being not able to use the surface object
> > obtained from an activity class in the native side. Here is what i am
> > doing,
>
> > * Getting a SurfaceView object with the help of findviewbyId()
> > function.
> > * Then obtaining its SurfaceHolder by calling getHolder() function of
> > the surfaceView class.
> > * Then adding a callback to the holder, so as to know when the surface
> > is being created and destroyed.
> > * Once i get the callback of onSurfaceCreated(), i am getting the
> > surface object by getSurface() of the SurfaceHolder class and setting
> > it to a (Surface mSUrface = null ) field in the Activity class.
> > * From onSurfaceCreated() itself, I am calling a native function that
> > tries to access the mSurface object and casts it to sp<Surface>.
>
> > Here is my native function,
>
> > JNIEXPORT void JNICALL setSurface(JNIEnv* env,jobject thiz)
> > {
> >    jfieldID    surfacefieldID;
> >    jfieldID    surface_native;
> >    Surface* p;
> >    jclass clazz;
>
> >    clazz = env->FindClass("com/example/SMFMediaPlayer/
> > SecondActivity");
> >    if (clazz == NULL) {
> >        LOGE("Can't find com/example/SMFMediaPlayer/SecondActivity
> > \n");
> >    }
>
> >    surfacefieldID = env->GetFieldID(clazz, "mSurface", "Landroid/view/
> > Surface;");
> >    if (surfacefieldID == NULL) {
> >        LOGE("Can't find MediaPlayer.mSurface\n");
> >    }
>
> >    jclass surface = env->FindClass("android/view/Surface");
> >    if (surface == NULL) {
> >        LOGE("Can't find android/view/Surface\n");
> >    }
>
> >    surface_native = env->GetFieldID(surface, "mSurface", "I");
>
> >    if (surface_native == NULL) {
> >        LOGE("Can't find Surface fields\n");
> >    }
>
> >    jobject surfaceobj = env->GetObjectField(thiz,surfacefieldID);
> >    if (surfaceobj != NULL)
> >    {
> >          p = (Surface*) env->GetIntField(surfaceobj, surface_native);
>
> >         if(p->isValid())
> >         {
> >                const sp<Surface>& native_Surface = sp<Surface>(p);
> >         }
> >    }
> >   .
> >  //There some more code down here
>
> > }
>
> > The problem here is that the execution is stopping at the
> > statement,"const sp<Surface>& native_Surface = sp<Surface>(p);".
>
> > I am not getting what is the mistake.
>
> > Actually i am using this code create my own media player. So i request
> > to let me know my mistake or an alternative way to access the surface
> > object. And also i need the SurfaceComposerClient object corresponding
> > the surface object.
>
> > SOmebody help me out.
>
> > Thanks You
> > Sandeep Patil
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to