51
|
1 |
// Copyright (c) 2004-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 |
#ifndef AVRCPUTILS_H
|
|
17 |
#define AVRCPUTILS_H
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
@internalComponent
|
|
22 |
@released
|
|
23 |
*/
|
|
24 |
|
|
25 |
_LIT(KAvrcpPanicName, "AVRCP Panic");
|
|
26 |
|
|
27 |
enum TAvrcpPanic
|
|
28 |
{
|
|
29 |
EAvrcpNoAVCFrame = 0,
|
|
30 |
EAvrcpNotConnected = 1,
|
|
31 |
EAvrcpNoOutstandingSend = 2,
|
|
32 |
EAvrcpHoldExpiryForRelease = 3,
|
|
33 |
EAvrcpReleaseExpiryForRelease = 4,
|
|
34 |
EAvrcpUnknownAvctpTransId = 5,
|
|
35 |
EAvrcpNoResponsesAvailable = 6,
|
|
36 |
EAvrcpResponseToUnknownCommand = 7,
|
|
37 |
EAvrcpBadBTAddr = 8,
|
|
38 |
EAvrcpCommandStillInUse = 9,
|
|
39 |
EAvrcpCommandDataTooLong = 10,
|
|
40 |
EAvrcpFunnyLengthData = 11,
|
|
41 |
EAvrcpTimerNotCancelled = 12,
|
|
42 |
EAvrcpNotVendorDependent = 13,
|
|
43 |
EAvrcpMismatchedConnectDisconnect = 14,
|
|
44 |
EAvrcpDummyCallbackCalled = 15,
|
|
45 |
EAvrcpUnknownButtonAction = 16,
|
|
46 |
EAvrcpPressHasPhantomResponse = 17,
|
|
47 |
EAvrcpReleaseTimerStartedWithoutResponse = 18,
|
|
48 |
EAvrcpReleaseExpiryForOldCommand = 19,
|
|
49 |
EAvrcpSendingMessageFailed = 20,
|
|
50 |
EAvrcpDisconnectRequestWhilePartiallyConstructed = 21,
|
|
51 |
EAvrcpReleaseExpiryForClick = 22,
|
|
52 |
EAvrcpIncomingCommandsNotHandled = 23,
|
|
53 |
EAvrcpCommandStillQueuedForHandling = 24,
|
|
54 |
EAvrcpCommandStillQueuedAsReady = 25,
|
|
55 |
EAvrcpCommandStillQueuedForSending = 26,
|
|
56 |
EAvrcpPressNotPreviousPassthroughCommand = 27,
|
|
57 |
EAvrcpInterfaceUidNotSet = 28,
|
|
58 |
EAvrcpCTypeNotSet = 29,
|
|
59 |
EAvrcpCompanyIDNotSet = 30,
|
|
60 |
EAvrcpNotFullyConstructed = 31,
|
|
61 |
EAvrcpInternalHandlingRequestedOnWrongInterface = 32,
|
|
62 |
EAvrcpVolumeBeyondMaxVolume = 33,
|
|
63 |
EAvrcpInvalidEventId = 34,
|
|
64 |
EAvrcpInvalidPlayerId = 35,
|
|
65 |
EAvrcpConnectConfirmOnBrowseChannel = 36,
|
|
66 |
EAvrcpDisconnectConfirmOnBrowseChannel = 37,
|
|
67 |
EAlreadyWatchingPlayer = 38,
|
|
68 |
ENotWatchingPlayer = 39,
|
|
69 |
EAvctpMessageTypeRequestedForInternalCommand = 40,
|
|
70 |
ELowerInterfaceUsedOnInternalHandler = 41,
|
|
71 |
EFurtherProcessingRequiredForNonSetBrowsedPlayer = 42,
|
|
72 |
ESetBrowsePlayerRequestCorruptedLocally = 43,
|
|
73 |
ESpecificAddressUsedForBrowsingCommand = 44,
|
|
74 |
EUidUpdateRequestWriteFailure = 45,
|
|
75 |
EUnmatchedResponseFromRemCon = 46,
|
|
76 |
EResponseForWrongInterface = 47,
|
|
77 |
EInvalidBtAddrInResponse = 48,
|
|
78 |
EInvalidPlayerId = 49,
|
|
79 |
EMysteryInternalResponse = 50,
|
|
80 |
ECommandAlreadyQueuedForSending = 52,
|
|
81 |
EPassthroughQueueNotEmptyAfterDisconnect = 53,
|
|
82 |
EPreviousPassthroughNonNullReplacing = 54,
|
|
83 |
ETooManyRemotesRegisterForLocalAddressedPlayerUpdates = 55,
|
|
84 |
ETooFewRemotesRegisterForLocalAddressedPlayerUpdates = 56,
|
|
85 |
};
|
|
86 |
|
|
87 |
template <typename XAny>
|
|
88 |
struct TAvrcpPanicCodeTypeChecker
|
|
89 |
{
|
|
90 |
inline static void Check(XAny) { }
|
|
91 |
};
|
|
92 |
|
|
93 |
#define AVRCP_PANIC(CODE) \
|
|
94 |
TAvrcpPanicCodeTypeChecker<TAvrcpPanic>::Check(CODE), \
|
|
95 |
PANIC(KAvrcpPanicName, CODE)
|
|
96 |
|
|
97 |
|
|
98 |
class TBTDevAddr;
|
|
99 |
class TRemConAddress;
|
|
100 |
class AvrcpUtils
|
|
101 |
{
|
|
102 |
public:
|
|
103 |
static void Panic(TAvrcpPanic aPanic); // The macro is probably more useful so this can be removed
|
|
104 |
|
|
105 |
static void SetCommandDataFromInt(RBuf8& aCommandData, TInt aOffset, TInt aLength, TInt aValue);
|
|
106 |
static void ReadCommandDataToInt(const RBuf8& aCommandData, TInt aOffset, TInt aLength, TInt& aValue);
|
|
107 |
|
|
108 |
static TInt RemConToBTAddr(const TRemConAddress& aRemoteAddress, TBTDevAddr& aBTAddr);
|
|
109 |
static void BTToRemConAddr(const TBTDevAddr& aBTAddr, TRemConAddress& aRemConAddress);
|
|
110 |
};
|
|
111 |
|
|
112 |
//
|
|
113 |
// Thread Assertions
|
|
114 |
//
|
|
115 |
|
|
116 |
enum TAvrcpThreadId
|
|
117 |
{
|
|
118 |
EControlThread = 0x00000001,
|
|
119 |
EBulkThread = 0x00000002,
|
|
120 |
};
|
|
121 |
|
|
122 |
#define ASSERT_THREAD(aaa) ASSERT_DEBUG(reinterpret_cast<TUint32>(Dll::Tls()) == aaa)
|
|
123 |
#define WEAK_ASSERT_THREAD(aaa) if(Dll::Tls()) { ASSERT_THREAD(aaa); }
|
|
124 |
#define ASSERT_CONTROL_THREAD ASSERT_THREAD(EControlThread)
|
|
125 |
#define ASSERT_BULK_THREAD ASSERT_THREAD(EBulkThread)
|
|
126 |
#define WEAK_ASSERT_BULK_THREAD WEAK_ASSERT_THREAD(EBulkThread)
|
|
127 |
|
|
128 |
//
|
|
129 |
// Cleanup Stack utils
|
|
130 |
//
|
|
131 |
|
|
132 |
template <class T>
|
|
133 |
class CleanupSignal
|
|
134 |
{
|
|
135 |
public:
|
|
136 |
inline static void PushL(T& aRef) {CleanupStack::PushL(TCleanupItem(&Signal,&aRef));};
|
|
137 |
private:
|
|
138 |
static void Signal(TAny *aPtr) {(static_cast<T*>(aPtr))->Signal();};
|
|
139 |
};
|
|
140 |
|
|
141 |
template <class T>
|
|
142 |
inline void CleanupSignalPushL(T& aRef)
|
|
143 |
{CleanupSignal<T>::PushL(aRef);}
|
|
144 |
|
|
145 |
template <class T>
|
|
146 |
class CleanupDeleteAndNull
|
|
147 |
{
|
|
148 |
public:
|
|
149 |
inline static void PushL(T*& aRef) {CleanupStack::PushL(TCleanupItem(&DeleteAndNull,&aRef));};
|
|
150 |
private:
|
|
151 |
static void DeleteAndNull(TAny *aPtr) {T*& ptr = *static_cast<T**>(aPtr); delete ptr; ptr = NULL;};
|
|
152 |
};
|
|
153 |
|
|
154 |
template <class T>
|
|
155 |
inline void CleanupDeleteAndNullPushL(T*& aRef)
|
|
156 |
{CleanupDeleteAndNull<T>::PushL(aRef);}
|
|
157 |
|
|
158 |
class CSpecificThreadCallBackBody;
|
|
159 |
NONSHARABLE_CLASS(RSpecificThreadCallBack)
|
|
160 |
{
|
|
161 |
public:
|
|
162 |
RSpecificThreadCallBack();
|
|
163 |
|
|
164 |
TInt Create(const TCallBack& aCallBack, TInt aPriority);
|
|
165 |
void Close();
|
|
166 |
|
|
167 |
TInt Start();
|
|
168 |
TInt CallBack();
|
|
169 |
void Cancel();
|
|
170 |
|
|
171 |
private:
|
|
172 |
CSpecificThreadCallBackBody* iBody;
|
|
173 |
};
|
|
174 |
|
|
175 |
/**
|
|
176 |
An extended double queue link class to provide additional features.
|
|
177 |
*/
|
|
178 |
NONSHARABLE_CLASS(TAvrcpDblQueLink) : public TDblQueLink
|
|
179 |
{
|
|
180 |
public:
|
|
181 |
inline TBool IsQueued() const;
|
|
182 |
};
|
|
183 |
|
|
184 |
/**
|
|
185 |
Indicates whether the queue link is attached to a queue.
|
|
186 |
@return True if the link is queued, false otherwise.
|
|
187 |
*/
|
|
188 |
inline TBool TAvrcpDblQueLink::IsQueued() const
|
|
189 |
{
|
|
190 |
return iNext ? ETrue : EFalse;
|
|
191 |
}
|
|
192 |
|
|
193 |
#endif // AVRCPUTILS_H
|