Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-bluetooth-sbc: Commit

external/bluetooth/sbc


Commit MetaInfo

Révision6e079c0287c81f91d76828f57d1154958a9f1989 (tree)
l'heure2014-01-23 21:19:42
AuteurLuiz Augusto von Dentz <luiz.von.dentz@inte...>
CommiterLuiz Augusto von Dentz

Message de Log

sbc: Add sbc_reinit_a2dp

This adds sbc_reinit_a2dp that can be used to reconfigure a previous
initialized sbc_t with new A2DP configuration.

Change Summary

Modification

--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -1087,19 +1087,14 @@ SBC_EXPORT int sbc_init_msbc(sbc_t *sbc, unsigned long flags)
10871087 return 0;
10881088 }
10891089
1090-SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
1090+static int sbc_set_a2dp(sbc_t *sbc, unsigned long flags,
10911091 const void *conf, size_t conf_len)
10921092 {
10931093 const struct a2dp_sbc *a2dp;
1094- int err;
10951094
10961095 if (conf_len != sizeof(*a2dp))
10971096 return -EINVAL;
10981097
1099- err = sbc_init(sbc, flags);
1100- if (err < 0)
1101- return err;
1102-
11031098 a2dp = conf;
11041099
11051100 switch (a2dp->frequency) {
@@ -1116,7 +1111,7 @@ SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
11161111 sbc->frequency = SBC_FREQ_48000;
11171112 break;
11181113 default:
1119- goto failed;
1114+ return -EINVAL;
11201115 }
11211116
11221117 switch (a2dp->channel_mode) {
@@ -1133,7 +1128,7 @@ SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
11331128 sbc->mode = SBC_MODE_JOINT_STEREO;
11341129 break;
11351130 default:
1136- goto failed;
1131+ return -EINVAL;
11371132 }
11381133
11391134 switch (a2dp->allocation_method) {
@@ -1144,7 +1139,7 @@ SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
11441139 sbc->allocation = SBC_AM_LOUDNESS;
11451140 break;
11461141 default:
1147- goto failed;
1142+ return -EINVAL;
11481143 }
11491144
11501145 switch (a2dp->subbands) {
@@ -1155,7 +1150,7 @@ SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
11551150 sbc->subbands = SBC_SB_8;
11561151 break;
11571152 default:
1158- goto failed;
1153+ return -EINVAL;
11591154 }
11601155
11611156 switch (a2dp->block_length) {
@@ -1172,14 +1167,40 @@ SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
11721167 sbc->blocks = SBC_BLK_16;
11731168 break;
11741169 default:
1175- goto failed;
1170+ return -EINVAL;
1171+ }
1172+
1173+ return 0;
1174+}
1175+
1176+SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
1177+ const void *conf, size_t conf_len)
1178+{
1179+ int err;
1180+
1181+ err = sbc_init(sbc, flags);
1182+ if (err < 0)
1183+ return err;
1184+
1185+ err = sbc_set_a2dp(sbc, flags, conf, conf_len);
1186+ if (err < 0) {
1187+ sbc_finish(sbc);
1188+ return err;
11761189 }
11771190
11781191 return 0;
1192+}
1193+
1194+int sbc_reinit_a2dp(sbc_t *sbc, unsigned long flags,
1195+ const void *conf, size_t conf_len)
1196+{
1197+ int err;
1198+
1199+ err = sbc_reinit(sbc, flags);
1200+ if (err < 0)
1201+ return err;
11791202
1180-failed:
1181- sbc_finish(sbc);
1182- return -EINVAL;
1203+ return sbc_set_a2dp(sbc, flags, conf, conf_len);
11831204 }
11841205
11851206 SBC_EXPORT ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len)
--- a/sbc/sbc.h
+++ b/sbc/sbc.h
@@ -87,6 +87,8 @@ int sbc_reinit(sbc_t *sbc, unsigned long flags);
8787 int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
8888 int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
8989 const void *conf, size_t conf_len);
90+int sbc_reinit_a2dp(sbc_t *sbc, unsigned long flags,
91+ const void *conf, size_t conf_len);
9092
9193 ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
9294
Afficher sur ancien navigateur de dépôt.