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/* Visualization implementation */ 18 19#include "sles_allinclusive.h" 20 21 22static SLresult IVisualization_RegisterVisualizationCallback(SLVisualizationItf self, 23 slVisualizationCallback callback, void *pContext, SLmilliHertz rate) 24{ 25 SL_ENTER_INTERFACE 26 27 if (!(0 < rate && rate <= 20000)) { 28 result = SL_RESULT_PARAMETER_INVALID; 29 } else { 30 IVisualization *thiz = (IVisualization *) self; 31 interface_lock_exclusive(thiz); 32 thiz->mCallback = callback; 33 thiz->mContext = pContext; 34 thiz->mRate = rate; 35 interface_unlock_exclusive(thiz); 36 result = SL_RESULT_SUCCESS; 37 } 38 39 SL_LEAVE_INTERFACE 40} 41 42 43static SLresult IVisualization_GetMaxRate(SLVisualizationItf self, SLmilliHertz *pRate) 44{ 45 SL_ENTER_INTERFACE 46 47 if (NULL == pRate) { 48 result = SL_RESULT_PARAMETER_INVALID; 49 } else { 50 *pRate = 20000; 51 result = SL_RESULT_SUCCESS; 52 } 53 54 SL_LEAVE_INTERFACE 55} 56 57 58static const struct SLVisualizationItf_ IVisualization_Itf = { 59 IVisualization_RegisterVisualizationCallback, 60 IVisualization_GetMaxRate 61}; 62 63void IVisualization_init(void *self) 64{ 65 IVisualization *thiz = (IVisualization *) self; 66 thiz->mItf = &IVisualization_Itf; 67 thiz->mCallback = NULL; 68 thiz->mContext = NULL; 69 thiz->mRate = 20000; 70} 71