×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    creating thread problem

    Hi, IS their any problem with the following code, bcz it is throwing an error e32user cbase66. I m calling playing_audio in the thread function. What should i do to remove this panic.Thread is created with out any errors.

    void playing_audio(Ccallback &callback)
    {
    CTrapCleanup* cleanup = CTrapCleanup::New();
    iWavePlayer=CMdaAudioPlayerUtility::NewFilePlayerL(_L("c:\\private\\E6125402\\ringin.wav"),callback);
    delete cleanup;

    }

    TInt* thread_func()
    {
    playing_audio(callback);
    return(0);
    }
    Last edited by Saritha Reddy; 2008-05-19 at 12:07.

  2. #2
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Cool Re: creating thread problem

    Hi,

    You need to wrap your leaving function in a TRAP.

    You need to have atleast one top level Trap handler when calling a leaving function.

    You can check this information
    http://www.newlc.com/Exception-Handl...d-Cleanup.html

    --MVP
    "Dare To Dream" -- A.P.J.Kalam

  3. #3
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: creating thread problem

    Hi,i changed my code,Plz go through this. It works fine with out any exception but the audio is not playing. If i call playing audio function directly from global function, the audio can be heard.

    CMdaAudioPlayerUtility *iWavePlayer;

    class Ccallback :public MMdaAudioPlayerCallback
    {
    public:
    void MapcInitComplete(TInt aError,const TTimeIntervalMicroSeconds &aDuration);
    void MapcPlayComplete(TInt aError);
    };

    Ccallback callback;

    void Ccallback::MapcInitComplete(TInt aError,const TTimeIntervalMicroSeconds &/*aDuration*/)
    {
    if(aError==KErrNone)
    {
    iWavePlayer->SetVolume(iWavePlayer->MaxVolume()/2);
    iWavePlayer->Play();
    }
    }

    void Ccallback::MapcPlayComplete(TInt /*aError*/)
    {
    //playing_audio(callback);
    }

    /**************** Playing audio function **************/

    TInt playing_audioL(Ccallback &callback)
    {
    TBuf<25> msg(_L("error in audio"));
    CleanupStack::PushL(&callback );
    TRAPD(error,iWavePlayer=CMdaAudioPlayerUtility::NewFilePlayerL(_L("c:\\private\\E6125402\\ringin.wav"),callback));
    if(error)
    {
    CEikonEnv::Static()->AlertWin(msg);
    }
    CleanupStack::Pop(&callback);
    return KErrNone;
    }
    /******************** thread function ************************/
    TInt* thread_func()
    {
    TInt retVal;
    CTrapCleanup* cleanup = CTrapCleanup::New();

    if (cleanup == NULL)
    {
    _LIT(KTxtServerPanic,"cleanup error");
    User::Panic(KTxtServerPanic,1);
    }
    // create an active scheduler and server
    CActiveScheduler *pA=new CActiveScheduler;
    __ASSERT_ALWAYS(pA!=NULL,2);

    //Install the active scheduler
    CActiveScheduler::Install(pA);

    // calling playing audio function
    TRAP( retVal, retVal = playing_audioL(callback ) );


    // Let everyone know that we are ready to
    // deal with requests.
    RThread::Rendezvous(KErrNone);

    // And start fielding requests from client(s).
    CActiveScheduler::Start();


    delete pA;
    delete cleanup;

    return(KErrNone);
    }
    /********** creating thread *************************/
    void StartThreadL()
    {
    TInt res=KErrNone;
    RThread thd;

    res = thd.Create (_L("MyThread"),(TInt(*)(TAny*))thread_func ,KDefaultStackSize + 1000,KMinHeapSize + 10,KMinHeapSize + 100, NULL, (TOwnerType)EOwnerProcess);

    if (res==KErrNone)
    {
    thd.Resume();
    }
    // The thread has not been created - clearly there's been a problem.
    else
    {
    thd.Close();
    }
    }

    /******global function calling StartThreadL **********/
    void playing_ringin(int flag)
    {
    if(flag == 1)
    {
    StartThreadL();
    // playing_audio(callback);
    }

    }
    Last edited by Saritha Reddy; 2008-05-20 at 06:35.

  4. #4
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: creating thread problem

    Hi, Plz do reply soon any one there.Do we follow any different method to play a wav file in thread other than this. Plz help me to sort this issue soon.

    BR,
    Saritha

  5. #5
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Smile Re: creating thread problem

    Hi,

    You could have a look at this example
    http://www.newlc.com/Playing-a-WAV-file.html

    or

    http://symbianexample.com/tags/cmdaaudioplayerutility

    And why do you need a seperate thread ?

    You can run it in same main thread of the process.

    Regards
    Regards

    - MVP
    "Dare To Dream" - A.P.J.Kalam

  6. #6
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: creating thread problem

    Hi mrudulpen, Thanks for the reply. I m able to play the audio in the parent thread itself, but as per my project need i m trying out in thread now. If i call that playing audio fuction directly from the global function without calling creating thread function StartThreadL(), the audio plays very well.I m not getting what to do for playing audio in child thread.

    BR,
    Saritha

  7. #7
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: creating thread problem

    Hi, Plz help me in solving this issue. I m struggling from 2 days with this problem. I m not knowing where it is going wrong .


    BR,
    Saritha

  8. #8
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Smile Re: creating thread problem

    Hi,

    What is ccallback defined as in your thread function?

    Also it would be better to make the iWavePlayer as a member variable. This way you can control its construction and destruction.

    Regards
    Regards

    - MVP
    "Dare To Dream" - A.P.J.Kalam

  9. #9
    Regular Contributor
    Join Date
    Sep 2007
    Posts
    247

    Re: creating thread problem

    The one of the major difference between, the default process (considering application) and a new thread is setup of ActiveScheduler. and Whenever you use CActiveScheduler::Start(), there must be one call outstanding, which is absent in your thread code.
    CMdaAudioPlayerUtility seems not to be an Active object class. So have one custom active object in your thread and then try the same code after issuing one outstanding request to newly installed active scheduler.

  10. #10
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: creating thread problem

    Hi jupitar, what is that custom active object. I searched in the net but i couldnt find any related stuff regarding it.Can you Please tell me with some sample code how to create custom active object or else what u r expecting me to add in the source code.


    BR,
    Saritha

  11. #11
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Thumbs up Re: creating thread problem

    Hi,

    You need to create your active object and issue a pending request on it.

    Regards
    Regards

    - MVP
    "Dare To Dream" - A.P.J.Kalam

  12. #12
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: creating thread problem

    Hi mrudulpen, I do know how to do it. can u please provide some sample code to do that.


    BR,
    Saritha

  13. #13
    Regular Contributor
    Join Date
    Sep 2007
    Posts
    247

    Re: creating thread problem

    once the SDK is installed, you can take help of \Examples\Base\IPC\Async\AcceptInput1 example, which simply give you more insight on Active Objects.

Similar Threads

  1. Problem in restarting thread
    By Aaypee in forum Symbian
    Replies: 1
    Last Post: 2007-07-18, 19:09
  2. 6680 Thread hang problem
    By OctoArthur in forum Mobile Java General
    Replies: 1
    Last Post: 2006-08-21, 22:48
  3. thread problem
    By shadow-2005 in forum Symbian
    Replies: 5
    Last Post: 2006-08-01, 04:53
  4. Thread problem
    By pillar in forum Mobile Java General
    Replies: 0
    Last Post: 2006-03-01, 09:53
  5. problem while creating database
    By ManishPatil in forum Symbian
    Replies: 4
    Last Post: 2003-12-26, 15:33

Posting Permissions

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