×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Nov 2003
    Posts
    145

    RunL() method is not being called

    hi all,

    I've written a progarmme that converts a jpeg image to bitmap. Program flow is like this

    //************************************************************/
    LoadFromDevice()-->StartDecode()-->Converter()->SetActive()-->RunL()->NotifyCompletition()
    //************************************************************/

    HandleCommandL()
    {
    //call LoadFromDevice()
    }


    void LoadFromDevice()
    {
    TInt count = <number of images>;

    for (TInt i =0; i< count; i++)
    {
    //1. GET A Jpeg
    //2. PASS THIS TO CONVERTER METHOD
    //
    StartDecode(aJpeg)

    }

    /**
    * working If I dont put in loop but it gets closed
    * if I put it in loop and RunL() method is not being
    * called
    */

    }

    StartDecode(aJpeg)
    {
    // Conevert(aJepg);
    SetActive();
    }

    RunL()
    {
    if (iStatus == KErrNone)
    {
    NotifyCompletion(KErrNone)
    }
    }

    void NotifyCompletion()
    {
    //do
    }


    this program is working fine if I am not putting it in loop (means calling once) but it application gets closed if I put "StartDecode()" method in loop.


    regards
    dotcdotc

  2. #2
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: RunL() method is not being called

    Originally posted by dotcdotc
    hi all,

    I've written a progarmme that converts a jpeg image to bitmap. Program flow is like this

    //************************************************************/
    LoadFromDevice()-->StartDecode()-->Converter()->SetActive()-->RunL()->NotifyCompletition()
    //************************************************************/

    HandleCommandL()
    {
    //call LoadFromDevice()
    }


    void LoadFromDevice()
    {
    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().

    StartDecode(aJpeg)

    }

    /**
    * working If I dont put in loop but it gets closed
    * if I put it in loop and RunL() method is not being
    * called
    */

    }

    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.
    StartDecode(aJpeg)
    {
    if(!IsActive())
    {
    Conevert(aJepg);
    SetActive();
    }
    }


    StartDecode(aJpeg)
    {
    // Conevert(aJepg);
    SetActive();
    }

    RunL()
    {
    if (iStatus == KErrNone)
    {
    NotifyCompletion(KErrNone)
    }
    }

    void NotifyCompletion()
    {
    //do
    }


    this program is working fine if I am not putting it in loop (means calling once) but it application gets closed if I put "StartDecode()" method in loop.


    regards
    dotcdotc

  3. #3
    Regular Contributor
    Join Date
    Nov 2003
    Posts
    145
    thankyou Itomuta.

    you are right, actually programme is busy in converting the image after first call.

    I have appended following line(as u described in ur post) in StartDecode(aJpeg) Method

    void StartDecode(aJpeg)
    {
    if(!IsActive())
    {
    Convert(aJpeg);
    }
    SetActive();

    //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
    //conversion

    }


    regards
    dotcdotc

  4. #4
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359
    StartDecode(aJpeg)
    {
    if(!IsActive())
    {
    Conevert(aJepg);
    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.

  5. #5
    Regular Contributor
    Join Date
    Nov 2003
    Posts
    145
    hi Itomuta,

    Thanks for your support. Its getting quite interested now !!

    I've got some clue. follwing text has been extracted from my log file. I Have embeded my own comments for understanding



    //////////////////////Log file contents Starts/////////////////////////////////////////////////////

    08/12/2004 6:50:49 count: 6
    08/12/2004 6:50:49 for loop start

    //entering in loop first time

    08/12/2004 6:50:49 loop 1
    08/12/2004 6:50:49 loop 2
    08/12/2004 6:50:49 loop 3
    08/12/2004 6:50:49 C:\Nokia\Images\1.jpg //this is file name to be converted


    //follwing output is from StartDecode() method

    08/12/2004 6:50:49 ------Start2Dcode start------------------
    08/12/2004 6:50:49 StartDcode: 1
    08/12/2004 6:50:49 StartDcode: 2
    08/12/2004 6:50:49 StartDcode: 3
    08/12/2004 6:50:49 StartDcode: 4
    08/12/2004 6:50:49 StartDcode: 5
    08/12/2004 6:50:49 ------Start2Dcode ends------------------


    //entering in loop second time

    08/12/2004 6:50:49 loop 1
    08/12/2004 6:50:49 loop 2
    08/12/2004 6:50:49 loop 3


    //entering in loop second time

    08/12/2004 6:50:49 C:\Nokia\Images\2.jpg
    08/12/2004 6:50:49 loop 1
    08/12/2004 6:50:49 loop 2
    08/12/2004 6:50:49 loop 3

    //entering in loop third time
    08/12/2004 6:50:49 C:\Nokia\Images\3.jpg
    08/12/2004 6:50:49 loop 1
    08/12/2004 6:50:49 loop 2
    08/12/2004 6:50:49 loop 3

    //entering in loop fourth time
    08/12/2004 6:50:49 C:\Nokia\Images\4.jpg
    08/12/2004 6:50:49 loop 1
    08/12/2004 6:50:49 loop 2
    08/12/2004 6:50:49 loop 3

    //entering in loop fifth time
    08/12/2004 6:50:49 C:\Nokia\Images\5.jpg
    08/12/2004 6:50:49 loop 1
    08/12/2004 6:50:49 loop 2
    08/12/2004 6:50:49 loop 3

    //entering in loop sixth time
    08/12/2004 6:50:49 C:\Nokia\Images\6.jpg


    08/12/2004 6:50:49 --------for loop ends-------



    //Now its calling RunL() after execution of enitre loop

    08/12/2004 6:50:49 -----------RunL----------
    08/12/2004 6:50:49 RunL: 0
    08/12/2004 6:50:49 RunL: 1

    //NotifyComletition is being called
    08/12/2004 6:50:49 NotifyCompletion

    ///////////////////////////Log file contents Ends//////////////////////////////////////////////////////////



    it shows that only first image has been converted.

    So now how can I force it to convert all images ?

    regards
    dotcdotc

  6. #6
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359
    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()

    E.g.

    HandleCommand()
    {

    iCount = 0;
    StartDecode(jpg[iCount++]); // start decoding the first jpg
    break;

    }


    NotifyCompletion()
    {
    ….
    If(iCount<iJpgToDecode)
    StartDecode(jpg[iCount++]); //start decoding the next jpg
    else
    //decoding sequence finished
    }

  7. #7
    Regular Contributor
    Join Date
    Nov 2003
    Posts
    145
    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

    TInt iImageIndex;,

    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?

    regards
    dotcdotc

  8. #8
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359
    See this document about AO and Active Scheduler:

    http://nds1.forum.nokia.com/nnds/For...F0b%5Fen%2Ezip

    "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."

  9. #9
    Regular Contributor
    Join Date
    Nov 2003
    Posts
    145
    hi Itomuta,

    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.

    regards
    dotcdotc

  10. #10
    Regular Contributor
    Join Date
    Nov 2003
    Posts
    145
    I have got the solution !!

    Actually I was scaling the image to vary large size.


    thankyou very much
    dotcdotc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×