sbMediacoreEqualizerBand.cpp
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2009 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
32 
35 
37 : mLock(nsnull)
38 , mIndex(0)
39 , mFrequency(0)
40 , mGain(0)
41 {
42 }
43 
45 {
46  if(mLock) {
47  nsAutoLock::DestroyLock(mLock);
48  }
49 }
50 
51 NS_IMETHODIMP
52 sbMediacoreEqualizerBand::Init(PRUint32 aIndex, PRUint32 aFrequency, double aGain)
53 {
54  NS_ENSURE_TRUE(!mLock, NS_ERROR_ALREADY_INITIALIZED);
55 
56  mLock = nsAutoLock::NewLock("sbMediacoreEqualizerBand::mLock");
57  NS_ENSURE_TRUE(mLock, NS_ERROR_OUT_OF_MEMORY);
58 
59  mIndex = aIndex;
60  mFrequency = aFrequency;
61  mGain = aGain;
62 
63  return NS_OK;
64 }
65 
66 /* attribute unsigned long index; */
67 NS_IMETHODIMP
68 sbMediacoreEqualizerBand::GetIndex(PRUint32 *aIndex)
69 {
70  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
71  NS_ENSURE_ARG_POINTER(aIndex);
72 
73  nsAutoLock lock(mLock);
74  *aIndex = mIndex;
75 
76  return NS_OK;
77 }
78 
79 NS_IMETHODIMP
80 sbMediacoreEqualizerBand::SetIndex(PRUint32 aIndex)
81 {
82  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
83 
84  nsAutoLock lock(mLock);
85  mIndex = aIndex;
86 
87  return NS_OK;
88 }
89 
90 /* attribute unsigned long frequency; */
91 NS_IMETHODIMP
92 sbMediacoreEqualizerBand::GetFrequency(PRUint32 *aFrequency)
93 {
94  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
95  NS_ENSURE_ARG_POINTER(aFrequency);
96 
97  nsAutoLock lock(mLock);
98  *aFrequency = mFrequency;
99 
100  return NS_OK;
101 }
102 
103 NS_IMETHODIMP
104 sbMediacoreEqualizerBand::SetFrequency(PRUint32 aFrequency)
105 {
106  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
107 
108  nsAutoLock lock(mLock);
109  mFrequency = aFrequency;
110 
111  return NS_OK;
112 }
113 
114 /* attribute double gain; */
115 NS_IMETHODIMP
116 sbMediacoreEqualizerBand::GetGain(double *aGain)
117 {
118  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
119 
120  nsAutoLock lock(mLock);
121  *aGain = mGain;
122 
123  return NS_OK;
124 }
125 
126 NS_IMETHODIMP
127 sbMediacoreEqualizerBand::SetGain(double aGain)
128 {
129  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
130 
131  nsAutoLock lock(mLock);
132  mGain = aGain;
133 
134  return NS_OK;
135 }
136 
137 NS_IMETHODIMP
138 sbMediacoreEqualizerBand::GetValues(PRUint32 *aIndex, PRUint32 *aFrequency, double *aGain)
139 {
140  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
141 
142  NS_ENSURE_ARG_POINTER(aIndex);
143  NS_ENSURE_ARG_POINTER(aFrequency);
144  NS_ENSURE_ARG_POINTER(aGain);
145 
146  *aIndex = mIndex;
147  *aFrequency = mFrequency;
148  *aGain = mGain;
149 
150  return NS_OK;
151 }
152 
153 NS_IMETHODIMP
154 sbMediacoreEqualizerBand::SetValues(PRUint32 aIndex, PRUint32 aFrequency, double aGain)
155 {
156  NS_ENSURE_TRUE(mLock, NS_ERROR_NOT_INITIALIZED);
157 
158  nsAutoLock lock(mLock);
159 
160  mIndex = aIndex;
161  mFrequency = aFrequency;
162  mGain = aGain;
163 
164  return NS_OK;
165 }
return NS_OK
NS_IMPL_THREADSAFE_ISUPPORTS1(sbMediacoreEqualizerBand, sbIMediacoreEqualizerBand)
Songbird Mediacore Equalizer Band Definition.
function Init()
NS_DECL_ISUPPORTS NS_DECL_SBIMEDIACOREEQUALIZERBAND sbMediacoreEqualizerBand()