comparison include/BeagleRT.h @ 56:3c3a1357657d newapi

Further API update to name three primary functions setup(), render() and cleanup(). Changed include paths so now can #include <BeagleRT.h>. Removed stale pru_rtaudio.bin file as this is now done as pru_rtaudio_bin.h. Updated examples to new API and fixed minor compiler warnings along the way. Network example needs further attention to compile.
author andrewm
date Wed, 15 Jul 2015 12:10:51 +0100
parents 41d24dba6b74
children e63563507edd
comparison
equal deleted inserted replaced
55:41d24dba6b74 56:3c3a1357657d
155 155
156 /** 156 /**
157 * \ingroup render 157 * \ingroup render
158 * \brief Structure holding current audio and sensor settings and pointers to data buffers. 158 * \brief Structure holding current audio and sensor settings and pointers to data buffers.
159 * 159 *
160 * This structure is passed to initialise_render(), render() and cleanup_render(). It is 160 * This structure is passed to setup(), render() and cleanup(). It is
161 * initialised in BeagleRT_initAudio() based on the contents of the BeagleRTInitSettings 161 * initialised in BeagleRT_initAudio() based on the contents of the BeagleRTInitSettings
162 * structure. 162 * structure.
163 */ 163 */
164 typedef struct { 164 typedef struct {
165 /// \brief Buffer holding audio input samples 165 /// \brief Buffer holding audio input samples
249 } BeagleRTContext; 249 } BeagleRTContext;
250 250
251 /** \ingroup auxtask 251 /** \ingroup auxtask
252 * 252 *
253 * Auxiliary task variable. Auxiliary tasks are created using createAuxiliaryTask() and 253 * Auxiliary task variable. Auxiliary tasks are created using createAuxiliaryTask() and
254 * automatically cleaned up after cleanup_render() finishes. 254 * automatically cleaned up after cleanup() finishes.
255 */ 255 */
256 typedef void* AuxiliaryTask; // Opaque data type to keep track of aux tasks 256 typedef void* AuxiliaryTask; // Opaque data type to keep track of aux tasks
257 257
258 /** \ingroup render 258 /** \ingroup render
259 * 259 *
283 * memory or resources that will be needed in render(). 283 * memory or resources that will be needed in render().
284 * 284 *
285 * \param context Data structure holding information on sample rates, numbers of channels, 285 * \param context Data structure holding information on sample rates, numbers of channels,
286 * frame sizes and other state. Note: the buffers for audio, analog and digital data will 286 * frame sizes and other state. Note: the buffers for audio, analog and digital data will
287 * \b not yet be available to use. Do not attempt to read or write audio or sensor data 287 * \b not yet be available to use. Do not attempt to read or write audio or sensor data
288 * in initialise_render(). 288 * in setup().
289 * \param userData An opaque pointer to an optional user-defined data structure. Whatever 289 * \param userData An opaque pointer to an optional user-defined data structure. Whatever
290 * is passed as the second argument to BeagleRT_initAudio() will appear here. 290 * is passed as the second argument to BeagleRT_initAudio() will appear here.
291 * 291 *
292 * \return true on success, or false if an error occurred. If no initialisation is 292 * \return true on success, or false if an error occurred. If no initialisation is
293 * required, initialise_render() should return true. 293 * required, setup() should return true.
294 */ 294 */
295 bool initialise_render(BeagleRTContext *context, void *userData); 295 bool setup(BeagleRTContext *context, void *userData);
296 296
297 /** 297 /**
298 * \brief User-defined callback function to process audio and sensor data. 298 * \brief User-defined callback function to process audio and sensor data.
299 * 299 *
300 * This function is called regularly by the system every time there is a new block of 300 * This function is called regularly by the system every time there is a new block of
302 * of data, store the results within \c context, and return. 302 * of data, store the results within \c context, and return.
303 * 303 *
304 * \param context Data structure holding buffers for audio, analog and digital data. The 304 * \param context Data structure holding buffers for audio, analog and digital data. The
305 * structure also holds information on numbers of channels, frame sizes and sample rates, 305 * structure also holds information on numbers of channels, frame sizes and sample rates,
306 * which are guaranteed to remain the same throughout the program and to match what was 306 * which are guaranteed to remain the same throughout the program and to match what was
307 * passed to initialise_render(). 307 * passed to setup().
308 * \param userData An opaque pointer to an optional user-defined data structure. Will 308 * \param userData An opaque pointer to an optional user-defined data structure. Will
309 * be the same as the \c userData parameter passed to initialise_render(). 309 * be the same as the \c userData parameter passed to setup().
310 */ 310 */
311 void render(BeagleRTContext *context, void *userData); 311 void render(BeagleRTContext *context, void *userData);
312 312
313 /** 313 /**
314 * \brief User-defined cleanup function which runs when the program finishes. 314 * \brief User-defined cleanup function which runs when the program finishes.
315 * 315 *
316 * This function is called by the system once after audio rendering has finished, before the 316 * This function is called by the system once after audio rendering has finished, before the
317 * program quits. Use it to release any memory allocated in initialise_render() and to perform 317 * program quits. Use it to release any memory allocated in setup() and to perform
318 * any other required cleanup. If no initialisation is performed in initialise_render(), then 318 * any other required cleanup. If no initialisation is performed in setup(), then
319 * this function will usually be empty. 319 * this function will usually be empty.
320 * 320 *
321 * \param context Data structure holding information on sample rates, numbers of channels, 321 * \param context Data structure holding information on sample rates, numbers of channels,
322 * frame sizes and other state. Note: the buffers for audio, analog and digital data will 322 * frame sizes and other state. Note: the buffers for audio, analog and digital data will
323 * no longer be available to use. Do not attempt to read or write audio or sensor data 323 * no longer be available to use. Do not attempt to read or write audio or sensor data
324 * in cleanup_render(). 324 * in cleanup().
325 * \param userData An opaque pointer to an optional user-defined data structure. Will 325 * \param userData An opaque pointer to an optional user-defined data structure. Will
326 * be the same as the \c userData parameter passed to initialise_render() and render(). 326 * be the same as the \c userData parameter passed to setup() and render().
327 */ 327 */
328 void cleanup_render(BeagleRTContext *context, void *userData); 328 void cleanup(BeagleRTContext *context, void *userData);
329 329
330 /** @} */ 330 /** @} */
331 331
332 /** 332 /**
333 * \defgroup control Control and command line functions 333 * \defgroup control Control and command line functions
398 /** 398 /**
399 * \brief Initialise audio and sensor rendering environment. 399 * \brief Initialise audio and sensor rendering environment.
400 * 400 *
401 * This function prepares audio rendering in BeagleRT. It should be called from main() sometime 401 * This function prepares audio rendering in BeagleRT. It should be called from main() sometime
402 * after command line option parsing has finished. It will initialise the rendering system, which 402 * after command line option parsing has finished. It will initialise the rendering system, which
403 * in the process will result in a call to the user-defined initialise_render() function. 403 * in the process will result in a call to the user-defined setup() function.
404 * 404 *
405 * \param settings Data structure holding system settings, including numbers of channels, frame sizes, 405 * \param settings Data structure holding system settings, including numbers of channels, frame sizes,
406 * volume levels and other information. 406 * volume levels and other information.
407 * \param userData An opaque pointer to a user-defined data structure which will be passed to 407 * \param userData An opaque pointer to a user-defined data structure which will be passed to
408 * initialise_render(), render() and cleanup_render(). You can use this to pass custom information 408 * setup(), render() and cleanup(). You can use this to pass custom information
409 * to the rendering functions, as an alternative to using global variables. 409 * to the rendering functions, as an alternative to using global variables.
410 * 410 *
411 * \return 0 on success, or nonzero if an error occurred. 411 * \return 0 on success, or nonzero if an error occurred.
412 */ 412 */
413 int BeagleRT_initAudio(BeagleRTInitSettings *settings, void *userData); 413 int BeagleRT_initAudio(BeagleRTInitSettings *settings, void *userData);
433 /** 433 /**
434 * \brief Clean up resources from audio and sensor processing. 434 * \brief Clean up resources from audio and sensor processing.
435 * 435 *
436 * This function should only be called after BeagleRT_stopAudio(). It will release any 436 * This function should only be called after BeagleRT_stopAudio(). It will release any
437 * internal resources for audio and sensor processing. In the process, it will call the 437 * internal resources for audio and sensor processing. In the process, it will call the
438 * user-defined cleanup_render() function. 438 * user-defined cleanup() function.
439 */ 439 */
440 void BeagleRT_cleanupAudio(); 440 void BeagleRT_cleanupAudio();
441 441
442 /** @} */ 442 /** @} */
443 443
524 * These functions are used to create separate real-time tasks (threads) which run at lower 524 * These functions are used to create separate real-time tasks (threads) which run at lower
525 * priority than the audio processing. They can be used, for example, for large time-consuming 525 * priority than the audio processing. They can be used, for example, for large time-consuming
526 * calculations which would take more than one audio frame length to process, or they could be 526 * calculations which would take more than one audio frame length to process, or they could be
527 * used to communicate with external hardware when that communication might block or be delayed. 527 * used to communicate with external hardware when that communication might block or be delayed.
528 * 528 *
529 * All auxiliary tasks used by the program should be created in initialise_render(). The tasks 529 * All auxiliary tasks used by the program should be created in setup(). The tasks
530 * can then be scheduled at will within the render() function. 530 * can then be scheduled at will within the render() function.
531 * 531 *
532 * @{ 532 * @{
533 */ 533 */
534 534
537 /** 537 /**
538 * \brief Create a new auxiliary task. 538 * \brief Create a new auxiliary task.
539 * 539 *
540 * This function creates a new auxiliary task which, when scheduled, runs the function specified 540 * This function creates a new auxiliary task which, when scheduled, runs the function specified
541 * in the first argument. Note that the task does not run until scheduleAuxiliaryTask() is called. 541 * in the first argument. Note that the task does not run until scheduleAuxiliaryTask() is called.
542 * Auxiliary tasks should be created in initialise_render() and never in render() itself. 542 * Auxiliary tasks should be created in setup() and never in render() itself.
543 * 543 *
544 * The second argument specifies the real-time priority. Valid values are between 0 544 * The second argument specifies the real-time priority. Valid values are between 0
545 * and 99, and usually should be lower than \ref BEAGLERT_AUDIO_PRIORITY. Tasks with higher priority always 545 * and 99, and usually should be lower than \ref BEAGLERT_AUDIO_PRIORITY. Tasks with higher priority always
546 * preempt tasks with lower priority. 546 * preempt tasks with lower priority.
547 * 547 *