comparison core/RTAudio.cpp @ 303:421a69d42943 prerelease

Changed BeagleRT -> Bela in defines and thread names; some preliminary mux capelet stuff
author andrewm
date Fri, 27 May 2016 17:40:44 +0100
parents e4392164b458
children ff5f346a293e
comparison
equal deleted inserted replaced
302:b26e7c61e3b6 303:421a69d42943
49 bool hasArgs; 49 bool hasArgs;
50 void* args; 50 void* args;
51 bool autoSchedule; 51 bool autoSchedule;
52 } InternalAuxiliaryTask; 52 } InternalAuxiliaryTask;
53 53
54 const char gRTAudioThreadName[] = "beaglert-audio"; 54 const char gRTAudioThreadName[] = "bela-audio";
55 const char gRTAudioInterruptName[] = "beaglert-pru-irq"; 55 const char gRTAudioInterruptName[] = "bela-pru-irq";
56 56
57 // Real-time tasks and objects 57 // Real-time tasks and objects
58 RT_TASK gRTAudioThread; 58 RT_TASK gRTAudioThread;
59 #ifdef BEAGLERT_USE_XENOMAI_INTERRUPTS 59 #ifdef BELA_USE_XENOMAI_INTERRUPTS
60 RT_INTR gRTAudioInterrupt; 60 RT_INTR gRTAudioInterrupt;
61 #endif 61 #endif
62 PRU *gPRU = 0; 62 PRU *gPRU = 0;
63 I2c_Codec *gAudioCodec = 0; 63 I2c_Codec *gAudioCodec = 0;
64 64
197 gContext.digitalChannels = 0; 197 gContext.digitalChannels = 0;
198 } 198 }
199 199
200 // Set flags based on init settings 200 // Set flags based on init settings
201 if(settings->interleave) 201 if(settings->interleave)
202 gContext.flags |= BEAGLERT_FLAG_INTERLEAVED; 202 gContext.flags |= BELA_FLAG_INTERLEAVED;
203 if(settings->analogOutputsPersist) 203 if(settings->analogOutputsPersist)
204 gContext.flags |= BEAGLERT_FLAG_ANALOG_OUTPUTS_PERSIST; 204 gContext.flags |= BELA_FLAG_ANALOG_OUTPUTS_PERSIST;
205 205
206 // Use PRU for audio 206 // Use PRU for audio
207 gPRU = new PRU(&gContext); 207 gPRU = new PRU(&gContext);
208 gAudioCodec = new I2c_Codec(); 208 gAudioCodec = new I2c_Codec();
209 209
283 if(gRTAudioVerbose) 283 if(gRTAudioVerbose)
284 rt_printf("Warning: couldn't set value (high) on amplifier mute pin\n"); 284 rt_printf("Warning: couldn't set value (high) on amplifier mute pin\n");
285 } 285 }
286 } 286 }
287 287
288 #ifdef BEAGLERT_USE_XENOMAI_INTERRUPTS 288 #ifdef BELA_USE_XENOMAI_INTERRUPTS
289 gPRU->loop(&gRTAudioInterrupt, gUserData); 289 gPRU->loop(&gRTAudioInterrupt, gUserData);
290 #else 290 #else
291 gPRU->loop(0, gUserData); 291 gPRU->loop(0, gUserData);
292 #endif 292 #endif
293 // Now clean up 293 // Now clean up
301 if(gRTAudioVerbose == 1) 301 if(gRTAudioVerbose == 1)
302 rt_printf("audio thread ended\n"); 302 rt_printf("audio thread ended\n");
303 } 303 }
304 304
305 // Create a calculation loop which can run independently of the audio, at a different 305 // Create a calculation loop which can run independently of the audio, at a different
306 // (equal or lower) priority. Audio priority is defined in BEAGLERT_AUDIO_PRIORITY; 306 // (equal or lower) priority. Audio priority is defined in BELA_AUDIO_PRIORITY;
307 // priority should be generally be less than this. 307 // priority should be generally be less than this.
308 // Returns an (opaque) pointer to the created task on success; 0 on failure 308 // Returns an (opaque) pointer to the created task on success; 0 on failure
309 AuxiliaryTask Bela_createAuxiliaryTask(void (*functionToCall)(void* args), int priority, const char *name, void* args, bool autoSchedule) 309 AuxiliaryTask Bela_createAuxiliaryTask(void (*functionToCall)(void* args), int priority, const char *name, void* args, bool autoSchedule)
310 { 310 {
311 InternalAuxiliaryTask *newTask = (InternalAuxiliaryTask*)malloc(sizeof(InternalAuxiliaryTask)); 311 InternalAuxiliaryTask *newTask = (InternalAuxiliaryTask*)malloc(sizeof(InternalAuxiliaryTask));
425 // on success. 425 // on success.
426 426
427 int Bela_startAudio() 427 int Bela_startAudio()
428 { 428 {
429 // Create audio thread with high Xenomai priority 429 // Create audio thread with high Xenomai priority
430 if(rt_task_create(&gRTAudioThread, gRTAudioThreadName, 0, BEAGLERT_AUDIO_PRIORITY, T_JOINABLE | T_FPU)) { 430 if(rt_task_create(&gRTAudioThread, gRTAudioThreadName, 0, BELA_AUDIO_PRIORITY, T_JOINABLE | T_FPU)) {
431 cout << "Error: unable to create Xenomai audio thread" << endl; 431 cout << "Error: unable to create Xenomai audio thread" << endl;
432 return -1; 432 return -1;
433 } 433 }
434 434
435 #ifdef BEAGLERT_USE_XENOMAI_INTERRUPTS 435 #ifdef BELA_USE_XENOMAI_INTERRUPTS
436 // Create an interrupt which the audio thread receives from the PRU 436 // Create an interrupt which the audio thread receives from the PRU
437 int result = 0; 437 int result = 0;
438 if((result = rt_intr_create(&gRTAudioInterrupt, gRTAudioInterruptName, PRU_RTAUDIO_IRQ, I_NOAUTOENA)) != 0) { 438 if((result = rt_intr_create(&gRTAudioInterrupt, gRTAudioInterruptName, PRU_RTAUDIO_IRQ, I_NOAUTOENA)) != 0) {
439 cout << "Error: unable to create Xenomai interrupt for PRU (error " << result << ")" << endl; 439 cout << "Error: unable to create Xenomai interrupt for PRU (error " << result << ")" << endl;
440 return -1; 440 return -1;
500 free(taskStruct); 500 free(taskStruct);
501 } 501 }
502 getAuxTasks().clear(); 502 getAuxTasks().clear();
503 503
504 // Delete the audio task and its interrupt 504 // Delete the audio task and its interrupt
505 #ifdef BEAGLERT_USE_XENOMAI_INTERRUPTS 505 #ifdef BELA_USE_XENOMAI_INTERRUPTS
506 rt_intr_delete(&gRTAudioInterrupt); 506 rt_intr_delete(&gRTAudioInterrupt);
507 #endif 507 #endif
508 rt_task_delete(&gRTAudioThread); 508 rt_task_delete(&gRTAudioThread);
509 509
510 if(gPRU != 0) 510 if(gPRU != 0)