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

# Stream

**Header:** `stream/inc/Stream.h`

## Structures

### `Stream`

**Members**

<ParamField path="mInitialized _(protected)_" type="bool" />

<ParamField path="mNoOfDevices _(protected)_" type="uint32_t" />

<ParamField path="mDevices _(protected)_" type="std::vector< std::shared_ptr< Device > >" />

<ParamField path="mPalDevices _(protected)_" type="std::vector< std::shared_ptr< Device > >" />

<ParamField path="session _(protected)_" type="Session *" />

<ParamField path="mStreamAttr _(protected)_" type="struct pal_stream_attributes *" />

<ParamField path="deviceMuteStateRx _(protected)_" type="bool" />

<ParamField path="deviceMuteStateTx _(protected)_" type="bool" />

<ParamField path="mGainLevel _(protected)_" type="int" />

<ParamField path="mOrientation _(protected)_" type="int" />

<ParamField path="mStreamMutex _(protected)_" type="std::mutex" />

<ParamField path="mGetParamMutex _(protected)_" type="std::mutex" />

<ParamField path="mModifiers _(protected)_" type="struct modifier_kv *" />

<ParamField path="mNoOfModifiers _(protected)_" type="uint32_t" />

<ParamField path="mStreamSelector _(protected)_" type="std::string" />

<ParamField path="mDevPPSelector _(protected)_" type="std::string" />

<ParamField path="inBufSize _(protected)_" type="size_t" />

<ParamField path="outBufSize _(protected)_" type="size_t" />

<ParamField path="inBufCount _(protected)_" type="size_t" />

<ParamField path="outBufCount _(protected)_" type="size_t" />

<ParamField path="outMaxMetadataSz _(protected)_" type="size_t" />

<ParamField path="inMaxMetadataSz _(protected)_" type="size_t" />

<ParamField path="currentState _(protected)_" type="stream_state_t" />

<ParamField path="cachedState _(protected)_" type="stream_state_t" />

<ParamField path="mInstanceID _(protected)_" type="uint32_t" />

<ParamField path="mutexLockedbyRm _(protected)_" type="bool" />

<ParamField path="mDutyCycleEnable _(protected)_" type="bool" />

<ParamField path="skipSSRHandling _(protected)_" type="bool" />

<ParamField path="mInUse _(protected)_" type="sem_t" />

<ParamField path="mBaseStreamMutex _(protected)_" type="std::mutex" />

<ParamField path="rm _(protected)_" type="std::shared_ptr< ResourceManager >" />

<ParamField path="pm _(protected)_" type="std::shared_ptr< PluginManager >" />

<ParamField path="pauseMutex _(protected)_" type="std::mutex" />

<ParamField path="mVolumeData" type="struct pal_volume_data *" />

<ParamField path="callTranslationConfigPayload" type="call_translation_config *" />

<ParamField path="streamCb" type="pal_stream_callback" />

<ParamField path="cookie" type="uint64_t" />

<ParamField path="isPaused" type="bool" />

<ParamField path="a2dpMuted" type="bool" />

<ParamField path="unMutePending" type="bool" />

<ParamField path="a2dpPaused" type="bool" />

<ParamField path="force_nlpi_vote" type="bool" />

<ParamField path="isMMap" type="bool" />

<ParamField path="isComboHeadsetActive" type="bool" />

<ParamField path="suspendedOutDevIds" type="std::vector< pal_device_id_t >" />

<ParamField path="suspendedInDevIds" type="std::vector< pal_device_id_t >" />

#### Functions

##### `connectToDefaultDevice`

*protected*

```cpp theme={null}
int connectToDefaultDevice(Stream *streamHandle, uint32_t dir)
```

##### `Stream`

```cpp theme={null}
 Stream()
```

##### `~Stream`

```cpp theme={null}
 ~Stream()
```

##### `isInitialized`

```cpp theme={null}
bool isInitialized() const
```

##### `open`

```cpp theme={null}
int32_t open()=0
```

##### `close`

```cpp theme={null}
int32_t close()=0
```

##### `start`

```cpp theme={null}
int32_t start()=0
```

##### `start_l`

```cpp theme={null}
int32_t start_l()
```

##### `stop`

```cpp theme={null}
int32_t stop()=0
```

##### `prepare`

```cpp theme={null}
int32_t prepare()=0
```

##### `drain`

```cpp theme={null}
int32_t drain(pal_drain_type_t type __unused)=0
```

##### `setVolume`

```cpp theme={null}
int32_t setVolume(struct pal_volume_data *volume)=0
```

##### `mute`

```cpp theme={null}
int32_t mute(bool state)=0
```

##### `mute_l`

```cpp theme={null}
int32_t mute_l(bool state)=0
```

##### `getDeviceMute`

```cpp theme={null}
int32_t getDeviceMute(pal_stream_direction_t dir, bool *state)
```

##### `setDeviceMute`

```cpp theme={null}
int32_t setDeviceMute(pal_stream_direction_t dir, bool state)
```

##### `pause`

```cpp theme={null}
int32_t pause()=0
```

##### `pause_l`

```cpp theme={null}
int32_t pause_l()=0
```

##### `resume`

```cpp theme={null}
int32_t resume()=0
```

##### `resume_l`

```cpp theme={null}
int32_t resume_l()=0
```

##### `flush`

```cpp theme={null}
int32_t flush()=0
```

##### `suspend`

```cpp theme={null}
int32_t suspend()=0
```

##### `read`

```cpp theme={null}
int32_t read(struct pal_buffer *buf)=0
```

##### `addRemoveEffect`

```cpp theme={null}
int32_t addRemoveEffect(pal_audio_effect_t effect, bool enable)=0
```

##### `setParameters`

```cpp theme={null}
int32_t setParameters(uint32_t param_id, void *payload)=0
```

##### `setParameters_l`

```cpp theme={null}
int32_t setParameters_l(uint32_t param_id, void *payload)
```

##### `write`

```cpp theme={null}
int32_t write(struct pal_buffer *buf)=0
```

##### `registerCallBack`

```cpp theme={null}
int32_t registerCallBack(pal_stream_callback cb, uint64_t cookie)=0
```

##### `getCallBack`

```cpp theme={null}
int32_t getCallBack(pal_stream_callback *cb)=0
```

##### `getParameters`

```cpp theme={null}
int32_t getParameters(uint32_t param_id, void **payload)=0
```

##### `setECRef`

```cpp theme={null}
int32_t setECRef(std::shared_ptr< Device > dev, bool is_enable)=0
```

##### `setECRef_l`

```cpp theme={null}
int32_t setECRef_l(std::shared_ptr< Device > dev, bool is_enable)=0
```

##### `ssrDownHandler`

```cpp theme={null}
int32_t ssrDownHandler()=0
```

##### `ssrUpHandler`

```cpp theme={null}
int32_t ssrUpHandler()=0
```

##### `isBitWidthSupported`

```cpp theme={null}
int32_t isBitWidthSupported(uint32_t bitWidth)=0
```

##### `isSampleRateSupported`

```cpp theme={null}
int32_t isSampleRateSupported(uint32_t sampleRate)=0
```

##### `isChannelSupported`

```cpp theme={null}
int32_t isChannelSupported(uint32_t numChannels)=0
```

##### `isStreamSupported`

```cpp theme={null}
bool isStreamSupported()
```

##### `createMmapBuffer`

```cpp theme={null}
int32_t createMmapBuffer(int32_t min_size_frames __unused, struct pal_mmap_buffer *info __unused)
```

##### `GetMmapPosition`

```cpp theme={null}
int32_t GetMmapPosition(struct pal_mmap_position *position __unused)
```

##### `GetNumEvents`

```cpp theme={null}
uint32_t GetNumEvents()
```

##### `GetOutputToken`

```cpp theme={null}
uint32_t GetOutputToken()
```

##### `GetPayloadSize`

```cpp theme={null}
uint32_t GetPayloadSize()
```

##### `GetSdzNumEvents`

```cpp theme={null}
uint32_t GetSdzNumEvents()
```

##### `GetSdzOutputToken`

```cpp theme={null}
uint32_t GetSdzOutputToken()
```

##### `GetSdzPayloadSize`

```cpp theme={null}
uint32_t GetSdzPayloadSize()
```

##### `GetMMAModelType`

```cpp theme={null}
uint32_t GetMMAModelType()
```

##### `setCustomParam`

```cpp theme={null}
int32_t setCustomParam(custom_payload_uc_info_t *uc_info, std::string param_str, void *param_payload, size_t payload_size)
```

##### `getCustomParam`

```cpp theme={null}
int32_t getCustomParam(custom_payload_uc_info_t *uc_info, std::string param_str, void *param_payload, size_t *payload_size)
```

##### `ConfigSupportLPI`

```cpp theme={null}
bool ConfigSupportLPI()
```

##### `checkStreamMatch`

```cpp theme={null}
bool checkStreamMatch(Stream *ref)
```

##### `IsStreamInBuffering`

```cpp theme={null}
bool IsStreamInBuffering()
```

##### `getVoteType`

```cpp theme={null}
vote_type_t getVoteType()
```

##### `getStreamAttributes`

```cpp theme={null}
int32_t getStreamAttributes(struct pal_stream_attributes *sattr)
```

##### `getStreamSelector`

```cpp theme={null}
const std::string & getStreamSelector() const
```

##### `getDevicePPSelector`

```cpp theme={null}
const std::string & getDevicePPSelector() const
```

##### `getStreamType`

```cpp theme={null}
int32_t getStreamType(pal_stream_type_t *streamType)
```

##### `getStreamDirection`

```cpp theme={null}
int32_t getStreamDirection(pal_stream_direction_t *dir)
```

##### `getRenderLatency`

```cpp theme={null}
uint32_t getRenderLatency()
```

##### `getLatency`

```cpp theme={null}
uint32_t getLatency()
```

##### `getAssociatedDevices`

```cpp theme={null}
int32_t getAssociatedDevices(std::vector< std::shared_ptr< Device > > &adevices)
```

##### `getAssociatedOutDevices`

```cpp theme={null}
int32_t getAssociatedOutDevices(std::vector< std::shared_ptr< Device > > &adevices)
```

##### `getAssociatedInDevices`

```cpp theme={null}
int32_t getAssociatedInDevices(std::vector< std::shared_ptr< Device > > &adevices)
```

##### `getPalDevices`

```cpp theme={null}
int32_t getPalDevices(std::vector< std::shared_ptr< Device > > &PalDevices)
```

##### `removePalDevice`

```cpp theme={null}
void removePalDevice(Stream *streamHandle, int palDevId)
```

##### `clearOutPalDevices`

```cpp theme={null}
void clearOutPalDevices(Stream *streamHandle)
```

##### `addPalDevice`

```cpp theme={null}
void addPalDevice(Stream *streamHandle, struct pal_device *dattr)
```

##### `getSoundCardId`

```cpp theme={null}
int32_t getSoundCardId()
```

##### `getAssociatedSession`

```cpp theme={null}
int32_t getAssociatedSession(Session **session)
```

##### `setBufInfo`

```cpp theme={null}
int32_t setBufInfo(pal_buffer_config *in_buffer_config, pal_buffer_config *out_buffer_config)
```

##### `getBufInfo`

```cpp theme={null}
int32_t getBufInfo(size_t *in_buf_size, size_t *in_buf_count, size_t *out_buf_size, size_t *out_buf_count)
```

##### `getMaxMetadataSz`

```cpp theme={null}
int32_t getMaxMetadataSz(size_t *in_max_metadata_sz, size_t *out_max_metadata_sz)
```

##### `getBufSize`

```cpp theme={null}
int32_t getBufSize(size_t *in_buf_size, size_t *out_buf_size)
```

##### `getVolumeData`

```cpp theme={null}
int32_t getVolumeData(struct pal_volume_data *vData)
```

##### `setGainLevel`

```cpp theme={null}
void setGainLevel(int level)
```

##### `getGainLevel`

```cpp theme={null}
int getGainLevel()
```

##### `setDutyCycleEnable`

```cpp theme={null}
void setDutyCycleEnable(bool enable)
```

##### `getDutyCycleEnable`

```cpp theme={null}
bool getDutyCycleEnable()
```

##### `setOrientation`

```cpp theme={null}
void setOrientation(int orientation)
```

##### `getOrientation`

```cpp theme={null}
int getOrientation()
```

##### `isStreamAudioOutFmtSupported`

```cpp theme={null}
bool isStreamAudioOutFmtSupported(pal_audio_fmt_t format)
```

##### `getTimestamp`

```cpp theme={null}
int32_t getTimestamp(struct pal_session_time *stime)
```

##### `disconnectStreamDevice`

```cpp theme={null}
int disconnectStreamDevice(Stream *streamHandle, pal_device_id_t dev_id)
```

##### `disconnectStreamDevice_l`

```cpp theme={null}
int disconnectStreamDevice_l(Stream *streamHandle, pal_device_id_t dev_id)
```

##### `connectStreamDevice`

```cpp theme={null}
int connectStreamDevice(Stream *streamHandle, struct pal_device *dattr)
```

##### `connectStreamDevice_l`

```cpp theme={null}
int connectStreamDevice_l(Stream *streamHandle, struct pal_device *dattr)
```

##### `switchDevice`

```cpp theme={null}
int switchDevice(Stream *streamHandle, uint32_t no_of_devices, struct pal_device *deviceArray)
```

##### `getEffectParameters`

```cpp theme={null}
int32_t getEffectParameters(void *effect_query, size_t *payload_size)
```

##### `getInstanceId`

```cpp theme={null}
uint32_t getInstanceId()
```

##### `setInstanceId`

```cpp theme={null}
void setInstanceId(uint32_t sid)
```

##### `initStreamSmph`

```cpp theme={null}
int initStreamSmph()
```

##### `deinitStreamSmph`

```cpp theme={null}
int deinitStreamSmph()
```

##### `postStreamSmph`

```cpp theme={null}
int postStreamSmph()
```

##### `waitStreamSmph`

```cpp theme={null}
int waitStreamSmph()
```

##### `checkStreamMatch`

```cpp theme={null}
bool checkStreamMatch(pal_device_id_t pal_device_id, pal_stream_type_t pal_stream_type)
```

##### `checkStreamMatch`

```cpp theme={null}
bool checkStreamMatch(pal_device_id_t pal_device_id, pal_stream_type_t pal_stream_type, char *address)
```

##### `isStreamSSRDownFeasibile`

```cpp theme={null}
bool isStreamSSRDownFeasibile()
```

##### `getCurState`

```cpp theme={null}
stream_state_t getCurState()
```

##### `isActive`

```cpp theme={null}
bool isActive()
```

##### `isAlive`

```cpp theme={null}
bool isAlive()
```

##### `isA2dpMuted`

```cpp theme={null}
bool isA2dpMuted()
```

##### `Resume`

```cpp theme={null}
int32_t Resume(bool is_internal=false)
```

##### `Pause`

```cpp theme={null}
int32_t Pause(bool is_internal=false)
```

##### `HandleConcurrentStream`

```cpp theme={null}
int32_t HandleConcurrentStream(bool active)
```

##### `DisconnectDevice`

```cpp theme={null}
int32_t DisconnectDevice(pal_device_id_t device_id)
```

##### `ConnectDevice`

```cpp theme={null}
int32_t ConnectDevice(pal_device_id_t device_id)
```

##### `getCallbackEventId`

```cpp theme={null}
uint32_t getCallbackEventId()
```

##### `HandleCallback`

```cpp theme={null}
void HandleCallback(uint64_t hdl, uint32_t event_id, void *data, uint32_t event_size)
```

##### `lockStreamMutex`

```cpp theme={null}
void lockStreamMutex()
```

##### `unlockStreamMutex`

```cpp theme={null}
void unlockStreamMutex()
```

##### `isMutexLockedbyRm`

```cpp theme={null}
bool isMutexLockedbyRm()
```

##### `lockGetParamMutex`

```cpp theme={null}
void lockGetParamMutex()
```

##### `unlockGetParamMutex`

```cpp theme={null}
void unlockGetParamMutex()
```

##### `setCachedState`

```cpp theme={null}
void setCachedState(stream_state_t state)
```

##### `clearmDevices`

```cpp theme={null}
void clearmDevices()
```

##### `removemDevice`

```cpp theme={null}
void removemDevice(int palDevId)
```

##### `addmDevice`

```cpp theme={null}
void addmDevice(struct pal_device *dattr)
```

##### `removeLastmDevice`

```cpp theme={null}
void removeLastmDevice()
```

##### `GetCurrentCaptureProfile`

```cpp theme={null}
std::shared_ptr< CaptureProfile > GetCurrentCaptureProfile()
```

##### `create`

```cpp theme={null}
Stream * create(struct pal_stream_attributes *sattr, struct pal_device *dattr, uint32_t no_of_devices, struct modifier_kv *modifiers, uint32_t no_of_modifiers)
```

##### `destroy`

```cpp theme={null}
int32_t destroy(Stream *s)
```

##### `handleStreamCreateFailure`

```cpp theme={null}
void handleStreamCreateFailure(struct pal_stream_attributes *attributes, pal_stream_callback cb, uint64_t cookie)
```

##### `mixerEventCallbackEntry`

```cpp theme={null}
void mixerEventCallbackEntry(uint64_t cookie, uint32_t event_id, void *payload, uint32_t payload_size)
```

## Enumerations

### `dataFlags`

#### Values

| Name                    | Value | Description |
| ----------------------- | ----- | ----------- |
| `DATA_MODE_SHMEM`       | = 0   |             |
| `DATA_MODE_BLOCKING`    |       |             |
| `DATA_MODE_NONBLOCKING` |       |             |

### `stream_state_t`

#### Values

| Name               | Value | Description |
| ------------------ | ----- | ----------- |
| `STREAM_IDLE`      | = 0   |             |
| `STREAM_INIT`      |       |             |
| `STREAM_OPENED`    |       |             |
| `STREAM_STARTED`   |       |             |
| `STREAM_PAUSED`    |       |             |
| `STREAM_SUSPENDED` |       |             |
| `STREAM_STOPPED`   |       |             |

## Macros

### `BUF_SIZE_PLAYBACK`

```c theme={null}
#define BUF_SIZE_PLAYBACK 1024
```

### `BUF_SIZE_CAPTURE`

```c theme={null}
#define BUF_SIZE_CAPTURE 960
```

### `AUDIO_CAPTURE_PERIOD_DURATION_MSEC`

```c theme={null}
#define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
```

### `DEEP_BUFFER_OUTPUT_PERIOD_DURATION`

```c theme={null}
#define DEEP_BUFFER_OUTPUT_PERIOD_DURATION 40
```

### `PCM_OFFLOAD_OUTPUT_PERIOD_DURATION`

```c theme={null}
#define PCM_OFFLOAD_OUTPUT_PERIOD_DURATION 80
```

### `COMPRESS_OFFLOAD_FRAGMENT_SIZE`

```c theme={null}
#define COMPRESS_OFFLOAD_FRAGMENT_SIZE (32 * 1024)
```

### `NO_OF_BUF`

```c theme={null}
#define NO_OF_BUF 4
```

### `SSR_RECOVERY`

```c theme={null}
#define SSR_RECOVERY 10000
```

### `VOLUME_RAMP_PERIOD`

```c theme={null}
#define VOLUME_RAMP_PERIOD (200*1000)
```

### `MUTE_RAMP_PERIOD`

```c theme={null}
#define MUTE_RAMP_PERIOD (40*1000)
```

### `DEFAULT_RAMP_PERIOD`

```c theme={null}
#define DEFAULT_RAMP_PERIOD 0x28
```
