diff options
| author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-08-29 21:35:39 +0000 | 
|---|---|---|
| committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-08-29 21:35:39 +0000 | 
| commit | 41b71b230e0aa4b495c091e7d17c6b939ddbce79 (patch) | |
| tree | 171620f6b798d846824be31bbfcfedaba8efb87b | |
| parent | 87bb7258bdf221195d010b0e03cda7cd7c0195b9 (diff) | |
Fix the need to have all parameters.
| -rw-r--r-- | audio/a2dp.c | 6 | ||||
| -rw-r--r-- | audio/pcm_bluetooth.c | 27 | ||||
| -rw-r--r-- | audio/unix.c | 35 | 
3 files changed, 25 insertions, 43 deletions
| diff --git a/audio/a2dp.c b/audio/a2dp.c index 5ecd8159..43b32ada 100644 --- a/audio/a2dp.c +++ b/audio/a2dp.c @@ -252,20 +252,20 @@ static gboolean a2dp_select_capabilities(struct avdtp_remote_sep *rsep,  						GSList **caps)  {  	struct avdtp_service_capability *media_transport, *media_codec; -	struct sbc_codec_cap sbc_cap; +	struct sbc_codec_cap sbc_cap, *acp_sbc;  	if (!setup)  		return FALSE;  	if (setup->media_codec) -		memcpy(&sbc_cap, setup->media_codec->data, sizeof(sbc_cap)); +		memcpy(&sbc_cap, setup->media_codec->data, sizeof(*acp_sbc));  	else {  		media_codec = avdtp_get_codec(rsep);  		if (!media_codec)  			return FALSE;  		select_sbc_params(&sbc_cap, -				(struct sbc_codec_cap *) media_codec->data); +			(struct sbc_codec_cap *) media_codec->data);  	}  	media_transport = avdtp_service_cap_new(AVDTP_MEDIA_TRANSPORT, diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c index c6dc0931..8ba18464 100644 --- a/audio/pcm_bluetooth.c +++ b/audio/pcm_bluetooth.c @@ -898,8 +898,10 @@ static int bluetooth_cfg_init(struct ipc_packet *pkt, snd_config_t *conf)  	struct ipc_data_cfg *cfg = (void *) pkt->data;  	struct ipc_codec_sbc *sbc = (void *) cfg->data;  	snd_config_iterator_t i, next; -	const char *addr, *pref, *mode, *allocation, *rate, *channels, -		*subbands, *blocks, *bitpool; +	const char *addr, *pref, *mode, *allocation, *rate, *subbands, +		*blocks, *bitpool; + +	cfg->channels = 2;  	snd_config_for_each(i, next, conf) {  		snd_config_t *n = snd_config_iterator_entry(i); @@ -930,8 +932,10 @@ static int bluetooth_cfg_init(struct ipc_packet *pkt, snd_config_t *conf)  			if (strcmp(pref, "auto") == 0)  				pkt->role = PKT_ROLE_AUTO;  			else if (strcmp(pref, "voice") == 0 || -						strcmp(pref, "hfp") == 0) +						strcmp(pref, "hfp") == 0) {  				pkt->role = PKT_ROLE_VOICE; +				cfg->channels = 1; +			}  			else if (strcmp(pref, "hifi") == 0 ||  						strcmp(pref, "a2dp") == 0)  				pkt->role = PKT_ROLE_HIFI; @@ -948,30 +952,23 @@ static int bluetooth_cfg_init(struct ipc_packet *pkt, snd_config_t *conf)  			continue;  		} -		if (strcmp(id, "channels") == 0) { -			if (snd_config_get_string(n, &channels) < 0) { -				SNDERR("Invalid type for %s", id); -				return -EINVAL; -			} - -			cfg->channels = strtod(channels, NULL); -			continue; -		} - -		if (strcmp(id, "channel_mode") == 0) { +		if (strcmp(id, "mode") == 0) {  			if (snd_config_get_string(n, &mode) < 0) {  				SNDERR("Invalid type for %s", id);  				return -EINVAL;  			} -			if (strcmp(pref, "mono") == 0) +			if (strcmp(pref, "mono") == 0) { +				cfg->channels = 1;  				cfg->channel_mode = CFG_CHANNEL_MODE_MONO; +			}  			else if (strcmp(pref, "dual") == 0)  				cfg->channel_mode = CFG_CHANNEL_MODE_DUAL_CHANNEL;  			else if (strcmp(pref, "stereo") == 0)  				cfg->channel_mode = CFG_CHANNEL_MODE_STEREO;  			else if (strcmp(pref, "joint") == 0)  				cfg->channel_mode = CFG_CHANNEL_MODE_JOINT_STEREO; +  			continue;  		} diff --git a/audio/unix.c b/audio/unix.c index ef8d6673..6239c203 100644 --- a/audio/unix.c +++ b/audio/unix.c @@ -469,12 +469,8 @@ static int cfg_to_caps(struct ipc_data_cfg *cfg, struct sbc_codec_cap *sbc_cap)  		default:  			return -EINVAL;  		} -	} else { -		sbc_cap->frequency = ( A2DP_SAMPLING_FREQ_48000 | -					A2DP_SAMPLING_FREQ_44100 | -					A2DP_SAMPLING_FREQ_32000 | -					A2DP_SAMPLING_FREQ_16000 ); -	} +	} else +		sbc_cap->frequency = A2DP_SAMPLING_FREQ_44100;  	if (cfg->channel_mode > 0) {  		switch (cfg->channel_mode) { @@ -487,12 +483,8 @@ static int cfg_to_caps(struct ipc_data_cfg *cfg, struct sbc_codec_cap *sbc_cap)  		default:  			return -EINVAL;  		} -	} else { -		sbc_cap->channel_mode = ( A2DP_CHANNEL_MODE_JOINT_STEREO | -					A2DP_CHANNEL_MODE_STEREO | -					A2DP_CHANNEL_MODE_DUAL_CHANNEL | -					A2DP_CHANNEL_MODE_MONO ); -	} +	} else +		sbc_cap->channel_mode = A2DP_CHANNEL_MODE_JOINT_STEREO;  	if (sbc->allocation > 0) {  		switch (sbc->allocation) { @@ -504,8 +496,7 @@ static int cfg_to_caps(struct ipc_data_cfg *cfg, struct sbc_codec_cap *sbc_cap)  			return -EINVAL;  		}  	} else -		sbc_cap->allocation_method = ( A2DP_ALLOCATION_LOUDNESS | -						A2DP_ALLOCATION_SNR ); +		sbc_cap->allocation_method = A2DP_ALLOCATION_LOUDNESS;  	if (sbc->subbands > 0) {  		switch (sbc->subbands) { @@ -519,7 +510,7 @@ static int cfg_to_caps(struct ipc_data_cfg *cfg, struct sbc_codec_cap *sbc_cap)  			return -EINVAL;  		}  	} else -		sbc_cap->subbands = ( A2DP_SUBBANDS_8 | A2DP_SUBBANDS_4 ); +		sbc_cap->subbands = A2DP_SUBBANDS_8;  	if (sbc->blocks > 0) {  		switch (sbc->blocks) { @@ -538,21 +529,15 @@ static int cfg_to_caps(struct ipc_data_cfg *cfg, struct sbc_codec_cap *sbc_cap)  		default:  			return -EINVAL;  		} -	} else { -		sbc_cap->block_length = ( A2DP_BLOCK_LENGTH_16 | -					A2DP_BLOCK_LENGTH_12 | -					A2DP_BLOCK_LENGTH_8 | -					A2DP_BLOCK_LENGTH_4 ); -	} +	} else +		sbc_cap->block_length = A2DP_BLOCK_LENGTH_16;  	if (sbc->bitpool > 250)  		return -EINVAL;  	else if (sbc->bitpool > 0)  		sbc_cap->min_bitpool = sbc_cap->max_bitpool = sbc->bitpool; -	else { -		sbc_cap->min_bitpool = 2; -		sbc_cap->max_bitpool = 250; -	} +	else +		sbc_cap->min_bitpool = 53;  	return 0;  } | 
