mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	bluetooth: Remove ipc.[ch] files in the bluetooth module
These files are remove in the bluez project. In case of definitions in the ipc files we could use defintions in the a2dp-codecs.h
This commit is contained in:
		
							parent
							
								
									67602d8743
								
							
						
					
					
						commit
						f0432ce6ae
					
				
					 4 changed files with 66 additions and 321 deletions
				
			
		| 
						 | 
					@ -30,7 +30,6 @@
 | 
				
			||||||
#include <pulsecore/dbus-shared.h>
 | 
					#include <pulsecore/dbus-shared.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "bluetooth-util.h"
 | 
					#include "bluetooth-util.h"
 | 
				
			||||||
#include "ipc.h"
 | 
					 | 
				
			||||||
#include "a2dp-codecs.h"
 | 
					#include "a2dp-codecs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define HFP_AG_ENDPOINT "/MediaEndpoint/HFPAG"
 | 
					#define HFP_AG_ENDPOINT "/MediaEndpoint/HFPAG"
 | 
				
			||||||
| 
						 | 
					@ -686,14 +685,14 @@ static void register_endpoint(pa_bluetooth_discovery *y, const char *path, const
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        a2dp_sbc_t capabilities;
 | 
					        a2dp_sbc_t capabilities;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        capabilities.channel_mode = BT_A2DP_CHANNEL_MODE_MONO | BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL |
 | 
					        capabilities.channel_mode = SBC_CHANNEL_MODE_MONO | SBC_CHANNEL_MODE_DUAL_CHANNEL |
 | 
				
			||||||
                                    BT_A2DP_CHANNEL_MODE_STEREO | BT_A2DP_CHANNEL_MODE_JOINT_STEREO;
 | 
					                                    SBC_CHANNEL_MODE_STEREO | SBC_CHANNEL_MODE_JOINT_STEREO;
 | 
				
			||||||
        capabilities.frequency = BT_SBC_SAMPLING_FREQ_16000 | BT_SBC_SAMPLING_FREQ_32000 |
 | 
					        capabilities.frequency = SBC_SAMPLING_FREQ_16000 | SBC_SAMPLING_FREQ_32000 |
 | 
				
			||||||
                                 BT_SBC_SAMPLING_FREQ_44100 | BT_SBC_SAMPLING_FREQ_48000;
 | 
					                                 SBC_SAMPLING_FREQ_44100 | SBC_SAMPLING_FREQ_48000;
 | 
				
			||||||
        capabilities.allocation_method = BT_A2DP_ALLOCATION_SNR | BT_A2DP_ALLOCATION_LOUDNESS;
 | 
					        capabilities.allocation_method = SBC_ALLOCATION_SNR | SBC_ALLOCATION_LOUDNESS;
 | 
				
			||||||
        capabilities.subbands = BT_A2DP_SUBBANDS_4 | BT_A2DP_SUBBANDS_8;
 | 
					        capabilities.subbands = SBC_SUBBANDS_4 | SBC_SUBBANDS_8;
 | 
				
			||||||
        capabilities.block_length = BT_A2DP_BLOCK_LENGTH_4 | BT_A2DP_BLOCK_LENGTH_8 |
 | 
					        capabilities.block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 |
 | 
				
			||||||
                                    BT_A2DP_BLOCK_LENGTH_12 | BT_A2DP_BLOCK_LENGTH_16;
 | 
					                                    SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16;
 | 
				
			||||||
        capabilities.min_bitpool = MIN_BITPOOL;
 | 
					        capabilities.min_bitpool = MIN_BITPOOL;
 | 
				
			||||||
        capabilities.max_bitpool = MAX_BITPOOL;
 | 
					        capabilities.max_bitpool = MAX_BITPOOL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1223,19 +1222,19 @@ fail:
 | 
				
			||||||
static uint8_t a2dp_default_bitpool(uint8_t freq, uint8_t mode) {
 | 
					static uint8_t a2dp_default_bitpool(uint8_t freq, uint8_t mode) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (freq) {
 | 
					    switch (freq) {
 | 
				
			||||||
        case BT_SBC_SAMPLING_FREQ_16000:
 | 
					        case SBC_SAMPLING_FREQ_16000:
 | 
				
			||||||
        case BT_SBC_SAMPLING_FREQ_32000:
 | 
					        case SBC_SAMPLING_FREQ_32000:
 | 
				
			||||||
            return 53;
 | 
					            return 53;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case BT_SBC_SAMPLING_FREQ_44100:
 | 
					        case SBC_SAMPLING_FREQ_44100:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            switch (mode) {
 | 
					            switch (mode) {
 | 
				
			||||||
                case BT_A2DP_CHANNEL_MODE_MONO:
 | 
					                case SBC_CHANNEL_MODE_MONO:
 | 
				
			||||||
                case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
 | 
					                case SBC_CHANNEL_MODE_DUAL_CHANNEL:
 | 
				
			||||||
                    return 31;
 | 
					                    return 31;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                case BT_A2DP_CHANNEL_MODE_STEREO:
 | 
					                case SBC_CHANNEL_MODE_STEREO:
 | 
				
			||||||
                case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
 | 
					                case SBC_CHANNEL_MODE_JOINT_STEREO:
 | 
				
			||||||
                    return 53;
 | 
					                    return 53;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                default:
 | 
					                default:
 | 
				
			||||||
| 
						 | 
					@ -1243,15 +1242,15 @@ static uint8_t a2dp_default_bitpool(uint8_t freq, uint8_t mode) {
 | 
				
			||||||
                    return 53;
 | 
					                    return 53;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case BT_SBC_SAMPLING_FREQ_48000:
 | 
					        case SBC_SAMPLING_FREQ_48000:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            switch (mode) {
 | 
					            switch (mode) {
 | 
				
			||||||
                case BT_A2DP_CHANNEL_MODE_MONO:
 | 
					                case SBC_CHANNEL_MODE_MONO:
 | 
				
			||||||
                case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
 | 
					                case SBC_CHANNEL_MODE_DUAL_CHANNEL:
 | 
				
			||||||
                    return 29;
 | 
					                    return 29;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                case BT_A2DP_CHANNEL_MODE_STEREO:
 | 
					                case SBC_CHANNEL_MODE_STEREO:
 | 
				
			||||||
                case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
 | 
					                case SBC_CHANNEL_MODE_JOINT_STEREO:
 | 
				
			||||||
                    return 51;
 | 
					                    return 51;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                default:
 | 
					                default:
 | 
				
			||||||
| 
						 | 
					@ -1277,10 +1276,10 @@ static DBusMessage *endpoint_select_configuration(DBusConnection *c, DBusMessage
 | 
				
			||||||
        uint32_t rate;
 | 
					        uint32_t rate;
 | 
				
			||||||
        uint8_t cap;
 | 
					        uint8_t cap;
 | 
				
			||||||
    } freq_table[] = {
 | 
					    } freq_table[] = {
 | 
				
			||||||
        { 16000U, BT_SBC_SAMPLING_FREQ_16000 },
 | 
					        { 16000U, SBC_SAMPLING_FREQ_16000 },
 | 
				
			||||||
        { 32000U, BT_SBC_SAMPLING_FREQ_32000 },
 | 
					        { 32000U, SBC_SAMPLING_FREQ_32000 },
 | 
				
			||||||
        { 44100U, BT_SBC_SAMPLING_FREQ_44100 },
 | 
					        { 44100U, SBC_SAMPLING_FREQ_44100 },
 | 
				
			||||||
        { 48000U, BT_SBC_SAMPLING_FREQ_48000 }
 | 
					        { 48000U, SBC_SAMPLING_FREQ_48000 }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dbus_error_init(&e);
 | 
					    dbus_error_init(&e);
 | 
				
			||||||
| 
						 | 
					@ -1323,51 +1322,51 @@ static DBusMessage *endpoint_select_configuration(DBusConnection *c, DBusMessage
 | 
				
			||||||
    pa_assert((unsigned) i < PA_ELEMENTSOF(freq_table));
 | 
					    pa_assert((unsigned) i < PA_ELEMENTSOF(freq_table));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (y->core->default_sample_spec.channels <= 1) {
 | 
					    if (y->core->default_sample_spec.channels <= 1) {
 | 
				
			||||||
        if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_MONO)
 | 
					        if (cap->channel_mode & SBC_CHANNEL_MODE_MONO)
 | 
				
			||||||
            config.channel_mode = BT_A2DP_CHANNEL_MODE_MONO;
 | 
					            config.channel_mode = SBC_CHANNEL_MODE_MONO;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (y->core->default_sample_spec.channels >= 2) {
 | 
					    if (y->core->default_sample_spec.channels >= 2) {
 | 
				
			||||||
        if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_JOINT_STEREO)
 | 
					        if (cap->channel_mode & SBC_CHANNEL_MODE_JOINT_STEREO)
 | 
				
			||||||
            config.channel_mode = BT_A2DP_CHANNEL_MODE_JOINT_STEREO;
 | 
					            config.channel_mode = SBC_CHANNEL_MODE_JOINT_STEREO;
 | 
				
			||||||
        else if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_STEREO)
 | 
					        else if (cap->channel_mode & SBC_CHANNEL_MODE_STEREO)
 | 
				
			||||||
            config.channel_mode = BT_A2DP_CHANNEL_MODE_STEREO;
 | 
					            config.channel_mode = SBC_CHANNEL_MODE_STEREO;
 | 
				
			||||||
        else if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL)
 | 
					        else if (cap->channel_mode & SBC_CHANNEL_MODE_DUAL_CHANNEL)
 | 
				
			||||||
            config.channel_mode = BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL;
 | 
					            config.channel_mode = SBC_CHANNEL_MODE_DUAL_CHANNEL;
 | 
				
			||||||
        else if (cap->channel_mode & BT_A2DP_CHANNEL_MODE_MONO) {
 | 
					        else if (cap->channel_mode & SBC_CHANNEL_MODE_MONO) {
 | 
				
			||||||
            config.channel_mode = BT_A2DP_CHANNEL_MODE_MONO;
 | 
					            config.channel_mode = SBC_CHANNEL_MODE_MONO;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            pa_log("No supported channel modes");
 | 
					            pa_log("No supported channel modes");
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (cap->block_length & BT_A2DP_BLOCK_LENGTH_16)
 | 
					    if (cap->block_length & SBC_BLOCK_LENGTH_16)
 | 
				
			||||||
        config.block_length = BT_A2DP_BLOCK_LENGTH_16;
 | 
					        config.block_length = SBC_BLOCK_LENGTH_16;
 | 
				
			||||||
    else if (cap->block_length & BT_A2DP_BLOCK_LENGTH_12)
 | 
					    else if (cap->block_length & SBC_BLOCK_LENGTH_12)
 | 
				
			||||||
        config.block_length = BT_A2DP_BLOCK_LENGTH_12;
 | 
					        config.block_length = SBC_BLOCK_LENGTH_12;
 | 
				
			||||||
    else if (cap->block_length & BT_A2DP_BLOCK_LENGTH_8)
 | 
					    else if (cap->block_length & SBC_BLOCK_LENGTH_8)
 | 
				
			||||||
        config.block_length = BT_A2DP_BLOCK_LENGTH_8;
 | 
					        config.block_length = SBC_BLOCK_LENGTH_8;
 | 
				
			||||||
    else if (cap->block_length & BT_A2DP_BLOCK_LENGTH_4)
 | 
					    else if (cap->block_length & SBC_BLOCK_LENGTH_4)
 | 
				
			||||||
        config.block_length = BT_A2DP_BLOCK_LENGTH_4;
 | 
					        config.block_length = SBC_BLOCK_LENGTH_4;
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
        pa_log_error("No supported block lengths");
 | 
					        pa_log_error("No supported block lengths");
 | 
				
			||||||
        goto fail;
 | 
					        goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (cap->subbands & BT_A2DP_SUBBANDS_8)
 | 
					    if (cap->subbands & SBC_SUBBANDS_8)
 | 
				
			||||||
        config.subbands = BT_A2DP_SUBBANDS_8;
 | 
					        config.subbands = SBC_SUBBANDS_8;
 | 
				
			||||||
    else if (cap->subbands & BT_A2DP_SUBBANDS_4)
 | 
					    else if (cap->subbands & SBC_SUBBANDS_4)
 | 
				
			||||||
        config.subbands = BT_A2DP_SUBBANDS_4;
 | 
					        config.subbands = SBC_SUBBANDS_4;
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
        pa_log_error("No supported subbands");
 | 
					        pa_log_error("No supported subbands");
 | 
				
			||||||
        goto fail;
 | 
					        goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (cap->allocation_method & BT_A2DP_ALLOCATION_LOUDNESS)
 | 
					    if (cap->allocation_method & SBC_ALLOCATION_LOUDNESS)
 | 
				
			||||||
        config.allocation_method = BT_A2DP_ALLOCATION_LOUDNESS;
 | 
					        config.allocation_method = SBC_ALLOCATION_LOUDNESS;
 | 
				
			||||||
    else if (cap->allocation_method & BT_A2DP_ALLOCATION_SNR)
 | 
					    else if (cap->allocation_method & SBC_ALLOCATION_SNR)
 | 
				
			||||||
        config.allocation_method = BT_A2DP_ALLOCATION_SNR;
 | 
					        config.allocation_method = SBC_ALLOCATION_SNR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    config.min_bitpool = (uint8_t) PA_MAX(MIN_BITPOOL, cap->min_bitpool);
 | 
					    config.min_bitpool = (uint8_t) PA_MAX(MIN_BITPOOL, cap->min_bitpool);
 | 
				
			||||||
    config.max_bitpool = (uint8_t) PA_MIN(a2dp_default_bitpool(config.frequency, config.channel_mode), cap->max_bitpool);
 | 
					    config.max_bitpool = (uint8_t) PA_MIN(a2dp_default_bitpool(config.frequency, config.channel_mode), cap->max_bitpool);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,134 +0,0 @@
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  BlueZ - Bluetooth protocol stack for Linux
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  This library is free software; you can redistribute it and/or
 | 
					 | 
				
			||||||
 *  modify it under the terms of the GNU Lesser General Public
 | 
					 | 
				
			||||||
 *  License as published by the Free Software Foundation; either
 | 
					 | 
				
			||||||
 *  version 2.1 of the License, or (at your option) any later version.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  This library is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
					 | 
				
			||||||
 *  Lesser General Public License for more details.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  You should have received a copy of the GNU Lesser General Public
 | 
					 | 
				
			||||||
 *  License along with this library; if not, write to the Free Software
 | 
					 | 
				
			||||||
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "ipc.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* This table contains the string representation for messages types */
 | 
					 | 
				
			||||||
static const char *strtypes[] = {
 | 
					 | 
				
			||||||
	"BT_REQUEST",
 | 
					 | 
				
			||||||
	"BT_RESPONSE",
 | 
					 | 
				
			||||||
	"BT_INDICATION",
 | 
					 | 
				
			||||||
	"BT_ERROR",
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* This table contains the string representation for messages names */
 | 
					 | 
				
			||||||
static const char *strnames[] = {
 | 
					 | 
				
			||||||
	"BT_GET_CAPABILITIES",
 | 
					 | 
				
			||||||
	"BT_OPEN",
 | 
					 | 
				
			||||||
	"BT_SET_CONFIGURATION",
 | 
					 | 
				
			||||||
	"BT_NEW_STREAM",
 | 
					 | 
				
			||||||
	"BT_START_STREAM",
 | 
					 | 
				
			||||||
	"BT_STOP_STREAM",
 | 
					 | 
				
			||||||
	"BT_SUSPEND_STREAM",
 | 
					 | 
				
			||||||
	"BT_RESUME_STREAM",
 | 
					 | 
				
			||||||
	"BT_CONTROL",
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int bt_audio_service_open(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int sk;
 | 
					 | 
				
			||||||
	int err;
 | 
					 | 
				
			||||||
	struct sockaddr_un addr = {
 | 
					 | 
				
			||||||
		AF_UNIX, BT_IPC_SOCKET_NAME
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sk = socket(PF_LOCAL, SOCK_STREAM, 0);
 | 
					 | 
				
			||||||
	if (sk < 0) {
 | 
					 | 
				
			||||||
		err = -errno;
 | 
					 | 
				
			||||||
		fprintf(stderr, "%s: Cannot open socket: %s (%d)\n",
 | 
					 | 
				
			||||||
			__FUNCTION__, strerror(-err), -err);
 | 
					 | 
				
			||||||
		errno = -err;
 | 
					 | 
				
			||||||
		return -1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 | 
					 | 
				
			||||||
		err = -errno;
 | 
					 | 
				
			||||||
		fprintf(stderr, "%s: connect() failed: %s (%d)\n",
 | 
					 | 
				
			||||||
			__FUNCTION__, strerror(-err), -err);
 | 
					 | 
				
			||||||
		close(sk);
 | 
					 | 
				
			||||||
		errno = -err;
 | 
					 | 
				
			||||||
		return -1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return sk;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int bt_audio_service_close(int sk)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return close(sk);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int bt_audio_service_get_data_fd(int sk)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char cmsg_b[CMSG_SPACE(sizeof(int))], m;
 | 
					 | 
				
			||||||
	int err, ret;
 | 
					 | 
				
			||||||
	struct iovec iov = { &m, sizeof(m) };
 | 
					 | 
				
			||||||
	struct msghdr msgh;
 | 
					 | 
				
			||||||
	struct cmsghdr *cmsg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	memset(&msgh, 0, sizeof(msgh));
 | 
					 | 
				
			||||||
	msgh.msg_iov = &iov;
 | 
					 | 
				
			||||||
	msgh.msg_iovlen = 1;
 | 
					 | 
				
			||||||
	msgh.msg_control = &cmsg_b;
 | 
					 | 
				
			||||||
	msgh.msg_controllen = CMSG_LEN(sizeof(int));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ret = recvmsg(sk, &msgh, 0);
 | 
					 | 
				
			||||||
	if (ret < 0) {
 | 
					 | 
				
			||||||
		err = -errno;
 | 
					 | 
				
			||||||
		fprintf(stderr, "%s: Unable to receive fd: %s (%d)\n",
 | 
					 | 
				
			||||||
			__FUNCTION__, strerror(-err), -err);
 | 
					 | 
				
			||||||
		errno = -err;
 | 
					 | 
				
			||||||
		return -1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Receive auxiliary data in msgh */
 | 
					 | 
				
			||||||
	for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL;
 | 
					 | 
				
			||||||
			cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
 | 
					 | 
				
			||||||
		if (cmsg->cmsg_level == SOL_SOCKET
 | 
					 | 
				
			||||||
				&& cmsg->cmsg_type == SCM_RIGHTS) {
 | 
					 | 
				
			||||||
			memcpy(&ret, CMSG_DATA(cmsg), sizeof(int));
 | 
					 | 
				
			||||||
			return ret;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	errno = EINVAL;
 | 
					 | 
				
			||||||
	return -1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const char *bt_audio_strtype(uint8_t type)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (type >= ARRAY_SIZE(strtypes))
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return strtypes[type];
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const char *bt_audio_strname(uint8_t name)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (name >= ARRAY_SIZE(strnames))
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return strnames[name];
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,117 +0,0 @@
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  BlueZ - Bluetooth protocol stack for Linux
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  This library is free software; you can redistribute it and/or
 | 
					 | 
				
			||||||
 *  modify it under the terms of the GNU Lesser General Public
 | 
					 | 
				
			||||||
 *  License as published by the Free Software Foundation; either
 | 
					 | 
				
			||||||
 *  version 2.1 of the License, or (at your option) any later version.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  This library is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
					 | 
				
			||||||
 *  Lesser General Public License for more details.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  You should have received a copy of the GNU Lesser General Public
 | 
					 | 
				
			||||||
 *  License along with this library; if not, write to the Free Software
 | 
					 | 
				
			||||||
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef BT_AUDIOCLIENT_H
 | 
					 | 
				
			||||||
#define BT_AUDIOCLIENT_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stdint.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <sys/socket.h>
 | 
					 | 
				
			||||||
#include <sys/un.h>
 | 
					 | 
				
			||||||
#include <errno.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * SBC Codec parameters as per A2DP profile 1.0 § 4.3
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* A2DP seid are 6 bytes long so HSP/HFP are assigned to 7-8 bits */
 | 
					 | 
				
			||||||
#define BT_A2DP_SEID_RANGE			(1 << 6) - 1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BT_A2DP_SBC_SOURCE			0x00
 | 
					 | 
				
			||||||
#define BT_A2DP_SBC_SINK			0x01
 | 
					 | 
				
			||||||
#define BT_A2DP_MPEG12_SOURCE			0x02
 | 
					 | 
				
			||||||
#define BT_A2DP_MPEG12_SINK			0x03
 | 
					 | 
				
			||||||
#define BT_A2DP_MPEG24_SOURCE			0x04
 | 
					 | 
				
			||||||
#define BT_A2DP_MPEG24_SINK			0x05
 | 
					 | 
				
			||||||
#define BT_A2DP_ATRAC_SOURCE			0x06
 | 
					 | 
				
			||||||
#define BT_A2DP_ATRAC_SINK			0x07
 | 
					 | 
				
			||||||
#define BT_A2DP_UNKNOWN_SOURCE			0x08
 | 
					 | 
				
			||||||
#define BT_A2DP_UNKNOWN_SINK			0x09
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BT_SBC_SAMPLING_FREQ_16000		(1 << 3)
 | 
					 | 
				
			||||||
#define BT_SBC_SAMPLING_FREQ_32000		(1 << 2)
 | 
					 | 
				
			||||||
#define BT_SBC_SAMPLING_FREQ_44100		(1 << 1)
 | 
					 | 
				
			||||||
#define BT_SBC_SAMPLING_FREQ_48000		1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BT_A2DP_CHANNEL_MODE_MONO		(1 << 3)
 | 
					 | 
				
			||||||
#define BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL	(1 << 2)
 | 
					 | 
				
			||||||
#define BT_A2DP_CHANNEL_MODE_STEREO		(1 << 1)
 | 
					 | 
				
			||||||
#define BT_A2DP_CHANNEL_MODE_JOINT_STEREO	1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BT_A2DP_BLOCK_LENGTH_4			(1 << 3)
 | 
					 | 
				
			||||||
#define BT_A2DP_BLOCK_LENGTH_8			(1 << 2)
 | 
					 | 
				
			||||||
#define BT_A2DP_BLOCK_LENGTH_12			(1 << 1)
 | 
					 | 
				
			||||||
#define BT_A2DP_BLOCK_LENGTH_16			1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BT_A2DP_SUBBANDS_4			(1 << 1)
 | 
					 | 
				
			||||||
#define BT_A2DP_SUBBANDS_8			1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BT_A2DP_ALLOCATION_SNR			(1 << 1)
 | 
					 | 
				
			||||||
#define BT_A2DP_ALLOCATION_LOUDNESS		1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
	uint8_t seid;
 | 
					 | 
				
			||||||
	uint8_t transport;
 | 
					 | 
				
			||||||
	uint8_t type;
 | 
					 | 
				
			||||||
	uint8_t length;
 | 
					 | 
				
			||||||
	uint8_t configured;
 | 
					 | 
				
			||||||
	uint8_t lock;
 | 
					 | 
				
			||||||
	uint8_t data[0];
 | 
					 | 
				
			||||||
} __attribute__ ((packed)) codec_capabilities_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
	codec_capabilities_t capability;
 | 
					 | 
				
			||||||
	uint8_t channel_mode;
 | 
					 | 
				
			||||||
	uint8_t frequency;
 | 
					 | 
				
			||||||
	uint8_t allocation_method;
 | 
					 | 
				
			||||||
	uint8_t subbands;
 | 
					 | 
				
			||||||
	uint8_t block_length;
 | 
					 | 
				
			||||||
	uint8_t min_bitpool;
 | 
					 | 
				
			||||||
	uint8_t max_bitpool;
 | 
					 | 
				
			||||||
} __attribute__ ((packed)) sbc_capabilities_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
	codec_capabilities_t capability;
 | 
					 | 
				
			||||||
	uint8_t channel_mode;
 | 
					 | 
				
			||||||
	uint8_t crc;
 | 
					 | 
				
			||||||
	uint8_t layer;
 | 
					 | 
				
			||||||
	uint8_t frequency;
 | 
					 | 
				
			||||||
	uint8_t mpf;
 | 
					 | 
				
			||||||
	uint16_t bitrate;
 | 
					 | 
				
			||||||
} __attribute__ ((packed)) mpeg_capabilities_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
	codec_capabilities_t capability;
 | 
					 | 
				
			||||||
	uint8_t flags;
 | 
					 | 
				
			||||||
	uint16_t sampling_rate;
 | 
					 | 
				
			||||||
} __attribute__ ((packed)) pcm_capabilities_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif /* BT_AUDIOCLIENT_H */
 | 
					 | 
				
			||||||
| 
						 | 
					@ -53,7 +53,6 @@
 | 
				
			||||||
#include <sbc/sbc.h>
 | 
					#include <sbc/sbc.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "module-bluetooth-device-symdef.h"
 | 
					#include "module-bluetooth-device-symdef.h"
 | 
				
			||||||
#include "ipc.h"
 | 
					 | 
				
			||||||
#include "a2dp-codecs.h"
 | 
					#include "a2dp-codecs.h"
 | 
				
			||||||
#include "rtp.h"
 | 
					#include "rtp.h"
 | 
				
			||||||
#include "bluetooth-util.h"
 | 
					#include "bluetooth-util.h"
 | 
				
			||||||
| 
						 | 
					@ -105,7 +104,6 @@ static const char* const valid_modargs[] = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct a2dp_info {
 | 
					struct a2dp_info {
 | 
				
			||||||
    sbc_capabilities_t sbc_capabilities;
 | 
					 | 
				
			||||||
    sbc_t sbc;                           /* Codec data */
 | 
					    sbc_t sbc;                           /* Codec data */
 | 
				
			||||||
    pa_bool_t sbc_initialized;           /* Keep track if the encoder is initialized */
 | 
					    pa_bool_t sbc_initialized;           /* Keep track if the encoder is initialized */
 | 
				
			||||||
    size_t codesize, frame_length;       /* SBC Codesize, frame_length. We simply cache those values here */
 | 
					    size_t codesize, frame_length;       /* SBC Codesize, frame_length. We simply cache those values here */
 | 
				
			||||||
| 
						 | 
					@ -119,7 +117,6 @@ struct a2dp_info {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct hsp_info {
 | 
					struct hsp_info {
 | 
				
			||||||
    pcm_capabilities_t pcm_capabilities;
 | 
					 | 
				
			||||||
    pa_sink *sco_sink;
 | 
					    pa_sink *sco_sink;
 | 
				
			||||||
    void (*sco_sink_set_volume)(pa_sink *s);
 | 
					    void (*sco_sink_set_volume)(pa_sink *s);
 | 
				
			||||||
    pa_source *sco_source;
 | 
					    pa_source *sco_source;
 | 
				
			||||||
| 
						 | 
					@ -1877,19 +1874,19 @@ static void bt_transport_config_a2dp(struct userdata *u) {
 | 
				
			||||||
    a2dp->sbc_initialized = TRUE;
 | 
					    a2dp->sbc_initialized = TRUE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (config->frequency) {
 | 
					    switch (config->frequency) {
 | 
				
			||||||
        case BT_SBC_SAMPLING_FREQ_16000:
 | 
					        case SBC_SAMPLING_FREQ_16000:
 | 
				
			||||||
            a2dp->sbc.frequency = SBC_FREQ_16000;
 | 
					            a2dp->sbc.frequency = SBC_FREQ_16000;
 | 
				
			||||||
            u->sample_spec.rate = 16000U;
 | 
					            u->sample_spec.rate = 16000U;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_SBC_SAMPLING_FREQ_32000:
 | 
					        case SBC_SAMPLING_FREQ_32000:
 | 
				
			||||||
            a2dp->sbc.frequency = SBC_FREQ_32000;
 | 
					            a2dp->sbc.frequency = SBC_FREQ_32000;
 | 
				
			||||||
            u->sample_spec.rate = 32000U;
 | 
					            u->sample_spec.rate = 32000U;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_SBC_SAMPLING_FREQ_44100:
 | 
					        case SBC_SAMPLING_FREQ_44100:
 | 
				
			||||||
            a2dp->sbc.frequency = SBC_FREQ_44100;
 | 
					            a2dp->sbc.frequency = SBC_FREQ_44100;
 | 
				
			||||||
            u->sample_spec.rate = 44100U;
 | 
					            u->sample_spec.rate = 44100U;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_SBC_SAMPLING_FREQ_48000:
 | 
					        case SBC_SAMPLING_FREQ_48000:
 | 
				
			||||||
            a2dp->sbc.frequency = SBC_FREQ_48000;
 | 
					            a2dp->sbc.frequency = SBC_FREQ_48000;
 | 
				
			||||||
            u->sample_spec.rate = 48000U;
 | 
					            u->sample_spec.rate = 48000U;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
| 
						 | 
					@ -1898,19 +1895,19 @@ static void bt_transport_config_a2dp(struct userdata *u) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (config->channel_mode) {
 | 
					    switch (config->channel_mode) {
 | 
				
			||||||
        case BT_A2DP_CHANNEL_MODE_MONO:
 | 
					        case SBC_CHANNEL_MODE_MONO:
 | 
				
			||||||
            a2dp->sbc.mode = SBC_MODE_MONO;
 | 
					            a2dp->sbc.mode = SBC_MODE_MONO;
 | 
				
			||||||
            u->sample_spec.channels = 1;
 | 
					            u->sample_spec.channels = 1;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL:
 | 
					        case SBC_CHANNEL_MODE_DUAL_CHANNEL:
 | 
				
			||||||
            a2dp->sbc.mode = SBC_MODE_DUAL_CHANNEL;
 | 
					            a2dp->sbc.mode = SBC_MODE_DUAL_CHANNEL;
 | 
				
			||||||
            u->sample_spec.channels = 2;
 | 
					            u->sample_spec.channels = 2;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_A2DP_CHANNEL_MODE_STEREO:
 | 
					        case SBC_CHANNEL_MODE_STEREO:
 | 
				
			||||||
            a2dp->sbc.mode = SBC_MODE_STEREO;
 | 
					            a2dp->sbc.mode = SBC_MODE_STEREO;
 | 
				
			||||||
            u->sample_spec.channels = 2;
 | 
					            u->sample_spec.channels = 2;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_A2DP_CHANNEL_MODE_JOINT_STEREO:
 | 
					        case SBC_CHANNEL_MODE_JOINT_STEREO:
 | 
				
			||||||
            a2dp->sbc.mode = SBC_MODE_JOINT_STEREO;
 | 
					            a2dp->sbc.mode = SBC_MODE_JOINT_STEREO;
 | 
				
			||||||
            u->sample_spec.channels = 2;
 | 
					            u->sample_spec.channels = 2;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
| 
						 | 
					@ -1919,10 +1916,10 @@ static void bt_transport_config_a2dp(struct userdata *u) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (config->allocation_method) {
 | 
					    switch (config->allocation_method) {
 | 
				
			||||||
        case BT_A2DP_ALLOCATION_SNR:
 | 
					        case SBC_ALLOCATION_SNR:
 | 
				
			||||||
            a2dp->sbc.allocation = SBC_AM_SNR;
 | 
					            a2dp->sbc.allocation = SBC_AM_SNR;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_A2DP_ALLOCATION_LOUDNESS:
 | 
					        case SBC_ALLOCATION_LOUDNESS:
 | 
				
			||||||
            a2dp->sbc.allocation = SBC_AM_LOUDNESS;
 | 
					            a2dp->sbc.allocation = SBC_AM_LOUDNESS;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
| 
						 | 
					@ -1930,10 +1927,10 @@ static void bt_transport_config_a2dp(struct userdata *u) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (config->subbands) {
 | 
					    switch (config->subbands) {
 | 
				
			||||||
        case BT_A2DP_SUBBANDS_4:
 | 
					        case SBC_SUBBANDS_4:
 | 
				
			||||||
            a2dp->sbc.subbands = SBC_SB_4;
 | 
					            a2dp->sbc.subbands = SBC_SB_4;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_A2DP_SUBBANDS_8:
 | 
					        case SBC_SUBBANDS_8:
 | 
				
			||||||
            a2dp->sbc.subbands = SBC_SB_8;
 | 
					            a2dp->sbc.subbands = SBC_SB_8;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
| 
						 | 
					@ -1941,16 +1938,16 @@ static void bt_transport_config_a2dp(struct userdata *u) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (config->block_length) {
 | 
					    switch (config->block_length) {
 | 
				
			||||||
        case BT_A2DP_BLOCK_LENGTH_4:
 | 
					        case SBC_BLOCK_LENGTH_4:
 | 
				
			||||||
            a2dp->sbc.blocks = SBC_BLK_4;
 | 
					            a2dp->sbc.blocks = SBC_BLK_4;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_A2DP_BLOCK_LENGTH_8:
 | 
					        case SBC_BLOCK_LENGTH_8:
 | 
				
			||||||
            a2dp->sbc.blocks = SBC_BLK_8;
 | 
					            a2dp->sbc.blocks = SBC_BLK_8;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_A2DP_BLOCK_LENGTH_12:
 | 
					        case SBC_BLOCK_LENGTH_12:
 | 
				
			||||||
            a2dp->sbc.blocks = SBC_BLK_12;
 | 
					            a2dp->sbc.blocks = SBC_BLK_12;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case BT_A2DP_BLOCK_LENGTH_16:
 | 
					        case SBC_BLOCK_LENGTH_16:
 | 
				
			||||||
            a2dp->sbc.blocks = SBC_BLK_16;
 | 
					            a2dp->sbc.blocks = SBC_BLK_16;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue