Skip to content

Commit 418a88b

Browse files
.....FIXES to many commits
1 parent 914c1e5 commit 418a88b

4 files changed

Lines changed: 26 additions & 11 deletions

File tree

src/audio/buffers/audio_buffer.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,30 @@ int audio_buffer_sync_secondary_buffer(struct sof_audio_buffer *buffer, size_t l
8282

8383
#endif /* CONFIG_PIPELINE_2_0 */
8484

85-
void audio_buffer_free(struct sof_audio_buffer *buffer)
85+
int audio_buffer_free(struct sof_audio_buffer *buffer)
8686
{
87+
int ret;
88+
89+
/* free of NULL is allowed */
8790
if (!buffer)
88-
return;
91+
return 0;
8992

9093
CORE_CHECK_STRUCT(buffer);
94+
95+
/* cannot free buffer if any of APIs is still connected */
96+
if ((sink_get_bound_module(&buffer->_sink_api)) ||
97+
(source_get_bound_module(&buffer->_source_api)))
98+
return -EINVAL;
99+
91100
#if CONFIG_PIPELINE_2_0
92-
audio_buffer_free(buffer->secondary_buffer_sink);
93-
audio_buffer_free(buffer->secondary_buffer_source);
101+
ret = audio_buffer_free(buffer->secondary_buffer_sink);
102+
if (ret)
103+
return ret;
104+
105+
ret = audio_buffer_free(buffer->secondary_buffer_source);
106+
if (ret)
107+
return ret;
108+
94109
#endif /* CONFIG_PIPELINE_2_0 */
95110
if (buffer->ops->free)
96111
buffer->ops->free(buffer);

src/audio/module_adapter/module/generic.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,14 @@ int module_unbind(struct processing_module *mod, struct unbind_info *unbind_data
520520
int ret;
521521
const struct module_interface *const ops = mod->dev->drv->adapter_ops;
522522

523-
if (bind_data->from_sink) {
524-
ret = sink_unbind(bind_data->from_sink);
523+
if (unbind_data->from_sink) {
524+
ret = sink_unbind(unbind_data->from_sink);
525525
if (ret)
526526
return ret;
527527
}
528528

529-
if (bind_data->from_source) {
530-
ret = source_unbind(bind_data->from_source);
529+
if (unbind_data->from_source) {
530+
ret = source_unbind(unbind_data->from_source);
531531
if (ret)
532532
return ret;
533533
}

src/include/sof/audio/audio_buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void audio_buffer_init(struct sof_audio_buffer *buffer, uint32_t buffer_type, bo
294294
/**
295295
* @brief free buffer and all allocated resources
296296
*/
297-
void audio_buffer_free(struct sof_audio_buffer *buffer);
297+
int audio_buffer_free(struct sof_audio_buffer *buffer);
298298

299299
/**
300300
* @brief clean all buffer data, set buffer positions to initial, leaving config as is

src/include/sof/audio/module_adapter/module/generic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ int module_set_configuration(struct processing_module *mod,
204204
enum module_cfg_fragment_position pos, size_t data_offset_size,
205205
const uint8_t *fragment, size_t fragment_size, uint8_t *response,
206206
size_t response_size);
207-
int module_bind(struct processing_module *mod, void *data);
208-
int module_unbind(struct processing_module *mod, void *data);
207+
int module_bind(struct processing_module *mod, struct bind_info *bind_data);
208+
int module_unbind(struct processing_module *mod, struct unbind_info *unbind_data);
209209

210210
struct comp_dev *module_adapter_new(const struct comp_driver *drv,
211211
const struct comp_ipc_config *config, const void *spec);

0 commit comments

Comments
 (0)