Hello Dianne H,
I have tried to use Surface & SurfaceView class as follows:
I have created my JAVA class from SurfaceView, also implementing
SurfaceHolder.Callback
JAVA Code:
===========
// class which will be passed to jni
class MySurface
{
Object mysurface;
};
class Test extends SurfaceView implements SurfaceHolder.Callback
{
...
public void surfaceCreated(SurfaceHolder holder)
{
//get surface from surface holder.
Surface sur = holder.getSurface();
// init class for jni
JNIClass objJNIClass = new JNIClass();
// init param for jni call
MySurface testSurface = new MySurface();
// setting surface in class
testSurface.mysurface = sur;
// calling jni method of class
objJNIClass.SetSurface(testSurface);
}
// JNIClass.c
===============
JNIEXPORT jint JNICALL Java_com_picus_utils_CJNIClass_1SetSurface
(JNIEnv *env, jobject objThis, jobject objTestSurface)
{
jclass class_OutputList = env->GetObjectClass(objTestSurface);
jfieldID id_object = env->GetFieldID
(class_OutputList,"mysurface","Ljava/leng/object;");
jobject surface = env->GetObjectField(objTestSurface,id_object);
// calling c function
return SetSurface((void*)surface);
}
// Actual C function
int SetSurface(void* pSurface)
{
sp<Surface> surf = (Surface*)pSurface;
}
It is crashing when doing above assignment in actual C function.
Please guide me how to use pSurface in C code to post buffers to
display !!!
I have taken surface object's type as void* because in JNI code I
wasn't able to find Surface definition. Do i need to typecast in JNI
code?
Thanks,
JC
On Sep 14, 9:39 am, Dianne Hackborn <
hack...@android.com> wrote:
> The API is Java (SurfaceView and Surface are indeed what you want). You'll
> just need to use JNI to call through to the Java API.
>
>
>
>
>
> On Mon, Sep 13, 2010 at 8:24 PM, JC <
j...@oriolesoftware.com> wrote:
> > Thanks David,
>
> > I have gone thru the classes provided on website.
> > classes that seems to be useful are
> > Surface, SurfaceView... but there is no direct class/API to use
> > flinger.
>
> > can u point me correct direction by psudo/example code/method. It
> > would be greatful.
>
> > Thanks in advance.
>
> > JC
>
> > On Sep 13, 6:39 pm, David Turner <
di...@android.com> wrote:
> > > On Mon, Sep 13, 2010 at 11:51 AM, JC <
j...@oriolesoftware.com> wrote:
>
> > > > David,
> > > > What could be other way to work with Surface flinger? From JAVA-JNI?
>
> > > Only use the public APIs documented on
developer.android.com. For
> > > SurfaceFlinger, you should only use the Java APIs (even if you access
> > > through JNI in your native code)
>
> > > > Mic_
> > > > I am using Eclipse, as per document it will create .keystore file and
> > > > signed APK file before loading onto emulator. (http://
> > > >
developer.android.com/guide/publishing/app-signing.html#setup)
> > > > How can application get signed?
>
> > > > Ganesh,
> > > > I am checking mentioned thing.
>
> > > > Thanks in advance
> > > > JC
>
> > > > On Sep 13, 2:40 pm, David Turner <
di...@android.com> wrote:
> > > > > Don't do that, SurfaceFlinger is a very volatile part of the system.
> > > > Unless
> > > > > you're considering a custom system image (instead of an application),
> > > > > chances that your code is going to work properly or even simply
> > link/run
> > > > on
> > > > > all devices or on future platform releases are pretty weak.
>
> > > > > On Mon, Sep 13, 2010 at 10:04 AM, JC <
j...@oriolesoftware.com>
> > wrote:
> > > > > > Hello All,
>
> > > > > > My C code uses surface flinger code, we have written C wrapper for
> > > > > > this based on (
http://people.debian.org.tw/~olv/surfaceflinger/
> > > > > > demo.tar.gz )
>
> > > > > > My jni SO file built successfully.
>
> > > > > > In AndroidMenifest.xml, I have added following:
>
> > > > > > <uses-permission
> > > > > > android:name="android.permission.ACCESS_SURFACE_FLINGER" />
>
> > > > > > But still during runtime i am getting following error..
>
> > > > > > 09-13 07:46:34.973: WARN/ServiceManager(57): Permission failure:
> > > > > > android.permission.ACCESS_SURFACE_FLINGER from uid=10033 pid=22849
> > > > > > 09-13 07:46:34.973: ERROR/SurfaceFlinger(57): Permission Denial:
> > can't
> > > > > > access SurfaceFlinger pid=22849, uid=10033
> > > > > > 09-13 07:46:34.983: ERROR/Demo(22849): failed to create surface
>
> > > > > > What could be reason and solution?
>
> > > > > > Is there any other way to do to initialize surface flinger from
> > JAVA &
> > > > > > access it in C module? Please provide reference to it?, if any
>
> > > > > > Thanks in advance,
> > > > > > JC
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "android-ndk" group.
> > > > > > To post to this group, send email to
andro...@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to
> > > > > >
android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr
oups.com>
> > <android-ndk%2Bunsubscribe@googlegr
oups.com>
> > > > <android-ndk%2Bunsubscribe@googlegr
oups.com>
> > > > > > .
> > > > > > For more options, visit this group at
> > > > > >
http://groups.google.com/group/android-ndk?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "android-ndk" group.
> > > > To post to this group, send email to
andro...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > >
android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr
oups.com>
> > <android-ndk%2Bunsubscribe@googlegr
oups.com>
> > > > .
> > > > For more options, visit this group at
> > > >
http://groups.google.com/group/android-ndk?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "android-ndk" group.
> > To post to this group, send email to
andro...@googlegroups.com.
> > To unsubscribe from this group, send email to
> >
android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr
oups.com>
> > .
> > For more options, visit this group at
> >
http://groups.google.com/group/android-ndk?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.