| 301 | === Mac OS X Video Threading Issue === #mac-thread |
| 302 | |
| 303 | On Mac OS X, our video implementation uses Cocoa frameworks, which require handling user events and drawing window content to be done in the main thread. Hence, to avoid deadlock, application should not call any PJSIP API which can potentially block from the main thread. We provide an API ```pj_run_app()``` to simplify creating a GUI app on Mac OS X, please refer to ```pjsua``` app located in ```pjsip-apps/src/pjsua``` for sample usage. Basically, ```pj_run_app()``` will setup an event loop management in the main thread and create a multi-threading environment, allowing PJSIP to be called from another thread. |
| 304 | |
| 305 | {{{ |
| 306 | int main_func(int argc, char *argv[]) |
| 307 | { |
| 308 | // This is your real main function |
| 309 | } |
| 310 | |
| 311 | int main(int argc, char *argv[]) |
| 312 | { |
| 313 | // pj_run_app() will call your main function from another thread (if necessary) |
| 314 | // this will free the main thread to handle GUI events and drawing |
| 315 | return pj_run_app(&main_func, argc, argv, 0); |
| 316 | } |
| 317 | }}} |