@@ -129,22 +129,19 @@ void AndroidAppBase::HandleCmd(struct android_app* app, int32_t cmd)
129129 LOG_INFO_MESSAGE (" INIT DISPLAY - HAS SURFACE" );
130130 eng->InitDisplay ();
131131 eng->DrawFrame ();
132- std::lock_guard<std::mutex> lock (eng->mutex );
133- eng->app_status_ |= APP_STATUS_FLAG_HAS_REAL_SURFACE;
132+ eng->app_status_ .store (eng->app_status_ .load () | APP_STATUS_FLAG_HAS_REAL_SURFACE);
134133 }
135134 else
136135 {
137136 LOG_INFO_MESSAGE (" NO SURFACE" );
138- std::lock_guard<std::mutex> lock (eng->mutex );
139- eng->app_status_ &= ~APP_STATUS_FLAG_HAS_REAL_SURFACE;
137+ eng->app_status_ .store (eng->app_status_ .load () & ~APP_STATUS_FLAG_HAS_REAL_SURFACE);
140138 }
141139 break ;
142140
143141 case APP_CMD_TERM_WINDOW:
144142 LOG_INFO_MESSAGE (" APP_CMD_TERM_WINDOW - LOST SURFACE - TERM DISPLAY" );
145143 {
146- std::lock_guard<std::mutex> lock (eng->mutex );
147- eng->app_status_ &= ~APP_STATUS_FLAG_HAS_REAL_SURFACE;
144+ eng->app_status_ .store (eng->app_status_ .load () & ~APP_STATUS_FLAG_HAS_REAL_SURFACE);
148145 }
149146 eng->TermDisplay ();
150147 break ;
@@ -186,26 +183,23 @@ void AndroidAppBase::HandleCmd(struct android_app* app, int32_t cmd)
186183 case APP_CMD_GAINED_FOCUS:
187184 LOG_INFO_MESSAGE (" APP_CMD_GAINED_FOCUS - HAS FOCUS" );
188185 {
189- std::lock_guard<std::mutex> lock (eng->mutex );
190- eng->app_status_ |= APP_STATUS_FLAG_FOCUSED;
186+ eng->app_status_ .store (eng->app_status_ .load () | APP_STATUS_FLAG_FOCUSED);
191187 }
192188 eng->ResumeSensors ();
193189 break ;
194190
195191 case APP_CMD_LOST_FOCUS:
196192 LOG_INFO_MESSAGE (" APP_CMD_LOST_FOCUS - LOST FOCUS" );
197193 {
198- std::lock_guard<std::mutex> lock (eng->mutex );
199- eng->app_status_ &= ~APP_STATUS_FLAG_FOCUSED;
194+ eng->app_status_ .store (eng->app_status_ .load () & ~APP_STATUS_FLAG_FOCUSED);
200195 }
201196 eng->SuspendSensors ();
202197 break ;
203198
204199 case APP_CMD_RESUME:
205200 LOG_INFO_MESSAGE (" APP_CMD_RESUME - IS ACTIVE" );
206201 {
207- std::lock_guard<std::mutex> lock (eng->mutex );
208- eng->app_status_ |= APP_STATUS_FLAG_ACTIVE;
202+ eng->app_status_ .store (eng->app_status_ .load () | APP_STATUS_FLAG_ACTIVE);
209203 }
210204 break ;
211205
@@ -216,8 +210,7 @@ void AndroidAppBase::HandleCmd(struct android_app* app, int32_t cmd)
216210 case APP_CMD_PAUSE:
217211 LOG_INFO_MESSAGE (" APP_CMD_PAUSE - IS NOT ACTIVE" );
218212 {
219- std::lock_guard<std::mutex> lock (eng->mutex );
220- eng->app_status_ &= ~APP_STATUS_FLAG_ACTIVE;
213+ eng->app_status_ .store (eng->app_status_ .load () & ~APP_STATUS_FLAG_ACTIVE);
221214 }
222215 break ;
223216
@@ -235,8 +228,7 @@ void AndroidAppBase::HandleCmd(struct android_app* app, int32_t cmd)
235228 case APP_CMD_DESTROY:
236229 LOG_INFO_MESSAGE (" APP_CMD_DESTROY - IS NOT RUNNING" );
237230 {
238- std::lock_guard<std::mutex> lock (eng->mutex );
239- eng->app_status_ &= ~APP_STATUS_FLAG_RUNNING;
231+ eng->app_status_ .store (eng->app_status_ .load () & ~APP_STATUS_FLAG_RUNNING);
240232 }
241233 break ;
242234
@@ -312,11 +304,11 @@ void AndroidAppBase::SetState(android_app* state, const char* native_activity_cl
312304
313305bool AndroidAppBase::IsReady ()
314306{
315- std::lock_guard<std::mutex> lock (mutex );
316- return (app_status_ & APP_STATUS_FLAG_RUNNING) != APP_STATUS_FLAG_NONE &&
317- (app_status_ & APP_STATUS_FLAG_ACTIVE) != APP_STATUS_FLAG_NONE &&
318- (app_status_ & APP_STATUS_FLAG_FOCUSED) != APP_STATUS_FLAG_NONE &&
319- (app_status_ & APP_STATUS_FLAG_HAS_REAL_SURFACE) != APP_STATUS_FLAG_NONE;
307+ APP_STATUS_FLAGS app_status = app_status_. load ( );
308+ return (app_status & APP_STATUS_FLAG_RUNNING) != APP_STATUS_FLAG_NONE &&
309+ (app_status & APP_STATUS_FLAG_ACTIVE) != APP_STATUS_FLAG_NONE &&
310+ (app_status & APP_STATUS_FLAG_FOCUSED) != APP_STATUS_FLAG_NONE &&
311+ (app_status & APP_STATUS_FLAG_HAS_REAL_SURFACE) != APP_STATUS_FLAG_NONE;
320312}
321313
322314// void Engine::TransformPosition( ndk_helper::Vec2& vec )
0 commit comments