Skip to content

Commit fbd273e

Browse files
gWaceynordicjm
authored andcommitted
applications: nrf5340_audio: Audio module improvements
Corrections from use, additional testing and fake function updates. Signed-off-by: Graham Wacey <graham.wacey@nordicsemi.no>
1 parent 3940f0e commit fbd273e

16 files changed

+410
-223
lines changed

include/audio_defines.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct audio_metadata {
5757
* bits_per_sample = 24
5858
* carrier_size = 32
5959
*/
60-
uint8_t carried_bits_pr_sample;
60+
uint8_t carried_bits_per_sample;
6161

6262
/* A 32 bit mask indicating which channel(s)/locations are active within
6363
* the data. A bit set indicates the location is active and

include/audio_module/audio_module.h

+25
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ extern "C" {
2323

2424
#include "audio_defines.h"
2525

26+
/**
27+
* @brief Helper macro to configure the modules parameters.
28+
*/
29+
#define AUDIO_MODULE_PARAMETERS(p, dest, stk, stk_size, pri, fifo_rx, fifo_tx, slab, slab_size) \
30+
(p).description = (dest); \
31+
(p).thread.stack = (stk); \
32+
(p).thread.stack_size = (stk_size); \
33+
(p).thread.priority = (pri); \
34+
(p).thread.msg_rx = (fifo_rx); \
35+
(p).thread.msg_tx = (fifo_tx); \
36+
(p).thread.data_slab = (slab); \
37+
(p).thread.data_size = (slab_size);
38+
2639
/**
2740
* @brief Number of valid location bits.
2841
*/
@@ -409,6 +422,10 @@ int audio_module_stop(struct audio_module_handle *handle);
409422
/**
410423
* @brief Send an audio data item to an audio module, all data is consumed by the module.
411424
*
425+
* @note: The data pointer and its associated size that are passed via the audio data
426+
* pointer, can be NULL and/or 0. It is the responsibility of the low level module functions
427+
* to handle this correctly.
428+
*
412429
* @param handle [in/out] The handle for the receiving module instance.
413430
* @param audio_data [in] Pointer to the audio data to send to the module.
414431
* @param response_cb [in] Pointer to a callback to run when the buffer is
@@ -423,6 +440,10 @@ int audio_module_data_tx(struct audio_module_handle *handle,
423440
/**
424441
* @brief Retrieve an audio data item from an audio module.
425442
*
443+
* @note: The data pointer and its associated size that are passed via the audio data
444+
* pointer, can be NULL and/or 0. It is the responsibility of the low level module functions
445+
* to handle this correctly.
446+
*
426447
* @param handle [in/out] The handle to the module instance.
427448
* @param audio_data [out] Pointer to the audio data from the module.
428449
* @param timeout [in] Non-negative waiting period to wait for operation to complete
@@ -441,6 +462,10 @@ int audio_module_data_rx(struct audio_module_handle *handle, struct audio_data *
441462
* returned via the module or final module's output FIFO. All the input data is consumed
442463
* within the call and thus the input data buffer maybe released once the function returns.
443464
*
465+
* @note: The data I/O pointers and their associated sizes that are passed via the audio data
466+
* pointers, can be NULL and/or 0. It is the responsibility of the low level module functions
467+
* to handle this correctly.
468+
*
444469
* @param handle_tx [in/out] The handle to the module to send the input audio data to.
445470
* @param handle_rx [in/out] The handle to the module to receive audio data from.
446471
* @param audio_data_tx [in] Pointer to the audio data to send.

include/data_fifo.h

+15-5
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ struct data_fifo {
4242
};
4343

4444
#define DATA_FIFO_DEFINE(name, elements_max_in, block_size_max_in) \
45-
char __aligned(WB_UP(1)) \
46-
_msgq_buffer_##name[(elements_max_in) * sizeof(struct data_fifo_msgq)] = {0}; \
47-
char __aligned(WB_UP(1)) \
48-
_slab_buffer_##name[(elements_max_in) * (block_size_max_in)] = {0}; \
45+
char __aligned(WB_UP( \
46+
1)) _msgq_buffer_##name[(elements_max_in) * sizeof(struct data_fifo_msgq)] = {0}; \
47+
char __aligned(WB_UP(1)) _slab_buffer_##name[(elements_max_in) * (block_size_max_in)] = { \
48+
0}; \
4949
struct data_fifo name = {.msgq_buffer = _msgq_buffer_##name, \
5050
.slab_buffer = _slab_buffer_##name, \
5151
.block_size_max = block_size_max_in, \
@@ -163,7 +163,7 @@ int data_fifo_empty(struct data_fifo *data_fifo);
163163
int data_fifo_uninit(struct data_fifo *data_fifo);
164164

165165
/**
166-
* @brief Initialise the data_fifo.
166+
* @brief Initialize the data_fifo.
167167
*
168168
* @param data_fifo Pointer to the data_fifo structure.
169169
*
@@ -172,6 +172,16 @@ int data_fifo_uninit(struct data_fifo *data_fifo);
172172
*/
173173
int data_fifo_init(struct data_fifo *data_fifo);
174174

175+
/**
176+
* @brief Test if the data_fifo state.
177+
*
178+
* @param data_fifo Pointer to the data_fifo structure.
179+
*
180+
* @retval false Uninitialized.
181+
* @retval true Initialized.
182+
*/
183+
bool data_fifo_state(struct data_fifo *data_fifo);
184+
175185
/**
176186
* @}
177187
*/

lib/data_fifo/data_fifo.c

+10
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,13 @@ int data_fifo_init(struct data_fifo *data_fifo)
206206

207207
return ret;
208208
}
209+
210+
bool data_fifo_state(struct data_fifo *data_fifo)
211+
{
212+
__ASSERT_NO_MSG(data_fifo != NULL);
213+
__ASSERT_NO_MSG(data_fifo->elements_max != 0);
214+
__ASSERT_NO_MSG(data_fifo->block_size_max != 0);
215+
__ASSERT_NO_MSG((data_fifo->block_size_max % WB_UP(1)) == 0);
216+
217+
return data_fifo->initialized;
218+
}

subsys/audio_module/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/audio_module.c)
7+
zephyr_sources_ifdef(CONFIG_AUDIO_MODULE audio_module.c)

subsys/audio_module/Kconfig

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
6-
7-
menu "Audio Module"
6+
menu "Audio Modules"
87

98
config AUDIO_MODULE
109
tristate "Enable the audio module"
@@ -20,8 +19,12 @@ config AUDIO_MODULE_NAME_SIZE
2019
int "Maximum size for module naming in characters"
2120
default 20
2221

22+
#----------------------------------------------------------------------------#
23+
menu "Log levels"
24+
2325
module = AUDIO_MODULE
2426
module-str = audio_module
2527
source "subsys/logging/Kconfig.template.log_config"
2628

27-
endmenu # Audio Module
29+
endmenu # Log levels
30+
endmenu # Audio Modules

0 commit comments

Comments
 (0)