annotate 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
rev   line source
robert@269 1 /*
robert@269 2 * default_main.cpp
robert@269 3 *
robert@269 4 * Created on: Oct 24, 2014
robert@269 5 * Author: parallels
robert@269 6 */
robert@269 7 //#include <unistd.h>
robert@269 8 #include <iostream>
robert@269 9 #include <cstdlib>
robert@269 10 #include <libgen.h>
robert@269 11 #include <signal.h>
robert@269 12 #include <getopt.h>
robert@269 13 #include "../include/BeagleRT.h"
robert@269 14
robert@269 15 using namespace std;
robert@269 16
robert@269 17 int returnCode = 0;
robert@269 18
robert@269 19 // Handle Ctrl-C by requesting that the audio rendering stop
robert@269 20 void interrupt_handler(int var)
robert@269 21 {
robert@269 22 gShouldStop = true;
robert@269 23 // allows other process to monitor why beagleRT has exited
robert@269 24 // var=15, returnCode = 143 if terminated with SIGTERM
robert@269 25 returnCode = var + 128;
robert@269 26 }
robert@269 27
robert@269 28 // Print usage information
robert@269 29 void usage(const char * processName)
robert@269 30 {
robert@269 31 cerr << "Usage: " << processName << " [options]" << endl;
robert@269 32
robert@269 33 BeagleRT_usage();
robert@269 34
robert@269 35 cerr << " --help [-h]: Print this menu\n";
robert@269 36 }
robert@269 37
robert@269 38 int main(int argc, char *argv[])
robert@269 39 {
robert@269 40 BeagleRTInitSettings settings; // Standard audio settings
robert@269 41
robert@269 42 struct option customOptions[] =
robert@269 43 {
robert@269 44 {"help", 0, NULL, 'h'},
robert@269 45 {NULL, 0, NULL, 0}
robert@269 46 };
robert@269 47
robert@269 48 // Set default settings
robert@269 49 BeagleRT_defaultSettings(&settings);
robert@269 50
robert@269 51 // Parse command-line arguments
robert@269 52 while (1) {
robert@269 53 int c;
robert@269 54 if ((c = BeagleRT_getopt_long(argc, argv, "h", customOptions, &settings)) < 0)
robert@269 55 break;
robert@269 56 switch (c) {
robert@269 57 case 'h':
robert@269 58 usage(basename(argv[0]));
robert@269 59 exit(0);
robert@269 60 case '?':
robert@269 61 default:
robert@269 62 usage(basename(argv[0]));
robert@269 63 exit(1);
robert@269 64 }
robert@269 65 }
robert@269 66
robert@269 67 // Initialise the PRU audio device
robert@269 68 if(BeagleRT_initAudio(&settings, 0) != 0) {
robert@269 69 cout << "Error: unable to initialise audio" << endl;
robert@269 70 return -1;
robert@269 71 }
robert@269 72
robert@269 73 // Start the audio device running
robert@269 74 if(BeagleRT_startAudio()) {
robert@269 75 cout << "Error: unable to start real-time audio" << endl;
robert@269 76 return -1;
robert@269 77 }
robert@269 78
robert@269 79 // Set up interrupt handler to catch Control-C and SIGTERM
robert@269 80 signal(SIGINT, interrupt_handler);
robert@269 81 signal(SIGTERM, interrupt_handler);
robert@269 82
robert@269 83 // Run until told to stop
robert@269 84 while(!gShouldStop) {
robert@269 85 usleep(100000);
robert@269 86 }
robert@269 87
robert@269 88 // Stop the audio device
robert@269 89 BeagleRT_stopAudio();
robert@269 90
robert@269 91 // Clean up any resources allocated for audio
robert@269 92 BeagleRT_cleanupAudio();
robert@269 93
robert@269 94 // All done!
robert@269 95 return returnCode;
robert@269 96 }