Quellcode durchsuchen

fix bits_per_sample for 32 bit + resilient cli_socket handling - release

Philippe G vor 3 Jahren
Ursprung
Commit
d68d163538

+ 5 - 0
components/squeezelite/ac101/ac101.c

@@ -89,7 +89,12 @@ static bool init(char *config, int i2c_port, i2s_config_t *i2s_config) {
 	adac_write_word(AC101_ADDR, I2S_SR_CTRL,  BIN(0111,0000,0000,0000));		// 44.1kHz
 	 
 	// analogue config
+#if BYTES_PER_FRAME == 8
+	adac_write_word(AC101_ADDR, I2S1LCK_CTRL, 	 BIN(1000,1000,0111,0000));	// Slave, BCLK=I2S/8,LRCK=32,24bits,I2Smode, Stereo
+	i2s_config->bits_per_sample = 24;
+#else
 	adac_write_word(AC101_ADDR, I2S1LCK_CTRL, 	 BIN(1000,1000,0101,0000));	// Slave, BCLK=I2S/8,LRCK=32,16bits,I2Smode, Stereo
+#endif
 	adac_write_word(AC101_ADDR, I2S1_SDOUT_CTRL, BIN(1100,0000,0000,0000));	// I2S1ADC (R&L) 	
 	adac_write_word(AC101_ADDR, I2S1_SDIN_CTRL,  BIN(1100,0000,0000,0000));	// IS21DAC (R&L)
 	adac_write_word(AC101_ADDR, I2S1_MXR_SRC, 	 BIN(0010,0010,0000,0000));	// ADCL, ADCR

+ 26 - 14
components/squeezelite/controls.c

@@ -166,6 +166,26 @@ const actrls_t LMS_controls = {
 	lms_knob_left, lms_knob_right, lms_knob_push,
 };
 
+/****************************************************************************************
+ * 
+ */
+static void connect_cli_socket(void) {
+	struct sockaddr_in addr = {
+		.sin_family = AF_INET,
+		.sin_addr.s_addr = server_ip,
+		.sin_port = htons(server_cport),
+	};
+	socklen_t addrlen = sizeof(addr);
+	
+	cli_sock = socket(AF_INET, SOCK_STREAM, 0);
+	
+	if (connect(cli_sock, (struct sockaddr *) &addr, addrlen) < 0) {
+		LOG_ERROR("unable to connect to server %s:%hu with cli", inet_ntoa(server_ip), server_cport);
+		closesocket(cli_sock);
+		cli_sock = -1;
+	}
+}
+
 /****************************************************************************************
  * 
  */
@@ -175,8 +195,12 @@ static void cli_send_cmd(char *cmd) {
 	
 	len = sprintf(packet, "%02x:%02x:%02x:%02x:%02x:%02x %s\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], cmd);
 	LOG_DEBUG("sending command %s at %s:%hu", packet, inet_ntoa(server_ip), server_cport);
-		
+	
+	if (cli_sock < 0) connect_cli_socket();
+
 	if (send(cli_sock, packet, len, MSG_DONTWAIT) < 0) {
+		closesocket(cli_sock);
+		cli_sock = -1;
 		LOG_WARN("cannot send CLI %s", packet);
 	}
 	
@@ -188,26 +212,14 @@ static void cli_send_cmd(char *cmd) {
  * Notification when server changes
  */
 static void notify(in_addr_t ip, u16_t hport, u16_t cport) {
-	struct sockaddr_in addr;
-	socklen_t addrlen = sizeof(addr);
-	
 	server_ip = ip;
 	server_hport = hport;
 	server_cport = cport;
 	
-	addr.sin_family = AF_INET;
-	addr.sin_addr.s_addr = server_ip;
-	addr.sin_port = htons(server_cport);
-	
 	// close existing CLI connection and open new one
 	if (cli_sock >= 0) closesocket(cli_sock);
 	cli_sock = socket(AF_INET, SOCK_STREAM, 0);
-
-	if (connect(cli_sock, (struct sockaddr *) &addr, addrlen) < 0) {
-		LOG_ERROR("unable to connect to server %s:%hu with cli", inet_ntoa(server_ip), server_cport);
-		closesocket(cli_sock);
-		cli_sock = -1;
-	}
+	connect_cli_socket();
 	
 	LOG_INFO("notified server %s hport %hu cport %hu", inet_ntoa(ip), hport, cport);
 	

+ 5 - 0
components/squeezelite/tas57xx/dac_57xx.c

@@ -43,6 +43,11 @@ static const struct tas57xx_cmd_s tas57xx_init_sequence[] = {
 	{ 0x25, 0x08 },		// ignore SCK halt 
 	{ 0x08, 0x10 },		// Mute control enable (from TAS5780)
 	{ 0x54, 0x02 },		// Mute output control (from TAS5780)
+#if BYTES_PER_FRAME == 8
+	{ 0x28, 0x03 },		// I2S length 32 bits
+#else	
+	{ 0x28, 0x00 },		// I2S length 16 bits
+#endif
 	{ 0x02, 0x00 },		// restart
 	{ 0xff, 0xff }		// end of table
 };