MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / main

Function main

Samples/NiAudioSample/NiAudioSample.cpp:241–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241int main(int argc, char* argv[])
242{
243 XnStatus nRetVal = XN_STATUS_OK;
244
245 Context context;
246 EnumerationErrors errors;
247 Mode mode;
248
249 // default mode
250#if XN_PLATFORM == XN_PLATFORM_WIN32
251 mode = MODE_PLAY;
252#else
253 mode = MODE_RECORD;
254#endif
255
256 // check if mode was provided by user
257 if (argc > 1)
258 {
259 if (strcmp(argv[1], "play") == 0)
260 {
261 mode = MODE_PLAY;
262 }
263 else if (strcmp(argv[1], "record") == 0)
264 {
265 mode = MODE_RECORD;
266 }
267 else
268 {
269 printUsage(argv[0]);
270 return -1;
271 }
272 }
273
274 // make sure mode is valid
275#if XN_PLATFORM != XN_PLATFORM_WIN32
276 if (mode == MODE_PLAY)
277 {
278 printf("Playing is not supported on this platform!\n");
279 return -1;
280 }
281#endif
282
283 ScriptNode scriptNode;
284
285 nRetVal = context.InitFromXmlFile(SAMPLE_XML_PATH, scriptNode);
286 if (nRetVal == XN_STATUS_NO_NODE_PRESENT)
287 {
288 XnChar strError[1024];
289 errors.ToString(strError, 1024);
290 printf("%s\n", strError);
291 return (nRetVal);
292 }
293 else if (nRetVal != XN_STATUS_OK)
294 {
295 printf("Open failed: %s\n", xnGetStatusString(nRetVal));
296 return (nRetVal);
297 }
298

Callers

nothing calls this directly

Calls 11

xnGetStatusStringFunction · 0.85
playFunction · 0.85
recordFunction · 0.85
InitFromXmlFileMethod · 0.80
printUsageFunction · 0.70
ToStringMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45
GetInstanceMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected