> ## 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.

# XApuEnqueueCommand

> XApuEnqueueCommand

# XApuEnqueueCommand

Submits a single command to the XAPU command queue.

## Syntax

```cpp theme={null}
HRESULT XApuEnqueueCommand(  
         XApuHandle handle,  
         XApuCommandId* command,  
         uint32_t* totalCommandCount  
)  
```

### Parameters

*handle*   \_In\_\
Type: XApuHandle

Handle returned by calling [XApuConnect](/reference/audio/xapu/functions/xapuconnect).

*command*   \_In\_\
Type: [XApuCommandId\*](/reference/audio/xapu/structs/xapucommandid)

Command to submit to the XAPU input queue.

*totalCommandCount*   \_Out\_opt\_\
Type: uint32\_t\*

Total command count, returned.

### Return value

Type: HRESULT

Returns S\_OK if successful; otherwise, returns an error code.

## Remarks

This call will be fast as it will not allocate resources or process data and just sends the command to the hardware server. This call will return [XAPU\_E\_QUEUE\_FULL](/reference/audio/xapu/enums/xapuerrors) if there are [XApuConnectInputParameters::maxQueuedCommandsPerStream](/reference/audio/xapu/structs/xapuconnectinputparameters) commands under processing. To avoid this error, the caller must retrieve one or more result(s) via [XApuDequeueResult](/reference/audio/xapu/functions/xapudequeueresult). This call is thread safe, i.e. it is possible to submit commands from multiple threads, however there is no performance advantage to call it from more than one thread.

This call will also take a pointer to uint32\_t to return the *totalCommandCount* for the current session. This number represents the total commands that have been submitted successfully since the session started and after [XApuConnect](/reference/audio/xapu/functions/xapuconnect) was called. This number will not go back to zero.

If the hardware server is in a bad state, [XApuEnqueueCommand](/reference/audio/xapu/functions/xapuenqueuecommand) will return the [XAPU\_E\_DEVICE\_FATAL\_ERROR](/reference/audio/xapu/enums/xapuerrors) error code. In this case, all XAPU clients should be disconnected and reconnected again.

If this method fails, a descriptive error code will be returned.

The following table maps each [XApuCommandType](/reference/audio/xapu/enums/xapucommandtype) to the struct type that should be passed to **XApuEnqueueCommand**:

| XApuCommandType             | Struct Type                                                                                        |
| --------------------------- | -------------------------------------------------------------------------------------------------- |
| XApuCommandType::Activate   | [XApuDecodeConvertActivateCommand](/reference/audio/xapu/structs/xapudecodeconvertactivatecommand) |
| XApuCommandType::Deactivate | [XApuCommandId](/reference/audio/xapu/structs/xapucommandid)                                       |
| XApuCommandType::Process    | [XApuDecodeConvertCommand](/reference/audio/xapu/structs/xapudecodeconvertcommand)                 |
| XApuCommandType::Notify     | [XApuCommandId](/reference/audio/xapu/structs/xapucommandid)                                       |
| XApuCommandType::Reset      | [XApuCommandId](/reference/audio/xapu/structs/xapucommandid)                                       |

## Requirements

**Header:** xapu.h

**Library:** xapu.lib

**Supported platforms:** XBOX Series X|S

## See also

[XAPU](/reference/audio/xapu/xapu_members)


## Related topics

- [XApuCommandType](/reference/audio/xapu/enums/xapucommandtype.md)
- [XApuDecodeConvertCommand](/reference/audio/xapu/structs/xapudecodeconvertcommand.md)
- [XApuDecodeConvertActivateCommand](/reference/audio/xapu/structs/xapudecodeconvertactivatecommand.md)
- [XApuConnect](/reference/audio/xapu/functions/xapuconnect.md)
- [XApuCommandId](/reference/audio/xapu/structs/xapucommandid.md)
