update CSpot + clear audio buffer when changing track

This commit is contained in:
philippe44
2022-08-23 17:06:59 -07:00
parent 36f18fc069
commit 0222dbd6de
22 changed files with 383 additions and 93 deletions

View File

@@ -115,6 +115,7 @@ std::shared_ptr<AudioChunk> MercuryManager::fetchAudioChunk(std::vector<uint8_t>
this->session->shanConn->sendPacket(static_cast<uint8_t>(MercuryType::AUDIO_CHUNK_REQUEST_COMMAND), buffer);
// Used for broken connection detection
CSPOT_LOG(info, "requesting Chunk %hu", this->audioChunkSequence - 1);
this->lastRequestTimestamp = this->timeProvider->getSyncedTimestamp();
return this->audioChunkManager->registerNewChunk(this->audioChunkSequence - 1, audioKey, startPos, endPos);
}
@@ -208,16 +209,19 @@ void MercuryManager::updateQueue() {
if (queueSemaphore->twait() == 0) {
if (this->queue.size() > 0)
{
auto packet = std::move(this->queue[0]);
std::unique_ptr<Packet> packet = std::move(this->queue[0]);
this->queue.erase(this->queue.begin());
if(packet == nullptr){
return;
}
CSPOT_LOG(debug, "Received packet with code %d of length %d", packet->command, packet->data.size());
switch (static_cast<MercuryType>(packet->command))
{
case MercuryType::COUNTRY_CODE_RESPONSE:
{
countryCode = std::string(packet->data.begin(), packet->data.end());
CSPOT_LOG(debug, "Received country code: %s", countryCode.c_str());
memcpy(countryCode, packet->data.data(), 2);
CSPOT_LOG(debug, "Received country code: %.2s", countryCode);
break;
}
case MercuryType::AUDIO_KEY_FAILURE_RESPONSE: