Home | History | Annotate | Download | only in itf
      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 
     22 static 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 *thiz = (IAudioEncoder *) self;
     31         SLAudioEncoderSettings settings = *pSettings;
     32         interface_lock_exclusive(thiz);
     33         thiz->mSettings = settings;
     34         interface_unlock_exclusive(thiz);
     35         result = SL_RESULT_SUCCESS;
     36     }
     37 
     38     SL_LEAVE_INTERFACE
     39 }
     40 
     41 
     42 static 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 *thiz = (IAudioEncoder *) self;
     51         interface_lock_shared(thiz);
     52         SLAudioEncoderSettings settings = thiz->mSettings;
     53         interface_unlock_shared(thiz);
     54         *pSettings = settings;
     55         result = SL_RESULT_SUCCESS;
     56     }
     57 
     58     SL_LEAVE_INTERFACE
     59 }
     60 
     61 
     62 static const struct SLAudioEncoderItf_ IAudioEncoder_Itf = {
     63     IAudioEncoder_SetEncoderSettings,
     64     IAudioEncoder_GetEncoderSettings
     65 };
     66 
     67 void IAudioEncoder_init(void *self)
     68 {
     69     IAudioEncoder *thiz = (IAudioEncoder *) self;
     70     thiz->mItf = &IAudioEncoder_Itf;
     71     memset(&thiz->mSettings, 0, sizeof(SLAudioEncoderSettings));
     72 }
     73