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 result = SL_RESULT_SUCCESS;
31 if (NULL != pDecoderIds) {
32 SLuint32 numDecoders = *pNumDecoders;
33 if (numDecoders > MAX_DECODERS) {
34 numDecoders = MAX_DECODERS;
35 } else if (numDecoders < MAX_DECODERS) {
36 // FIXME starting in 1.1 this will be SL_RESULT_BUFFER_INSUFFICIENT
37 result = SL_RESULT_PARAMETER_INVALID;
38 }
39 memcpy(pDecoderIds, Decoder_IDs, numDecoders * sizeof(SLuint32));
40 }
41 *pNumDecoders = MAX_DECODERS;
42 }
43
44 SL_LEAVE_INTERFACE
45 }
46
47
IAudioDecoderCapabilities_GetAudioDecoderCapabilities(SLAudioDecoderCapabilitiesItf self,SLuint32 decoderId,SLuint32 * pIndex,SLAudioCodecDescriptor * pDescriptor)48 static SLresult IAudioDecoderCapabilities_GetAudioDecoderCapabilities(
49 SLAudioDecoderCapabilitiesItf self, SLuint32 decoderId, SLuint32 *pIndex,
50 SLAudioCodecDescriptor *pDescriptor)
51 {
52 SL_ENTER_INTERFACE
53
54 result = GetCodecCapabilities(decoderId, pIndex, pDescriptor, DecoderDescriptors);
55
56 SL_LEAVE_INTERFACE
57 }
58
59
60 static const struct SLAudioDecoderCapabilitiesItf_ IAudioDecoderCapabilities_Itf = {
61 IAudioDecoderCapabilities_GetAudioDecoders,
62 IAudioDecoderCapabilities_GetAudioDecoderCapabilities
63 };
64
IAudioDecoderCapabilities_init(void * self)65 void IAudioDecoderCapabilities_init(void *self)
66 {
67 IAudioDecoderCapabilities *thiz = (IAudioDecoderCapabilities *) self;
68 thiz->mItf = &IAudioDecoderCapabilities_Itf;
69 }
70