MICGetStatus

Syntax

#include <cafe/mic.h>

int MICGetStatus(mic_handle_t h_mic, mic_status_t* p_status);

Parameters

h_mic Handle returned from MICInit.
p_status Pointer to a structure of type mic_status_t, that will be filled with current status information, such as the number of audio samples that are ready.

Return Values

A value of MIC_ERROR_NONE (zero) indicates success and any other value indicates the type of error that was encountered.

MIC_ERROR_INV_ARG is returned if an invalid handle is passed in.
MIC_ERROR_NOT_INIT is returned when the MICClose is called before MICInit.

Description

This function is used to query the present status of the ring buffer. It shows the number of samples available in the ring buffer and the index to the samples in the ring buffer. In a DMA based, zero copy playback design, it is necessary to flush the data cache as indicated by the read index and the number of available samples.

The read index into the ring buffer is an unsigned integer indexing an array of type mic_pcm_sample_t. Any ring buffer wraparound logic must be implemented by the caller.

Using AX, an application can construct a ring buffer in multiples of playback chunks and be properly aligned for DMA. That will simplify the ring buffer and cache management logic. The SDK provided demo application uses this logic.

Separate, bitwise flags indicate connection status and whether the DRC microphone library is open.

The status flag MIC_STATUS_FLAG_CONNECTED and the return value MIC_ERROR_NOT_INIT are a reliable way to poll whether the DRC is still connected to the console. As soon as DRC and console become disconnected, the DRC microphone library is uninitialized. That leads to MIC_ERROR_NOT_INIT being returned.

An application needs to call MICSetDataConsumed to indicate how many samples are being processed.

The processing performed in MICGetStatus is lightweight and calling this function from a timing sensitive thread, such as the AX callback, can be performed.

Do Not Call From

Background Do not call this function from the background.
Interrupt handler Do not call this function from any interrupt handler.
Exception handler Do not call this function from any exception handler.

See Also

mic_handle_t
mic_pcm_sample_t
mic_status_t
MICInit
MICSetDataConsumed
Error Codes

Revision History

2013/05/08 Automated cleanup pass.
2012/08/03 Cleanup Pass.
2012/06/08 Update to match SDK 2.06.
2011/10/27 Initial version.


CONFIDENTIAL