comparison projects/empty_project/main.cpp @ 269:ac8eb07afcf5

Oxygen text added to each render.cpp file for the default projects. Text includes project explanation from Wiki, edited in places. Empty project added as a default project. Doxyfile updated. Each of the project locations added to INPUT configuration option. Consider just watching the whole project file so all new projects are automatically pulled through.
author Robert Jack <robert.h.jack@gmail.com>
date Tue, 17 May 2016 15:40:16 +0100
parents
children
comparison
equal deleted inserted replaced
252:381f352c44eb 269:ac8eb07afcf5
1 /*
2 * default_main.cpp
3 *
4 * Created on: Oct 24, 2014
5 * Author: parallels
6 */
7 //#include <unistd.h>
8 #include <iostream>
9 #include <cstdlib>
10 #include <libgen.h>
11 #include <signal.h>
12 #include <getopt.h>
13 #include "../include/BeagleRT.h"
14
15 using namespace std;
16
17 int returnCode = 0;
18
19 // Handle Ctrl-C by requesting that the audio rendering stop
20 void interrupt_handler(int var)
21 {
22 gShouldStop = true;
23 // allows other process to monitor why beagleRT has exited
24 // var=15, returnCode = 143 if terminated with SIGTERM
25 returnCode = var + 128;
26 }
27
28 // Print usage information
29 void usage(const char * processName)
30 {
31 cerr << "Usage: " << processName << " [options]" << endl;
32
33 BeagleRT_usage();
34
35 cerr << " --help [-h]: Print this menu\n";
36 }
37
38 int main(int argc, char *argv[])
39 {
40 BeagleRTInitSettings settings; // Standard audio settings
41
42 struct option customOptions[] =
43 {
44 {"help", 0, NULL, 'h'},
45 {NULL, 0, NULL, 0}
46 };
47
48 // Set default settings
49 BeagleRT_defaultSettings(&settings);
50
51 // Parse command-line arguments
52 while (1) {
53 int c;
54 if ((c = BeagleRT_getopt_long(argc, argv, "h", customOptions, &settings)) < 0)
55 break;
56 switch (c) {
57 case 'h':
58 usage(basename(argv[0]));
59 exit(0);
60 case '?':
61 default:
62 usage(basename(argv[0]));
63 exit(1);
64 }
65 }
66
67 // Initialise the PRU audio device
68 if(BeagleRT_initAudio(&settings, 0) != 0) {
69 cout << "Error: unable to initialise audio" << endl;
70 return -1;
71 }
72
73 // Start the audio device running
74 if(BeagleRT_startAudio()) {
75 cout << "Error: unable to start real-time audio" << endl;
76 return -1;
77 }
78
79 // Set up interrupt handler to catch Control-C and SIGTERM
80 signal(SIGINT, interrupt_handler);
81 signal(SIGTERM, interrupt_handler);
82
83 // Run until told to stop
84 while(!gShouldStop) {
85 usleep(100000);
86 }
87
88 // Stop the audio device
89 BeagleRT_stopAudio();
90
91 // Clean up any resources allocated for audio
92 BeagleRT_cleanupAudio();
93
94 // All done!
95 return returnCode;
96 }