Changeset 16 for pa_proposals/trunk

Show
Ignore:
Timestamp:
07/31/02 14:24:31 (6 years ago)
Author:
rossbencina
Message:

- clarified proposal
- added paFormatIsSupported symbol for successful return value of Pa_IsFormatSupported
- removed requirements for "native sample format" flags

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pa_proposals/trunk/002-ImproveDeviceFormatsQueryInterface.html

    r4 r16  
    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: July 23, 2002 </P> 
     20<P>Updated: August 1, 2002 </P> 
    2121 
    2222<H4>Status</H4> 
     
    2727 
    2828<P> 
    29 It has been noted that the current method (Pa_GetDeviceInfo()) of querying devices for supported sample formats, channels and sample rates is weak. It does not cleanly differentiate between 'PortAudio supported' formats and 'native' formats, and it is incapable of representing formats where the parameters are interdependent (eg where full duplex is only supported for certain sample rates.) We have also found that a static structure is not a good match for many host APIs where format discovery is performed by polling the driver. Even if a sound card supports arbitrary sample rates, the host API may only allow a client to poll to see whether a rate is available rather than providing the available rate ranges. 
     29The current (V18) method of querying devices for supported sample formats, channels, and sample rates (Pa_GetDeviceInfo()) is weak.  
     30It is incapable of representing formats where the parameters are interdependent (eg where full duplex is only supported for certain sample rates.) We have also found that a static structure is not a good match for many host APIs where format discovery is performed by polling the driver, as filling the structure may involve many polling operations. Even if a sound card supports arbitrary sample rates, the host API may only allow a client to poll to see whether a rate is available rather than providing the available rate ranges. 
    3031</P> 
    3132 
    3233<P> 
    33 It has been noted that most (platform specific) audio APIs do a pretty bad job of allowing for device capability querying. Even the better APIs (ALSA is perhaps one) don't necessarily provide accurate information. This proposal should seek to maximise the amount of information that can be extracted from existing APIs while remaining expressive enough to take full advantage of APIs with more advanced capability querying systems should they become available in the future. 
     34It has been noted that most (platform specific) audio APIs have poor device capability querying mechanisms. Even the better APIs (ALSA is perhaps one) don't necessarily provide accurate information. This proposal should seek to maximise the amount of information that can be extracted from existing APIs while remaining expressive enough to take full advantage of APIs with more advanced capability querying systems should they become available in the future. 
    3435</P> 
    3536 
     
    3738 
    3839<P> 
    39 A number of options are being considered with regard to supplying clients with format information:</P> 
     40The PaDeviceInfo structure and Pa_GetDeviceInfo() function will be retained to provide simple  
     41attribute information about the device such as it's name, and for representing information  
     42that can be obtained without querying the host API multiple times, such as input and output channel counts: 
     43</P> 
     44 
     45<PRE> 
     46typedef struct PaDeviceInfo { 
     47    int structVersion;  
     48    const char *name; 
     49    PaHostApiTypeCode hostApi; 
     50 
     51    unsigned int maxInputChannels; 
     52    unsigned int maxOutputChannels;  
     53} PaDeviceInfo; 
     54</PRE> 
     55 
    4056<P> 
    41 Use PaDeviceInfo only for representing information that can be expressed without querying the host API multiple times, or only check for "standard" formats, or leave it unchanged. 
     57The notion of "native sample formats" - those that are directly supported by the underlying 
     58host API - will be removed from the PortAudio specification as PortAudio's conversion 
     59capabilities allow support for all PortAudio sample formats. 
    4260</P> 
    43 <P>And/Or</P> 
    44 <P>Add a Pa_IsFormatSupported() function:</P> 
    45 <PRE>Pa_IsFormatSupported( PaDeviceIndex inputDevice,  
     61 
     62<P> 
     63A new Pa_IsFormatSupported() function will be added, which allows clients to query whether 
     64a particular combination of formats for input and output is valid. It returns 0 if the format 
     65is supported, and a PortAudio error code if the format is not supported. The special symbol 
     66paFormatIsSupported is provided to compare against the return value. 
     67</P> 
     68 
     69<PRE> 
     70#define paFormatIsSupported (0) 
     71 
     72PaError Pa_IsFormatSupported( PaDeviceIndex inputDevice,  
    4673                        int numInputChannels,  
    4774                        PaSampleFormat inputSampleFormat, 
     
    5178                        PaSampleFormat outputSampleFormat,  
    5279                        void *outputDriverInfo,  
    53                         double sampleRate );</PRE> 
    54 <P> 
    55 At a minimum this call would need to return values indicating whether the requested format(s) are supported natively, or will undergo conversion by PortAudio. The result could be a set of flags indicating: 
    56 </P> 
     80                        double sampleRate ); 
     81</PRE> 
    5782 
    58 <UL> 
    59 <LI>Input byte order (native/converted) </LI> 
    60 <LI>Input sample format (native/converted) </LI> 
    61 <LI>Output byte order (native/converted) </LI> 
    62 <LI>Output sample format (native/converted)</LI></UL> 
    6383 
    64 <P> 
    65 There also needs to be a method for accommodating host-API-specific return flags. 
    66 </P> 
    6784 
    6885<H4>Discussion</H4> 
    6986 
    70 <P> 
    71 At present it seems desirable to retain Pa_GetDeviceInfo() and the PaDeviceInfo structure. At a minimum PaDeviceInfo needs to contain name and host API type code fields: 
     87<P> This proposal provides a mechanism for querying PortAudio for supported 
     88formats without requiring implementations to construct device information structures 
     89by polling the host api multiple times. 
    7290</P> 
    7391 
    74 <PRE> 
    75 typedef struct{ 
    76     int structVersion;  
    77     const char *name; 
    78     PaHostApiTypeCode hostApi; 
    79 } PaDeviceInfo; 
    80 </PRE> 
    81  
    82 <P> It has been suggested that it may be desirable to retain maxInputChannels and 
    83 maxOutputChannels in the PaDeviceInfo structure, however it has not yet been 
    84 determined whether this is practical without polling some host APIs multiple times. </P> 
    8592 
    8693<P> 
    87 It was suggested that we could do things the way MME does: if Pa_OpenStream() is called with a NULL stream parameter then the stream isn't opened, but it is checked to see if the device supports the specified format - if the format is supported then paNoError would be returned, otherwise an error code would be returned. However, this has been ruled to be unsatisfactory, since querying for supported formats is really a different function from opening a stream. 
     94Originally a goal existed to provide clients with information about which sample formats were 
     95natively supported and which were emulated by PortAudio. The idea was to allow clients to bypass 
     96PortAudio's conversion capabilities (and overhead) by using natively formatted buffers. This 
     97goal has been removed for three main reasons. A) Both buffer block adaption and unusual  
     98formats (such as varying endianness in ASIO, and multiple stereo interleaved with MME)  
     99make it difficult to provide 
     100a direct path between client and host api except in rare cases. B) PortAudio 
     101aims to use best-of-breed buffer conversion routines, thus making it undesirable for clients 
     102to implement their own conversion layer on top of PortAudio. C) It is difficult to imagine 
     103a Portable software design that would want to determine its output sample buffer format  
     104based on host api native format constraints; usually internal constraints such as use of a  
     105floating point signal path, or the format of a soundfile being played back would be more 
     106important. 
     107</P> 
     108 
     109 
     110<P> 
     111Although the retention of maxInputChannels and maxOutputChannels in the PaDeviceInfo 
     112structure is considered desirable by some clients, it has not yet been 
     113determined whether implementation of this feature is practical without polling  
     114some host APIs multiple times. 
     115</P> 
     116 
     117 
     118<P> 
     119It was suggested that we could do things the way MME does: if Pa_OpenStream() is called with a 
     120NULL stream parameter then the stream isn't opened, but it is checked to see if the device  
     121supports the specified format - if the format is supported then paNoError would be returned, 
     122otherwise an error code would be returned. However, this has been ruled to be unsatisfactory,  
     123since querying for supported formats is really a different function from opening a stream. 
    88124</P> 
    89125 
     
    91127 
    92128<P> 
    93 This proposal will provide clients with more expressive methods for querying device capabilities, which should improve the utility of PortAudio. It is not yet clear what the full impact of this proposal will be. 
     129This proposal will provide clients with more expressive methods for querying device capabilities, which should improve the utility of PortAudio. Clients which currently depend on PaDeviceInfo fields which have been removed (sample rate and native formates information) may have to make significant changes to their code. 
    94130</P> 
    95131 
    96132</BODY> 
    97133</HTML> 
    98  
     134