1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmplugins/lib3gp/impl/src/filewriter.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,610 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +
1.20 +// INCLUDE FILES
1.21 +#include <e32base.h>
1.22 +#include <f32file.h>
1.23 +#include "mp4atom.h"
1.24 +#include "filewriter.h"
1.25 +
1.26 +// MACROS
1.27 +// Debug print macro
1.28 +#ifdef _DEBUG
1.29 +#include <e32svr.h>
1.30 +//#define PRINT(x) RDebug::Print x
1.31 +#define PRINT(x)
1.32 +#else
1.33 +#define PRINT(x)
1.34 +#endif
1.35 +
1.36 +// ============================ MEMBER FUNCTIONS ===============================
1.37 +
1.38 +// -----------------------------------------------------------------------------
1.39 +// CFileWriter::CFileWriter
1.40 +// C++ default constructor can NOT contain any code, that
1.41 +// might leave.
1.42 +// -----------------------------------------------------------------------------
1.43 +//
1.44 +CFileWriter::CFileWriter( TInt aInitSetSize, TInt aOutputBufferSizeSmall, TInt aOutputBufferSizeLarge ):
1.45 + CActive( EPriorityHigh ),
1.46 + iSetSize( aInitSetSize ),
1.47 + iOutputBufferSizeSmall( aOutputBufferSizeSmall ),
1.48 + iOutputBufferSizeLarge( aOutputBufferSizeLarge )
1.49 + {
1.50 + }
1.51 +
1.52 +// -----------------------------------------------------------------------------
1.53 +// CFileWriter::ConstructL
1.54 +// Symbian 2nd phase constructor can leave.
1.55 +// -----------------------------------------------------------------------------
1.56 +//
1.57 +void CFileWriter::ConstructL( RFile64& aFile )
1.58 + {
1.59 + PRINT((_L("CFileWriter::ConstructL() in")));
1.60 + iFlush = EFalse;
1.61 + iError = KErrNone;
1.62 +
1.63 + iOutputFile = &aFile;
1.64 + iWritingStarted = EFalse;
1.65 + iOutputBufferSize = KFileWriterBufferSizeSmall;
1.66 + iMaxOutputBufHardLimit = KFileWriterHardBufLimit;
1.67 + iMaxOutputBufSoftLimit = KFileWriterSoftBufLimit;
1.68 +
1.69 + iMemReadyForWriting = EFalse;
1.70 + iInputBuf = NULL;
1.71 + iEmptyBufferQueue.Reset();
1.72 + iFullBufferQueue.Reset();
1.73 +
1.74 + AllocateBuffersL();
1.75 + CActiveScheduler::Add(this);
1.76 + PRINT((_L("CFileWriter::ConstructL() out")));
1.77 + }
1.78 +
1.79 +// -----------------------------------------------------------------------------
1.80 +// CFileWriter::NewL
1.81 +// Two-phased constructor.
1.82 +// -----------------------------------------------------------------------------
1.83 +//
1.84 +CFileWriter* CFileWriter::NewL( RFile64& aFile, TInt aInitSetSize, TInt aOutputBufferSizeSmall, TInt aOutputBufferSizeLarge )
1.85 + {
1.86 + CFileWriter* self = new(ELeave) CFileWriter( aInitSetSize, aOutputBufferSizeSmall, aOutputBufferSizeLarge );
1.87 + CleanupStack::PushL(self);
1.88 + self->ConstructL( aFile );
1.89 + CleanupStack::Pop(self);
1.90 + return self;
1.91 + }
1.92 +
1.93 +
1.94 +// Destructor
1.95 +CFileWriter::~CFileWriter()
1.96 + {
1.97 + PRINT((_L("CFileWriter::~CFileWriter() in")));
1.98 + if ( IsActive() )
1.99 + {
1.100 + if ( iAsyncWritingOngoing )
1.101 + {
1.102 + Cancel();
1.103 + }
1.104 + else
1.105 + {
1.106 + TRequestStatus* status = &iStatus;
1.107 + User::RequestComplete( status, KErrNone );
1.108 + Cancel();
1.109 + }
1.110 + }
1.111 +
1.112 + if ( iInputBuf )
1.113 + {
1.114 + delete iInputBuf;
1.115 + }
1.116 +
1.117 + iEmptyBufferQueue.ResetAndDestroy();
1.118 + iFullBufferQueue.ResetAndDestroy();
1.119 + PRINT((_L("CFileWriter::~CFileWriter() out")));
1.120 + }
1.121 +
1.122 +// -----------------------------------------------------------------------------
1.123 +// CFileWriter::UpdateOutputFileSize()
1.124 +// Updates output file size and reserves extra space for following writing
1.125 +// if iSetSize is set.
1.126 +// Takes into account if the position in the file was changed.
1.127 +// -----------------------------------------------------------------------------
1.128 +//
1.129 +void CFileWriter::UpdateOutputFileSize()
1.130 + {
1.131 + TInt64 pos = 0;
1.132 + PRINT((_L("e_cfilewriter_write_updateoutputfilesize_seek 1")));
1.133 + iOutputFile->Seek(ESeekCurrent, pos);
1.134 + PRINT((_L("e_cfilewriter_write_updateoutputfilesize_seek 0")));
1.135 +
1.136 + PRINT((_L("CFileWriter::UpdateOutputFileSize() pos: %Ld"), pos));
1.137 + PRINT((_L("CFileWriter::UpdateOutputFileSize() iOutputFileSize: %Ld"), iOutputFileSize));
1.138 + PRINT((_L("CFileWriter::UpdateOutputFileSize() iSetSize: %Ld"), iSetSize));
1.139 +
1.140 + if (pos > iOutputFileSize)
1.141 + {
1.142 + iOutputFileSize = pos;
1.143 + }
1.144 +
1.145 + while (iOutputFileSize >= iSetSize)
1.146 + {
1.147 + iSetSize += static_cast<TInt64>(iOutputBufferSize) * (static_cast<TInt64>(iMaxOutputBufHardLimit) >> 1);
1.148 + PRINT((_L("e_cfilewriter_updateoutputfilesize_setsize 1")));
1.149 + iOutputFile->SetSize( iSetSize );
1.150 + PRINT((_L("e_cfilewriter_updateoutputfilesize_setsize 0")));
1.151 + }
1.152 + }
1.153 +
1.154 +// -----------------------------------------------------------------------------
1.155 +// CFileWriter::Write( const TDesC8& aBuf )
1.156 +// Writes incoming buffer data to internal buffers for writing to disk.
1.157 +// (other items were commented in a header).
1.158 +// -----------------------------------------------------------------------------
1.159 +//
1.160 +TInt CFileWriter::Write( const TDesC8& aBuf )
1.161 + {
1.162 + PRINT(_L("CFileWriter::Write() in"));
1.163 + PRINT((_L("e_cfilewriter_write 1")));
1.164 +
1.165 + iWritingStarted = ETrue;
1.166 +
1.167 + if ( !iMemReadyForWriting )
1.168 + {
1.169 + return KErrNoMemory;
1.170 + }
1.171 +
1.172 + PRINT((_L("e_cfilewriter_write_adddatatobuffer 1")));
1.173 + TInt error = AddDataToBuffer( aBuf );
1.174 + PRINT((_L("e_cfilewriter_write_adddatatobuffer 0")));
1.175 +
1.176 + if ( error != KErrNone )
1.177 + {
1.178 + PRINT((_L("CFileWriter::Write() buffer write error: %d"), error));
1.179 + return error;
1.180 + }
1.181 +
1.182 + PRINT((_L("CFileWriter::Write() Write Buffer, Status: Full:%d Empty:%d "),
1.183 + iFullBufferQueue.Count(), iEmptyBufferQueue.Count() ));
1.184 +
1.185 + if ( iAsyncWritingOngoing )
1.186 + {
1.187 + if ( iFullBufferQueue.Count() >= iMaxOutputBufHardLimit )
1.188 + {
1.189 + PRINT((_L("CFileWriter::Write() Waiting async write to complete")));
1.190 + PRINT((_L("e_cfilewriter_write_wait_async 1")));
1.191 + User::WaitForRequest( iStatus );
1.192 + PRINT((_L("e_cfilewriter_write_wait_async 0")));
1.193 + PRINT((_L("CFileWriter::Write() Async write done")));
1.194 + TRAP(error, RunL());
1.195 + if (error != KErrNone)
1.196 + {
1.197 + PRINT((_L("CFileWriter::Write() call runL leave, error: %d"), error));
1.198 + return error;
1.199 + }
1.200 + }
1.201 + }
1.202 + else
1.203 + {
1.204 + if ( iFullBufferQueue.Count() )
1.205 + {
1.206 + PRINT(_L("CFileWriter::Write() writing async"));
1.207 + PRINT((_L("e_cfilewriter_write_startwrite 1")));
1.208 + iOutputFile->Write( *iFullBufferQueue[0], iStatus );
1.209 + PRINT((_L("e_cfilewriter_write_startwrite 0")));
1.210 + iAsyncWritingOngoing = ETrue;
1.211 + if ( !IsActive() )
1.212 + {
1.213 + SetActive();
1.214 + }
1.215 + }
1.216 + }
1.217 +
1.218 + PRINT(_L("CFileWriter::Write() out"));
1.219 + PRINT((_L("e_cfilewriter_write 0")));
1.220 + return error;
1.221 + }
1.222 +
1.223 +// -----------------------------------------------------------------------------
1.224 +// CFileWriter::Flush( const TDesC8& aBuf )
1.225 +// Flush internal buffers to disk.
1.226 +// (other items were commented in a header).
1.227 +// -----------------------------------------------------------------------------
1.228 +//
1.229 +TInt CFileWriter::Flush( const TDesC8& aBuf )
1.230 + {
1.231 + PRINT(_L("CFileWriter::Flush() in"));
1.232 + PRINT((_L("e_cfilewriter_flush 1")));
1.233 +
1.234 + if ( !iMemReadyForWriting )
1.235 + {
1.236 + return KErrNoMemory;
1.237 + }
1.238 +
1.239 + iWritingStarted = ETrue;
1.240 +
1.241 + PRINT((_L("e_cfilewriter_flush_adddatatobuf 1")));
1.242 + TInt error = AddDataToBuffer( aBuf );
1.243 + if ( error != KErrNone )
1.244 + {
1.245 + return error;
1.246 + }
1.247 + PRINT((_L("e_cfilewriter_flush_adddatatobuf 0")));
1.248 +
1.249 + PRINT((_L("CFileWriter::Flush() FullCount: %d "), iFullBufferQueue.Count()));
1.250 + iFlush = ETrue;
1.251 +
1.252 + if ( iAsyncWritingOngoing )
1.253 + {
1.254 + PRINT((_L("CFileWriter::Flush() Waiting async write to complete")));
1.255 + PRINT((_L("e_cfilewriter_flush_waitasynctostop 1")));
1.256 + User::WaitForRequest( iStatus );
1.257 + PRINT((_L("e_cfilewriter_flush_waitasynctostop 0")));
1.258 + PRINT((_L("CFileWriter::Flush() Async write done, flushing")));
1.259 + TRAP(error, RunL());
1.260 + if (error != KErrNone)
1.261 + {
1.262 + PRINT((_L("CFileWriter::Flush() call runL leave, error: %d"), error));
1.263 + return error;
1.264 + }
1.265 + }
1.266 +
1.267 + while ( iFullBufferQueue.Count() )
1.268 + {
1.269 + PRINT((_L("e_cfilewriter_flush_writequeue_sync 1")));
1.270 + error = iOutputFile->Write( *iFullBufferQueue[0] );
1.271 + PRINT((_L("e_cfilewriter_flush_writequeue_sync 0")));
1.272 + PRINT((_L("e_cfilewriter_flush_remove_buf 1")));
1.273 + if ( error == KErrNone )
1.274 + {
1.275 + UpdateOutputFileSize();
1.276 + iFullBufferQueue[0]->Des().Zero();
1.277 + if ( iEmptyBufferQueue.Append( iFullBufferQueue[0] ) )
1.278 + {
1.279 + PRINT(_L("CFileWriter::Flush() Append failed"));
1.280 + delete ( iFullBufferQueue[0] );
1.281 + }
1.282 + iFullBufferQueue.Remove( 0 );
1.283 + }
1.284 + else
1.285 + {
1.286 + PRINT((_L("CFileWriter::Flush() fullBufQueue write failed, error: %d"), error));
1.287 + iFlush = EFalse;
1.288 + return error;
1.289 + }
1.290 + PRINT((_L("e_cfilewriter_flush_remove_buf 0")));
1.291 + }
1.292 +
1.293 + if ( iInputBuf->Length() )
1.294 + {
1.295 + PRINT((_L("e_cfilewriter_flush_writeinput_sync 1")));
1.296 + error = iOutputFile->Write( *iInputBuf );
1.297 + PRINT((_L("e_cfilewriter_flush_writeinput_sync 0")));
1.298 + if ( error == KErrNone )
1.299 + {
1.300 + UpdateOutputFileSize();
1.301 + iInputBuf->Des().Zero();
1.302 + }
1.303 + else
1.304 + {
1.305 + PRINT((_L("CFileWriter::Flush() inputbuf write failed, error: %d"), error));
1.306 + iFlush = EFalse;
1.307 + return error;
1.308 + }
1.309 + }
1.310 +
1.311 + iFlush = EFalse;
1.312 + PRINT((_L("CFileWriter::Flush() FullCount: %d <= Should be 0"), iFullBufferQueue.Count()));
1.313 + PRINT(_L("CFileWriter::Flush() out"));
1.314 + PRINT((_L("e_cfilewriter_flush 0")));
1.315 + return KErrNone;
1.316 + }
1.317 +
1.318 +
1.319 +// -----------------------------------------------------------------------------
1.320 +// CFileWriter::SetOutputBufferSize( TOutputBufferSize aBufferSize )
1.321 +// Set output buffer sizes.
1.322 +// (other items were commented in a header).
1.323 +// -----------------------------------------------------------------------------
1.324 +//
1.325 +TInt CFileWriter::SetOutputBufferSize( TOutputBufferSize aBufferSize, MP4Handle aHandle )
1.326 + {
1.327 + MP4HandleImp handle = (MP4HandleImp)aHandle;
1.328 + TInt size = 0;
1.329 +
1.330 + if ( iWritingStarted )
1.331 + {
1.332 + return KErrNotReady;
1.333 + }
1.334 +
1.335 + if ( aBufferSize == EBufferSizeSmall )
1.336 + {
1.337 + size = iOutputBufferSizeSmall;
1.338 + }
1.339 + else if ( aBufferSize == EBufferSizeLarge )
1.340 + {
1.341 + size = iOutputBufferSizeLarge;
1.342 + }
1.343 + else if ( aBufferSize == EBufferSizeCustom )
1.344 + {
1.345 + size = handle->mediaWriteBufferSize;
1.346 + }
1.347 + else
1.348 + {
1.349 + return KErrArgument;
1.350 + }
1.351 +
1.352 + if ( size == iOutputBufferSize )
1.353 + {
1.354 + return KErrNone;
1.355 + }
1.356 + else
1.357 + {
1.358 + iOutputBufferSize = size;
1.359 + }
1.360 +
1.361 + iMemReadyForWriting = EFalse;
1.362 + delete iInputBuf;
1.363 + iInputBuf = NULL;
1.364 + iEmptyBufferQueue.ResetAndDestroy();
1.365 + iFullBufferQueue.ResetAndDestroy();
1.366 +
1.367 + TRAPD(err, AllocateBuffersL() );
1.368 + return err;
1.369 + }
1.370 +
1.371 +// -----------------------------------------------------------------------------
1.372 +// CFileWriter::SetOutputBufferCount( MP4Handle aHandle )
1.373 +// Set output buffer count.
1.374 +// (other items were commented in a header).
1.375 +// -----------------------------------------------------------------------------
1.376 +//
1.377 +void CFileWriter::SetOutputBufferCount( MP4Handle aHandle )
1.378 + {
1.379 + MP4HandleImp handle = (MP4HandleImp)aHandle;
1.380 +
1.381 + if ( handle->writeBufferMaxCount >= 6 )
1.382 + {
1.383 + iMaxOutputBufHardLimit = handle->writeBufferMaxCount;
1.384 + iMaxOutputBufSoftLimit = KFileWriterMinBufferCount + ((iMaxOutputBufHardLimit-KFileWriterMinBufferCount)/2);
1.385 + }
1.386 + }
1.387 +
1.388 +
1.389 +// -----------------------------------------------------------------------------
1.390 +// CFileWriter::AddDataToBuffer( const TDesC8& aBuf )
1.391 +// Writes incoming data to internal buffers and buffer queues..
1.392 +// (other items were commented in a header).
1.393 +// -----------------------------------------------------------------------------
1.394 +//
1.395 +TInt CFileWriter::AddDataToBuffer( const TDesC8& aBuf )
1.396 + {
1.397 + PRINT(_L("CFileWriter::AddDataToBuffer() in"));
1.398 +
1.399 + TInt byteswritten = 0;
1.400 + TInt numbytes = 0;
1.401 + TInt available = 0; // Available bytes in write buffer
1.402 + TInt error = KErrNone;
1.403 +
1.404 + if ( iError != KErrNone )
1.405 + {
1.406 + PRINT((_L("CFileWriter::AddDataToBuffer() out, RunL iError: %d"), iError));
1.407 + return iError;
1.408 + }
1.409 +
1.410 + if ( iInputBuf == NULL )
1.411 + {
1.412 + return KErrNoMemory;
1.413 + }
1.414 +
1.415 + while (byteswritten < aBuf.Length() )
1.416 + {
1.417 + available = iOutputBufferSize - iInputBuf->Length();
1.418 +
1.419 + if (available > 0)
1.420 + {
1.421 + numbytes = aBuf.Length() - byteswritten;
1.422 + if (numbytes > available)
1.423 + {
1.424 + numbytes = available;
1.425 + }
1.426 + iInputBuf->Des().Append( aBuf.Mid( byteswritten, numbytes ) );
1.427 + byteswritten += numbytes;
1.428 + }
1.429 + else // Buffer is full, write it to disk
1.430 + {
1.431 + // input is full, move full inputbuf to full buf queue
1.432 + if ( iFullBufferQueue.Append( iInputBuf ) != KErrNone )
1.433 + {
1.434 + PRINT(_L("CFileWriter::AddDataToBuffer() Append failed"));
1.435 + delete iInputBuf;
1.436 + iInputBuf = NULL;
1.437 + }
1.438 + if ( iEmptyBufferQueue.Count() == 0 )
1.439 + {
1.440 + // no empty buffers in queue, allocating new one
1.441 + TRAP(error, iInputBuf = HBufC8::NewL( iOutputBufferSize ));
1.442 + if ( error != KErrNone )
1.443 + {
1.444 + PRINT((_L("CFileWriter::AddDataToBuffer(), memory alloc failed: %d"), error));
1.445 + iInputBuf = NULL;
1.446 + iError = error;
1.447 + break;
1.448 + }
1.449 + }
1.450 + else
1.451 + {
1.452 + iInputBuf = iEmptyBufferQueue[ 0 ];
1.453 + iEmptyBufferQueue.Remove( 0 );
1.454 + }
1.455 + }
1.456 + }
1.457 +
1.458 + PRINT((_L("CFileWriter::AddDataToBuffer() out, error: %d"), error));
1.459 + return error;
1.460 + }
1.461 +
1.462 +// -----------------------------------------------------------------------------
1.463 +// CFileWriter::AllocateBuffersL()
1.464 +// Allocates input and output buffers.
1.465 +// (other items were commented in a header).
1.466 +// -----------------------------------------------------------------------------
1.467 +//
1.468 +void CFileWriter::AllocateBuffersL()
1.469 + {
1.470 + PRINT((_L("CFileWriter::AllocateBuffersL() in, outbufsize: %d"), iOutputBufferSize));
1.471 + HBufC8* buf = NULL;
1.472 + TInt err = 0;
1.473 + iMemReadyForWriting = EFalse;
1.474 +
1.475 + iInputBuf = HBufC8::NewL( iOutputBufferSize );
1.476 + for( TInt i=0; i<KFileWriterMinBufferCount; i++ )
1.477 + {
1.478 + buf = HBufC8::NewL( iOutputBufferSize );
1.479 + err = iEmptyBufferQueue.Append( buf );
1.480 + if ( err )
1.481 + {
1.482 + delete ( buf );
1.483 + User::Leave( err );
1.484 + }
1.485 + }
1.486 + iMemReadyForWriting = ETrue;
1.487 + PRINT((_L("CFileWriter::AllocateBuffersL() out")));
1.488 + }
1.489 +
1.490 +// -----------------------------------------------------------------------------
1.491 +// CFileWriter::DoCancel()
1.492 +// From CActive Cancels async request.
1.493 +// -----------------------------------------------------------------------------
1.494 +//
1.495 +void CFileWriter::DoCancel()
1.496 + {
1.497 + }
1.498 +
1.499 +// -----------------------------------------------------------------------------
1.500 +// CFileWriter::RunL()
1.501 +// From CActive Called when async request completes.
1.502 +// -----------------------------------------------------------------------------
1.503 +//
1.504 +void CFileWriter::RunL()
1.505 + {
1.506 + PRINT(_L("CFileWriter::RunL() in"));
1.507 + PRINT((_L("e_cfilewriter_runl 1")));
1.508 + iAsyncWritingOngoing = EFalse;
1.509 +
1.510 + if ( iStatus == KErrNone )
1.511 + {
1.512 + UpdateOutputFileSize();
1.513 + iFullBufferQueue[0]->Des().Zero();
1.514 + iError = iEmptyBufferQueue.Append( iFullBufferQueue[0] );
1.515 + if ( iError )
1.516 + {
1.517 + PRINT((_L("CFileWriter::RunL() Append failed 1 %d"), iError ));
1.518 + delete ( iFullBufferQueue[0] );
1.519 + iFullBufferQueue.Remove( 0 );
1.520 + return;
1.521 + }
1.522 + iFullBufferQueue.Remove( 0 );
1.523 + }
1.524 + else
1.525 + {
1.526 + PRINT((_L("CFileWriter::RunL() Write error in previous async: %d "), iStatus.Int() ));
1.527 + iError = iStatus.Int();
1.528 + return;
1.529 + }
1.530 +
1.531 + PRINT((_L("CFileWriter::RunL() Buffer written, Status: Full:%d Empty:%d Filesize:%Ld"), iFullBufferQueue.Count(), iEmptyBufferQueue.Count(), iOutputFileSize ));
1.532 +
1.533 + if ( iFlush )
1.534 + {
1.535 + PRINT(_L("CFileWriter::RunL() out, flushing"));
1.536 + PRINT((_L("e_cfilewriter_runl 0")));
1.537 + return;
1.538 + }
1.539 +
1.540 + if ( iFullBufferQueue.Count() >= iMaxOutputBufHardLimit )
1.541 + {
1.542 + while ( iFullBufferQueue.Count() > iMaxOutputBufSoftLimit )
1.543 + {
1.544 + PRINT((_L("e_cfilewriter_runl_write 1")));
1.545 + iError = iOutputFile->Write( *iFullBufferQueue[0]);
1.546 + PRINT((_L("e_cfilewriter_runl_write 0")));
1.547 + if ( iError == KErrNone )
1.548 + {
1.549 + UpdateOutputFileSize();
1.550 + iFullBufferQueue[0]->Des().Zero();
1.551 + iError = iEmptyBufferQueue.Append( iFullBufferQueue[0] );
1.552 + if ( iError )
1.553 + {
1.554 + PRINT((_L("CFileWriter::RunL() Append failed 2 %d"), iError));
1.555 + delete ( iFullBufferQueue[0] );
1.556 + iFullBufferQueue.Remove( 0 );
1.557 + return;
1.558 + }
1.559 + iFullBufferQueue.Remove( 0 );
1.560 + PRINT((_L("CFileWriter::RunL() Hardlimit : Buffer sync written, Status: Full:%d Empty:%d Filesize:%Ld"), iFullBufferQueue.Count(), iEmptyBufferQueue.Count(), iOutputFileSize ));
1.561 + }
1.562 + else
1.563 + {
1.564 + PRINT((_L("CFileWriter::RunL() Write error: %d "), iError));
1.565 + return;
1.566 + }
1.567 + }
1.568 + }
1.569 +
1.570 + if ( iFullBufferQueue.Count() >= iMaxOutputBufSoftLimit )
1.571 + {
1.572 + PRINT((_L("e_cfilewriter_runl_outfile_write 1")));
1.573 + iError = iOutputFile->Write( *iFullBufferQueue[0]);
1.574 + PRINT((_L("e_cfilewriter_runl_outfile_write 0")));
1.575 + if ( iError == KErrNone )
1.576 + {
1.577 + UpdateOutputFileSize();
1.578 + iFullBufferQueue[0]->Des().Zero();
1.579 + iError = iEmptyBufferQueue.Append( iFullBufferQueue[0] );
1.580 + if ( iError )
1.581 + {
1.582 + PRINT((_L("CFileWriter::RunL() Append failed 3 %d"), iError));
1.583 + delete ( iFullBufferQueue[0] );
1.584 + iFullBufferQueue.Remove( 0 );
1.585 + return;
1.586 + }
1.587 + iFullBufferQueue.Remove( 0 );
1.588 + PRINT((_L("CFileWriter::RunL() Softlimit : Buffer sync written, Status: Full:%d Empty:%d Filesize:%Ld"), iFullBufferQueue.Count(), iEmptyBufferQueue.Count(), iOutputFileSize ));
1.589 + }
1.590 + else
1.591 + {
1.592 + PRINT((_L("CFileWriter::RunL() Write error: %d "), iError));
1.593 + return;
1.594 + }
1.595 + }
1.596 +
1.597 + if ( iFullBufferQueue.Count() )
1.598 + {
1.599 + PRINT((_L("e_cfilewriter_runl_outfile2_write 1")));
1.600 + iOutputFile->Write( *iFullBufferQueue[0], iStatus );
1.601 + PRINT((_L("e_cfilewriter_runl_outfile2_write 0")));
1.602 + iAsyncWritingOngoing = ETrue;
1.603 + if ( !IsActive() )
1.604 + {
1.605 + SetActive();
1.606 + }
1.607 + }
1.608 +
1.609 + PRINT((_L("e_cfilewriter_runl 0")));
1.610 + PRINT((_L("CFileWriter::RunL() out, iError=%d"), iError));
1.611 + }
1.612 +
1.613 +// End of File