mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 13:07:03 +03:00
add mono channel option - release
This commit is contained in:
@@ -253,6 +253,9 @@ frames_t _output_frames(frames_t avail) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
out_frames = !silence ? min(size, cont_frames) : size;
|
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);
|
wrote = output.write_cb(out_frames, silence, gainL, gainR, cross_gain_in, cross_gain_out, &cross_ptr);
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
_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);
|
||||||
_apply_gain(outputbuf, out_frames, gainL, gainR);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if BYTES_PER_FRAME == 4
|
#if BYTES_PER_FRAME == 4
|
||||||
memcpy(btout + oframes * BYTES_PER_FRAME, outputbuf->readp, out_frames * BYTES_PER_FRAME);
|
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 BYTES_PER_FRAME == 4
|
||||||
if (gainL != FIXED_ONE || gainR!= FIXED_ONE) {
|
_apply_gain(outputbuf, out_frames, gainL, gainR);
|
||||||
_apply_gain(outputbuf, out_frames, gainL, gainR);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(obuf + oframes * BYTES_PER_FRAME, outputbuf->readp, out_frames * BYTES_PER_FRAME);
|
memcpy(obuf + oframes * BYTES_PER_FRAME, outputbuf->readp, out_frames * BYTES_PER_FRAME);
|
||||||
#else
|
#else
|
||||||
optr = (s32_t*) outputbuf->readp;
|
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
|
#if !WIN
|
||||||
inline
|
inline
|
||||||
#endif
|
#endif
|
||||||
void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR) {
|
void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR) {
|
||||||
ISAMPLE_T *ptrL = (ISAMPLE_T *)(void *)outputbuf->readp;
|
if (gainL == FIXED_ONE && gainR == FIXED_ONE) {
|
||||||
ISAMPLE_T *ptrR = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
|
return;
|
||||||
while (count--) {
|
} else if (gainL == MONO_MUTED) {
|
||||||
*ptrL = gain(gainL, *ptrL);
|
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
|
||||||
*ptrR = gain(gainR, *ptrR);
|
while (count--) {
|
||||||
ptrL += 2;
|
*(ptr - 1) = *ptr = gain(gainR, *ptr);
|
||||||
ptrR += 2;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -397,8 +397,9 @@ static void process_strm(u8_t *pkt, int len) {
|
|||||||
output.next_replay_gain = unpackN(&strm->replay_gain);
|
output.next_replay_gain = unpackN(&strm->replay_gain);
|
||||||
output.fade_mode = strm->transition_type - '0';
|
output.fade_mode = strm->transition_type - '0';
|
||||||
output.fade_secs = strm->transition_period;
|
output.fade_secs = strm->transition_period;
|
||||||
output.invert = (strm->flags & 0x03) == 0x03;
|
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;
|
UNLOCK_O;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -471,7 +471,8 @@ void _wake_create(event_event*);
|
|||||||
|
|
||||||
#define MAX_SILENCE_FRAMES 2048
|
#define MAX_SILENCE_FRAMES 2048
|
||||||
|
|
||||||
#define FIXED_ONE 0x10000
|
#define FIXED_ONE 0x10000
|
||||||
|
#define MONO_MUTED (FIXED_ONE + 1)
|
||||||
|
|
||||||
#ifndef BYTES_PER_FRAME
|
#ifndef BYTES_PER_FRAME
|
||||||
#define BYTES_PER_FRAME 8
|
#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 {
|
struct outputstate {
|
||||||
output_state state;
|
output_state state;
|
||||||
output_format format;
|
output_format format;
|
||||||
|
u8_t channels;
|
||||||
const char *device;
|
const char *device;
|
||||||
int external;
|
int external;
|
||||||
u32_t init_size;
|
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 USE_SSL
|
||||||
if (ntohs(port) == 443) {
|
if (ntohs(port) == 443) {
|
||||||
char *server = strcasestr(header, "Host:");
|
char server[256], *p;
|
||||||
|
|
||||||
ssl = SSL_new(SSLctx);
|
ssl = SSL_new(SSLctx);
|
||||||
SSL_set_fd(ssl, sock);
|
SSL_set_fd(ssl, sock);
|
||||||
|
|
||||||
// add SNI
|
// add SNI
|
||||||
|
sscanf(header, "Host:%255s", server);
|
||||||
if (server) {
|
if (server) {
|
||||||
char *p, *servername = malloc(1024);
|
if ((p = strchr(server, ':')) != NULL) *p = '\0';
|
||||||
|
SSL_set_tlsext_host_name(ssl, server);
|
||||||
sscanf(server, "Host:%255[^:]s", servername);
|
|
||||||
for (p = servername; *p == ' '; p++);
|
|
||||||
SSL_set_tlsext_host_name(ssl, p);
|
|
||||||
free(servername);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user