IAudioEncoder.c revision 262059f71a68edc5e510427c63f5f1623d3672a8
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/* AudioEncoder implementation */
18
19#include "sles_allinclusive.h"
20
21
22static SLresult IAudioEncoder_SetEncoderSettings(SLAudioEncoderItf self,
23    SLAudioEncoderSettings  *pSettings)
24{
25    SL_ENTER_INTERFACE
26
27    if (NULL == pSettings) {
28        result = SL_RESULT_PARAMETER_INVALID;
29    } else {
30        IAudioEncoder *this = (IAudioEncoder *) self;
31        SLAudioEncoderSettings settings = *pSettings;
32        interface_lock_exclusive(this);
33        this->mSettings = settings;
34        interface_unlock_exclusive(this);
35        result = SL_RESULT_SUCCESS;
36    }
37
38    SL_LEAVE_INTERFACE
39}
40
41
42static SLresult IAudioEncoder_GetEncoderSettings(SLAudioEncoderItf self,
43    SLAudioEncoderSettings *pSettings)
44{
45    SL_ENTER_INTERFACE
46
47    if (NULL == pSettings) {
48        result = SL_RESULT_PARAMETER_INVALID;
49    } else {
50        IAudioEncoder *this = (IAudioEncoder *) self;
51        interface_lock_shared(this);
52        SLAudioEncoderSettings settings = this->mSettings;
53        interface_unlock_shared(this);
54        *pSettings = settings;
55        result = SL_RESULT_SUCCESS;
56    }
57
58    SL_LEAVE_INTERFACE
59}
60
61
62static const struct SLAudioEncoderItf_ IAudioEncoder_Itf = {
63    IAudioEncoder_SetEncoderSettings,
64    IAudioEncoder_GetEncoderSettings
65};
66
67void IAudioEncoder_init(void *self)
68{
69    IAudioEncoder *this = (IAudioEncoder *) self;
70    this->mItf = &IAudioEncoder_Itf;
71    memset(&this->mSettings, 0, sizeof(SLAudioEncoderSettings));
72}
73