IAndroidConfiguration.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/* AndroidConfiguration implementation */ 18 19#include "sles_allinclusive.h" 20 21 22static SLresult IAndroidConfiguration_SetConfiguration(SLAndroidConfigurationItf self, 23 const SLchar *configKey, 24 const void *pConfigValue, 25 SLuint32 valueSize) 26{ 27 SL_ENTER_INTERFACE 28 29 IAndroidConfiguration *this = (IAndroidConfiguration *) self; 30 31 interface_lock_exclusive(this); 32 33 // route configuration to the appropriate object 34 if (SL_OBJECTID_AUDIORECORDER == IObjectToObjectID((this)->mThis)) { 35 SL_LOGV("SetConfiguration issued for AudioRecorder key=%s valueSize=%lu", 36 configKey, valueSize); 37 result = android_audioRecorder_setConfig((CAudioRecorder *) this->mThis, configKey, 38 pConfigValue, valueSize); 39 } else if (SL_OBJECTID_AUDIOPLAYER == IObjectToObjectID((this)->mThis)) { 40 SL_LOGV("SetConfiguration issued for AudioPlayer key=%s valueSize=%lu", 41 configKey, valueSize); 42 result = android_audioPlayer_setConfig((CAudioPlayer *) this->mThis, configKey, 43 pConfigValue, valueSize); 44 } else { 45 result = SL_RESULT_PARAMETER_INVALID; 46 } 47 48 interface_unlock_exclusive(this); 49 50 SL_LEAVE_INTERFACE 51} 52 53 54static SLresult IAndroidConfiguration_GetConfiguration(SLAndroidConfigurationItf self, 55 const SLchar *configKey, 56 SLuint32 *pValueSize, 57 void *pConfigValue) 58{ 59 SL_ENTER_INTERFACE 60 61 // having value size is required, but pConfigValue being NULL is allowed to allow properties 62 // to report their actual value size (if applicable) 63 if (NULL == pValueSize) { 64 result = SL_RESULT_PARAMETER_INVALID; 65 } else { 66 IAndroidConfiguration *this = (IAndroidConfiguration *) self; 67 68 interface_lock_exclusive(this); 69 70 // route configuration request to the appropriate object 71 if (SL_OBJECTID_AUDIORECORDER == IObjectToObjectID((this)->mThis)) { 72 result = android_audioRecorder_getConfig((CAudioRecorder *) this->mThis, configKey, 73 pValueSize, pConfigValue); 74 } else if (SL_OBJECTID_AUDIOPLAYER == IObjectToObjectID((this)->mThis)) { 75 result = android_audioPlayer_getConfig((CAudioPlayer *) this->mThis, configKey, 76 pValueSize, pConfigValue); 77 } else { 78 result = SL_RESULT_PARAMETER_INVALID; 79 } 80 81 interface_unlock_exclusive(this); 82 } 83 84 SL_LEAVE_INTERFACE 85} 86 87 88static const struct SLAndroidConfigurationItf_ IAndroidConfiguration_Itf = { 89 IAndroidConfiguration_SetConfiguration, 90 IAndroidConfiguration_GetConfiguration 91}; 92 93void IAndroidConfiguration_init(void *self) 94{ 95 IAndroidConfiguration *this = (IAndroidConfiguration *) self; 96 this->mItf = &IAndroidConfiguration_Itf; 97} 98