mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-01-30 06:10:54 +03:00
fix another ancient bug with sync start time (visible with AirPlay and SPDIF, but impacts all)
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
#include "log_util.h"
|
#include "log_util.h"
|
||||||
|
|
||||||
#define RTSP_STACK_SIZE (8*1024)
|
#define RTSP_STACK_SIZE (8*1024)
|
||||||
#define SEARCH_STACK_SIZE (3*1048)
|
#define SEARCH_STACK_SIZE (3*1024)
|
||||||
|
|
||||||
typedef struct raop_ctx_s {
|
typedef struct raop_ctx_s {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|||||||
@@ -539,13 +539,11 @@ static void output_thread_i2s(void *arg) {
|
|||||||
output.frames_played_dmp = output.frames_played;
|
output.frames_played_dmp = output.frames_played;
|
||||||
// try to estimate how much we have consumed from the DMA buffer (calculation is incorrect at the very beginning ...)
|
// try to estimate how much we have consumed from the DMA buffer (calculation is incorrect at the very beginning ...)
|
||||||
output.device_frames = dma_buf_frames - ((output.updated - fullness) * output.current_sample_rate) / 1000;
|
output.device_frames = dma_buf_frames - ((output.updated - fullness) * output.current_sample_rate) / 1000;
|
||||||
|
// we'll try to produce iframes if we have any, but we might return less if outpuf does not have enough
|
||||||
_output_frames( iframes );
|
_output_frames( iframes );
|
||||||
// oframes must be a global updated by the write callback
|
// oframes must be a global updated by the write callback
|
||||||
output.frames_in_process = oframes;
|
output.frames_in_process = oframes;
|
||||||
|
|
||||||
// force some sin
|
|
||||||
//memcpy(obuf, __obuf, oframes*BYTES_PER_FRAME);
|
|
||||||
|
|
||||||
SET_MIN_MAX_SIZED(oframes,rec,iframes);
|
SET_MIN_MAX_SIZED(oframes,rec,iframes);
|
||||||
SET_MIN_MAX_SIZED(_buf_used(outputbuf),o,outputbuf->size);
|
SET_MIN_MAX_SIZED(_buf_used(outputbuf),o,outputbuf->size);
|
||||||
SET_MIN_MAX_SIZED(_buf_used(streambuf),s,streambuf->size);
|
SET_MIN_MAX_SIZED(_buf_used(streambuf),s,streambuf->size);
|
||||||
@@ -558,12 +556,12 @@ static void output_thread_i2s(void *arg) {
|
|||||||
discard = output.frames_played_dmp ? 0 : output.device_frames;
|
discard = output.frames_played_dmp ? 0 : output.device_frames;
|
||||||
synced = true;
|
synced = true;
|
||||||
} else if (discard) {
|
} else if (discard) {
|
||||||
discard -= oframes;
|
discard -= min(oframes, discard);
|
||||||
iframes = discard ? min(FRAME_BLOCK, discard) : FRAME_BLOCK;
|
iframes = discard ? min(FRAME_BLOCK, discard) : FRAME_BLOCK;
|
||||||
UNLOCK;
|
UNLOCK;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNLOCK;
|
UNLOCK;
|
||||||
|
|
||||||
// now send all the data
|
// now send all the data
|
||||||
@@ -576,7 +574,7 @@ static void output_thread_i2s(void *arg) {
|
|||||||
i2s_start(CONFIG_I2S_NUM);
|
i2s_start(CONFIG_I2S_NUM);
|
||||||
adac->power(ADAC_ON);
|
adac->power(ADAC_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this does not work well as set_sample_rates resets the fifos (and it's too early)
|
// this does not work well as set_sample_rates resets the fifos (and it's too early)
|
||||||
if (i2s_config.sample_rate != output.current_sample_rate) {
|
if (i2s_config.sample_rate != output.current_sample_rate) {
|
||||||
LOG_INFO("changing sampling rate %u to %u", i2s_config.sample_rate, output.current_sample_rate);
|
LOG_INFO("changing sampling rate %u to %u", i2s_config.sample_rate, output.current_sample_rate);
|
||||||
@@ -608,7 +606,7 @@ static void output_thread_i2s(void *arg) {
|
|||||||
i2s_write(CONFIG_I2S_NUM, spdif.buf, chunk * 16, &obytes, portMAX_DELAY);
|
i2s_write(CONFIG_I2S_NUM, spdif.buf, chunk * 16, &obytes, portMAX_DELAY);
|
||||||
bytes += obytes / (16 / BYTES_PER_FRAME);
|
bytes += obytes / (16 / BYTES_PER_FRAME);
|
||||||
count += chunk;
|
count += chunk;
|
||||||
}
|
}
|
||||||
#if BYTES_PER_FRAME == 4
|
#if BYTES_PER_FRAME == 4
|
||||||
} else if (i2s_config.bits_per_sample == 32) {
|
} else if (i2s_config.bits_per_sample == 32) {
|
||||||
i2s_write_expand(CONFIG_I2S_NUM, obuf, oframes * BYTES_PER_FRAME, 16, 32, &bytes, portMAX_DELAY);
|
i2s_write_expand(CONFIG_I2S_NUM, obuf, oframes * BYTES_PER_FRAME, 16, 32, &bytes, portMAX_DELAY);
|
||||||
|
|||||||
Reference in New Issue
Block a user