Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Audio play_qeue() documentation

  1. #1
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,245

    Audio play_qeue() documentation

    The documentation https://www.pjrc.com/teensy/gui/?info=AudioPlayQueue for play_qeue is not OK.
    https://github.com/PaulStoffregen/Au..._queue.cpp#L31

    It does not mention available(), and getBuffer() does not return null.

    Then, a short example, probably pesudocode should be given:

    Code:
    if (queue1.available()) {   
      audio_buffer = queue1.getBuffer();
      ..fill buffer here..
      queue1.playBuffer(); 
      ...
    }
    I leave the pullrequest to others with better English skills.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,573
    Looking at this I see:
    getBuffer();
    Returns a pointer to an array of 128 int16. This buffer is within the audio library memory pool, providing the most efficient way to input data to the audio system. The buffer is likely to be populated by previously used data, so the entire 128 words should be written before calling playBuffer(). Only a single buffer should be requested at a time. This function may return NULL if no memory is available.
    Versus the linked code.

    Indeed getBuffer() will not return NULL, it will not return at all until a buffer can be allocated and then returned for use.

    As Frank's code demonstrates a call to the undocumented available() would be advised to prevent getBuffer() from giving an indeterminate wait when not desired.

    Perhaps:
    getBuffer();
    Returns a pointer to an array of 128 int16. This buffer is within the audio library memory pool, providing the most efficient way to input data to the audio system. The buffer is likely to be populated by previously used data, so the entire 128 words should be written before calling playBuffer(). Only a single buffer should be requested at a time. This function will not return until a free memory block is available. Calling available() first will return true if a buffer is allocated or false otherwise
    and add:
    Code:
    available();
    A single 'userblock' is maintained for this object. If one is already allocated this function will return true, if one is not already allocated a single attempt to acquire one will be made and will return true if that succeeds, otherwise false will be returned

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,573
    Frank reviewed the suggested text - just opened this issue: github.com/PaulStoffregen/Audio/issues/264

Posting Permissions

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