1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11 /**************************************************************************/
12 /**************************************************************************/
13 /** */
14 /** USBX Component */
15 /** */
16 /** Device Audio Class */
17 /** */
18 /**************************************************************************/
19 /**************************************************************************/
20
21 #define UX_SOURCE_CODE
22
23
24 /* Include necessary system files. */
25
26 #include "ux_api.h"
27 #include "ux_device_class_audio.h"
28 #include "ux_device_stack.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_device_class_audio_stream_get PORTABLE C */
36 /* 6.2.1 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function get the stream instance of Audio class. */
44 /* */
45 /* INPUT */
46 /* */
47 /* audio Address of audio class */
48 /* instance */
49 /* stream_index Stream instance index 0 based */
50 /* stream Pointer to buffer to fill */
51 /* pointer to stream instance */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* Completion Status */
56 /* */
57 /* CALLS */
58 /* */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* Application */
63 /* */
64 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
69 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
70 /* resulting in version 6.1 */
71 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
72 /* resulting in version 6.1.10 */
73 /* 03-08-2023 Chaoqiong Xiao Modified comment(s), */
74 /* added error checks support, */
75 /* resulting in version 6.2.1 */
76 /* */
77 /**************************************************************************/
_ux_device_class_audio_stream_get(UX_DEVICE_CLASS_AUDIO * audio,ULONG stream_index,UX_DEVICE_CLASS_AUDIO_STREAM ** stream)78 UINT _ux_device_class_audio_stream_get(UX_DEVICE_CLASS_AUDIO *audio,
79 ULONG stream_index, UX_DEVICE_CLASS_AUDIO_STREAM **stream)
80 {
81
82 /* Store the stream instance found. */
83 *stream = audio -> ux_device_class_audio_streams + stream_index;
84
85 /* Return completion status. */
86 return(UX_SUCCESS);
87 }
88
89 /**************************************************************************/
90 /* */
91 /* FUNCTION RELEASE */
92 /* */
93 /* _uxe_device_class_audio_stream_get PORTABLE C */
94 /* 6.2.1 */
95 /* AUTHOR */
96 /* */
97 /* Chaoqiong Xiao, Microsoft Corporation */
98 /* */
99 /* DESCRIPTION */
100 /* */
101 /* This function checks errors in stream instance getting function. */
102 /* */
103 /* INPUT */
104 /* */
105 /* audio Address of audio class */
106 /* instance */
107 /* stream_index Stream instance index 0 based */
108 /* stream Pointer to buffer to fill */
109 /* pointer to stream instance */
110 /* */
111 /* OUTPUT */
112 /* */
113 /* Completion Status */
114 /* */
115 /* CALLS */
116 /* */
117 /* _ux_device_class_audio_stream_get Get stream instance */
118 /* */
119 /* CALLED BY */
120 /* */
121 /* Application */
122 /* */
123 /* RELEASE HISTORY */
124 /* */
125 /* DATE NAME DESCRIPTION */
126 /* */
127 /* 03-08-2023 Chaoqiong Xiao Initial Version 6.2.1 */
128 /* */
129 /**************************************************************************/
_uxe_device_class_audio_stream_get(UX_DEVICE_CLASS_AUDIO * audio,ULONG stream_index,UX_DEVICE_CLASS_AUDIO_STREAM ** stream)130 UINT _uxe_device_class_audio_stream_get(UX_DEVICE_CLASS_AUDIO *audio,
131 ULONG stream_index, UX_DEVICE_CLASS_AUDIO_STREAM **stream)
132 {
133
134 /* Sanity check. */
135 if (audio == UX_NULL)
136 return(UX_INVALID_PARAMETER);
137
138 /* Index validation. */
139 if (stream_index >= audio -> ux_device_class_audio_streams_nb)
140 return(UX_INVALID_PARAMETER);
141
142 /* Store the stream instance found. */
143 if (stream == UX_NULL)
144 return(UX_INVALID_PARAMETER);
145
146 /* Get audio stream instance. */
147 return(_ux_device_class_audio_stream_get(audio, stream_index, stream));
148 }
149