# Perform Bluetooth A2DP source functions

Source: [https://docs.qualcomm.com/doc/80-70017-13/topic/perform-a2dp-source-functions.html](https://docs.qualcomm.com/doc/80-70017-13/topic/perform-a2dp-source-functions.html)

You can perform A2DP source functions using the `a2dp_source_menu`
        options.

Before you begin, set up the device and go to the A2DP source menu as described in
                    [Set up device for A2DP functions](https://docs.qualcomm.com/doc/80-70017-13/topic/set-up-a2dp.html#set-up-a2dp__section_j44_jzy_kcc_navyanka_08-18-24-2110-52-709).

## Connect to an A2DP source device

To connect to an A2DP source device, run the following command:

    connect <bt_address>Copy to clipboard

**Parameters**

`<bt_address>` is the Bluetooth address of the remote device.

**Example**

To connect to a remote device with the Bluetooth address
                    `20:19:d8:36:90:40`, run the following command:

    connect 20:19:d8:36:90:40Copy to clipboard

**Sample output**

connect 20:19:d8:36:90:40
    A2DP Source Connecting to 20:19:d8:36:90:40
    ACL state:0 change with reason 00 for device: 20:19:d8:36:90:40
    Codec Configuration for device 20:19:d8:36:90:40
    Codec type = sbc
    Sample Rate = 48000
    Bits per sample = 16
    Channel Mode = joint
    Block Len = 16
    Num of Subbands = 8
    Allocation Method = loudness
    Max Bitpool = 53
    Min Bitpool = 2
    A2DP Source Connected to 20:19:d8:36:90:40
    param is device_connection=trueBT a2dp source connect success
    percent volume changed: 81Copy to clipboard

## Set the sampling rate of codecs

To set the sampling rate of codecs, run the following
                command:

    codec_list <codec1,param1,param2....,codec2,param1,param2....>Copy to clipboard

**Parameters**

`<codec1,param1,param2....,codec2,param1,param2....>` is the list
                of codecs with respective parameters.

**Example**

- To set the sampling rate of SBC and AAC codecs to 48 kHz, run the following
                        command:

        [codec_list sbc,48,16,joint,16,8,loud,250,2 ] [codec_list aac,48,16,stereo,128,195000 ]Copy to clipboard
- To set the sampling rate of SBC and AAC codecs to 44.1 kHz, run the
                        following command:

        [codec_list sbc,44.1,16,joint,16,8,loud,250,2 ] [codec_list aac,44.1,16,stereo,128,195000 ]Copy to clipboard

## Play songs from the DUT

To play songs from the DUT, do the following:

1. Open a command prompt window.
2. Push the WAV or MP3 files to the DUT.
3. Play the audio as follows: 
Note: The DUT does not support an audio player. Use
                            `paplay` commands to play music.

    - To play PCM samples, run the following command:

            paplay <wav_filepath> --device=<device_name>Copy to clipboard

        **Parameters**

        - `<wav_filepath>` is the filepath of the WAV
                                    file to play.
        - `<device_name>` is the name of the playback
                                    device.
    - To play compressed audio files like MP3, run the following command:

            paplay -d offload0 --encoding=<format> --raw <audio_filepath>Copy to clipboard

        **Parameters**

        - `<audio_filepath>` is the filepath of the MP3
                                    file to play.
        - `<format>` is the audio file format.

        **Example**

        To play an MP3 audio file at
                                    `/tmp/Chogada.mp3`, run the following
                                command:

            paplay -d offload0 --encoding=mpeg --raw /tmp/Chogada.mp3Copy to clipboard

        **Sample                                    output**

sh-5.1# paplay -d offload0 --encoding=mpeg --raw /tmp/Chogada.mp3
            sh-5.1# paplay -d offload0 --encoding=mpeg --raw /tmp/Chogada.mp3Copy to clipboard

## Set the absolute volume

To set the absolute volume, run the following
                command:

    avrcp_setabsolutevol <volstep>Copy to clipboard

**Parameters**

`<volstep>` is the level of volume. It ranges from 0 to 15.

**Example**

To set the absolute volume to level 15, run the following
                command:

    avrcp_setabsolutevol 15Copy to clipboard

**Sample output**

avrcp_setabsolutevol 0
    percent volume changed: 0
    avrcp_setabsolutevol 10
    percent volume changed: 66
    avrcp_setabsolutevol 15
    percent volume changed: 100
    avrcp_setabsolutevol 10
    percent volume changed: 66
    avrcp_setabsolutevol 7
    percent volume changed: 47Copy to clipboard

Note: To set the absolute volume, the DUT and the remote device must support the
                absolute volume functionality.

## Increase the volume

To increase the volume by one, run the following command:

    avrcp_sendvolupdown 1Copy to clipboard

**Sample output**

avrcp_sendvolupdown 1
    percent volume changed: 53
    avrcp_sendvolupdown 1
    percent volume changed: 59Copy to clipboard

Note: To increase the volume, the DUT and the remote device must support the volume
                increase functionality.

## Decrease the volume

To decrease the volume by one, run the following command:

    avrcp_sendvolupdown 0Copy to clipboard

**Sample output**

avrcp_sendvolupdown 0
    percent volume changed: 53Copy to clipboard

Note: To increase the volume, the DUT and the remote device must support the volume
                decrease functionality.

## Disconnect an A2DP source device

To disconnect an A2DP source device, run the following command:

    disconnect <bt_address>Copy to clipboard

**Parameters**

`<bt_address>` is the Bluetooth address of the remote device.

**Example**

To disconnect a remote device with the Bluetooth address
                    `20:19:d8:36:90:40`, run the following command:

    disconnect 20:19:d8:36:90:40Copy to clipboard

**Sample output**

disconnect 20:19:d8:36:90:40
    A2DP Source DisConnecting: 20:19:d8:36:90:40
    A2DP Source DisConnected
    param is device_connection=falseBT a2dp source disconnect success
    ACL state:1 change with reason 13 for device: 20:19:d8:36:90:40Copy to clipboard

**Parent Topic:** [Advanced Audio Distribution Profile](https://docs.qualcomm.com/doc/80-70017-13/topic/set-up-a2dp.html)

Last Published: Dec 26, 2024

[Previous Topic
Advanced Audio Distribution Profile](https://docs.qualcomm.com/bundle/publicresource/80-70017-13/topics/set-up-a2dp.md) [Next Topic
Perform Bluetooth A2DP sink functions](https://docs.qualcomm.com/bundle/publicresource/80-70017-13/topics/perform-a2dp-sink-functions.md)