On Fri 2/22/13, at 16:25, David Moore <david.moore@...> wrote:
> Hi Rodolphe,
>
> I am the original author of the Mac OS port of libdc1394 but it's been a few years since I did any active hacking on it.
>
Hi David.
> I can say that the platform_camera_t structure is supposed to be initialized to zero here:
>
> macosx/control.c:227:
>
> camera = calloc (1, sizeof (platform_camera_t));
>
yes I saw this
So what I did is adding some of the internal headers and adding a 'bad hack" to my code to be able to force the capture_is_set to 0 before calling the dc1394_capture_schedule_with_runloop function and in that case it 'works'
> However, it seems very clear that something is going wrong in your case. It might be a more subtle memory smasher.
>
I also think that something is bleeding on this variable (and may be more).
> However, you are probably in the best position to debug it further. Your test case has narrowed things down to a fairly narrow portion of code. Any further debugging would be much appreciated!
>
I intend to solve this issue … if I can.
> Is there any possibility that other threads are running that may stomp on this memory?
>
It's in a simple Cocoa application and there is no other tread accessing the camera or using the library.
Even with my hack :
// bad hack
dc1394camera_priv_t * cpriv = DC1394_CAMERA_PRIV (camera);
platform_camera_t * craw = cpriv->pcam;
craw->capture_is_set = 0;
// end of bad hack
theRunLopp = CFRunLoopGetCurrent();
err = dc1394_capture_schedule_with_runloop (camera, theRunLopp, kCFRunLoopDefaultMode);
DC1394_ERR(err,"Failed to setup the runloop");
the callback is neer called after I start the capture :
if (camera) {
err = dc1394_capture_setup(camera, 4, DC1394_CAPTURE_FLAGS_DEFAULT);
DC1394_ERR(err,"Failed to setup the capture");
err = dc1394_video_set_transmission (camera, DC1394_ON);
DC1394_ERR(err,"Failed to set video transmission to DC1394_ON");
}
I have a breakpoint inside the callback and I verified that the callback address in the camera private structure match the address of the callback function.
So something else is also happening there and if some data is getting overwritten by something it could also be the cause of the callback not being called,
> Thanks,
> David
>
Thanks for replying. I'll keep investigating.
>
>
> On Fri, Feb 22, 2013 at 3:23 PM, Rodolphe Pineau <pineau@...> wrote:
> I've been trying for a few hours to get the runloop working on OS X
> Here is the code snipset that causes issue :
>
> ======== CODE START ========
>
> // let's only use the first camera for now
> camera = dc1394_camera_new (dc1394_lib, list->ids[0].guid);
> if (!camera) {
> camera = NULL;
> dc1394_log_error("Failed to initialize camera with guid %"PRIx64, list->ids[0].guid);
> dc1394_camera_free_list (list);
> return;
> }
> printf("Using %s %s\n", camera->vendor, camera->model);
> // setup the runloop so that the callback is properly called.
> err = dc1394_capture_schedule_with_runloop (camera, CFRunLoopGetCurrent (), kCFRunLoopDefaultMode);
> DC1394_ERR(err,"Failed to setup the runloop");
>
> ======== CODE END ========
>
> This mostly always fails on the dc1394_capture_schedule_with_runloop (from dc1394/macosx/capture.h) and here is the error message I get :
>
> libdc1394 warning: schedule_with_runloop must be called before capture_setup
>
> Except I don't call dc1394_capture_setup before setting the runloop !!
> As you can see I do a dc1394_camera_new, display the name of the cam and init the runloop… nothing else.
> If I check in dc1394/macosx/capture.c I see that it test for a private variable :
>
> int
> dc1394_capture_schedule_with_runloop (dc1394camera_t * camera,
> CFRunLoopRef run_loop, CFStringRef run_loop_mode)
> {
> dc1394camera_priv_t * cpriv = DC1394_CAMERA_PRIV (camera);
> platform_camera_t * craw = cpriv->pcam;
> dc1394capture_t * capture = &(craw->capture);
>
> if (craw->capture_is_set) {
> dc1394_log_warning("schedule_with_runloop must be called before capture_setup");
> return -1;
> }
>
> capture->run_loop = run_loop;
> capture->run_loop_mode = run_loop_mode;
> return 0;
> }
>
> I wonder if the capture_is_set variable is properly initialized to 0 before being set ?
>
> Any idea on this ? … or am I the only OS X developer around here ;)
>
> Thanks, Rodolphe
>
> --
>
> | Rodolphe Pineau RTI-Zone |
> | http://www.rti-zone.org/ |
> | Robotics / Unix / Mac OS X / Astronomy |
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Mailing list for libdc1394-devel
> libdc1394-devel@...
> https://lists.sourceforge.net/lists/listinfo/libdc1394-devel
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb_______________________________________________
> Mailing list for libdc1394-devel
> libdc1394-devel@...
> https://lists.sourceforge.net/lists/listinfo/libdc1394-devel
--
| Rodolphe Pineau RTI-Zone |
| http://www.rti-zone.org/ |
| Robotics / Unix / Mac OS X / Astronomy |
|