bluetooth/btstack/avdtp/avdtpMuxChannel.cpp
branchRCL_3
changeset 22 786b94c6f0a4
parent 0 29b1cd4cb562
--- a/bluetooth/btstack/avdtp/avdtpMuxChannel.cpp	Thu Jul 15 19:55:36 2010 +0300
+++ b/bluetooth/btstack/avdtp/avdtpMuxChannel.cpp	Thu Aug 19 11:01:00 2010 +0300
@@ -295,7 +295,7 @@
 	#pragma message("is there n pools for eg media, or just one?")
 	}
 */	
-TInt CMuxChannel::AttachTransportSession(CUserPlaneTransportSession& aSession, TAvdtpTransportSessionType aType)
+TInt CMuxChannel::AttachTransportSession(CUserPlaneTransportSession& aSession, TAvdtpTransportSessionType aType, TL2CapConfig::TChannelPriority aPriority)
 /**
 Protocol must ensure it has found appropriate muxchannel for
 Recovery packets
@@ -321,7 +321,45 @@
 	
 	__ASSERT_DEBUG(sessionArray, Panic(EAVDTPBadSessionAttachToTransportChannel));
 	
-	return sessionArray->Append(TUserPlaneTransportSessionState(aSession));
+	TInt err = sessionArray->Append(TUserPlaneTransportSessionState(aSession, aPriority));
+	if(err == KErrNone)
+		{
+		UpdateChannelPriority();
+		}
+	return err;
+	}
+
+void CMuxChannel::UpdateChannelPriority()
+	{
+	LOG_FUNC
+	
+	TL2CapConfig::TChannelPriority maxPriority = TL2CapConfig::ELow;
+	
+	MaxChannelPriority(maxPriority, iMediaSessions);
+	MaxChannelPriority(maxPriority, iReportingSessions);
+	MaxChannelPriority(maxPriority, iRecoverySessions);
+	
+	if(iLogicalChannel)
+		{
+		TPckgBuf<TL2CapConfig> configBuf;
+		configBuf().ConfigureChannelPriority(maxPriority);
+		(void)iLogicalChannel->SetOption(KSolBtL2CAP, KL2CAPUpdateChannelConfig, configBuf);
+		}
+	}
+
+
+void CMuxChannel::MaxChannelPriority(TL2CapConfig::TChannelPriority& aMaxPriority, const RArray<TUserPlaneTransportSessionState>& aSessions)
+	{
+	LOG_STATIC_FUNC
+	
+	for(TInt i=0; i < aSessions.Count(); ++i)
+		{
+		TL2CapConfig::TChannelPriority priority = aSessions[i].iChannelPriority;
+		if(aMaxPriority < priority)
+			{
+			aMaxPriority = priority;
+			}
+		}
 	}
 
 /**
@@ -419,6 +457,7 @@
 		}
 	__ASSERT_DEBUG(found==1, Panic(EAVDTPBadSessionDetachFromTransportChannel));
 
+	UpdateChannelPriority();
 	CheckForClose();
 	}