|
1 /* |
|
2 * Copyright (c) 2007-2010 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: Implements the class CSPAudioHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cspaudiohandler.h" |
|
19 #include "tmshandler.h" |
|
20 #include "csplogger.h" |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // CSPAudioHandler::NewL. |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 CSPAudioHandler* CSPAudioHandler::NewL() |
|
27 { |
|
28 CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::NewL()" ); |
|
29 CSPAudioHandler* self = new (ELeave) CSPAudioHandler(); |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(); |
|
32 CleanupStack::Pop(self); |
|
33 return self; |
|
34 } |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Destructs the object by canceling first ongoing monitoring. |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CSPAudioHandler::~CSPAudioHandler() |
|
41 { |
|
42 CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::~CSPAudioHandler()" ); |
|
43 delete iTmsHandler; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CSPAudioHandler::Start |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 void CSPAudioHandler::Start() |
|
51 { |
|
52 iCallCount++; |
|
53 CSPLOGSTRING2(CSPINT, "CSPAudioHandler::Start callcount: %d", iCallCount); |
|
54 |
|
55 if (iTmsHandler && iCallCount == 1) |
|
56 { |
|
57 iTmsHandler->StartStreams(); |
|
58 } |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CSPAudioHandler::Stop |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CSPAudioHandler::Stop() |
|
66 { |
|
67 CSPLOGSTRING2(CSPINT, "CSPAudioHandler::Stop callcount: %d", iCallCount); |
|
68 if (iTmsHandler && iCallCount == 1) |
|
69 { |
|
70 iTmsHandler->StopStreams(); |
|
71 iCallCount--; |
|
72 } |
|
73 else if (iCallCount > 1) |
|
74 { |
|
75 iCallCount--; |
|
76 } |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // Constructs the monitor. |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CSPAudioHandler::CSPAudioHandler() |
|
84 { |
|
85 CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::CSPAudioHandler()"); |
|
86 iCallCount = 0; // Active calls count |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // Second phase construction. |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CSPAudioHandler::ConstructL() |
|
94 { |
|
95 if (!iTmsHandler) |
|
96 { |
|
97 iTmsHandler = TmsHandler::NewL(); |
|
98 } |
|
99 } |
|
100 |
|
101 // End of file |