40 return ctx !=
nullptr;
45 bool dropped = aptx_decode_sync_finish(
ctx);
52 operator bool() {
return ctx !=
nullptr; }
54 virtual size_t write(
const uint8_t *data,
size_t len) {
55 LOGI(
"write: %d", len);
69 processed = aptx_decode_sync(
ctx, (
const uint8_t *)data, len,
84 return is_ok ? len : 0;
88 struct aptx_context *
ctx =
nullptr;
102 LOGI(
"samples: %d", samples);
105 for (
int j = 0; j < samples; j++) {
111 LOGE(
"aptX decoding failed to write decoded data");
118 void checkSync(
bool synced,
bool dropped,
bool &is_ok) {
122 LOGE(
"aptX decoding failed, synchronizing");
127 LOGE(
"aptX synchronization successful, dropped %lu byte%s",
128 (
unsigned long)dropped, (dropped != 1) ?
"s" :
"");
133 LOGE(
"aptX decoding failed, synchronizing");
139 if (!
syncing)
LOGE(
"aptX decoding failed, synchronizing");
140 LOGE(
"aptX synchronization successful, dropped %lu byte%s",
141 (
unsigned long)dropped, (dropped != 1) ?
"s" :
"");
145 LOGI(
"aptX synchronization successful");
155 if (length >= 4 && memcmp(input_buffer,
"\x4b\xbf\x4b\xbf", 4) == 0) {
157 LOGE(
"aptX audio stream (not aptX HD)");
160 }
else if (length >= 6 &&
161 memcmp(input_buffer,
"\x73\xbe\xff\x73\xbe\xff", 6) == 0) {
163 LOGE(
"aptX HD audio stream");
167 if (length >= 4 && memcmp(input_buffer,
"\x6b\xbf\x6b\xbf", 4) == 0) {
168 LOGE(
"standard aptX audio stream - not supported");
171 LOGE(
"No aptX nor aptX HD audio stream");
203 LOGI(
"is_hd: %s",
is_hd ?
"true" :
"false");
210 if (
ctx !=
nullptr) {
211 size_t output_written = 0;
214 if (output_written > 0) {
218 if (written != output_written) {
219 LOGE(
"write requested: %d eff: %d", output_written, written);
227 virtual const char *
mime() {
return "audio/aptx"; }
245 operator bool() {
return ctx !=
nullptr; }
247 virtual size_t write(
const uint8_t *data,
size_t len) {
248 LOGI(
"write: %d", len);
249 if (
ctx ==
nullptr)
return 0;
250 size_t output_written = 0;
253 int16_t *in_ptr16 = (int16_t *)data;
254 int in_samples = len / 2;
255 for (
int j = 0; j < in_samples; j++) {
260 size_t result = aptx_encode(
297 struct aptx_context *
ctx =
nullptr;
#define LOGW(...)
Definition AudioLoggerIDF.h:29
#define TRACEI()
Definition AudioLoggerIDF.h:32
#define LOGI(...)
Definition AudioLoggerIDF.h:28
#define LOGE(...)
Definition AudioLoggerIDF.h:30
virtual size_t write(const uint8_t *data, size_t len)
Definition Arduino.h:120