Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Registered User andrea993's Avatar
    Join Date
    Apr 2011
    Posts
    108
    I've a problem with CMdaAudioOutputStream.
    My stream is never completely played.

    This is my MaoscBufferCopied function:
    Code:
    void RawPlayer::MaoscBufferCopied(TInt aError, const TDesC8& aBuffer)
    	{
            if ((aError==KErrNone || aError==KErrAbort)  && iStream)
    			State=STATE_WRITED;
    		else
            {
    			State=STATE_ERROR;
            }
    
    
               int by=iStream->GetBytes();
    
    
               iStream->Stop();
    	}
    I inserted this line to verify the problem: int "by=iStream->GetBytes();"

    The value of "by" is ever a bit less than the length of aBuffer.
    Why?

  2. #2
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    1) "Copied" is not "Played", when the API gives the buffer back to you it is still playing the data, just from a private copy of it
    2) do you actually hear some problem?
    3) if you have some 'framed' audio format (AMR, MP3), that also matters, fragment data can not be played until its ending part becomes available

  3. #3
    Registered User andrea993's Avatar
    Join Date
    Apr 2011
    Posts
    108
    Yes I can hear some problem, it seems to occur when I play a stream and then I play another stream more short.

    The data is raw format (unformatted)

  4. #4
    Registered User andrea993's Avatar
    Join Date
    Apr 2011
    Posts
    108
    I've understand the problem but I don't know how can I solve it.

    I call "iStream->Stop();" in "MaoscBufferCopied" and it don't finish to play the buffer.
    On Nokia N8 I don't need to call "Stop()" function but in the S60v5 series if I don't call "Stop()" the callback "MaoscPlayComplete" is never called!

    How can I solve the problem?
    Last edited by andrea993; 2012-01-24 at 09:18.

  5. #5
    Nokia Developer Champion pavarang's Avatar
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    576
    Hello,
    into "Symbian OS C++ for Mobile Phones Volume 3" I found:

    To stop streaming, you have two options. Either you can just stop
    writing buffers back to the stream when they are returned to you ­ in this
    case, you get a callback to MaoscPlayComplete() with an error of
    KErrUnderflow when all the data you have provided has been played
    completely. This method ensures that all the data is played fully.
    If you want to stop the streaming immediately, you should call Stop()
    on the audio stream.
    iStream->Stop();
    In this case, you should expect the following callbacks:
    · MaoscBufferCopied() with an error of KErrAbort for each
    buffer that you have written to the stream but which has not yet been
    returned
    · MaoscPlayComplete() with an error of KErrCancel.
    These callbacks happen synchronously from within the call to Stop().
    By the time this call returns, you can be sure that streaming has terminated.
    otherwise I don't have any other suggestions....

    regards
    pg

  6. #6
    Registered User andrea993's Avatar
    Join Date
    Apr 2011
    Posts
    108
    "you can just stop writing buffers back to the stream when they are returned to you ­ in this
    case, you get a callback to MaoscPlayComplete() with an error of
    KErrUnderflow when all the data you have provided has been played
    completely. This method ensures that all the data is played fully."
    is interesting, but I don't understand when and what is returned to me ("when they are returned to you").

  7. #7
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    It probably refers to the buffers, in MaoscBufferCopied.

  8. #8
    Registered User andrea993's Avatar
    Join Date
    Apr 2011
    Posts
    108
    And when is returned to me?

    EDIT I've read this document, but the "stop" function is called immediately in MaoscBufferCopied

    EDIT2:
    I've insert these lines at the end of MaoscBufferCopied:
    Code:
             int bynow,byafter;
    
             do
             {
                bynow=iStream->GetBytes();
                User::After(100);
                byafter=iStream->GetBytes();
             }
             while(bynow<byafter);
    
             iStream->Stop();
    And it work correctly

    EDIT3 It doesn't work correctly ever
    Last edited by andrea993; 2012-01-24 at 15:46.

  9. #9
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    Quote Originally Posted by andrea993 View Post
    And when is returned to me?
    The story about CMdaAudioOutputStream is that WriteL builds a list of the passed descriptors, but generally it does not make a copy of them. However after a while the buffers get played, and they can be re-used or just deleted, etc. This is why you get "const TDesC8 &aBuffer" in MaoscBufferCopied, that is the buffer which is no longer needed by the stream. Because of this way of operation it is a good idea to have at least 2 buffers, while one is playing, the other can be used for generating/loading audio data.
    EDIT2:
    I've insert these lines at the end of MaoscBufferCopied:
    Code:
             int bynow,byafter;
    
             do
             {
                bynow=iStream->GetBytes();
                User::After(100);
                byafter=iStream->GetBytes();
             }
             while(bynow<byafter);
    
             iStream->Stop();
    And it work correctly

    EDIT3 It doesn't work correctly ever
    I do not understand the purpose of that Stop. Unfortunately I have missed it in the first post already, otherwise I would not have understood it there already.

  10. #10
    Registered User andrea993's Avatar
    Join Date
    Apr 2011
    Posts
    108
    I do not understand the purpose of that Stop.
    In the s60v5 series if I don't call Stop the callback maoscplaycompleted is not called at the end of the stream

  11. #11
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    Ok, but does it really matter? Do you have some explicit need for that callback?

  12. #12
    Registered User andrea993's Avatar
    Join Date
    Apr 2011
    Posts
    108
    Yes, I need to know when the stream is completely played

  13. #13
    Nokia Developer Champion pavarang's Avatar
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    576
    Quote Originally Posted by andrea993 View Post
    Yes, I need to know when the stream is completely played
    But are you reading content from a file? Because in that case you know when you have entirely read the file.... ?
    regards
    pg

  14. #14
    Registered User andrea993's Avatar
    Join Date
    Apr 2011
    Posts
    108
    Quote Originally Posted by pavarang View Post
    But are you reading content from a file? Because in that case you know when you have entirely read the file.... ?
    regards
    pg
    No, I read the stream from an HBufC
    regards
    A993

  15. #15
    Nokia Developer Champion pavarang's Avatar
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    576
    Quote Originally Posted by andrea993 View Post
    No, I read the stream from an HBufC
    regards
    A993
    well... you know when you reach the end of HBufC... ?

Page 1 of 2 12 LastLast

Similar Threads

  1. [CMdaAudioOutputStream] SetVolume problem
    By Katatunix in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2011-12-20, 11:24
  2. Replies: 2
    Last Post: 2011-01-17, 10:11
  3. Problem while using CMdaAudioOutputStream.
    By cosock in forum Symbian Media (Closed)
    Replies: 6
    Last Post: 2011-01-11, 09:52
  4. Replies: 1
    Last Post: 2008-08-01, 08:35
  5. CMdaAudioOutputStream problem
    By lab1348 in forum Symbian C++
    Replies: 8
    Last Post: 2004-07-06, 11:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved