Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#1278 closed defect (fixed)

System specific initialization during application startup

Reported by: bennylp Owned by: ming
Priority: major Milestone: release-2.0-alpha
Component: common Version: 2.0-dev-branch
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description (last modified by bennylp)

Some video devices implementation (in pjmedia-videodev) assumes that the application has been initialized in certain way in order for it to work. For example, the SDL and QuickTime video device implementation on Mac OS X requires NSApplication and NSAutoreleasePool to be present in the application.

That normally is not a problem if the application is GUI application created with IDE such as XCode, since the IDE will create those for us. But for application created manually, such as console apps that are common in our samples, these objects have to be created manually.

This ticket implements a generic way to initialize system specific settings to the application. This new API in pj/os.h is proposed:

/* Type for main function. */
typedef int (*pj_main_func_ptr)(int argc, char *argv[]);

/**
 * Run the application. This function has to be called in the main thread
 * and after doing the necessary initialization according to the flags
 * provided, it will call main_func() function.
 *
 * @param main_func Application's main function.
 * @param argc	    Number of arguments from the main() function, which
 * 		    will be passed to main_func() function.
 * @param argv	    The arguments from the main() function, which will
 * 		    be passed to main_func() function.
 * @param flags     Flags for application execution, currently must be 0.
 *
 * @return          main_func()'s return value.
 */
int pj_run_app(pj_main_func_ptr main_func, int argc, char *argv[],
	       unsigned flags);

Console apps need to call the above pj_run_app() API, passing it's main routine as the argument.

Change History (7)

comment:1 Changed 14 years ago by bennylp

SDL memory allocation error log with NSAutoReleasePool on Mac

comment:2 Changed 13 years ago by ming

  • Description modified (diff)
  • Summary changed from NSApplication and NSAutoReleasePool management for Mac OS for SDL to NSApplication and NSAutoreleasePool management for Mac OS X

comment:3 Changed 13 years ago by ming

  • Description modified (diff)

comment:4 Changed 13 years ago by ming

(In [3643]) Re #1278: NSApplication and NSAutoreleasePool management for Mac OS X

Application now needs to call pj_run_app() from its main() function and pass a pointer to the application's main function. For some examples, please refer to aviplay, pjmedia_test, and pjsua.

comment:5 Changed 13 years ago by ming

  • Resolution set to fixed
  • Status changed from new to closed

comment:6 Changed 13 years ago by ming

(In [3670]) Re #1278: Fixed linker error on Mac and iOS.

comment:7 Changed 13 years ago by bennylp

  • Component changed from pjmedia-videodev to common
  • Description modified (diff)
  • Summary changed from NSApplication and NSAutoreleasePool management for Mac OS X to System specific initialization during application startup
Note: See TracTickets for help on using tickets.