55 iOutputFile = &aFile; |
55 iOutputFile = &aFile; |
56 iWritingStarted = EFalse; |
56 iWritingStarted = EFalse; |
57 iOutputBufferSize = KFileWriterBufferSizeSmall; |
57 iOutputBufferSize = KFileWriterBufferSizeSmall; |
58 iMaxOutputBufHardLimit = KFileWriterHardBufLimit; |
58 iMaxOutputBufHardLimit = KFileWriterHardBufLimit; |
59 iMaxOutputBufSoftLimit = KFileWriterSoftBufLimit; |
59 iMaxOutputBufSoftLimit = KFileWriterSoftBufLimit; |
60 iOutputFileSetSizeCooldown = 0; |
|
61 |
60 |
62 iMemReadyForWriting = EFalse; |
61 iMemReadyForWriting = EFalse; |
63 iInputBuf = NULL; |
62 iInputBuf = NULL; |
64 iEmptyBufferQueue.Reset(); |
63 iEmptyBufferQueue.Reset(); |
65 iFullBufferQueue.Reset(); |
64 iFullBufferQueue.Reset(); |
494 { |
493 { |
495 PRINT(_L("CFileWriter::RunL() out, flushing")); |
494 PRINT(_L("CFileWriter::RunL() out, flushing")); |
496 PRINT((_L("e_cfilewriter_runl 0"))); |
495 PRINT((_L("e_cfilewriter_runl 0"))); |
497 return; |
496 return; |
498 } |
497 } |
499 |
498 |
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 ) |
499 if ( iFullBufferQueue.Count() >= iMaxOutputBufHardLimit ) |
519 { |
500 { |
520 while ( iFullBufferQueue.Count() > iMaxOutputBufSoftLimit ) |
501 while ( iFullBufferQueue.Count() > iMaxOutputBufSoftLimit ) |
521 { |
502 { |
522 PRINT((_L("e_cfilewriter_runl_write 1"))); |
503 PRINT((_L("e_cfilewriter_runl_write 1"))); |