|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Mic stream to DevSound. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cspmicrophone.h" |
|
20 #include "csplogger.h" |
|
21 #include "mcspdevsoundobserver.h" |
|
22 |
|
23 #include <AudioPreference.h> |
|
24 |
|
25 // Mute value |
|
26 const TInt KSetMuteToDevSound = 0; |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // Static constructor. |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CSPMicrophone* CSPMicrophone::NewL( |
|
35 MCSPDevSoundObserver& aObserver ) |
|
36 { |
|
37 CSPMicrophone* self = new( ELeave ) CSPMicrophone( aObserver ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Destructor |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CSPMicrophone::~CSPMicrophone() |
|
49 { |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // Gives mic mute state |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 TBool CSPMicrophone::IsMuted() |
|
57 { |
|
58 const TInt gain( iDevSound->Gain() ); |
|
59 TBool isMuted = EFalse; |
|
60 if ( !gain ) |
|
61 { |
|
62 // Mute is on |
|
63 isMuted = ETrue; |
|
64 } |
|
65 CSPLOGSTRING( CSPINT, "CSPMicrophone::IsMuted" ); |
|
66 return isMuted; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // Set mic muted. |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 void CSPMicrophone::SetMuted() |
|
74 { |
|
75 CSPLOGSTRING( CSPINT, "CSPMicrophone::SetMicMuted" ); |
|
76 iDevSound->SetGain( KSetMuteToDevSound ); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // Set mic unmuted |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CSPMicrophone::SetUnmuted() |
|
84 { |
|
85 CSPLOGSTRING( CSPINT, "CSPMicrophone::SetUnmuted" ); |
|
86 iDevSound->SetGain( iDevSound->MaxGain() ); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // From class MDevSoundObserver |
|
91 // Activation was successfull. |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CSPMicrophone::BufferToBeEmptied( CMMFBuffer* /*aBuffer*/ ) |
|
95 { |
|
96 CSPLOGSTRING( CSPINT, "CSPMicrophone::BufferToBeEmptied" ); |
|
97 |
|
98 // We dont react to devsound messages unless we are activating. |
|
99 if( IsActivationOngoing() ) |
|
100 { |
|
101 iActive = ETrue; |
|
102 iActivationOngoing = EFalse; |
|
103 iObserver.MicActivatedSuccessfully(); |
|
104 } |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // From class MDevSoundObserver |
|
109 // Activation feiled |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void CSPMicrophone::RecordError( TInt aError ) |
|
113 { |
|
114 CSPLOGSTRING( CSPINT, "CSPMicrophone::RecordError" ); |
|
115 |
|
116 // We dont react to devsound messages unless we are activating. |
|
117 if( IsActivationOngoing() ) |
|
118 { |
|
119 if( aError == KErrAccessDenied ) |
|
120 { |
|
121 iActivationOngoing = EFalse; |
|
122 iObserver.MicActivationFailed(); |
|
123 } |
|
124 } |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // From class CSPDevSound |
|
129 // Tries to activate mic stream. Stream becomes active when BufferToBeFilled |
|
130 // gets called. |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CSPMicrophone::DoActivateL() |
|
134 { |
|
135 iDevSound->RecordInitL(); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // Constructor |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 CSPMicrophone::CSPMicrophone( |
|
143 MCSPDevSoundObserver& aObserver ) : |
|
144 CSPDevSound( aObserver ) |
|
145 { |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // Second phase constructor |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 void CSPMicrophone::ConstructL() |
|
153 { |
|
154 CSPDevSound::ConstructL( |
|
155 EMMFStateRecording, |
|
156 KAudioPrefCSCallUplink, |
|
157 KAudioPriorityCSCallUplink ); |
|
158 } |
|
159 |
|
160 // End of File |