Glenn Kasten | 61ac0ad | 2010-05-20 08:54:02 -0700 | [diff] [blame] | 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 | |
Glenn Kasten | ed46c29 | 2010-07-02 15:58:46 -0700 | [diff] [blame] | 21 | |
Glenn Kasten | 61ac0ad | 2010-05-20 08:54:02 -0700 | [diff] [blame] | 22 | static SLresult IAudioEncoder_SetEncoderSettings(SLAudioEncoderItf self, |
| 23 | SLAudioEncoderSettings *pSettings) |
| 24 | { |
Glenn Kasten | ed46c29 | 2010-07-02 15:58:46 -0700 | [diff] [blame] | 25 | SL_ENTER_INTERFACE |
| 26 | |
| 27 | if (NULL == pSettings) { |
| 28 | result = SL_RESULT_PARAMETER_INVALID; |
| 29 | } else { |
Glenn Kasten | bcc5c72 | 2011-01-18 11:44:36 -0800 | [diff] [blame] | 30 | IAudioEncoder *thiz = (IAudioEncoder *) self; |
Glenn Kasten | ed46c29 | 2010-07-02 15:58:46 -0700 | [diff] [blame] | 31 | SLAudioEncoderSettings settings = *pSettings; |
Glenn Kasten | bcc5c72 | 2011-01-18 11:44:36 -0800 | [diff] [blame] | 32 | interface_lock_exclusive(thiz); |
| 33 | thiz->mSettings = settings; |
| 34 | interface_unlock_exclusive(thiz); |
Glenn Kasten | ed46c29 | 2010-07-02 15:58:46 -0700 | [diff] [blame] | 35 | result = SL_RESULT_SUCCESS; |
| 36 | } |
| 37 | |
| 38 | SL_LEAVE_INTERFACE |
Glenn Kasten | 61ac0ad | 2010-05-20 08:54:02 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Glenn Kasten | ed46c29 | 2010-07-02 15:58:46 -0700 | [diff] [blame] | 41 | |
Glenn Kasten | 61ac0ad | 2010-05-20 08:54:02 -0700 | [diff] [blame] | 42 | static SLresult IAudioEncoder_GetEncoderSettings(SLAudioEncoderItf self, |
| 43 | SLAudioEncoderSettings *pSettings) |
| 44 | { |
Glenn Kasten | ed46c29 | 2010-07-02 15:58:46 -0700 | [diff] [blame] | 45 | SL_ENTER_INTERFACE |
| 46 | |
| 47 | if (NULL == pSettings) { |
| 48 | result = SL_RESULT_PARAMETER_INVALID; |
| 49 | } else { |
Glenn Kasten | bcc5c72 | 2011-01-18 11:44:36 -0800 | [diff] [blame] | 50 | IAudioEncoder *thiz = (IAudioEncoder *) self; |
| 51 | interface_lock_shared(thiz); |
| 52 | SLAudioEncoderSettings settings = thiz->mSettings; |
| 53 | interface_unlock_shared(thiz); |
Glenn Kasten | ed46c29 | 2010-07-02 15:58:46 -0700 | [diff] [blame] | 54 | *pSettings = settings; |
| 55 | result = SL_RESULT_SUCCESS; |
| 56 | } |
| 57 | |
| 58 | SL_LEAVE_INTERFACE |
Glenn Kasten | 61ac0ad | 2010-05-20 08:54:02 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Glenn Kasten | ed46c29 | 2010-07-02 15:58:46 -0700 | [diff] [blame] | 61 | |
Glenn Kasten | 61ac0ad | 2010-05-20 08:54:02 -0700 | [diff] [blame] | 62 | static const struct SLAudioEncoderItf_ IAudioEncoder_Itf = { |
| 63 | IAudioEncoder_SetEncoderSettings, |
| 64 | IAudioEncoder_GetEncoderSettings |
| 65 | }; |
| 66 | |
| 67 | void IAudioEncoder_init(void *self) |
| 68 | { |
Glenn Kasten | bcc5c72 | 2011-01-18 11:44:36 -0800 | [diff] [blame] | 69 | IAudioEncoder *thiz = (IAudioEncoder *) self; |
| 70 | thiz->mItf = &IAudioEncoder_Itf; |
| 71 | memset(&thiz->mSettings, 0, sizeof(SLAudioEncoderSettings)); |
Glenn Kasten | 61ac0ad | 2010-05-20 08:54:02 -0700 | [diff] [blame] | 72 | } |