Try Mode.
IsPreviewOn is True
Decoding is true.
Callback Done.
An error occured.
main_ti_tick (java line: 319)
java.lang.NullPointerException
at anywheresoftware.b4a.agraham.byteconverter.ByteConverter.HexFromBytes(ByteConverter.java:237)
at com.rootsoft.streamnationstudio.main._ti_tick(main.java:319)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:104)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:101)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3652)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
In onPreviewFrame
Initialize raw2jpg
In raw2jpg.
Done with raw2jpg
Decoding is false.
isDecoding = false;
notify();
Log.i("B4A","Decoding is false.");
currentFrame();
}
};
public byte[] currentFrame() {
return mCurrentFrame;
}
Sub mnuFocusMode_Click
s = b.HexFromBytes(camera1.currentFrame)
Msgbox(s,"")
End Sub
Sub TI_Tick
Timer1.Enabled = False
Msgbox("camera1.Picture.Length","")
'Dim out1 As OutputStream
'out1.WriteBytes(camera1.Picture, 0, camera1.Picture.Length)
's = BytesToString(camera1.Picture, 0, camera1.Picture.Length, "UTF-8")
s = b.HexFromBytes(camera1.Picture)
Msgbox("s","")
End Sub
public byte[] getPicture()
c.setOneShotPreviewCallback(mPreviewCallback);
public synchronized byte[] getPicture()
that the camera [B]is trying[/B] to call onPreviewFrame() on its own thread but as that is also a synchronised method it blocks waiting
It can't call it because the object instance is locked so the camera thread is blocked waiting for getPicture() to complete. Read up on "synchronised" in Java.So here you mean that it is trying, but it doesn't call it?
You replied "Yes" but looking in the jar you just posted they are NOT present in startPreview() and stopPreview()I've looked in the jar you posted earlier and can't see any notify() calls in startPreview(), stopPreview() or onPreviewFrame(). You have reinstated them haven't you?
It won't work anyway as you have messed up the original interlock structure by trying to use a separate monitor object which won't work with wait() and notify() as they use the monitor associated with the instance.
It is unlikely that it is stuck there as isPreviewOn is true and doesn't have to wait.getPicture() is probably stuck on "while (!isPreviewOn) wait();"
comment out "while (isDecoding) wait();" in getPicture().
@Override
public void run()
{
isMainRunning(true);
double deltaT0=0;
boolean recState=true;
double deltaT1=0;
double fps_cnt=0;
setText(osdState, " R E C ");
setText(osdFps, " 0 fps ");
while (isMainRunning())
{
final double dateT1 = new Date().getTime();
currentJPEG = cameraFrame.getPicture();
final double dateT2 = new Date().getTime();
fps_cnt += 1;
deltaT1 += dateT2 - dateT1;
deltaT0 += dateT2 - dateT1;
if (deltaT0 >= 1000)
{
if (!recState)
{
recState = true;
setText(osdState, " R E C ");
}
else
{
recState = false;
setText(osdState, " ");
}
deltaT0 = 0;
}
if (deltaT1 >= 250)
{
final String fps =
Integer.toString((int)(1000 * fps_cnt / deltaT1));
setText(osdFps, " " + fps + " fps ");
fps_cnt=0;
deltaT1 = 0;
}
}
setText(osdState, "");
setText(osdFps, "");
}
public CameraView ( Context context,
Camera camera,
Display display,
FrameLayout osd,
FrameLayout border,
Settings settings )
{
super(context);
mCamera = camera;
mDisplay = display;
mOSD = osd;
mBorder = border;
mSettings = settings;
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}