|
1 // Copyright (c) 2006-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 |
|
17 // INCLUDE FILES |
|
18 #include <e32base.h> |
|
19 #include <f32file.h> |
|
20 #include "mp4atom.h" |
|
21 #include "filewriter.h" |
|
22 |
|
23 // MACROS |
|
24 // Debug print macro |
|
25 #ifdef _DEBUG |
|
26 #include <e32svr.h> |
|
27 //#define PRINT(x) RDebug::Print x |
|
28 #define PRINT(x) |
|
29 #else |
|
30 #define PRINT(x) |
|
31 #endif |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CFileWriter::CFileWriter |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CFileWriter::CFileWriter() : CActive( EPriorityHigh ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CFileWriter::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CFileWriter::ConstructL( RFile64& aFile ) |
|
51 { |
|
52 PRINT((_L("CFileWriter::ConstructL() in"))); |
|
53 iFlush = EFalse; |
|
54 iError = KErrNone; |
|
55 iOutputFile = &aFile; |
|
56 iWritingStarted = EFalse; |
|
57 iOutputBufferSize = KFileWriterBufferSizeSmall; |
|
58 iMaxOutputBufHardLimit = KFileWriterHardBufLimit; |
|
59 iMaxOutputBufSoftLimit = KFileWriterSoftBufLimit; |
|
60 iOutputFileSetSizeCooldown = 0; |
|
61 |
|
62 iMemReadyForWriting = EFalse; |
|
63 iInputBuf = NULL; |
|
64 iEmptyBufferQueue.Reset(); |
|
65 iFullBufferQueue.Reset(); |
|
66 |
|
67 AllocateBuffersL(); |
|
68 CActiveScheduler::Add(this); |
|
69 PRINT((_L("CFileWriter::ConstructL() out"))); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CFileWriter::NewL |
|
74 // Two-phased constructor. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CFileWriter* CFileWriter::NewL( RFile64& aFile ) |
|
78 { |
|
79 CFileWriter* self = new(ELeave) CFileWriter; |
|
80 CleanupStack::PushL(self); |
|
81 self->ConstructL( aFile ); |
|
82 CleanupStack::Pop(self); |
|
83 return self; |
|
84 } |
|
85 |
|
86 |
|
87 // Destructor |
|
88 CFileWriter::~CFileWriter() |
|
89 { |
|
90 PRINT((_L("CFileWriter::~CFileWriter() in"))); |
|
91 if ( IsActive() ) |
|
92 { |
|
93 if ( iAsyncWritingOngoing ) |
|
94 { |
|
95 Cancel(); |
|
96 } |
|
97 else |
|
98 { |
|
99 TRequestStatus* status = &iStatus; |
|
100 User::RequestComplete( status, KErrNone ); |
|
101 Cancel(); |
|
102 } |
|
103 } |
|
104 |
|
105 if ( iInputBuf ) |
|
106 { |
|
107 delete iInputBuf; |
|
108 } |
|
109 |
|
110 iEmptyBufferQueue.ResetAndDestroy(); |
|
111 iFullBufferQueue.ResetAndDestroy(); |
|
112 PRINT((_L("CFileWriter::~CFileWriter() out"))); |
|
113 } |
|
114 |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CFileWriter::Write( const TDesC8& aBuf ) |
|
118 // Writes incoming buffer data to internal buffers for writing to disk. |
|
119 // (other items were commented in a header). |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TInt CFileWriter::Write( const TDesC8& aBuf ) |
|
123 { |
|
124 PRINT(_L("CFileWriter::Write() in")); |
|
125 PRINT((_L("e_cfilewriter_write 1"))); |
|
126 |
|
127 iWritingStarted = ETrue; |
|
128 |
|
129 if ( !iMemReadyForWriting ) |
|
130 { |
|
131 return KErrNoMemory; |
|
132 } |
|
133 |
|
134 PRINT((_L("e_cfilewriter_write_adddatatobuffer 1"))); |
|
135 TInt error = AddDataToBuffer( aBuf ); |
|
136 PRINT((_L("e_cfilewriter_write_adddatatobuffer 0"))); |
|
137 |
|
138 if ( error != KErrNone ) |
|
139 { |
|
140 PRINT((_L("CFileWriter::Write() buffer write error: %d"), error)); |
|
141 return error; |
|
142 } |
|
143 |
|
144 PRINT((_L("CFileWriter::Write() Write Buffer, Status: Full:%d Empty:%d "), |
|
145 iFullBufferQueue.Count(), iEmptyBufferQueue.Count() )); |
|
146 |
|
147 if ( iAsyncWritingOngoing ) |
|
148 { |
|
149 if ( iFullBufferQueue.Count() >= iMaxOutputBufHardLimit ) |
|
150 { |
|
151 PRINT((_L("CFileWriter::Write() Waiting async write to complete"))); |
|
152 PRINT((_L("e_cfilewriter_write_wait_async 1"))); |
|
153 User::WaitForRequest( iStatus ); |
|
154 PRINT((_L("e_cfilewriter_write_wait_async 0"))); |
|
155 PRINT((_L("CFileWriter::Write() Async write done"))); |
|
156 TRAP(error, RunL()); |
|
157 if (error != KErrNone) |
|
158 { |
|
159 PRINT((_L("CFileWriter::Write() call runL leave, error: %d"), error)); |
|
160 return error; |
|
161 } |
|
162 } |
|
163 } |
|
164 else |
|
165 { |
|
166 if ( iFullBufferQueue.Count() ) |
|
167 { |
|
168 PRINT(_L("CFileWriter::Write() writing async")); |
|
169 PRINT((_L("e_cfilewriter_write_startwrite 1"))); |
|
170 iOutputFile->Write( *iFullBufferQueue[0], iStatus ); |
|
171 PRINT((_L("e_cfilewriter_write_startwrite 0"))); |
|
172 iAsyncWritingOngoing = ETrue; |
|
173 if ( !IsActive() ) |
|
174 { |
|
175 SetActive(); |
|
176 } |
|
177 } |
|
178 } |
|
179 |
|
180 PRINT(_L("CFileWriter::Write() out")); |
|
181 PRINT((_L("e_cfilewriter_write 0"))); |
|
182 return error; |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CFileWriter::Flush( const TDesC8& aBuf ) |
|
187 // Flush internal buffers to disk. |
|
188 // (other items were commented in a header). |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CFileWriter::Flush( const TDesC8& aBuf ) |
|
192 { |
|
193 PRINT(_L("CFileWriter::Flush() in")); |
|
194 PRINT((_L("e_cfilewriter_flush 1"))); |
|
195 |
|
196 if ( !iMemReadyForWriting ) |
|
197 { |
|
198 return KErrNoMemory; |
|
199 } |
|
200 |
|
201 iWritingStarted = ETrue; |
|
202 |
|
203 PRINT((_L("e_cfilewriter_flush_adddatatobuf 1"))); |
|
204 TInt error = AddDataToBuffer( aBuf ); |
|
205 if ( error != KErrNone ) |
|
206 { |
|
207 return error; |
|
208 } |
|
209 PRINT((_L("e_cfilewriter_flush_adddatatobuf 0"))); |
|
210 |
|
211 PRINT((_L("CFileWriter::Flush() FullCount: %d "), iFullBufferQueue.Count())); |
|
212 iFlush = ETrue; |
|
213 |
|
214 if ( iAsyncWritingOngoing ) |
|
215 { |
|
216 PRINT((_L("CFileWriter::Flush() Waiting async write to complete"))); |
|
217 PRINT((_L("e_cfilewriter_flush_waitasynctostop 1"))); |
|
218 User::WaitForRequest( iStatus ); |
|
219 PRINT((_L("e_cfilewriter_flush_waitasynctostop 0"))); |
|
220 PRINT((_L("CFileWriter::Flush() Async write done, flushing"))); |
|
221 TRAP(error, RunL()); |
|
222 if (error != KErrNone) |
|
223 { |
|
224 PRINT((_L("CFileWriter::Flush() call runL leave, error: %d"), error)); |
|
225 return error; |
|
226 } |
|
227 } |
|
228 |
|
229 while ( iFullBufferQueue.Count() ) |
|
230 { |
|
231 PRINT((_L("e_cfilewriter_flush_writequeue_sync 1"))); |
|
232 error = iOutputFile->Write( *iFullBufferQueue[0] ); |
|
233 PRINT((_L("e_cfilewriter_flush_writequeue_sync 0"))); |
|
234 PRINT((_L("e_cfilewriter_flush_remove_buf 1"))); |
|
235 if ( error == KErrNone ) |
|
236 { |
|
237 iFullBufferQueue[0]->Des().Zero(); |
|
238 if ( iEmptyBufferQueue.Append( iFullBufferQueue[0] ) ) |
|
239 { |
|
240 PRINT(_L("CFileWriter::Flush() Append failed")); |
|
241 delete ( iFullBufferQueue[0] ); |
|
242 } |
|
243 iFullBufferQueue.Remove( 0 ); |
|
244 } |
|
245 else |
|
246 { |
|
247 PRINT((_L("CFileWriter::Flush() fullBufQueue write failed, error: %d"), error)); |
|
248 iFlush = EFalse; |
|
249 return error; |
|
250 } |
|
251 PRINT((_L("e_cfilewriter_flush_remove_buf 0"))); |
|
252 } |
|
253 |
|
254 if ( iInputBuf->Length() ) |
|
255 { |
|
256 PRINT((_L("e_cfilewriter_flush_writeinput_sync 1"))); |
|
257 error = iOutputFile->Write( *iInputBuf ); |
|
258 PRINT((_L("e_cfilewriter_flush_writeinput_sync 0"))); |
|
259 if ( error == KErrNone ) |
|
260 { |
|
261 iInputBuf->Des().Zero(); |
|
262 } |
|
263 else |
|
264 { |
|
265 PRINT((_L("CFileWriter::Flush() inputbuf write failed, error: %d"), error)); |
|
266 iFlush = EFalse; |
|
267 return error; |
|
268 } |
|
269 } |
|
270 |
|
271 iFlush = EFalse; |
|
272 PRINT((_L("CFileWriter::Flush() FullCount: %d <= Should be 0"), iFullBufferQueue.Count())); |
|
273 PRINT(_L("CFileWriter::Flush() out")); |
|
274 PRINT((_L("e_cfilewriter_flush 0"))); |
|
275 return KErrNone; |
|
276 } |
|
277 |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CFileWriter::SetOutputBufferSize( TOutputBufferSize aBufferSize ) |
|
281 // Set output buffer sizes. |
|
282 // (other items were commented in a header). |
|
283 // ----------------------------------------------------------------------------- |
|
284 // |
|
285 TInt CFileWriter::SetOutputBufferSize( TOutputBufferSize aBufferSize, MP4Handle aHandle ) |
|
286 { |
|
287 MP4HandleImp handle = (MP4HandleImp)aHandle; |
|
288 TInt size = 0; |
|
289 |
|
290 if ( iWritingStarted ) |
|
291 { |
|
292 return KErrNotReady; |
|
293 } |
|
294 |
|
295 if ( aBufferSize == EBufferSizeSmall ) |
|
296 { |
|
297 size = KFileWriterBufferSizeSmall; |
|
298 } |
|
299 else if ( aBufferSize == EBufferSizeLarge ) |
|
300 { |
|
301 size = KFileWriterBufferSizeLarge; |
|
302 } |
|
303 else if ( aBufferSize == EBufferSizeCustom ) |
|
304 { |
|
305 size = handle->mediaWriteBufferSize; |
|
306 } |
|
307 else |
|
308 { |
|
309 return KErrArgument; |
|
310 } |
|
311 |
|
312 if ( size == iOutputBufferSize ) |
|
313 { |
|
314 return KErrNone; |
|
315 } |
|
316 else |
|
317 { |
|
318 iOutputBufferSize = size; |
|
319 } |
|
320 |
|
321 iMemReadyForWriting = EFalse; |
|
322 delete iInputBuf; |
|
323 iInputBuf = NULL; |
|
324 iEmptyBufferQueue.ResetAndDestroy(); |
|
325 iFullBufferQueue.ResetAndDestroy(); |
|
326 |
|
327 TRAPD(err, AllocateBuffersL() ); |
|
328 return err; |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CFileWriter::SetOutputBufferCount( MP4Handle aHandle ) |
|
333 // Set output buffer count. |
|
334 // (other items were commented in a header). |
|
335 // ----------------------------------------------------------------------------- |
|
336 // |
|
337 void CFileWriter::SetOutputBufferCount( MP4Handle aHandle ) |
|
338 { |
|
339 MP4HandleImp handle = (MP4HandleImp)aHandle; |
|
340 |
|
341 if ( handle->writeBufferMaxCount >= 6 ) |
|
342 { |
|
343 iMaxOutputBufHardLimit = handle->writeBufferMaxCount; |
|
344 iMaxOutputBufSoftLimit = KFileWriterMinBufferCount + ((iMaxOutputBufHardLimit-KFileWriterMinBufferCount)/2); |
|
345 } |
|
346 } |
|
347 |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CFileWriter::AddDataToBuffer( const TDesC8& aBuf ) |
|
351 // Writes incoming data to internal buffers and buffer queues.. |
|
352 // (other items were commented in a header). |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 TInt CFileWriter::AddDataToBuffer( const TDesC8& aBuf ) |
|
356 { |
|
357 PRINT(_L("CFileWriter::AddDataToBuffer() in")); |
|
358 |
|
359 TInt byteswritten = 0; |
|
360 TInt numbytes = 0; |
|
361 TInt available = 0; // Available bytes in write buffer |
|
362 TInt error = KErrNone; |
|
363 |
|
364 if ( iError != KErrNone ) |
|
365 { |
|
366 PRINT((_L("CFileWriter::AddDataToBuffer() out, RunL iError: %d"), iError)); |
|
367 return iError; |
|
368 } |
|
369 |
|
370 if ( iInputBuf == NULL ) |
|
371 { |
|
372 return KErrNoMemory; |
|
373 } |
|
374 |
|
375 while (byteswritten < aBuf.Length() ) |
|
376 { |
|
377 available = (iInputBuf->Des()).MaxLength() - iInputBuf->Length(); |
|
378 |
|
379 if (available > 0) |
|
380 { |
|
381 numbytes = aBuf.Length() - byteswritten; |
|
382 if (numbytes > available) |
|
383 { |
|
384 numbytes = available; |
|
385 } |
|
386 iInputBuf->Des().Append( aBuf.Mid( byteswritten, numbytes ) ); |
|
387 byteswritten += numbytes; |
|
388 } |
|
389 else // Buffer is full, write it to disk |
|
390 { |
|
391 // input is full, move full inputbuf to full buf queue |
|
392 if ( iFullBufferQueue.Append( iInputBuf ) != KErrNone ) |
|
393 { |
|
394 PRINT(_L("CFileWriter::AddDataToBuffer() Append failed")); |
|
395 delete iInputBuf; |
|
396 iInputBuf = NULL; |
|
397 } |
|
398 if ( iEmptyBufferQueue.Count() == 0 ) |
|
399 { |
|
400 // no empty buffers in queue, allocating new one |
|
401 TRAP(error, iInputBuf = HBufC8::NewL( iOutputBufferSize )); |
|
402 if ( error != KErrNone ) |
|
403 { |
|
404 PRINT((_L("CFileWriter::AddDataToBuffer(), memory alloc failed: %d"), error)); |
|
405 iInputBuf = NULL; |
|
406 iError = error; |
|
407 break; |
|
408 } |
|
409 } |
|
410 else |
|
411 { |
|
412 iInputBuf = iEmptyBufferQueue[ 0 ]; |
|
413 iEmptyBufferQueue.Remove( 0 ); |
|
414 } |
|
415 } |
|
416 } |
|
417 |
|
418 PRINT((_L("CFileWriter::AddDataToBuffer() out, error: %d"), error)); |
|
419 return error; |
|
420 } |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CFileWriter::AllocateBuffersL() |
|
424 // Allocates input and output buffers. |
|
425 // (other items were commented in a header). |
|
426 // ----------------------------------------------------------------------------- |
|
427 // |
|
428 void CFileWriter::AllocateBuffersL() |
|
429 { |
|
430 PRINT((_L("CFileWriter::AllocateBuffersL() in, outbufsize: %d"), iOutputBufferSize)); |
|
431 HBufC8* buf = NULL; |
|
432 TInt err = 0; |
|
433 iMemReadyForWriting = EFalse; |
|
434 |
|
435 iInputBuf = HBufC8::NewL( iOutputBufferSize ); |
|
436 for( TInt i=0; i<KFileWriterMinBufferCount; i++ ) |
|
437 { |
|
438 buf = HBufC8::NewL( iOutputBufferSize ); |
|
439 err = iEmptyBufferQueue.Append( buf ); |
|
440 if ( err ) |
|
441 { |
|
442 delete ( buf ); |
|
443 User::Leave( err ); |
|
444 } |
|
445 } |
|
446 iMemReadyForWriting = ETrue; |
|
447 PRINT((_L("CFileWriter::AllocateBuffersL() out"))); |
|
448 } |
|
449 |
|
450 // ----------------------------------------------------------------------------- |
|
451 // CFileWriter::DoCancel() |
|
452 // From CActive Cancels async request. |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 void CFileWriter::DoCancel() |
|
456 { |
|
457 } |
|
458 |
|
459 // ----------------------------------------------------------------------------- |
|
460 // CFileWriter::RunL() |
|
461 // From CActive Called when async request completes. |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 void CFileWriter::RunL() |
|
465 { |
|
466 PRINT(_L("CFileWriter::RunL() in")); |
|
467 PRINT((_L("e_cfilewriter_runl 1"))); |
|
468 iAsyncWritingOngoing = EFalse; |
|
469 |
|
470 if ( iStatus == KErrNone ) |
|
471 { |
|
472 iOutputFileSize += iFullBufferQueue[0]->Des().Length(); |
|
473 iFullBufferQueue[0]->Des().Zero(); |
|
474 iError = iEmptyBufferQueue.Append( iFullBufferQueue[0] ); |
|
475 if ( iError ) |
|
476 { |
|
477 PRINT((_L("CFileWriter::RunL() Append failed 1 %d"), iError )); |
|
478 delete ( iFullBufferQueue[0] ); |
|
479 iFullBufferQueue.Remove( 0 ); |
|
480 return; |
|
481 } |
|
482 iFullBufferQueue.Remove( 0 ); |
|
483 } |
|
484 else |
|
485 { |
|
486 PRINT((_L("CFileWriter::RunL() Write error in previous async: %d "), iStatus.Int() )); |
|
487 iError = iStatus.Int(); |
|
488 return; |
|
489 } |
|
490 |
|
491 PRINT((_L("CFileWriter::RunL() Buffer written, Status: Full:%d Empty:%d Filesize:%d"), iFullBufferQueue.Count(), iEmptyBufferQueue.Count(), iOutputFileSize )); |
|
492 |
|
493 if ( iFlush ) |
|
494 { |
|
495 PRINT(_L("CFileWriter::RunL() out, flushing")); |
|
496 PRINT((_L("e_cfilewriter_runl 0"))); |
|
497 return; |
|
498 } |
|
499 |
|
500 // SetSize - reserve room for file writes in output file for all full buffers. |
|
501 // This is done for performance reasons. Reserving space beforehand reduce FS overhead per write. |
|
502 // Don't do new setsize until previously increased filesize has been filled. |
|
503 if ( iOutputFileSetSizeCooldown ) |
|
504 { |
|
505 iOutputFileSetSizeCooldown--; |
|
506 PRINT((_L("CFileWriter::RunL() Setsize, buffer was written to reserved space, cooldown: %d"), iOutputFileSetSizeCooldown)); |
|
507 } |
|
508 |
|
509 // if we have cumulated over iMaxOutputBufSoftLimit/2 full output buffers and setsize not in cooldown then set new size. |
|
510 if ( !iOutputFileSetSizeCooldown && (iFullBufferQueue.Count() > iMaxOutputBufSoftLimit/2) ) |
|
511 { |
|
512 PRINT(_L("CFileWriter::RunL() Setsize, start new size set")); |
|
513 iOutputFile->SetSize(iOutputFileSize + (iFullBufferQueue.Count()*iOutputBufferSize) ); |
|
514 iOutputFileSetSizeCooldown = iFullBufferQueue.Count(); |
|
515 PRINT((_L("CFileWriter::RunL() Setsize, New size set to: %d, cooldown set: %d"), iOutputFileSize + (iFullBufferQueue.Count()*iOutputBufferSize), iOutputFileSetSizeCooldown)); |
|
516 } |
|
517 |
|
518 if ( iFullBufferQueue.Count() >= iMaxOutputBufHardLimit ) |
|
519 { |
|
520 while ( iFullBufferQueue.Count() > iMaxOutputBufSoftLimit ) |
|
521 { |
|
522 PRINT((_L("e_cfilewriter_runl_write 1"))); |
|
523 iError = iOutputFile->Write( *iFullBufferQueue[0]); |
|
524 PRINT((_L("e_cfilewriter_runl_write 0"))); |
|
525 if ( iError == KErrNone ) |
|
526 { |
|
527 iOutputFileSize += iFullBufferQueue[0]->Des().Length(); |
|
528 iFullBufferQueue[0]->Des().Zero(); |
|
529 iError = iEmptyBufferQueue.Append( iFullBufferQueue[0] ); |
|
530 if ( iError ) |
|
531 { |
|
532 PRINT((_L("CFileWriter::RunL() Append failed 2 %d"), iError)); |
|
533 delete ( iFullBufferQueue[0] ); |
|
534 iFullBufferQueue.Remove( 0 ); |
|
535 return; |
|
536 } |
|
537 iFullBufferQueue.Remove( 0 ); |
|
538 PRINT((_L("CFileWriter::RunL() Hardlimit : Buffer sync written, Status: Full:%d Empty:%d Filesize:%d"), iFullBufferQueue.Count(), iEmptyBufferQueue.Count(), iOutputFileSize )); |
|
539 } |
|
540 else |
|
541 { |
|
542 PRINT((_L("CFileWriter::RunL() Write error: %d "), iError)); |
|
543 return; |
|
544 } |
|
545 } |
|
546 } |
|
547 |
|
548 if ( iFullBufferQueue.Count() >= iMaxOutputBufSoftLimit ) |
|
549 { |
|
550 PRINT((_L("e_cfilewriter_runl_outfile_write 1"))); |
|
551 iError = iOutputFile->Write( *iFullBufferQueue[0]); |
|
552 PRINT((_L("e_cfilewriter_runl_outfile_write 0"))); |
|
553 if ( iError == KErrNone ) |
|
554 { |
|
555 iOutputFileSize += iFullBufferQueue[0]->Des().Length(); |
|
556 iFullBufferQueue[0]->Des().Zero(); |
|
557 iError = iEmptyBufferQueue.Append( iFullBufferQueue[0] ); |
|
558 if ( iError ) |
|
559 { |
|
560 PRINT((_L("CFileWriter::RunL() Append failed 3 %d"), iError)); |
|
561 delete ( iFullBufferQueue[0] ); |
|
562 iFullBufferQueue.Remove( 0 ); |
|
563 return; |
|
564 } |
|
565 iFullBufferQueue.Remove( 0 ); |
|
566 PRINT((_L("CFileWriter::RunL() Softlimit : Buffer sync written, Status: Full:%d Empty:%d Filesize:%d"), iFullBufferQueue.Count(), iEmptyBufferQueue.Count(), iOutputFileSize )); |
|
567 } |
|
568 else |
|
569 { |
|
570 PRINT((_L("CFileWriter::RunL() Write error: %d "), iError)); |
|
571 return; |
|
572 } |
|
573 } |
|
574 |
|
575 if ( iFullBufferQueue.Count() ) |
|
576 { |
|
577 PRINT((_L("e_cfilewriter_runl_outfile2_write 1"))); |
|
578 iOutputFile->Write( *iFullBufferQueue[0], iStatus ); |
|
579 PRINT((_L("e_cfilewriter_runl_outfile2_write 0"))); |
|
580 iAsyncWritingOngoing = ETrue; |
|
581 if ( !IsActive() ) |
|
582 { |
|
583 SetActive(); |
|
584 } |
|
585 } |
|
586 |
|
587 PRINT((_L("e_cfilewriter_runl 0"))); |
|
588 PRINT((_L("CFileWriter::RunL() out, iError=%d"), iError)); |
|
589 } |
|
590 |
|
591 // End of File |