A2DP: scanAsyncDone & scanAsyncResults; fix write and availableForWrite (#2839)

This commit is contained in:
InfiniteCoder 2025-03-06 21:55:56 +03:00 committed by GitHub
parent 5bfc35caf5
commit 5bd1a3a0f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -223,7 +223,7 @@ size_t A2DPSource::write(const uint8_t *buffer, size_t size) {
size = std::min((size_t)availableForWrite(), size);
size_t count = 0;
size /= 2;
size /= sizeof(int16_t); // Convert size to samples
// First copy from writer to either end of
uint32_t start = _pcmWriter;
@ -262,7 +262,7 @@ int A2DPSource::availableForWrite() {
} else {
avail = _pcmBufferSize - _pcmWriter + _pcmReader - 1;
}
avail /= sizeof(uint32_t); // availableForWrite always 32b sample pairs in this core...
avail *= sizeof(int16_t); // Convert samples to bytes
return avail;
}

View file

@ -125,6 +125,14 @@ public:
return _hci.scan(mask, scanTimeSec, async);
}
bool scanAsyncDone() {
return _hci.scanAsyncDone();
}
std::vector<BTDeviceInfo> scanAsyncResult() {
return _hci.scanAsyncResult();
}
bool connect(const uint8_t *addr = nullptr);
bool connected() {
@ -151,6 +159,7 @@ public:
}
// from Print (see notes on write() methods below)
// Writes only full samples (size must be divisible by sample size in bytes)
virtual size_t write(const uint8_t *buffer, size_t size) override;
virtual int availableForWrite() override;