Mercurial > hg > beaglert
comparison projects/basic_passthru/render.cpp @ 174:1e629f126322
AuxiliaryTask can now be scheduled from setup(). Closes #1373
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 28 Dec 2015 13:53:11 +0100 |
parents | 3c3a1357657d |
children | 07cfd337ad18 |
comparison
equal
deleted
inserted
replaced
173:2877bc2cd449 | 174:1e629f126322 |
---|---|
17 // userData holds an opaque pointer to a data structure that was passed | 17 // userData holds an opaque pointer to a data structure that was passed |
18 // in from the call to initAudio(). | 18 // in from the call to initAudio(). |
19 // | 19 // |
20 // Return true on success; returning false halts the program. | 20 // Return true on success; returning false halts the program. |
21 | 21 |
22 AuxiliaryTask taskOne; | |
23 AuxiliaryTask taskTwo; | |
24 void funOne(){ | |
25 rt_printf("setup\n"); | |
26 } | |
27 void funTwo(){ | |
28 rt_printf("render\n"); | |
29 } | |
22 bool setup(BeagleRTContext *context, void *userData) | 30 bool setup(BeagleRTContext *context, void *userData) |
23 { | 31 { |
24 // Nothing to do here... | 32 // Nothing to do here... |
25 | 33 // taskOne = BeagleRT_createAuxiliaryTask(funOne, 1, "funOne"); |
34 // taskTwo = BeagleRT_createAuxiliaryTask(funTwo, 99, "funTwo"); | |
35 // BeagleRT_scheduleAuxiliaryTask(taskOne); | |
26 return true; | 36 return true; |
27 } | 37 } |
28 | 38 |
29 // render() is called regularly at the highest priority by the audio engine. | 39 // render() is called regularly at the highest priority by the audio engine. |
30 // Input and output are given from the audio hardware and the other | 40 // Input and output are given from the audio hardware and the other |
31 // ADCs and DACs (if available). If only audio is available, numMatrixFrames | 41 // ADCs and DACs (if available). If only audio is available, numMatrixFrames |
32 // will be 0. | 42 // will be 0. |
33 | 43 |
34 void render(BeagleRTContext *context, void *userData) | 44 void render(BeagleRTContext *context, void *userData) |
35 { | 45 { |
46 // if(context->audioSampleCount % 16384 == 0) | |
47 // BeagleRT_scheduleAuxiliaryTask(taskTwo); | |
36 // Simplest possible case: pass inputs through to outputs | 48 // Simplest possible case: pass inputs through to outputs |
37 for(unsigned int n = 0; n < context->audioFrames; n++) { | 49 for(unsigned int n = 0; n < context->audioFrames; n++) { |
38 for(unsigned int ch = 0; ch < context->audioChannels; ch++) | 50 for(unsigned int ch = 0; ch < context->audioChannels; ch++) |
39 context->audioOut[n * context->audioChannels + ch] = context->audioIn[n * context->audioChannels + ch]; | 51 context->audioOut[n * context->audioChannels + ch] = |
52 context->audioIn[n * context->audioChannels + ch]; | |
40 } | 53 } |
41 | 54 |
42 // Same with matrix, only if matrix is enabled | 55 // Same with matrix, only if matrix is enabled |
43 if(context->analogFrames != 0) { | 56 // if(context->analogFrames != 0) { |
44 for(unsigned int n = 0; n < context->analogFrames; n++) { | 57 // for(unsigned int n = 0; n < context->analogFrames; n++) { |
45 for(unsigned int ch = 0; ch < context->analogChannels; ch++) { | 58 // for(unsigned int ch = 0; ch < context->analogChannels; ch++) { |
46 // Two equivalent ways to write this code | 59 // // Two equivalent ways to write this code |
47 // The long way, using the buffers directly: | 60 // // The long way, using the buffers directly: |
48 // context->analogOut[n * context->analogChannels + ch] = context->analogIn[n * context->analogChannels + ch]; | 61 // // context->analogOut[n * context->analogChannels + ch] = context->analogIn[n * context->analogChannels + ch]; |
49 | 62 // |
50 // Or using the macros: | 63 // // Or using the macros: |
51 analogWriteFrame(context, n, ch, analogReadFrame(context, n, ch)); | 64 // analogWriteFrame(context, n, ch, analogReadFrame(context, n, ch)); |
52 } | 65 // } |
53 } | 66 // } |
54 } | 67 // } |
55 } | 68 } |
56 | 69 |
57 // cleanup() is called once at the end, after the audio has stopped. | 70 // cleanup() is called once at the end, after the audio has stopped. |
58 // Release any resources that were allocated in setup(). | 71 // Release any resources that were allocated in setup(). |
59 | 72 |