• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  /* Pitch implementation */
18  
19  #include "sles_allinclusive.h"
20  
21  
IPitch_SetPitch(SLPitchItf self,SLpermille pitch)22  static SLresult IPitch_SetPitch(SLPitchItf self, SLpermille pitch)
23  {
24      SL_ENTER_INTERFACE
25  
26      IPitch *thiz = (IPitch *) self;
27      // const, so no lock needed
28      if (!(thiz->mMinPitch <= pitch && pitch <= thiz->mMaxPitch)) {
29          result = SL_RESULT_PARAMETER_INVALID;
30      } else {
31          interface_lock_poke(thiz);
32          thiz->mPitch = pitch;
33          interface_unlock_poke(thiz);
34          result = SL_RESULT_SUCCESS;
35      }
36  
37      SL_LEAVE_INTERFACE
38  }
39  
40  
IPitch_GetPitch(SLPitchItf self,SLpermille * pPitch)41  static SLresult IPitch_GetPitch(SLPitchItf self, SLpermille *pPitch)
42  {
43      SL_ENTER_INTERFACE
44  
45      if (NULL == pPitch) {
46          result = SL_RESULT_PARAMETER_INVALID;
47      } else {
48          IPitch *thiz = (IPitch *) self;
49          interface_lock_peek(thiz);
50          SLpermille pitch = thiz->mPitch;
51          interface_unlock_peek(thiz);
52          *pPitch = pitch;
53          result = SL_RESULT_SUCCESS;
54      }
55  
56      SL_LEAVE_INTERFACE
57  }
58  
59  
IPitch_GetPitchCapabilities(SLPitchItf self,SLpermille * pMinPitch,SLpermille * pMaxPitch)60  static SLresult IPitch_GetPitchCapabilities(SLPitchItf self,
61      SLpermille *pMinPitch, SLpermille *pMaxPitch)
62  {
63      SL_ENTER_INTERFACE
64  
65      // per spec, each is optional, and does not require that at least one must be non-NULL
66  #if 0
67      if (NULL == pMinPitch && NULL == pMaxPitch)
68          result = SL_RESULT_PARAMETER_INVALID;
69  #endif
70      IPitch *thiz = (IPitch *) self;
71      // const, so no lock needed
72      SLpermille minPitch = thiz->mMinPitch;
73      SLpermille maxPitch = thiz->mMaxPitch;
74      if (NULL != pMinPitch)
75          *pMinPitch = minPitch;
76      if (NULL != pMaxPitch)
77          *pMaxPitch = maxPitch;
78      result = SL_RESULT_SUCCESS;
79  
80      SL_LEAVE_INTERFACE
81  }
82  
83  
84  static const struct SLPitchItf_ IPitch_Itf = {
85      IPitch_SetPitch,
86      IPitch_GetPitch,
87      IPitch_GetPitchCapabilities
88  };
89  
IPitch_init(void * self)90  void IPitch_init(void *self)
91  {
92      IPitch *thiz = (IPitch *) self;
93      thiz->mItf = &IPitch_Itf;
94      thiz->mPitch = 1000;
95      // const
96      thiz->mMinPitch = -500;
97      thiz->mMaxPitch = 2000;
98  }
99