|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "mdasoundadapter.h" |
|
17 #include "mdasoundadapterbody.h" |
|
18 #include <e32debug.h> |
|
19 |
|
20 EXPORT_C RMdaDevSound::RMdaDevSound() |
|
21 :iBody(NULL) |
|
22 { |
|
23 } |
|
24 |
|
25 EXPORT_C TInt RMdaDevSound::Open(TInt aUnit) |
|
26 { |
|
27 TInt err = KErrNone; |
|
28 if(iBody == NULL) |
|
29 { |
|
30 TRAP(err, iBody = RMdaDevSound::CBody::NewL()); |
|
31 } |
|
32 if(err == KErrNone) |
|
33 { |
|
34 err = iBody->Open(aUnit); |
|
35 } |
|
36 return err; |
|
37 } |
|
38 |
|
39 EXPORT_C TVersion RMdaDevSound::VersionRequired() const |
|
40 { |
|
41 if(iBody) |
|
42 { |
|
43 return iBody->VersionRequired(); |
|
44 } |
|
45 return TVersion(); |
|
46 } |
|
47 |
|
48 EXPORT_C TInt RMdaDevSound::IsMdaSound() |
|
49 { |
|
50 return iBody->IsMdaSound(); |
|
51 } |
|
52 |
|
53 EXPORT_C TInt RMdaDevSound::PlayVolume() |
|
54 { |
|
55 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
56 return iBody->PlayVolume(); |
|
57 } |
|
58 |
|
59 EXPORT_C void RMdaDevSound::SetPlayVolume(TInt aVolume) |
|
60 { |
|
61 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
62 iBody->SetPlayVolume(aVolume); |
|
63 } |
|
64 |
|
65 EXPORT_C void RMdaDevSound::SetVolume(TInt aLogarithmicVolume) |
|
66 { |
|
67 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
68 iBody->SetVolume(aLogarithmicVolume); |
|
69 } |
|
70 |
|
71 EXPORT_C void RMdaDevSound::CancelPlayData() |
|
72 { |
|
73 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
74 iBody->CancelPlayData(); |
|
75 } |
|
76 |
|
77 EXPORT_C TInt RMdaDevSound::RecordLevel() |
|
78 { |
|
79 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
80 return iBody->RecordLevel(); |
|
81 } |
|
82 |
|
83 EXPORT_C void RMdaDevSound::SetRecordLevel(TInt aLevel) |
|
84 { |
|
85 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
86 iBody->SetRecordLevel(aLevel); |
|
87 } |
|
88 |
|
89 EXPORT_C void RMdaDevSound::CancelRecordData() |
|
90 { |
|
91 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
92 iBody->CancelRecordData(); |
|
93 } |
|
94 |
|
95 EXPORT_C void RMdaDevSound::FlushRecordBuffer() |
|
96 { |
|
97 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
98 iBody->FlushRecordBuffer(); |
|
99 } |
|
100 |
|
101 EXPORT_C TInt RMdaDevSound::BytesPlayed() |
|
102 { |
|
103 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
104 return iBody->BytesPlayed(); |
|
105 } |
|
106 |
|
107 EXPORT_C void RMdaDevSound::ResetBytesPlayed() |
|
108 { |
|
109 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
110 return iBody->ResetBytesPlayed(); |
|
111 } |
|
112 |
|
113 EXPORT_C void RMdaDevSound::PausePlayBuffer() |
|
114 { |
|
115 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
116 iBody->PausePlayBuffer(); |
|
117 } |
|
118 |
|
119 EXPORT_C void RMdaDevSound::ResumePlaying() |
|
120 { |
|
121 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
122 iBody->ResumePlaying(); |
|
123 } |
|
124 |
|
125 EXPORT_C void RMdaDevSound::ResumePlaying(TRequestStatus&) |
|
126 { |
|
127 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
128 iBody->ResumePlaying(); |
|
129 } |
|
130 |
|
131 EXPORT_C void RMdaDevSound::PauseRecordBuffer() |
|
132 { |
|
133 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
134 iBody->PauseRecordBuffer(); |
|
135 } |
|
136 |
|
137 EXPORT_C void RMdaDevSound::ResumeRecording() |
|
138 { |
|
139 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
140 iBody->ResumeRecording(); |
|
141 } |
|
142 |
|
143 EXPORT_C TInt RMdaDevSound::GetTimePlayed(TTimeIntervalMicroSeconds& aTimePlayed) |
|
144 { |
|
145 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
146 return iBody->GetTimePlayed(aTimePlayed); |
|
147 } |
|
148 |
|
149 |
|
150 |
|
151 EXPORT_C void RMdaDevSound::PlayFormatsSupported(TSoundFormatsSupportedBuf& aFormatsSupported) |
|
152 { |
|
153 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
154 iBody->PlayFormatsSupported(aFormatsSupported); |
|
155 } |
|
156 |
|
157 EXPORT_C void RMdaDevSound::GetPlayFormat(TCurrentSoundFormatBuf& aFormat) |
|
158 { |
|
159 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
160 iBody->GetPlayFormat(aFormat); |
|
161 } |
|
162 |
|
163 EXPORT_C TInt RMdaDevSound::SetPlayFormat(const TCurrentSoundFormatBuf& aFormat) |
|
164 { |
|
165 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
166 return iBody->SetPlayFormat(aFormat); |
|
167 } |
|
168 |
|
169 EXPORT_C void RMdaDevSound::RecordFormatsSupported(TSoundFormatsSupportedBuf& aFormatsSupported) |
|
170 { |
|
171 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
172 iBody->RecordFormatsSupported(aFormatsSupported); |
|
173 } |
|
174 |
|
175 EXPORT_C void RMdaDevSound::GetRecordFormat(TCurrentSoundFormatBuf& aFormat) |
|
176 { |
|
177 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
178 iBody->GetRecordFormat(aFormat); |
|
179 } |
|
180 |
|
181 EXPORT_C TInt RMdaDevSound::SetRecordFormat(const TCurrentSoundFormatBuf& aFormat) |
|
182 { |
|
183 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
184 return iBody->SetRecordFormat(aFormat); |
|
185 } |
|
186 |
|
187 EXPORT_C void RMdaDevSound::Close() |
|
188 { |
|
189 if(iBody) |
|
190 { |
|
191 iBody->Close(); |
|
192 delete iBody; |
|
193 iBody = NULL; |
|
194 } |
|
195 } |
|
196 |
|
197 EXPORT_C TInt RMdaDevSound::Handle() |
|
198 { |
|
199 if(iBody) |
|
200 { |
|
201 return iBody->Handle(); |
|
202 } |
|
203 return 0; |
|
204 } |
|
205 |
|
206 EXPORT_C void RMdaDevSound::PlayData(TRequestStatus& aStatus, const TDesC8& aData) |
|
207 { |
|
208 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
209 iBody->PlayData(aStatus, aData); |
|
210 } |
|
211 |
|
212 EXPORT_C void RMdaDevSound::RecordData(TRequestStatus& aStatus, TDes8& aData) |
|
213 { |
|
214 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
215 iBody->RecordData(aStatus, aData); |
|
216 } |
|
217 |
|
218 EXPORT_C void RMdaDevSound::NotifyRecordError(TRequestStatus& aStatus) |
|
219 { |
|
220 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
221 iBody->NotifyRecordError(aStatus); |
|
222 } |
|
223 |
|
224 EXPORT_C void RMdaDevSound::NotifyPlayError(TRequestStatus& aStatus) |
|
225 { |
|
226 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
227 iBody->NotifyPlayError(aStatus); |
|
228 } |
|
229 |
|
230 EXPORT_C void RMdaDevSound::CancelNotifyPlayError() |
|
231 { |
|
232 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
233 iBody->CancelNotifyPlayError(); |
|
234 } |
|
235 |
|
236 EXPORT_C void RMdaDevSound::CancelNotifyRecordError() |
|
237 { |
|
238 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
239 iBody->CancelNotifyRecordError(); |
|
240 } |
|
241 |
|
242 EXPORT_C void RMdaDevSound::FlushPlayBuffer() |
|
243 { |
|
244 __ASSERT_DEBUG(iBody != NULL, Panic(EDeviceNotOpened)); |
|
245 iBody->FlushPlayBuffer(); |
|
246 } |