IOException on Camera.startPreview

All your problems with Audio, Video and Images.

IOException on Camera.startPreview

Postby pure » Tue Dec 09, 2008 9:43 pm

I am trying to use the PreviewCallback but i get an IOException saying:
"startPreview failed". I run the emulator in the debugger.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class CamApp extends Activity implements Camera.PreviewCallback {
  2.        
  3.         @Override
  4.     public void onCreate(Bundle savedInstanceState) {
  5.         super.onCreate(savedInstanceState);
  6.        
  7.         SurfaceView surfView = new SurfaceView(this);
  8.         setContentView(surfView);
  9.              
  10.         Camera cam = Camera.open();
  11.         Camera.Parameters parameters = cam.getParameters();
  12.         parameters.setPreviewSize(100, 100);
  13.         cam.setParameters(parameters);  
  14.         cam.setPreviewCallback(this);
  15.         cam.startPreview();
  16.  
  17.     }
  18.  
  19.         @Override
  20.         public void onPreviewFrame(byte[] data, Camera camera) {
  21.                        
  22.         }
  23.  
  24. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Stack Trace
Code: Select all
Thread [<3> main] (Suspended (exception RuntimeException))   
   ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord) line: 2140   <--- Here is where i can see the IOException
   ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord) line: 2156   
   ActivityThread.access$1800(ActivityThread, ActivityThread$ActivityRecord) line: 112   
   ActivityThread$H.handleMessage(Message) line: 1580   
   ActivityThread$H(Handler).dispatchMessage(Message) line: 88   
   Looper.loop() line: 123   
   ActivityThread.main(String[]) line: 3742   
   Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]   
   Method.invoke(Object, Object...) line: 515   
   ZygoteInit$MethodAndArgsCaller.run() line: 739   
   ZygoteInit.main(String[]) line: 497   
   NativeStart.main(String[]) line: not available [native method]   
pure
Freshman
Freshman
 
Posts: 4
Joined: Sun Dec 07, 2008 4:25 pm

Top

Postby pure » Thu Dec 11, 2008 9:44 pm

I have located the the line that throws the exception. What the hell
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. static void android_hardware_Camera_startPreview(JNIEnv *env, jobject thiz)
  3.  
  4. {
  5.  
  6.     Camera *c = get_native_camera(env, thiz);
  7.  
  8.     if (c == 0)
  9.  
  10.         return;
  11.  
  12.  
  13.  
  14.     if (c->startPreview() != NO_ERROR) {
  15.  
  16.         jniThrowException(env, "java/io/IOException", "startPreview failed");
  17.  
  18.         return;
  19.  
  20.     }
  21.  
  22. }
  23.  
  24.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

So i guess the c->startPreview() rerurns an error.. but what error and how

There is a lot of logging going on in the cpp files. Is it possible to have the logging turned on in the emulator?
pure
Freshman
Freshman
 
Posts: 4
Joined: Sun Dec 07, 2008 4:25 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 17 guests