blob: 112b63a12a9e09bb175dd1fc74d35ce9f6eb0f2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Device Audio Class */
/** */
/**************************************************************************/
/**************************************************************************/
#define UX_SOURCE_CODE
/* Include necessary system files. */
#include "ux_api.h"
#include "ux_device_class_audio.h"
#include "ux_device_stack.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_device_class_audio_uninitialize PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function uninitialize the Audio class. */
/* */
/* INPUT */
/* */
/* command Pointer to a class command */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* _ux_device_thread_delete Delete thread used */
/* _ux_utility_memory_free Free used local memory */
/* */
/* CALLED BY */
/* */
/* Device Audio Class */
/* */
/**************************************************************************/
UINT _ux_device_class_audio_uninitialize(UX_SLAVE_CLASS_COMMAND *command)
{
UX_DEVICE_CLASS_AUDIO *audio;
UX_DEVICE_CLASS_AUDIO_STREAM *stream;
UX_SLAVE_CLASS *audio_class;
ULONG i;
/* Get the class container. */
audio_class = command -> ux_slave_class_command_class_ptr;
/* Get the class instance in the container. */
audio = (UX_DEVICE_CLASS_AUDIO *) audio_class -> ux_slave_class_instance;
/* Sanity check. */
if (audio != UX_NULL)
{
/* Free the stream resources. */
stream = (UX_DEVICE_CLASS_AUDIO_STREAM *)((UCHAR *)audio + sizeof(UX_DEVICE_CLASS_AUDIO));
for (i = 0; i < audio -> ux_device_class_audio_streams_nb; i ++)
{
#if !defined(UX_DEVICE_STANDALONE)
_ux_device_thread_delete(&stream -> ux_device_class_audio_stream_thread);
#if defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT)
if (stream -> ux_device_class_audio_stream_feedback_thread_stack)
{
_ux_device_thread_delete(&stream -> ux_device_class_audio_stream_feedback_thread);
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_feedback_thread_stack);
}
#endif
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_thread_stack);
#endif
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_buffer);
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
#if defined(UX_DEVICE_CLASS_AUDIO_FEEDBACK_SUPPORT)
_ux_utility_memory_free(stream -> ux_device_class_audio_stream_feedback_buffer);
#endif
#endif
/* Next stream instance. */
stream ++;
}
#if defined(UX_DEVICE_CLASS_AUDIO_INTERRUPT_SUPPORT)
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
_ux_utility_memory_free(audio -> ux_device_class_audio_interrupt_buffer);
#endif
#if !defined(UX_DEVICE_STANDALONE)
_ux_device_thread_delete(&audio_class -> ux_slave_class_thread);
_ux_utility_memory_free(audio_class -> ux_slave_class_thread_stack);
_ux_device_semaphore_delete(&audio -> ux_device_class_audio_status_semaphore);
_ux_device_mutex_delete(&audio -> ux_device_class_audio_status_mutex);
#else
#endif
#endif
/* Free the audio instance with controls and streams. */
_ux_utility_memory_free(audio);
}
/* Return completion status. */
return(UX_SUCCESS);
}
|