Home |
Function USBAudioRecord |
Function USBAudioRecordUSBAudioRecord submits a data buffer for recording sound from an Audio function: int USBAudioRecord(int AudioID, void * Data, UINT Len); ParametersAudioIDAudio ID value previously returned by function USBAudioGetInfo. DataPointer to a buffer to receive the recorded audio data. LenSize in bytes of the buffer pointed to by parameter Data. return valueNumber of currently queued transactions or a negative error code in case of an error. USBAudioRecord may only be called on Audio functions with Direction RTUInput (see USBAudioGetInfo). The data to be written to the buffer pointed to by parameter Data will have the format and frequency of the audio function (see USBAudioGetInfo and USBAudioGetFrequency). USBAudioRecord may need some of the submitted buffer space for house keeping purposes. Thus, the amount of data recorded may be less that what could fit into the submitted buffer. Function USBAudioWaitDone returns the size of the recorded data, which will always correspond to an integral number of milliseconds. In total, at most 1 second worth of data can be submitted for recording. The maximum amount of data accepted by a single call of USBAudioRecord depends on RTUSBAudioConfig.MaxIOsRecord. For example, if RTUSBAudioConfig.MaxIOsRecord is 2 (default), at most 1000 / 2 = 500 milliseconds of data are accepted. If RTUSBAudioConfig.MaxIOsRecord is 5, 1000 / 5 = 200 milliseconds can be used. USBAudioRecord does not wait until the audio device has filled all of the submitted buffer. Rather, it uses RTUStartIO to start a transaction and then returns to the application immediately. The application may not access, safe, or deallocate the submitted data buffer before USBAudioWaitDone has been called and USBAudioWaitDone returns the buffer address submitted with this call. USBAudioRecord returns the number of transactions currently pending. Once it returns RTUSBAudioConfig.MaxIOsRecord, the application must call USBAudioWaitDone to let at least one transaction complete before USBAudioRecord may be called again. Once recording is done, the application should call USBAudioWaitDone for each still pending transaction.
|