TInt count = <number of images>;
for (TInt i =0; i< count; i++)
//1. GET A Jpeg
//2. PASS THIS TO CONVERTER METHOD
After the first call your AO is busy converting the image. You must use multiple converters or start another conversion only on NotifyCompletion().
* working If I dont put in loop but it gets closed
* if I put it in loop and RunL() method is not being
I assume that Conevert(aJepg) actually calls a asynchronous method otherwise just calling SetActive() is pointless. Furthermore you should be checking if your AO is not already active.
//now its converting all images in sequence but
//RunL()-->NotifyCompletion() is being called only after
// last conversion which is undesired.
//Because NotifyCompletition should be called after each
SetActive(); //you only need to set it active if you really start a conversion and is not already active
So you use multiple decoders, each processing a different jpg? And only one of them is calling NotifyCompletion() ?
Or is it that you call StartDecode on the same decoder AO multiple times without waiting for each conversion to complete by calling NotifyCompletion() ? This should only convert the first image so it's quite allright to get only one completion notification.
Without knowing where exactly every message is put in the log much of the info there is meaningless for me…
Anyhow the conclusion you reach appears to be the right one: only the first file is being decoded.
Here is how it works:
- you have a loop where you call StartDecode for every jpg file you need to convert.
- the first StartDecode() returns after launching a asynchronous operation; it does not wait for the operation to complete
- Is a sure thing that all the loop cycles coming after the first one will find the decoder active and as such the StartDecode() does nothing but return for the next loop cycle to take place
What you can do:
- for every loop cycle create a new decoder instance and call its StartDecoder() – resource wasting solution
- use only one decoder but only lunch a new StartDecoder() after the previous one finished by calling NotifyCompletion()
iCount = 0;
StartDecode(jpg[iCount++]); // start decoding the first jpg
StartDecode(jpg[iCount++]); //start decoding the next jpg
//decoding sequence finished
ltomuta , thankyou very much for your kind support.
finally I've got done by implementing second solution you suggested in your last post.
I have taken a globle variable
incrementing it in NotifyCompletion while its less than max val(no. of files) and calling StartDecode(aJpeg[iImageIndex]) there.
LoadFromDevice()-->StartDecode(aJpeg[iImageIndex])-->Convert(aJpeg[iImageIndex])-->SetActive()-->RunL()-->NotifyCompletition()-->StartDecode(aJpeg[iImageIndex]) --> (here cycle restarts until it acomplishes final conversion)
but there is still more I need to know about Active Object. I really dont know how will I manage more than one Active Objects (say e.g. 5).
Is there any limit of Active Objects that I can have in an Application?
"This document provides a general introduction to active objects and multitasking in Symbian OS. It is intended for beginners in Symbian OS programming, but because even more experienced developers often make mistakes with active objects, it might be useful for advanced developers as well."
the AO doc u suggested me has been very useful to me(good insight of AO).
but in same program I've been caught in different problem its "Not Enough Memory" or "KErrNoMemory" or value -4.
Actually, Now I am doing two things at a time
1) converting a Jpeg in Bitmap (it is done successfully)
2) then scaling it to a an ICON size (50x50, creating my own icon or smaller bitmap). Method is running succesfully but response code retured is KErrNoMemory/-4 or "Not Enough Memory".
its happening like this...
LoadFromDevice()-->StartDecodeL(aJpeg)-->SetActive()-->RunL()-->NotifyDecodeCompletion(/**being called with KErrNone**/)-->ScaleToIconL(aBitmap /**aBitmap is Converted aJpeg by StartToDecodeL**/)-->SetActive()-->RunL()-->NotifyScaleToIconL(/**being called with KErrNoMemory**/)
and "aJpeg" size is only 4KB and this is the only image I am using in program.