mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 12:07:09 +03:00
tweak BT + start to add AirPlay
This commit is contained in:
@@ -13,7 +13,8 @@ CFLAGS += -O3 -DLINKALL -DLOOPBACK -DNO_FAAD -DRESAMPLE16 -DEMBEDDED -DTREMOR_ON
|
||||
-I$(COMPONENT_PATH)/../tools \
|
||||
-I$(COMPONENT_PATH)/../codecs/inc/opus \
|
||||
-I$(COMPONENT_PATH)/../codecs/inc/opusfile \
|
||||
-I$(COMPONENT_PATH)/../driver_bt
|
||||
-I$(COMPONENT_PATH)/../driver_bt \
|
||||
-I$(COMPONENT_PATH)/../airplay
|
||||
|
||||
# -I$(COMPONENT_PATH)/../codecs/inc/faad2
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "squeezelite.h"
|
||||
#include "bt_app_sink.h"
|
||||
#include "airplay_sink.h"
|
||||
|
||||
#define LOCK_O mutex_lock(outputbuf->mutex)
|
||||
#define UNLOCK_O mutex_unlock(outputbuf->mutex)
|
||||
@@ -92,15 +93,17 @@ static void bt_sink_cmd_handler(bt_sink_cmd_t cmd, ...)
|
||||
|
||||
switch(cmd) {
|
||||
case BT_SINK_CONNECTED:
|
||||
output.external = true;
|
||||
output.state = OUTPUT_STOPPED;
|
||||
LOG_INFO("BT sink started");
|
||||
break;
|
||||
case BT_SINK_DISCONNECTED:
|
||||
output.external = false;
|
||||
output.state = OUTPUT_OFF;
|
||||
LOG_INFO("BT sink stopped");
|
||||
break;
|
||||
case BT_SINK_PLAY:
|
||||
output.state = OUTPUT_EXTERNAL;
|
||||
output.state = OUTPUT_RUNNING;
|
||||
LOG_INFO("BT sink playing");
|
||||
break;
|
||||
case BT_SINK_PAUSE:
|
||||
@@ -138,4 +141,12 @@ void register_other(void) {
|
||||
LOG_WARN("Cannot be a BT sink and source");
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_AIRPLAY_SINK
|
||||
if (!strcasestr(output.device, "BT ")) {
|
||||
airplay_sink_init();
|
||||
LOG_INFO("Initializing AirPlay sink");
|
||||
} else {
|
||||
LOG_WARN("Cannot be an AirPlay sink and BT source");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -417,7 +417,7 @@ static void *output_thread_i2s() {
|
||||
LOG_INFO("Output state is %d", output.state);
|
||||
if (output.state == OUTPUT_OFF) led_blink(LED_GREEN, 100, 2500);
|
||||
else if (output.state == OUTPUT_STOPPED) led_blink(LED_GREEN, 200, 1000);
|
||||
else if (output.state >= OUTPUT_RUNNING) led_on(LED_GREEN);
|
||||
else if (output.state == OUTPUT_RUNNING) led_on(LED_GREEN);
|
||||
}
|
||||
state = output.state;
|
||||
|
||||
|
||||
@@ -371,6 +371,7 @@ static void process_strm(u8_t *pkt, int len) {
|
||||
sendSTAT("STMc", 0);
|
||||
sentSTMu = sentSTMo = sentSTMl = false;
|
||||
LOCK_O;
|
||||
output.external = false;
|
||||
output.threshold = strm->output_threshold;
|
||||
output.next_replay_gain = unpackN(&strm->replay_gain);
|
||||
output.fade_mode = strm->transition_type - '0';
|
||||
@@ -688,7 +689,7 @@ static void slimproto_run() {
|
||||
status.current_sample_rate = output.current_sample_rate;
|
||||
status.updated = output.updated;
|
||||
status.device_frames = output.device_frames;
|
||||
|
||||
|
||||
if (output.track_started) {
|
||||
_sendSTMs = true;
|
||||
output.track_started = false;
|
||||
@@ -703,7 +704,7 @@ static void slimproto_run() {
|
||||
if (_start_output && (output.state == OUTPUT_STOPPED || output.state == OUTPUT_OFF)) {
|
||||
output.state = OUTPUT_BUFFER;
|
||||
}
|
||||
if (output.state == OUTPUT_RUNNING && !sentSTMu && status.output_full == 0 && status.stream_state <= DISCONNECT &&
|
||||
if (!output.external && output.state == OUTPUT_RUNNING && !sentSTMu && status.output_full == 0 && status.stream_state <= DISCONNECT &&
|
||||
_decode_state == DECODE_STOPPED) {
|
||||
|
||||
_sendSTMu = true;
|
||||
@@ -721,7 +722,7 @@ static void slimproto_run() {
|
||||
output.state = OUTPUT_OFF;
|
||||
LOG_DEBUG("output timeout");
|
||||
}
|
||||
if (output.state == OUTPUT_RUNNING && now - status.last > 1000) {
|
||||
if (!output.external && output.state == OUTPUT_RUNNING && now - status.last > 1000) {
|
||||
_sendSTMt = true;
|
||||
status.last = now;
|
||||
}
|
||||
|
||||
@@ -634,7 +634,7 @@ bool resample_init(char *opt);
|
||||
|
||||
// output.c output_alsa.c output_pa.c output_pack.c
|
||||
typedef enum { OUTPUT_OFF = -1, OUTPUT_STOPPED = 0, OUTPUT_BUFFER, OUTPUT_RUNNING,
|
||||
OUTPUT_PAUSE_FRAMES, OUTPUT_SKIP_FRAMES, OUTPUT_START_AT, OUTPUT_EXTERNAL } output_state;
|
||||
OUTPUT_PAUSE_FRAMES, OUTPUT_SKIP_FRAMES, OUTPUT_START_AT } output_state;
|
||||
|
||||
#if DSD
|
||||
typedef enum { PCM, DOP, DSD_U8, DSD_U16_LE, DSD_U32_LE, DSD_U16_BE, DSD_U32_BE, DOP_S24_LE, DOP_S24_3LE } dsd_format;
|
||||
@@ -654,6 +654,7 @@ struct outputstate {
|
||||
output_state state;
|
||||
output_format format;
|
||||
const char *device;
|
||||
bool external;
|
||||
#if ALSA
|
||||
unsigned buffer;
|
||||
unsigned period;
|
||||
|
||||
Reference in New Issue
Block a user