dmACGetMinInputSize(3dm) dmACGetMinInputSize(3dm)
dmACGetMinInputSize, dmACGetMinOutputSize - auxiliary routines for
querying input and output buffer sizes for dmACConvert.
#include <dmedia/dm_audioconvert.h>
DMstatus dmACGetMinInputSize( [Toc] [Back]
DMaudioconverter converter,
int outputSize,
int *minInputSize)
DMstatus dmACGetMinOutputSize( [Toc] [Back]
DMaudioconverter converter,
int inputSize,
int *minOutputSize)
converter is a DMaudioconverter handle created by a previous call
to the creation method dmACCreate(3dm).
outputSize is a integer set to the requested output buffer size.
The units will be bytes if compressing, otherwise frames.
minInputSize is a pointer to integer which will be set to the minimum
allowable input buffer size for the given outputSize.
The units will be bytes if decompressing, otherwise
frames.
inputSize is a integer set to the requested input buffer size. The
units will be bytes if decompressing, otherwise frames.
minOutputSize is a pointer to integer which will be set to the minimum
allowable output buffer size for the given inputSize.
The units will be bytes if compressing, otherwise frames.
Returns DM_SUCCESS if the operation succeeds. If DM_FAILURE is returned,
the error number and/or message can be retrieved via dmGetError(3dm).
The handle passed to these routines is declared as follows:
typedef struct _DMaudioconverter *DMaudioconverter;
dmACGetMinInputSize and dmACGetMinOutputSize are a faster way to query
the value of the two audio conversion parameters DM_AUDIO_MIN_INPUT_LEN
and DM_AUDIO_MIN_OUTPUT_LEN. These values may also be retrieved via
dmACGetParamsDM_AUDIO_MAX_REQUEST_LEN set to either the input or output size,
depending on the conversion mode.
Page 1
dmACGetMinInputSize(3dm) dmACGetMinInputSize(3dm)
Only one of these two routines will be valid for any given configuration
of the audio converter handle -- more specifically, dependent on the
value of DM_AUDIO_PROCESS_MODE. A fixed input size indicates the
converter is running in DM_AUDIO_PROCESS_PUSH mode; a fixed output size
similarly indicates DM_AUDIO_PROCESS_PULL mode. A call to the opposite
routine will return DM_FAILURE, and the error value will be set to
DM_AUDIO_BAD_REQUEST.
Typically, buffer sizes only need be set and queried if the audio data is
being compressed, decompressed, or rate-converted. In all other cases,
the output buffer length (in frames) will and must equal the input
length.
If an application wishes to compress blocks of data to be written to a
file or a device, the sequence might look like this (error checking has
been omitted for brevity):
#include <dmedia/dm_params.h>
#include <dmedia/dm_audioconvert.h>
DMaudioconverter converter;
DMparams *inputParams, *outputParams;
/* create the parameter lists and the converter */
dmParamsCreate(&inputParams);
dmParamsCreate(&outputParams);
dmACCreate(&converter);
/* set up input params for 16bit, mono, 44.1K */
dmSetAudioDefaults(inputParams, 16, 44100, 1);
/* set up output params for GSM compression */
dmSetAudioDefaults(outputParams, 16, 44100, 1);
dmParamsSetString(params, DM_AUDIO_COMPRESSION, DM_AUDIO_GSM);
/* configure the converter */
dmACSetParams(converter, inputParams, outputParams);
/* loop forever, compressing data from some buffer */
while(1) {
int inputFrames; /* app sets this */
int outputBytes; /* and queries for this */
void *inBuffer = getInputBuffer(&inputFrames);
void *outBuffer;
/* do the query */
dmACGetMinOutputSize(converter, inputFrames, &outputBytes);
/* then perhaps the output buffer will be dynamically alloc'd */
outBuffer = getLargeEnoughOutBuffer(outputBytes);
Page 2
dmACGetMinInputSize(3dm) dmACGetMinInputSize(3dm)
/* now we can compress our data into that buffer safely */
dmACConvert(converter, inBuffer, outBuffer,
&inputFrames, &outputBytes);
...
}
dmACCreate(3dm), dmACSetParams(3dm), dmACGetParams(3dm),
dmACConvert(3dm), dmACReset(3dm), dmACDestroy(3dm),
PPPPaaaaggggeeee 3333 [ Back ]
|