mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-05-18 19:25:31 +01:00
update CSpot
This commit is contained in:
@@ -43,7 +43,7 @@ void Player::seekMs(size_t positionMs)
|
||||
// VALGRIND_DO_LEAK_CHECK;
|
||||
}
|
||||
|
||||
void Player::feedPCM(std::vector<uint8_t>& data)
|
||||
void Player::feedPCM(uint8_t *data, size_t len)
|
||||
{
|
||||
// Simple digital volume control alg
|
||||
// @TODO actually extract it somewhere
|
||||
@@ -51,8 +51,8 @@ void Player::feedPCM(std::vector<uint8_t>& data)
|
||||
{
|
||||
int16_t* psample;
|
||||
uint32_t pmax;
|
||||
psample = (int16_t*)(data.data());
|
||||
for (int32_t i = 0; i < (data.size() / 2); i++)
|
||||
psample = (int16_t*)(data);
|
||||
for (int32_t i = 0; i < (len / 2); i++)
|
||||
{
|
||||
int32_t temp;
|
||||
// Offset data for unsigned sinks
|
||||
@@ -68,25 +68,27 @@ void Player::feedPCM(std::vector<uint8_t>& data)
|
||||
}
|
||||
}
|
||||
|
||||
this->audioSink->feedPCMFrames(data.data(), data.size());
|
||||
this->audioSink->feedPCMFrames(data, len);
|
||||
}
|
||||
|
||||
void Player::runTask()
|
||||
{
|
||||
uint8_t *pcmOut = (uint8_t *) malloc(4096 / 4);
|
||||
std::scoped_lock lock(this->runningMutex);
|
||||
this->isRunning = true;
|
||||
while (isRunning)
|
||||
{
|
||||
if (this->trackQueue.wpop(currentTrack)) {
|
||||
currentTrack->audioStream->startPlaybackLoop();
|
||||
currentTrack->audioStream->startPlaybackLoop(pcmOut, 4096 / 4);
|
||||
currentTrack->loadedTrackCallback = nullptr;
|
||||
currentTrack->audioStream->streamFinishedCallback = nullptr;
|
||||
currentTrack->audioStream->audioSink = nullptr;
|
||||
currentTrack->audioStream->pcmCallback = nullptr;
|
||||
} else {
|
||||
//usleep(100000);
|
||||
usleep(100);
|
||||
}
|
||||
}
|
||||
free(pcmOut);
|
||||
}
|
||||
|
||||
void Player::stop() {
|
||||
@@ -115,9 +117,9 @@ void Player::handleLoad(std::shared_ptr<TrackReference> trackReference, std::fun
|
||||
std::lock_guard<std::mutex> guard(loadTrackMutex);
|
||||
cancelCurrentTrack();
|
||||
|
||||
pcmDataCallback framesCallback = [=](std::vector<uint8_t>& frames) {
|
||||
this->feedPCM(frames);
|
||||
};
|
||||
pcmDataCallback framesCallback = [=](uint8_t *frames, size_t len) {
|
||||
this->feedPCM(frames, len);
|
||||
};
|
||||
|
||||
auto loadedLambda = trackLoadedCallback;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user