29 TInt aMaxNumPackets,MTransferObserver& aObserver,TInt aTransferId) |
33 TInt aMaxNumPackets,MTransferObserver& aObserver,TInt aTransferId) |
30 : CBaseTransfer(aPipe,aInterface,aObserver,aTransferId), |
34 : CBaseTransfer(aPipe,aInterface,aObserver,aTransferId), |
31 iTransferDescriptor(aMaxPacketSize,aMaxNumPackets), |
35 iTransferDescriptor(aMaxPacketSize,aMaxNumPackets), |
32 iMaxPacketSize(aMaxPacketSize) |
36 iMaxPacketSize(aMaxPacketSize) |
33 { |
37 { |
34 RDebug::Printf("aMaxPacketSize = %d, aMaxNumPackets = %d",aMaxPacketSize, aMaxNumPackets); |
38 OstTraceFunctionEntryExt( CISOCHTRANSFER_CISOCHTRANSFER_ENTRY, this ); |
|
39 OstTraceExt2(TRACE_NORMAL, CISOCHTRANSFER_CISOCHTRANSFER, "aMaxPacketSize = %d, aMaxNumPackets = %d",aMaxPacketSize, aMaxNumPackets); |
|
40 OstTraceFunctionExit1( CISOCHTRANSFER_CISOCHTRANSFER_EXIT, this ); |
35 } |
41 } |
36 |
42 |
37 CIsochTransfer::~CIsochTransfer() |
43 CIsochTransfer::~CIsochTransfer() |
38 { |
44 { |
39 LOG_FUNC |
45 OstTraceFunctionEntry1( CISOCHTRANSFER_CISOCHTRANSFER_ENTRY_DUP01, this ); |
40 |
46 |
41 // Cancel the transfer |
47 // Cancel the transfer |
42 |
48 |
43 Cancel(); |
49 Cancel(); |
|
50 OstTraceFunctionExit1( CISOCHTRANSFER_CISOCHTRANSFER_EXIT_DUP01, this ); |
44 } |
51 } |
45 |
52 |
46 TBool CIsochTransfer::DataPolled(TUint aPacketsToBeRead, RBuf8& aDataPolled) |
53 TBool CIsochTransfer::DataPolled(TUint aPacketsToBeRead, RBuf8& aDataPolled) |
47 { |
54 { |
48 LOG_FUNC |
55 OstTraceFunctionEntryExt( CISOCHTRANSFER_DATAPOLLED_ENTRY, this ); |
49 TInt numOfPacketsReturned = 0; |
56 TInt numOfPacketsReturned = 0; |
50 |
57 |
51 TInt firstPacketIndex = 0; |
58 TInt firstPacketIndex = 0; |
52 TInt totalPacketsRead = 0; |
59 TInt totalPacketsRead = 0; |
53 TInt packetsToBeRead = aPacketsToBeRead; |
60 TInt packetsToBeRead = aPacketsToBeRead; |
55 TUint dataPolledBufSize = iMaxPacketSize*aPacketsToBeRead; |
62 TUint dataPolledBufSize = iMaxPacketSize*aPacketsToBeRead; |
56 aDataPolled.CreateL(dataPolledBufSize); |
63 aDataPolled.CreateL(dataPolledBufSize); |
57 |
64 |
58 do { |
65 do { |
59 TPtrC8 ptrRet = iTransferDescriptor.Packets(firstPacketIndex, packetsToBeRead, numOfPacketsReturned); |
66 TPtrC8 ptrRet = iTransferDescriptor.Packets(firstPacketIndex, packetsToBeRead, numOfPacketsReturned); |
60 RDebug::Printf("numOfPacketsReturned = %d", numOfPacketsReturned); |
67 OstTrace1(TRACE_NORMAL, CISOCHTRANSFER_DATAPOLLED, "numOfPacketsReturned = %d", numOfPacketsReturned); |
61 RDebug::Printf("ptrRet.Length() = %d", ptrRet.Length()); |
68 OstTrace1(TRACE_NORMAL, CISOCHTRANSFER_DATAPOLLED_DUP01, "ptrRet.Length() = %d", ptrRet.Length()); |
62 firstPacketIndex = numOfPacketsReturned; |
69 firstPacketIndex = numOfPacketsReturned; |
63 totalPacketsRead += numOfPacketsReturned; |
70 totalPacketsRead += numOfPacketsReturned; |
64 packetsToBeRead = packetsToBeRead - numOfPacketsReturned; |
71 packetsToBeRead = packetsToBeRead - numOfPacketsReturned; |
65 RDebug::Printf("totalPacketsRead = %d", totalPacketsRead); |
72 OstTrace1(TRACE_NORMAL, CISOCHTRANSFER_DATAPOLLED_DUP02, "totalPacketsRead = %d", totalPacketsRead); |
66 RDebug::Printf("packetsToBeRead = %d", packetsToBeRead); |
73 OstTrace1(TRACE_NORMAL, CISOCHTRANSFER_DATAPOLLED_DUP03, "packetsToBeRead = %d", packetsToBeRead); |
67 aDataPolled.Append(ptrRet); |
74 aDataPolled.Append(ptrRet); |
68 } while(totalPacketsRead != aPacketsToBeRead); |
75 } while(totalPacketsRead != aPacketsToBeRead); |
69 |
76 |
|
77 OstTraceFunctionExitExt( CISOCHTRANSFER_DATAPOLLED_EXIT, this, ETrue ); |
70 return ETrue; |
78 return ETrue; |
71 } |
79 } |
72 |
80 |
73 |
81 |
74 TInt CIsochTransfer::TransferInL(TInt aPacketsExpected) |
82 TInt CIsochTransfer::TransferInL(TInt aPacketsExpected) |
75 { |
83 { |
76 LOG_FUNC |
84 OstTraceFunctionEntryExt( CISOCHTRANSFER_TRANSFERINL_ENTRY, this ); |
77 |
85 |
78 // Activate the asynchronous transfer |
86 // Activate the asynchronous transfer |
79 RDebug::Printf("Activating isoch. in transfer"); |
87 OstTrace0(TRACE_NORMAL, CISOCHTRANSFER_TRANSFERINL, "Activating isoch. in transfer"); |
80 |
88 |
81 iTransferDescriptor.Reset(); |
89 iTransferDescriptor.Reset(); |
82 TPacketLengths fullLengths = iTransferDescriptor.Lengths(); |
90 TPacketLengths fullLengths = iTransferDescriptor.Lengths(); |
83 |
91 |
84 for(TInt packet = 0; packet < fullLengths.MaxNumPackets(); packet++) |
92 for(TInt packet = 0; packet < fullLengths.MaxNumPackets(); packet++) |
85 { |
93 { |
86 fullLengths[packet] = iMaxPacketSize; |
94 fullLengths[packet] = iMaxPacketSize; |
87 } |
95 } |
88 |
96 |
89 RDebug::Printf("fullLengths.MaxNumPackets() == %d",fullLengths.MaxNumPackets()); |
97 OstTrace1(TRACE_NORMAL, CISOCHTRANSFER_TRANSFERINL_DUP01, "fullLengths.MaxNumPackets() == %d",fullLengths.MaxNumPackets()); |
90 iTransferDescriptor.ReceivePackets(aPacketsExpected); |
98 iTransferDescriptor.ReceivePackets(aPacketsExpected); |
91 |
99 |
92 Pipe().Transfer(iTransferDescriptor,iStatus); |
100 Pipe().Transfer(iTransferDescriptor,iStatus); |
93 SetActive(); |
101 SetActive(); |
|
102 OstTraceFunctionExitExt( CISOCHTRANSFER_TRANSFERINL_EXIT, this, KErrNone ); |
94 return KErrNone; |
103 return KErrNone; |
95 } |
104 } |
96 |
105 |
97 TInt CIsochTransfer::RegisterTransferDescriptor() |
106 TInt CIsochTransfer::RegisterTransferDescriptor() |
98 { |
107 { |
99 LOG_FUNC |
108 OstTraceFunctionEntry1( CISOCHTRANSFER_REGISTERTRANSFERDESCRIPTOR_ENTRY, this ); |
100 |
109 |
101 // Register the transfer descriptor with the interface |
110 // Register the transfer descriptor with the interface |
102 TInt err(Interface().RegisterTransferDescriptor(iTransferDescriptor)); |
111 TInt err(Interface().RegisterTransferDescriptor(iTransferDescriptor)); |
103 if(err != KErrNone) |
112 if(err != KErrNone) |
104 { |
113 { |
105 RDebug::Printf("<Error %d> Unable to register transfer descriptor",err); |
114 OstTrace1(TRACE_NORMAL, CISOCHTRANSFER_REGISTERTRANSFERDESCRIPTOR, "<Error %d> Unable to register transfer descriptor",err); |
106 } |
115 } |
|
116 OstTraceFunctionExitExt( CISOCHTRANSFER_REGISTERTRANSFERDESCRIPTOR_EXIT, this, err ); |
107 return err; |
117 return err; |
108 } |
118 } |
109 |
119 |
110 TInt CIsochTransfer::PrepareTransfer(const TDesC8& aIsochData) |
120 TInt CIsochTransfer::PrepareTransfer(const TDesC8& aIsochData) |
111 { |
121 { |
112 LOG_FUNC |
122 OstTraceFunctionEntryExt( CISOCHTRANSFER_PREPARETRANSFER_ENTRY, this ); |
113 |
123 |
114 // |
124 // |
115 iTransferDescriptor.Reset(); |
125 iTransferDescriptor.Reset(); |
116 TPacketLengths fullLengths = iTransferDescriptor.Lengths(); |
126 TPacketLengths fullLengths = iTransferDescriptor.Lengths(); |
117 |
127 |
118 RDebug::Printf("fullLengths.MaxNumPackets() == %d",fullLengths.MaxNumPackets()); |
128 OstTrace1(TRACE_NORMAL, CISOCHTRANSFER_PREPARETRANSFER, "fullLengths.MaxNumPackets() == %d",fullLengths.MaxNumPackets()); |
119 |
129 |
120 // |
130 // |
121 TInt bytesRemaining(aIsochData.Size()); |
131 TInt bytesRemaining(aIsochData.Size()); |
122 TInt maxAvailablePacketSlots; |
132 TInt maxAvailablePacketSlots; |
123 TInt startOffset(0); |
133 TInt startOffset(0); |
124 TInt startPacket(0); |
134 TInt startPacket(0); |
125 |
135 |
126 RDebug::Printf("Audio data is %d bytes",bytesRemaining); |
136 OstTrace1(TRACE_NORMAL, CISOCHTRANSFER_PREPARETRANSFER_DUP01, "Audio data is %d bytes",bytesRemaining); |
127 |
137 |
128 // Keep saving the isoch data to transfer in each packet buffer supplied |
138 // Keep saving the isoch data to transfer in each packet buffer supplied |
129 // by the transfer descriptor |
139 // by the transfer descriptor |
130 |
140 |
131 while(bytesRemaining) |
141 while(bytesRemaining) |
155 iTransferDescriptor.SaveMultiple(maxPacket); |
165 iTransferDescriptor.SaveMultiple(maxPacket); |
156 bytesRemaining -= maxPacket * iMaxPacketSize; |
166 bytesRemaining -= maxPacket * iMaxPacketSize; |
157 startOffset += maxPacket * iMaxPacketSize; |
167 startOffset += maxPacket * iMaxPacketSize; |
158 startPacket += maxPacket; |
168 startPacket += maxPacket; |
159 } |
169 } |
|
170 OstTraceFunctionExitExt( CISOCHTRANSFER_PREPARETRANSFER_EXIT, this, KErrNone ); |
160 return KErrNone; |
171 return KErrNone; |
161 } |
172 } |
162 |
173 |
163 TInt CIsochTransfer::TransferOut() |
174 TInt CIsochTransfer::TransferOut() |
164 { |
175 { |
|
176 OstTraceFunctionEntry1( CISOCHTRANSFER_TRANSFEROUT_ENTRY, this ); |
165 // Transfer the iscohronous data |
177 // Transfer the iscohronous data |
166 RDebug::Printf("Activating isochronous out transfer"); |
178 OstTrace0(TRACE_NORMAL, CISOCHTRANSFER_TRANSFEROUT, "Activating isochronous out transfer"); |
167 Pipe().Transfer(iTransferDescriptor,iStatus); |
179 Pipe().Transfer(iTransferDescriptor,iStatus); |
168 SetActive(); |
180 SetActive(); |
|
181 OstTraceFunctionExitExt( CISOCHTRANSFER_TRANSFEROUT_EXIT, this, KErrNone ); |
169 return KErrNone; |
182 return KErrNone; |
170 } |
183 } |
171 |
184 |
172 |
185 |
173 } |
186 } |