Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Trusted Contributor
itcraps
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
Accepted Solution

Camera Code Sample from HelloCameraApp

void HelloCameraApp::onWindowAttached(screen_window_t win,
                                          const QString &group,
                                          const QString &id)
{
    qDebug() << "onWindowAttached: " << win << ", " << group << ", " << id;
    // set screen properties to mirror if this is the front-facing camera
    int i = (mCameraUnit == CAMERA_UNIT_FRONT);
    screen_set_window_property_iv(win, SCREEN_PROPERTY_MIRROR, &i);
    // put the viewfinder window behind the cascades window
    i = -1;
    screen_set_window_property_iv(win, SCREEN_PROPERTY_ZORDER, &i);
#ifdef WORKAROUND_FWC
    // seems we still need a workaround in R9 for a potential race due to
    // ForeignWindowControl updating/flushing the window's properties in
    // parallel with the execution of the onWindowAttached() handler.
    mViewfinderWindow->setVisible(false);
    mViewfinderWindow->setVisible(true);
#endif
}

 

Hi, the code above was copied from the HelloCameraApp sample project.


The example works fine but I have a question about the code in Bold above.

What does it mean by these?? Thanks

// seems we still need a workaround in R9 for a potential race due to
    // ForeignWindowControl updating/flushing the window's properties in
    // parallel with the execution of the onWindowAttached() handler
www.jackdevora.com
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Camera Code Sample from HelloCameraApp

Hi,

It means there is a bug in the current 10.0.9 software release for the devices where there is a race condition between the thread updating the libscreen properties in onWindowAttached() and the Cascades UI thread which is running some ForeignWindowControl code in parallel.  If I do not include this workaround, the window may remain invisible despite being explicity set to visible by the Cascades thread.

 

I am still debugging this with the Cascades team and the graphics team.  For now, the workaround in the #ifdef will cause a re-sync with the Cascades UI thread.  Once it's fixed, this workaround (toggling visibility) will not be required.

 

Another workaround would be to tell Cascades not to update ANY window properties by initializing the window with mViewfinderWindow->setUpdateProperties(0), but then you will have to respond appropriately to all layout changes and do a manual update of all associated libscreen properties.

Cheers,

Sean

 

 

Trusted Contributor
itcraps
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10

Re: Camera Code Sample from HelloCameraApp

I see, thanks for the explanation.. Right from the coder.. :smileyvery-happy:

 

Btw, is there any plan to deprecate the camera_api.h and replace it with Cascades Camera? Cause now theres currently 2 camera libraries available.

 

Thanks

www.jackdevora.com
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: Camera Code Sample from HelloCameraApp

no plans to deprecate it.  it will always be requred as a lowest-common-demonimator.

you can't write a C app or a non-cascades app using the cascades camera API, and in fact the cascades camera API is just a convenience wrapper around a subset of camera_api.h functionality.

 

Cheers,

Sean

Trusted Contributor
itcraps
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10

Re: Camera Code Sample from HelloCameraApp

that clears things up.. Thanksss

www.jackdevora.com