2
0
Эх сурвалжийг харах

fix AirPlay playback with SPDIF

philippe44 5 жил өмнө
parent
commit
655af81a97

+ 1 - 1
components/raop/rtp.c

@@ -263,7 +263,7 @@ rtp_resp_t rtp_init(struct in_addr host, int latency, char *aeskey, char *aesiv,
 #ifdef WIN32
 		pthread_create(&ctx->rtp_thread, NULL, rtp_thread_func, (void *) ctx);
 #else
-		xTaskCreate((TaskFunction_t) rtp_thread_func, "RTP_thread", 4096, ctx, configMAX_PRIORITIES - 3, &ctx->rtp_thread);
+		xTaskCreate((TaskFunction_t) rtp_thread_func, "RTP_thread", 4096, ctx,  CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT , &ctx->rtp_thread);
 #endif
 	} else {
 		rtp_end(ctx);

+ 3 - 2
components/squeezelite/decode_external.c

@@ -184,13 +184,14 @@ void raop_sink_cmd_handler(raop_event_t event, void *param)
 				// how many ms have we really played
 				ms = now - output.updated + ((u64_t) (output.frames_played_dmp - output.device_frames) * 1000) / RAOP_SAMPLE_RATE;
 				error = ms - (now - raop_sync.start_time); 
-				LOG_INFO("backend played %u, desired %u, (delta:%d)", ms, now - raop_sync.start_time, error);
+				LOG_DEBUG("backend played %u, desired %u, (delta:%d)", ms, now - raop_sync.start_time, error);
 				if (abs(error) < 10 && abs(raop_sync.error) < 10) raop_sync.start = false;
 			} else {	
 				// in how many ms will the most recent block play 
 				ms = ((u64_t) ((_buf_used(outputbuf) - raop_sync.len) / BYTES_PER_FRAME + output.device_frames + output.frames_in_process) * 1000) / RAOP_SAMPLE_RATE - (now - output.updated);
 				error = (raop_sync.playtime - now) - ms;
-				LOG_INFO("head local:%u, remote:%u (delta:%d)", ms, raop_sync.playtime - now, error);
+				LOG_DEBUG("head local:%u, remote:%u (delta:%d)", ms, raop_sync.playtime - now, error);
+				LOG_DEBUG("obuf:%u, sync_len:%u, devframes:%u, inproc:%u", _buf_used(outputbuf), raop_sync.len, output.device_frames, output.frames_in_process);
 			}	
 			
 			if (error < -10 && raop_sync.error < -10) {

+ 14 - 9
components/squeezelite/output_i2s.c

@@ -41,6 +41,7 @@ sure that using rate_delay would fix that
 */
 
 #include "squeezelite.h"
+#include "esp_pthread.h"
 #include "driver/i2s.h"
 #include "driver/i2c.h"
 #include "driver/gpio.h"
@@ -315,16 +316,20 @@ void output_init_i2s(log_level level, char *device, unsigned output_buf_size, ch
 	
 	dac_cmd(DAC_OFF);
 	
-	pthread_attr_t attr;
-	pthread_attr_init(&attr);
-	pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + OUTPUT_THREAD_STACK_SIZE);
-	pthread_create_name(&thread, &attr, output_thread_i2s, NULL, "output_i2s");
-		
-	pthread_attr_init(&attr);
-	pthread_attr_setstacksize(&attr, 2048);
-	pthread_create_name(&stats_thread, NULL, output_thread_i2s_stats, NULL, "output_i2s_sts");
+	esp_pthread_cfg_t cfg = esp_pthread_get_default_config();
+	
+    cfg.thread_name= "output_i2s";
+    cfg.inherit_cfg = false;
+	cfg.prio = CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT + 1;
+    cfg.stack_size = PTHREAD_STACK_MIN + OUTPUT_THREAD_STACK_SIZE;
+    esp_pthread_set_cfg(&cfg);
+	pthread_create(&thread, NULL, output_thread_i2s, NULL);
 	
-	pthread_attr_destroy(&attr);
+	cfg.thread_name= "output_i2s_sts";
+	cfg.prio = CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT - 1;
+    cfg.stack_size = 2048;	
+	esp_pthread_set_cfg(&cfg);
+	pthread_create(&stats_thread, NULL, output_thread_i2s_stats, NULL);
 }