Changeset 10
- Timestamp:
- 07/30/02 22:01:20 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pa_proposals/trunk/003-ImproveLatencySpecificationInterface.html
r4 r10 18 18 <P><A href="index.html">Enhancement Proposals Index</A>, 19 19 <A href="http://www.portaudio.com/">PortAudio Home Page</A></P> 20 <P>Updated: July 23, 2002 </P>20 <P>Updated: July 30, 2002 </P> 21 21 22 22 <H4>Status</H4> 23 23 24 <P>This proposal is open for discussion.</P> 24 <P> 25 This proposal is sufficiently well defined to be implemented. The current V19 implementation is not up to date (it uses frames instead of seconds for the suggestedInputLatency and suggestedOuputLatency parameters to Pa_OpenStream, and doesn't provide the default latency or latency querying functions.) 26 </P> 25 27 26 28 <H4>Background</H4> … … 42 44 43 45 <P> 44 The numBuffers parameter to Pa_OpenStream() could be removed, and replaced by two new parameters inputLatency and outputLatency, both expressed in frames. These parameters allow clients to fine-tune latency in a portable manner. Where possiblePortAudio implementations should select buffer sizes based on these parameters, otherwise they may choose the closest viable buffer size and latency instead. In such cases the PortAudio implementations should round-up (ie always provide an equal or higher latency than requested.)46 The numBuffers parameter to Pa_OpenStream() will be removed, and replaced by two new parameters suggestedInputLatency and suggestedOutputLatency, both expressed in seconds. These parameters allow clients to fine-tune latency in a portable manner. Where practical PortAudio implementations should select buffer sizes based on these parameters, otherwise they may choose the closest viable buffer size and latency instead. In such cases the PortAudio implementations should round-up (ie always provide an equal or higher latency than requested.) 45 47 </P> 46 48 47 49 <P> 48 The special latency value of 0 indicates that the implementation should use a default latency value, this will produce the same behavior as passing 0 for numBuffers in existing PortAudio implementations. Clients may retrieve recommended safe latency settings using the following two functions:50 The following functions will be supplied to retrieve default input and output latency values. Separate default latency values are provided for interactive applications where low latency is important to useful operation, and for robust applications where additional latency is acceptable if it will result in more stable performance or place a reduced load on the system. 49 51 </P> 50 52 51 53 <PRE> 52 unsigned long Pa_GetRecommendedLowInputLatency( PaDeviceIndex deviceID ); /* For interactive performance. */ 53 unsigned long Pa_GetRecommendedHighInputLatency( PaDeviceIndex deviceID ); /* For playing sound files. */ 54 unsigned long Pa_GetRecommendedLowOutputLatency( PaDeviceIndex deviceID ); /* For interactive performance. */ 55 unsigned long Pa_GetRecommendedHighOutputLatency( PaDeviceIndex deviceID ); /* For playing sound files. */ 54 typedef double PaTime; /* time expressed in seconds */ 55 56 PaTime Pa_GetDefaultLowInputLatency( PaDeviceIndex deviceID ); /* For interactive performance. */ 57 PaTime Pa_GetDefaultHighInputLatency( PaDeviceIndex deviceID ); /* For playing sound files. */ 58 PaTime Pa_GetDefaultLowOutputLatency( PaDeviceIndex deviceID ); /* For interactive performance. */ 59 PaTime Pa_GetDefaultHighOutputLatency( PaDeviceIndex deviceID ); /* For playing sound files. */ 56 60 </PRE> 57 61 58 62 <P> 59 Currently, when numBuffers is greater than 0, Pa_OpenStream will constrain the actual numBuffers so that the latency is within a valid range determined by the host API, or an environment variables such as PA_MIN_LATENCY_MSEC. Propose changing the behavior so that the requested value is honored as much as possible. This will allow the user to override the recommended minimum latency if they know their system can handle it. This might be used, for example on patched Linux kernels 63 Currently, when numBuffers is greater than 0, Pa_OpenStream will constrain the actual numBuffers so that the latency is within a valid range determined by the host API, or an environment variables such as PA_MIN_LATENCY_MSEC. Propose changing the behavior so that the requested value is honored as much as possible. This will allow the user to override the recommended minimum latency if they know their system can handle it. This might be used, for example on patched Linux kernels. 60 64 </P> 61 65 62 66 <P> 63 The following two functions have beenproposed to retrieve the input and output latency of a stream. Both return the latency in seconds.67 The following two functions are proposed to retrieve the input and output latency of a stream. Both return the latency in seconds. 64 68 </P> 65 69 66 70 <PRE> 67 71 /* the following would operate directly on streams */ 68 double Pa_GetStreamInputLatency( PaStream *stream );69 double Pa_GetStreamOutputLatency( PaStream *stream );72 PaTime Pa_GetStreamInputLatency( PaStream *stream ); 73 PaTime Pa_GetStreamOutputLatency( PaStream *stream ); 70 74 </PRE> 71 75 … … 90 94 91 95 <P> 92 This proposal provides both a high level mechanism for portable latency tuning, and suggests method for providing a host-API specific latency tuning interface. The provision of both default latency settings (via 0 valued latency parameters) and query functions for recommended latency settings provide the needed flexibility for simple, andportable applications.96 This proposal provides both a high level mechanism for portable latency tuning, and suggests a method for providing a host-API specific latency tuning interface. Default latency query functions are provided to support simple portable applications. 93 97 </P> 94 98 95 99 <P> 96 It is not clear whether a 0 latency parameter produces the same latency as returned by Pa_GetRecommendedHighLatencySamples() or whether there is a separate default latency value, in which case there should also be a Pa_GetDefaultLatencySamples() function. 97 </P> 98 99 <P> 100 It is unclear whether the Pa_GetStreamInputLatency() and Pa_GetStreamOutputLatency() functions are needed, whether they relate directly to this proposal, and how they will be effected by the <U>Improve Callback Timestamp Information</U> proposal. 101 </P> 102 103 <P> 104 Should we provide a way of notifying the client if the latency parameters have not been accurately honored? 100 Expressing suggestedLatency in frames was considered, but rejected because it makes sense to return the actual latency from Pa_GetStreamInputLatency() in seconds, and being consistent was deemed to be important for clarity and avoiding usage errors. 105 101 </P> 106 102
