1 /*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /* AudioDecoderCapabilities implementation */
18
19 #include "sles_allinclusive.h"
20
21
IAudioDecoderCapabilities_GetAudioDecoders(SLAudioDecoderCapabilitiesItf self,SLuint32 * pNumDecoders,SLuint32 * pDecoderIds)22 static SLresult IAudioDecoderCapabilities_GetAudioDecoders(SLAudioDecoderCapabilitiesItf self,
23 SLuint32 *pNumDecoders, SLuint32 *pDecoderIds)
24 {
25 SL_ENTER_INTERFACE
26
27 if (NULL == pNumDecoders) {
28 result = SL_RESULT_PARAMETER_INVALID;
29 } else {
30 if (NULL == pDecoderIds) {
31 *pNumDecoders = MAX_DECODERS;
32 } else {
33 SLuint32 numDecoders = *pNumDecoders;
34 if (MAX_DECODERS <= numDecoders)
35 *pNumDecoders = numDecoders = MAX_DECODERS;
36 memcpy(pDecoderIds, Decoder_IDs, numDecoders * sizeof(SLuint32));
37 }
38 result = SL_RESULT_SUCCESS;
39 }
40
41 SL_LEAVE_INTERFACE
42 }
43
44
IAudioDecoderCapabilities_GetAudioDecoderCapabilities(SLAudioDecoderCapabilitiesItf self,SLuint32 decoderId,SLuint32 * pIndex,SLAudioCodecDescriptor * pDescriptor)45 static SLresult IAudioDecoderCapabilities_GetAudioDecoderCapabilities(
46 SLAudioDecoderCapabilitiesItf self, SLuint32 decoderId, SLuint32 *pIndex,
47 SLAudioCodecDescriptor *pDescriptor)
48 {
49 SL_ENTER_INTERFACE
50
51 result = GetCodecCapabilities(decoderId, pIndex, pDescriptor, DecoderDescriptors);
52
53 SL_LEAVE_INTERFACE
54 }
55
56
57 static const struct SLAudioDecoderCapabilitiesItf_ IAudioDecoderCapabilities_Itf = {
58 IAudioDecoderCapabilities_GetAudioDecoders,
59 IAudioDecoderCapabilities_GetAudioDecoderCapabilities
60 };
61
IAudioDecoderCapabilities_init(void * self)62 void IAudioDecoderCapabilities_init(void *self)
63 {
64 IAudioDecoderCapabilities *thiz = (IAudioDecoderCapabilities *) self;
65 thiz->mItf = &IAudioDecoderCapabilities_Itf;
66 }
67