> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SHAPE_XMA_CONTEXT

> SHAPE_XMA_CONTEXT

# SHAPE\_XMA\_CONTEXT

The XBOX Media Audio (XMA) context.

<a id="syntaxSection" />

## Syntax

```cpp theme={null}
typedef struct SHAPE_XMA_CONTEXT {  
    UINT32 sizeRead0 : 12;  
    UINT32 numLoops : 8;  
    UINT32 validBuffer : 2;  
    UINT32 sizeWrite : 5;  
    UINT32 offsetWrite : 5;  
    UINT32 sizeRead1 : 12;  
    UINT32 loopSubframeEnd : 2;  
    UINT32 reserved0 : 3;  
    UINT32 loopSubframeSkip : 3;  
    UINT32 numSubframesToDecode : 4;  
    UINT32 numSubframesToSkip : 3;  
    UINT32 sampleRate : 2;  
    UINT32 numChannels : 1;  
    UINT32 reserved1 : 1;  
    UINT32 validWrite : 1;  
    UINT32 offsetRead : 26;  
    UINT32 errorStatus : 5;  
    UINT32 errorSet : 1;  
    UINT32 loopStartOffset : 26;  
    UINT32 parserErrorStatus : 5;  
    UINT32 parserErrorSet : 1;  
    UINT32 loopEndOffset : 26;  
    UINT32 packetMetaData : 5;  
    UINT32 currentBuffer : 1;  
    UINT32 ptrRead0;  
    UINT32 ptrRead1;  
    UINT32 ptrWrite;  
    UINT32 ptrOverlapAdd;  
    UINT32 writeBufferOffsetRead : 5;  
    UINT32 reserved2 : 25;  
    UINT32 stopWhenDone : 1;  
    UINT32 interruptWhenDone : 1;  
    UINT32 reserved[6];  
} SHAPE_XMA_CONTEXT  
```

<a id="membersSection" />

### Members

*sizeRead0*\
Type: UINT32

Write: Size, in 2-KB blocks, of the left input buffer.

*numLoops*\
Type: UINT32

Read/Write: Number of loops. 255 specifies infinite (continuous) looping.

*validBuffer*\
Type: UINT32

Read/Write: Validity flags for the input buffers.

| Value | Description                     |
| ----- | ------------------------------- |
| 00    | Neither buffer is valid.        |
| 01    | Only buffer 0 (left) is valid.  |
| 10    | Only buffer 1 (right) is valid. |
| 11    | Both buffers are valid.         |

*sizeWrite*\
Type: UINT32

Write: Size, in 256-byte blocks, of the output buffer.

*offsetWrite*\
Type: UINT32

Read: Offset, in 256-byte blocks, into the output buffer where the hardware will write.

*sizeRead1*\
Type: UINT32

Write: Size, in 2-KB blocks, of the right input buffer.

*loopSubframeEnd*\
Type: UINT32

Write: Subframe number of the loop endpoint, inclusive.

*reserved0*\
Type: UINT32

Reserved.

*loopSubframeSkip*\
Type: UINT32

Write: Number of subframes to skip at the beginning of the loop. Valid values are 0, 1, 2, 3, and 4.

*numSubframesToDecode*\
Type: UINT32

Write: Number of subframes to decode per pass. Valid values are 1, 2, 4, and 8.

*numSubframesToSkip*\
Type: UINT32

Write: Number of subframes to skip. Valid values are 0, 1, 2, 3, and 4.

*sampleRate*\
Type: UINT32

Write: Sample rate of the stream. Valid values are in the [SHAPE\_XMA\_SAMPLE\_RATE](/reference/audio/shapexmacontext/enums/shape_xma_sample_rate) enumeration.

*numChannels*\
Type: UINT32

Write: Number of channels in the stream. 0 specifies mono (one channel); 1 specifies stereo (two channels).

*reserved1*\
Type: UINT32

Reserved.

*validWrite*\
Type: UINT32

Read/Write: Validity flag for the write buffer. 1 indicates that the hardware can write; 0 indicates that the hardware cannot write.

*offsetRead*\
Type: UINT32

Read/Write: Offset, in bits, from the beginning of the input buffer.

*errorStatus*\
Type: UINT32

Read: One or more error values.

| Error                                                                                                         | Value |
| ------------------------------------------------------------------------------------------------------------- | ----- |
| SHAPE\_XMA\_ERROR\_STATUS\_NO\_ERROR\_OCCURRED\_ERRORSET\_IS\_0                                               | 0     |
| SHAPE\_XMA\_ERROR\_STATUS\_WRITE\_BUFFER\_INVALID\_VALIDWR\_IS\_0                                             | 1     |
| SHAPE\_XMA\_ERROR\_STATUS\_INSUFFICIENT\_WRITE\_BUFFER\_SPACE\_VALIDWR\_IS\_1                                 | 2     |
| SHAPE\_XMA\_ERROR\_STATUS\_READ\_BUFFER\_INVALID\_VALIDBUFFER\_CURRBUF\_IS\_0                                 | 4     |
| SHAPE\_XMA\_ERROR\_STATUS\_FRAME\_CROSSES\_BOUNDARY\_INTO\_INVALID\_READ\_BUFFER\_VALIDBUFFER\_CURRBUF\_IS\_0 | 8     |
| SHAPE\_XMA\_ERROR\_STATUS\_FRAME\_CROSSES\_BOTH\_READ\_BUFFER\_BOUNDARIES                                     | 16    |

*errorSet*\
Type: UINT32

Read: Error flag. 0 if no error has occurred; 1 if an error has occurred. Use [GetShapeXmaErrorStatus](/reference/audio/shapexmacontext/functions/getshapexmaerrorstatus) to retrieve error values.

*loopStartOffset*\
Type: UINT32

Write: Offset, in bits, from the read-buffer pointer where the hardware will start decoding.

*parserErrorStatus*\
Type: UINT32

Read: Parser error value.

| Error                                                    | Value |
| -------------------------------------------------------- | ----- |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_UNKNOWN\_STATE        | 1     |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_OUT\_OF\_RANGE        | 2     |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_FRAME\_SIZE\_EXCEEDED | 3     |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_BITSTREAM\_CORRUPTION | 4     |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_BARKVLC\_ERROR        | 5     |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_BARKRLC\_ERROR        | 6     |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_VLC4D\_ERROR          | 7     |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_VLC2D\_ERROR          | 8     |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_VLC1D\_ERROR          | 9     |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_RLC0\_ERROR           | 10    |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_RLC1\_ERROR           | 11    |
| SHAPE\_XMA\_PARSER\_ERROR\_STATUS\_LARGEVAL24\_ERROR     | 15    |

*parserErrorSet*\
Type: UINT32

Read: Parser error flag. 0 if no error has occurred; 1 if an error has occurred. Use [GetShapeXmaParserErrorStatus](/reference/audio/shapexmacontext/functions/getshapexmaparsererrorstatus) to retrieve error value.

*loopEndOffset*\
Type: UINT32

Write: Offset, in bits, from the read-buffer pointer where the hardware will end decoding.

*packetMetaData*\
Type: UINT32

Reserved for internal use.

*currentBuffer*\
Type: UINT32

Read/Write: Current input buffer. 0 specifies the left buffer, and 1 specifies the right buffer.

*ptrRead0*\
Type: UINT32

Write: Pointer to the left input buffer. Aligned on 2-KB boundaries; lower 11 bits are ignored.

*ptrRead1*\
Type: UINT32

Write: Pointer to the right input buffer. Aligned on 2-KB boundaries; lower 11 bits are ignored.

*ptrWrite*\
Type: UINT32

Write: Pointer to the output buffer. Aligned on 64-byte boundaries.

*ptrOverlapAdd*\
Type: UINT32

Write: Pointer to the working buffer. Aligned on 128-byte boundaries.

*writeBufferOffsetRead*\
Type: UINT32

Write: Offset, in 256-byte blocks, of the read pointer in the output buffer.

*reserved2*\
Type: UINT32

Reserved.

*stopWhenDone*\
Type: UINT32

Reserved for internal use.

*interruptWhenDone*\
Type: UINT32

Reserved for internal use.

*reserved*\
Type: UINT32\[6]

Reserved.

<a id="remarksSection" />

## Remarks

This structure contains the context for the XMA decoder block.

The maximum size of an input buffer is 8 MB. To determine the status of an input buffer's consumption, examine the *offsetRead*, *currentBuffer*, and *validBuffer* members.

Members that are marked as **Read** are written by the Audio Control Processor (ACP) library and should only be read by your application. Members that marked as **Write** are set by your application and are not changed by the ACP library. Members that are marked as **Read/Write** are set by your application but can be changed by the ACP library.

For more information, see the [XMA](/build/console-features/audio/overviews/shape-overview#ID4EYD) section of [Overview of SHAPE](/build/console-features/audio/overviews/shape-overview).

<a id="requirementsSection" />

## Requirements

**Header:** shapexmacontext.h

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

<a id="seealsoSection" />

## Conceptual documentation

* [ACP overview](/build/console-features/audio/overviews/acp-overview)

## See also

[ShapeXmaContext](/reference/audio/shapexmacontext/shapexmacontext_members)
