xref: /aosp_15_r20/frameworks/wilhelm/src/itf/IPitch.cpp (revision bebae9c0e76121f8312ccb50385c080b3a0b023c)
1*bebae9c0SAndroid Build Coastguard Worker /*
2*bebae9c0SAndroid Build Coastguard Worker  * Copyright (C) 2010 The Android Open Source Project
3*bebae9c0SAndroid Build Coastguard Worker  *
4*bebae9c0SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*bebae9c0SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*bebae9c0SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*bebae9c0SAndroid Build Coastguard Worker  *
8*bebae9c0SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*bebae9c0SAndroid Build Coastguard Worker  *
10*bebae9c0SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*bebae9c0SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*bebae9c0SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*bebae9c0SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*bebae9c0SAndroid Build Coastguard Worker  * limitations under the License.
15*bebae9c0SAndroid Build Coastguard Worker  */
16*bebae9c0SAndroid Build Coastguard Worker 
17*bebae9c0SAndroid Build Coastguard Worker /* Pitch implementation */
18*bebae9c0SAndroid Build Coastguard Worker 
19*bebae9c0SAndroid Build Coastguard Worker #include "sles_allinclusive.h"
20*bebae9c0SAndroid Build Coastguard Worker 
21*bebae9c0SAndroid Build Coastguard Worker 
IPitch_SetPitch(SLPitchItf self,SLpermille pitch)22*bebae9c0SAndroid Build Coastguard Worker static SLresult IPitch_SetPitch(SLPitchItf self, SLpermille pitch)
23*bebae9c0SAndroid Build Coastguard Worker {
24*bebae9c0SAndroid Build Coastguard Worker     SL_ENTER_INTERFACE
25*bebae9c0SAndroid Build Coastguard Worker 
26*bebae9c0SAndroid Build Coastguard Worker     IPitch *thiz = (IPitch *) self;
27*bebae9c0SAndroid Build Coastguard Worker     // const, so no lock needed
28*bebae9c0SAndroid Build Coastguard Worker     if (!(thiz->mMinPitch <= pitch && pitch <= thiz->mMaxPitch)) {
29*bebae9c0SAndroid Build Coastguard Worker         result = SL_RESULT_PARAMETER_INVALID;
30*bebae9c0SAndroid Build Coastguard Worker     } else {
31*bebae9c0SAndroid Build Coastguard Worker         interface_lock_poke(thiz);
32*bebae9c0SAndroid Build Coastguard Worker         thiz->mPitch = pitch;
33*bebae9c0SAndroid Build Coastguard Worker         interface_unlock_poke(thiz);
34*bebae9c0SAndroid Build Coastguard Worker         result = SL_RESULT_SUCCESS;
35*bebae9c0SAndroid Build Coastguard Worker     }
36*bebae9c0SAndroid Build Coastguard Worker 
37*bebae9c0SAndroid Build Coastguard Worker     SL_LEAVE_INTERFACE
38*bebae9c0SAndroid Build Coastguard Worker }
39*bebae9c0SAndroid Build Coastguard Worker 
40*bebae9c0SAndroid Build Coastguard Worker 
IPitch_GetPitch(SLPitchItf self,SLpermille * pPitch)41*bebae9c0SAndroid Build Coastguard Worker static SLresult IPitch_GetPitch(SLPitchItf self, SLpermille *pPitch)
42*bebae9c0SAndroid Build Coastguard Worker {
43*bebae9c0SAndroid Build Coastguard Worker     SL_ENTER_INTERFACE
44*bebae9c0SAndroid Build Coastguard Worker 
45*bebae9c0SAndroid Build Coastguard Worker     if (NULL == pPitch) {
46*bebae9c0SAndroid Build Coastguard Worker         result = SL_RESULT_PARAMETER_INVALID;
47*bebae9c0SAndroid Build Coastguard Worker     } else {
48*bebae9c0SAndroid Build Coastguard Worker         IPitch *thiz = (IPitch *) self;
49*bebae9c0SAndroid Build Coastguard Worker         interface_lock_peek(thiz);
50*bebae9c0SAndroid Build Coastguard Worker         SLpermille pitch = thiz->mPitch;
51*bebae9c0SAndroid Build Coastguard Worker         interface_unlock_peek(thiz);
52*bebae9c0SAndroid Build Coastguard Worker         *pPitch = pitch;
53*bebae9c0SAndroid Build Coastguard Worker         result = SL_RESULT_SUCCESS;
54*bebae9c0SAndroid Build Coastguard Worker     }
55*bebae9c0SAndroid Build Coastguard Worker 
56*bebae9c0SAndroid Build Coastguard Worker     SL_LEAVE_INTERFACE
57*bebae9c0SAndroid Build Coastguard Worker }
58*bebae9c0SAndroid Build Coastguard Worker 
59*bebae9c0SAndroid Build Coastguard Worker 
IPitch_GetPitchCapabilities(SLPitchItf self,SLpermille * pMinPitch,SLpermille * pMaxPitch)60*bebae9c0SAndroid Build Coastguard Worker static SLresult IPitch_GetPitchCapabilities(SLPitchItf self,
61*bebae9c0SAndroid Build Coastguard Worker     SLpermille *pMinPitch, SLpermille *pMaxPitch)
62*bebae9c0SAndroid Build Coastguard Worker {
63*bebae9c0SAndroid Build Coastguard Worker     SL_ENTER_INTERFACE
64*bebae9c0SAndroid Build Coastguard Worker 
65*bebae9c0SAndroid Build Coastguard Worker     // per spec, each is optional, and does not require that at least one must be non-NULL
66*bebae9c0SAndroid Build Coastguard Worker #if 0
67*bebae9c0SAndroid Build Coastguard Worker     if (NULL == pMinPitch && NULL == pMaxPitch)
68*bebae9c0SAndroid Build Coastguard Worker         result = SL_RESULT_PARAMETER_INVALID;
69*bebae9c0SAndroid Build Coastguard Worker #endif
70*bebae9c0SAndroid Build Coastguard Worker     IPitch *thiz = (IPitch *) self;
71*bebae9c0SAndroid Build Coastguard Worker     // const, so no lock needed
72*bebae9c0SAndroid Build Coastguard Worker     SLpermille minPitch = thiz->mMinPitch;
73*bebae9c0SAndroid Build Coastguard Worker     SLpermille maxPitch = thiz->mMaxPitch;
74*bebae9c0SAndroid Build Coastguard Worker     if (NULL != pMinPitch)
75*bebae9c0SAndroid Build Coastguard Worker         *pMinPitch = minPitch;
76*bebae9c0SAndroid Build Coastguard Worker     if (NULL != pMaxPitch)
77*bebae9c0SAndroid Build Coastguard Worker         *pMaxPitch = maxPitch;
78*bebae9c0SAndroid Build Coastguard Worker     result = SL_RESULT_SUCCESS;
79*bebae9c0SAndroid Build Coastguard Worker 
80*bebae9c0SAndroid Build Coastguard Worker     SL_LEAVE_INTERFACE
81*bebae9c0SAndroid Build Coastguard Worker }
82*bebae9c0SAndroid Build Coastguard Worker 
83*bebae9c0SAndroid Build Coastguard Worker 
84*bebae9c0SAndroid Build Coastguard Worker static const struct SLPitchItf_ IPitch_Itf = {
85*bebae9c0SAndroid Build Coastguard Worker     IPitch_SetPitch,
86*bebae9c0SAndroid Build Coastguard Worker     IPitch_GetPitch,
87*bebae9c0SAndroid Build Coastguard Worker     IPitch_GetPitchCapabilities
88*bebae9c0SAndroid Build Coastguard Worker };
89*bebae9c0SAndroid Build Coastguard Worker 
IPitch_init(void * self)90*bebae9c0SAndroid Build Coastguard Worker void IPitch_init(void *self)
91*bebae9c0SAndroid Build Coastguard Worker {
92*bebae9c0SAndroid Build Coastguard Worker     IPitch *thiz = (IPitch *) self;
93*bebae9c0SAndroid Build Coastguard Worker     thiz->mItf = &IPitch_Itf;
94*bebae9c0SAndroid Build Coastguard Worker     thiz->mPitch = 1000;
95*bebae9c0SAndroid Build Coastguard Worker     // const
96*bebae9c0SAndroid Build Coastguard Worker     thiz->mMinPitch = -500;
97*bebae9c0SAndroid Build Coastguard Worker     thiz->mMaxPitch = 2000;
98*bebae9c0SAndroid Build Coastguard Worker }
99