blob: 511a0080b9def1bbf60320bb63a08e11438df5d4 [file] [log] [blame]
Glenn Kasten61ac0ad2010-05-20 08:54:02 -07001/*
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/* AudioEncoder implementation */
18
19#include "sles_allinclusive.h"
20
Glenn Kastened46c292010-07-02 15:58:46 -070021
Glenn Kasten61ac0ad2010-05-20 08:54:02 -070022static SLresult IAudioEncoder_SetEncoderSettings(SLAudioEncoderItf self,
23 SLAudioEncoderSettings *pSettings)
24{
Glenn Kastened46c292010-07-02 15:58:46 -070025 SL_ENTER_INTERFACE
26
27 if (NULL == pSettings) {
28 result = SL_RESULT_PARAMETER_INVALID;
29 } else {
Glenn Kastenbcc5c722011-01-18 11:44:36 -080030 IAudioEncoder *thiz = (IAudioEncoder *) self;
Glenn Kastened46c292010-07-02 15:58:46 -070031 SLAudioEncoderSettings settings = *pSettings;
Glenn Kastenbcc5c722011-01-18 11:44:36 -080032 interface_lock_exclusive(thiz);
33 thiz->mSettings = settings;
34 interface_unlock_exclusive(thiz);
Glenn Kastened46c292010-07-02 15:58:46 -070035 result = SL_RESULT_SUCCESS;
36 }
37
38 SL_LEAVE_INTERFACE
Glenn Kasten61ac0ad2010-05-20 08:54:02 -070039}
40
Glenn Kastened46c292010-07-02 15:58:46 -070041
Glenn Kasten61ac0ad2010-05-20 08:54:02 -070042static SLresult IAudioEncoder_GetEncoderSettings(SLAudioEncoderItf self,
43 SLAudioEncoderSettings *pSettings)
44{
Glenn Kastened46c292010-07-02 15:58:46 -070045 SL_ENTER_INTERFACE
46
47 if (NULL == pSettings) {
48 result = SL_RESULT_PARAMETER_INVALID;
49 } else {
Glenn Kastenbcc5c722011-01-18 11:44:36 -080050 IAudioEncoder *thiz = (IAudioEncoder *) self;
51 interface_lock_shared(thiz);
52 SLAudioEncoderSettings settings = thiz->mSettings;
53 interface_unlock_shared(thiz);
Glenn Kastened46c292010-07-02 15:58:46 -070054 *pSettings = settings;
55 result = SL_RESULT_SUCCESS;
56 }
57
58 SL_LEAVE_INTERFACE
Glenn Kasten61ac0ad2010-05-20 08:54:02 -070059}
60
Glenn Kastened46c292010-07-02 15:58:46 -070061
Glenn Kasten61ac0ad2010-05-20 08:54:02 -070062static const struct SLAudioEncoderItf_ IAudioEncoder_Itf = {
63 IAudioEncoder_SetEncoderSettings,
64 IAudioEncoder_GetEncoderSettings
65};
66
67void IAudioEncoder_init(void *self)
68{
Glenn Kastenbcc5c722011-01-18 11:44:36 -080069 IAudioEncoder *thiz = (IAudioEncoder *) self;
70 thiz->mItf = &IAudioEncoder_Itf;
71 memset(&thiz->mSettings, 0, sizeof(SLAudioEncoderSettings));
Glenn Kasten61ac0ad2010-05-20 08:54:02 -070072}