Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions components/dsp_processor/dsp_processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,13 @@ static inline int16_t float_to_int16_clamped(float value) {
/**
*
*/
int dsp_processor_worker(void *p_pcmChnk, const void *p_scSet) {
int dsp_processor_worker(char *pcmChnk, uint16_t len, uint32_t samplerate, int ch) {
ESP_LOGV(TAG, "%s: processing audio chunk", __func__);
const snapcastSetting_t *scSet = (const snapcastSetting_t *)p_scSet;
pcm_chunk_message_t *pcmChnk = (pcm_chunk_message_t *)p_pcmChnk;
uint32_t samplerate = scSet->sr;

if (!pcmChnk || !pcmChnk->fragment->payload) {
if (!pcmChnk) {
return -1;
}

int bits = scSet->bits;
int ch = scSet->ch;

if (bits == 0) {
bits = 16;
}

if (ch == 0) {
ch = 2;
}
Expand All @@ -285,12 +275,11 @@ int dsp_processor_worker(void *p_pcmChnk, const void *p_scSet) {
ESP_LOGW(TAG, "%s: Sample rate is not set, using default: %lu", __func__, (unsigned long)samplerate);
}

int16_t len = pcmChnk->fragment->size / ((bits / 8) * ch);
int16_t valint;
uint16_t i;
// volatile needed to ensure 32 bit access
volatile uint32_t *audio_tmp =
(volatile uint32_t *)(pcmChnk->fragment->payload);
(volatile uint32_t *)(pcmChnk);

// Local working copy of filter parameters
static filterParams_t currentFilterParams = {0};
Expand Down
2 changes: 1 addition & 1 deletion components/dsp_processor/include/dsp_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum filtertypes {

void dsp_processor_init(void);
void dsp_processor_uninit(void);
int dsp_processor_worker(void *pcmChnk, const void *scSet);
int dsp_processor_worker(char *pcmChnk, uint16_t len, uint32_t samplerate, int ch);
esp_err_t dsp_processor_update_filter_params(filterParams_t *params);

void dsp_processor_set_volome(double volume);
Expand Down
27 changes: 10 additions & 17 deletions components/lightsnapcast/include/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,20 @@ typedef struct pcmData {

typedef enum codec_type_e { NONE = 0, PCM, FLAC, OGG, OPUS } codec_type_t;

typedef struct snapcastSetting_s {
uint32_t buf_ms;
uint32_t chkInFrames;
int32_t cDacLat_ms;

codec_type_t codec;
typedef struct playerSetting_s {
uint16_t buf_ms;
uint16_t chkInFrames;
int16_t cDacLat_ms;
int32_t sr;
uint8_t ch;
i2s_data_bit_width_t bits;
} playerSetting_t;

bool muted;
uint32_t volume;

char *pcmBuf;
uint32_t pcmBufSize;
} snapcastSetting_t;

int init_player(i2s_std_gpio_config_t pin_config0_, i2s_port_t i2sNum_);
int init_player(i2s_std_gpio_config_t pin_config0_, i2s_port_t i2sNum_, void (*set_mute_cb)(bool), void (*cb)(bool), bool (*lock)(bool, TickType_t));
int deinit_player(void);
int start_player(snapcastSetting_t *setting);
int start_player(void);
void pause_player(bool pause);
void stop_player_task(void);

int32_t allocate_pcm_chunk_memory(pcm_chunk_message_t **pcmChunk, size_t bytes);
int32_t insert_pcm_chunk(pcm_chunk_message_t *pcmChunk);
Expand All @@ -87,8 +81,7 @@ int32_t player_latency_insert(int64_t newValue);
int32_t get_diff_to_server(int64_t *tDiff, int64_t now);
int32_t latency_buffer_full(bool *is_full);

int32_t player_send_snapcast_setting(snapcastSetting_t *setting);
int8_t player_get_snapcast_settings(snapcastSetting_t *setting);
int32_t player_send_snapcast_setting(playerSetting_t *setting);

int32_t reset_latency_buffer(void);

Expand Down
Loading
Loading