Changeset 19

Show
Ignore:
Timestamp:
08/19/02 22:24:04 (6 years ago)
Author:
rossbencina
Message:

- added note about current callback outTime mechanism not being robust to buffer underflow/overflow conditions
- renamed Pa_GetStreamTimeBase() to Pa_GetStreamTime()
- explicitly documented when the stream clock is running, and that its origin is unspecified

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pa_proposals/trunk/015-ImproveCallbackTimestampInfo.html

    r17 r19  
    1818<P><A href="index.html">Enhancement Proposals Index</A>, 
    1919<A href="http://www.portaudio.com/">PortAudio Home Page</A></P> 
    20 <P>Updated: August 9, 2002 </P> 
     20<P>Updated: August 20, 2002 </P> 
    2121 
    2222<H4>Status</H4> 
     
    2727 
    2828<P> 
    29 The information provided by the outTime callback parameter and Pa_StreamTime() function does 
    30 not provide sufficient information to perform some syncronisation tasks. One example is that of syncronising 
     29The timing information provided by the outTime callback parameter and Pa_StreamTime() function is not sufficient to perform some syncronisation tasks. One example is that of syncronising 
    3130PortAudio generated audio with another timebase, such as syncronisation pulses in a timestamped 
    32 MIDI event stream. 
     31MIDI event stream. Furthermore, the behavior of the outTime callback parameters is not 
     32defined in the presence of buffer underflows and overflows and it is difficult to conceive of a single behavioral definition for outTime which could fulfill all possible requirements. 
    3333</P> 
    3434 
     
    3636 
    3737<P> 
    38 Remove the Pa_StreamTime(), as its functionality can be implemented using the features added by the  
    39 remainder of this proposal. 
    40 </P> 
    41  
    42 <P> 
    43 Add a function to retrieve a stream's time base expressed in seconds.  
    44 It is unspecified what this timebase is relative to. 
     38Redefine Pa_GetStreamTime() (formerly Pa_StreamTime()) to have completely different behavior. The new behavior is to return the current time in seconds according to the clock used to generate buffer timestamps for the associated stream. The clock runs continuously while the stream is open, i.e. between calls to Pa_OpenStream() and Pa_CloseStream(). The clock's origin (the time at which it was zero) is unspecified. 
    4539</P> 
    4640 
    4741<PRE> 
    48 typedef double PaTime; 
     42typedef double PaTime; /* time expressed in seconds */ 
    4943 
    50 PaTime Pa_GetStreamTimeBase( PaStream *stream ); 
     44/* 
     45Return the current time according to the clock used  
     46to generate buffer timestamps for stream. 
     47*/ 
     48PaTime Pa_GetStreamTime( PaStream *stream ); 
    5149</PRE> 
     50 
    5251 
    5352<P> 
     
    5756the time at which the first sample of the output buffer will exit the DAC (outputBufferDACTime),  
    5857and the time at which the callback was initiated (currentTime). These times are all expressed 
    59 in seconds relative to the stream's time base returned by Pa_GetStreamTimeBase(). 
     58in seconds based on the stream-specific clock returned by Pa_GetStreamTime(). 
    6059</P> 
    6160 
     
    7675 
    7776<P> 
    78 The possibility of retaining Pa_StreamTime() for clients which simply need to display the current stream time was discussed. It was suggested that the functionality currently provided by Pa_StreamTime() could be implemented using the new timestamp parameters, and that doing so would be more robust. One reason is because it is difficult to define a single useful behavior of Pa_StreamTime() in the presence of buffer overruns and underruns. 
     77Various alternate names were considered for the function named Pa_GetStreamTime() in this proposal - primarily because GetStreamTime() collides with the old StreamTime() function which had a completely different behavior. However a better name could not be found. 
    7978</P> 
    8079 
    8180<P> 
    82 Originally it was planned to have a global PortAudio timebase returned by a function named Pa_GetTime(). However, different host APIs on the same platform may dictate that their timebases are relative to different time sources (timeGetTime() vs. QueryPerformanceCounter() on windows for example.) Trying to syncronise multiple independent time bases is a problematic task (due to potential clock drift), so it was concluded that a safer approach would be to provide separate time bases for each stream. 
     81The possibility of retaining the original form of Pa_StreamTime() for clients which simply need to display the elapsed stream playback time was discussed. This proposal was rejected as the functionality currently provided by Pa_StreamTime() can be implemented using the new timestamp parameters. Such a solution can potentially be more robust than implementing the functionality in PortAudio because it is difficult to define a single useful behavior of the old Pa_StreamTime() function in the presence of buffer overruns and underruns. 
    8382</P> 
     83 
     84<P> 
     85Originally it was planned to have a global PortAudio timebase returned by a function named Pa_GetTime(). However, different host APIs on the same platform may dictate that their timebases are relative to different time sources (timeGetTime() vs. QueryPerformanceCounter() on windows for example.) Trying to syncronise multiple independent time bases is a problematic task (due to potential clock drift), so it was concluded that a safer approach would be to allow each stream to have its own time base. 
     86</P> 
     87 
     88<P> 
     89Various options for specifying the stream clock's origin and lifetime (times when it is running) have been considered, including only allowing the clock to run between StreamStart() and StreamStop(). The current solution provides clients who whish to use the clock with access to the clock even while the stream is not running - this may be useful for applications that timestamp events using the stream's clock, or display time-based information even when the stream is stopped. 
     90</P> 
     91 
    8492 
    8593<H4>Impact Analysis</H4>