Skip to content

Commit

Permalink
Update Camera Samples - remove ForeignWindowControl race condition wo…
Browse files Browse the repository at this point in the history
…rkaround
  • Loading branch information
Sean McVeigh committed Dec 12, 2012
1 parent 42d7e66 commit 057ef88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
17 changes: 0 additions & 17 deletions HelloCamera/src/hellocameraapp.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@


using namespace bb::cascades; using namespace bb::cascades;


// define this to debug the ForeignWindowControl race condition
#define BREAK_FWC
// define this to enable a workaround for the above race condition
//#define WORKAROUND_FWC

HelloCameraApp::HelloCameraApp(bb::cascades::Application *app) : HelloCameraApp::HelloCameraApp(bb::cascades::Application *app) :
QObject(app), QObject(app),
mCameraHandle(CAMERA_HANDLE_INVALID) mCameraHandle(CAMERA_HANDLE_INVALID)
Expand Down Expand Up @@ -102,28 +97,16 @@ void HelloCameraApp::onWindowAttached(screen_window_t win,
const QString &group, const QString &group,
const QString &id) const QString &id)
{ {
#ifdef BREAK_FWC
// typically a value of 1ms will cause the window to only be visible the
// first time you start it. on subsequent invocations, it does not become visible
// unless you force a refresh of the cascades window.
// a value of 10 ms seems to expose the problem every time.
usleep(10000);
#endif
qDebug() << "onWindowAttached: " << win << ", " << group << ", " << id; qDebug() << "onWindowAttached: " << win << ", " << group << ", " << id;
// set screen properties to mirror if this is the front-facing camera // set screen properties to mirror if this is the front-facing camera
int i = (mCameraUnit == CAMERA_UNIT_FRONT); int i = (mCameraUnit == CAMERA_UNIT_FRONT);
screen_set_window_property_iv(win, SCREEN_PROPERTY_MIRROR, &i); screen_set_window_property_iv(win, SCREEN_PROPERTY_MIRROR, &i);
// put the viewfinder window behind the cascades window // put the viewfinder window behind the cascades window
i = -1; i = -1;
screen_set_window_property_iv(win, SCREEN_PROPERTY_ZORDER, &i); screen_set_window_property_iv(win, SCREEN_PROPERTY_ZORDER, &i);
#ifdef WORKAROUND_FWC
mViewfinderWindow->setVisible(false);
mViewfinderWindow->setVisible(true);
#endif
screen_context_t screen_ctx; screen_context_t screen_ctx;
screen_get_window_property_pv(win, SCREEN_PROPERTY_CONTEXT, (void **)&screen_ctx); screen_get_window_property_pv(win, SCREEN_PROPERTY_CONTEXT, (void **)&screen_ctx);
screen_flush_context(screen_ctx, 0); screen_flush_context(screen_ctx, 0);

} }




Expand Down
13 changes: 3 additions & 10 deletions HelloVideoCamera/src/hellovideocameraapp.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@


using namespace bb::cascades; using namespace bb::cascades;


// workaround a ForeignWindowControl race condition
#define WORKAROUND_FWC



HelloVideoCameraApp::HelloVideoCameraApp(bb::cascades::Application *app) : HelloVideoCameraApp::HelloVideoCameraApp(bb::cascades::Application *app) :
mCameraHandle(CAMERA_HANDLE_INVALID), mCameraHandle(CAMERA_HANDLE_INVALID),
Expand Down Expand Up @@ -113,13 +110,9 @@ void HelloVideoCameraApp::onWindowAttached(screen_window_t win,
// put the viewfinder window behind the cascades window // put the viewfinder window behind the cascades window
i = -1; i = -1;
screen_set_window_property_iv(win, SCREEN_PROPERTY_ZORDER, &i); screen_set_window_property_iv(win, SCREEN_PROPERTY_ZORDER, &i);
#ifdef WORKAROUND_FWC screen_context_t screen_ctx;
// seems we still need a workaround in R9 for a potential race due to screen_get_window_property_pv(win, SCREEN_PROPERTY_CONTEXT, (void **)&screen_ctx);
// ForeignWindowControl updating/flushing the window's properties in screen_flush_context(screen_ctx, 0);
// parallel with the execution of the onWindowAttached() handler.
mViewfinderWindow->setVisible(false);
mViewfinderWindow->setVisible(true);
#endif
} }




Expand Down

0 comments on commit 057ef88

Please sign in to comment.