mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 20:17:04 +03:00
add mono channel option - release
This commit is contained in:
@@ -254,6 +254,9 @@ frames_t _output_frames(frames_t avail) {
|
||||
|
||||
out_frames = !silence ? min(size, cont_frames) : size;
|
||||
|
||||
if (output.channels & 0x01) gainR = MONO_MUTED;
|
||||
else if (output.channels & 0x02) gainL = MONO_MUTED;
|
||||
|
||||
wrote = output.write_cb(out_frames, silence, gainL, gainR, cross_gain_in, cross_gain_out, &cross_ptr);
|
||||
|
||||
if (wrote <= 0) {
|
||||
|
||||
@@ -90,9 +90,7 @@ static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t g
|
||||
_apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out, cross_ptr);
|
||||
}
|
||||
|
||||
if (gainL != FIXED_ONE || gainR!= FIXED_ONE) {
|
||||
_apply_gain(outputbuf, out_frames, gainL, gainR);
|
||||
}
|
||||
|
||||
#if BYTES_PER_FRAME == 4
|
||||
memcpy(btout + oframes * BYTES_PER_FRAME, outputbuf->readp, out_frames * BYTES_PER_FRAME);
|
||||
|
||||
@@ -410,10 +410,7 @@ static int _i2s_write_frames(frames_t out_frames, bool silence, s32_t gainL, s32
|
||||
}
|
||||
|
||||
#if BYTES_PER_FRAME == 4
|
||||
if (gainL != FIXED_ONE || gainR!= FIXED_ONE) {
|
||||
_apply_gain(outputbuf, out_frames, gainL, gainR);
|
||||
}
|
||||
|
||||
memcpy(obuf + oframes * BYTES_PER_FRAME, outputbuf->readp, out_frames * BYTES_PER_FRAME);
|
||||
#else
|
||||
optr = (s32_t*) outputbuf->readp;
|
||||
|
||||
@@ -356,17 +356,34 @@ void _apply_cross(struct buffer *outputbuf, frames_t out_frames, s32_t cross_gai
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if !WIN
|
||||
inline
|
||||
#endif
|
||||
void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR) {
|
||||
if (gainL == FIXED_ONE && gainR == FIXED_ONE) {
|
||||
return;
|
||||
} else if (gainL == MONO_MUTED) {
|
||||
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
|
||||
while (count--) {
|
||||
*(ptr - 1) = *ptr = gain(gainR, *ptr);
|
||||
ptr += 2;
|
||||
}
|
||||
} else if (gainR == MONO_MUTED) {
|
||||
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp;
|
||||
while (count--) {
|
||||
*(ptr + 1) = *ptr = gain(gainL, *ptr);
|
||||
ptr += 2;
|
||||
}
|
||||
} else {
|
||||
ISAMPLE_T *ptrL = (ISAMPLE_T *)(void *)outputbuf->readp;
|
||||
ISAMPLE_T *ptrR = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
|
||||
while (count--) {
|
||||
*ptrL = gain(gainL, *ptrL);
|
||||
*ptrR = gain(gainR, *ptrR);
|
||||
ptrL += 2;
|
||||
ptrR += 2;
|
||||
ptrL += 2; ptrR += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -398,7 +398,8 @@ static void process_strm(u8_t *pkt, int len) {
|
||||
output.fade_mode = strm->transition_type - '0';
|
||||
output.fade_secs = strm->transition_period;
|
||||
output.invert = (strm->flags & 0x03) == 0x03;
|
||||
LOG_DEBUG("set fade mode: %u", output.fade_mode);
|
||||
output.channels = (strm->flags & 0x0c) >> 2;
|
||||
LOG_DEBUG("set fade: %u, channels: %u, invert: %u", output.fade_mode, output.channels, output.invert);
|
||||
UNLOCK_O;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -472,6 +472,7 @@ void _wake_create(event_event*);
|
||||
#define MAX_SILENCE_FRAMES 2048
|
||||
|
||||
#define FIXED_ONE 0x10000
|
||||
#define MONO_MUTED (FIXED_ONE + 1)
|
||||
|
||||
#ifndef BYTES_PER_FRAME
|
||||
#define BYTES_PER_FRAME 8
|
||||
@@ -660,6 +661,7 @@ typedef enum { FADE_NONE = 0, FADE_CROSSFADE, FADE_IN, FADE_OUT, FADE_INOUT } fa
|
||||
struct outputstate {
|
||||
output_state state;
|
||||
output_format format;
|
||||
u8_t channels;
|
||||
const char *device;
|
||||
int external;
|
||||
u32_t init_size;
|
||||
|
||||
@@ -521,19 +521,16 @@ void stream_sock(u32_t ip, u16_t port, const char *header, size_t header_len, un
|
||||
|
||||
#if USE_SSL
|
||||
if (ntohs(port) == 443) {
|
||||
char *server = strcasestr(header, "Host:");
|
||||
char server[256], *p;
|
||||
|
||||
ssl = SSL_new(SSLctx);
|
||||
SSL_set_fd(ssl, sock);
|
||||
|
||||
// add SNI
|
||||
sscanf(header, "Host:%255s", server);
|
||||
if (server) {
|
||||
char *p, *servername = malloc(1024);
|
||||
|
||||
sscanf(server, "Host:%255[^:]s", servername);
|
||||
for (p = servername; *p == ' '; p++);
|
||||
SSL_set_tlsext_host_name(ssl, p);
|
||||
free(servername);
|
||||
if ((p = strchr(server, ':')) != NULL) *p = '\0';
|
||||
SSL_set_tlsext_host_name(ssl, server);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
||||
Reference in New Issue
Block a user