Răsfoiți Sursa

unify (as much as possible) 4.0 and 4.3 for AirPlay

Philippe G 3 ani în urmă
părinte
comite
fff5a6bf03
3 a modificat fișierele cu 6 adăugiri și 9 ștergeri
  1. 3 3
      components/raop/raop.c
  2. 1 1
      components/raop/raop.h
  3. 2 5
      components/raop/raop_sink.c

+ 3 - 3
components/raop/raop.c

@@ -111,7 +111,7 @@ extern char private_key[];
 static void on_dmap_string(void *ctx, const char *code, const char *name, const char *buf, size_t len);
 
 /*----------------------------------------------------------------------------*/
-struct raop_ctx_s *raop_create(struct in_addr host, char *name,
+struct raop_ctx_s *raop_create(uint32_t host, char *name,
 						unsigned char mac[6], int latency,
 						raop_cmd_cb_t cmd_cb, raop_data_cb_t data_cb) {
 	struct raop_ctx_s *ctx = malloc(sizeof(struct raop_ctx_s));
@@ -150,7 +150,7 @@ struct raop_ctx_s *raop_create(struct in_addr host, char *name,
 #ifdef WIN32
 	ctx->svr = glmDNSServer;
 #endif
-	ctx->host = host;
+	ctx->host.s_addr = host;
 	ctx->sock = socket(AF_INET, SOCK_STREAM, 0);
 	ctx->cmd_cb = cmd_cb;
 	ctx->data_cb = data_cb;
@@ -162,7 +162,7 @@ struct raop_ctx_s *raop_create(struct in_addr host, char *name,
 	}
 
 	memset(&addr, 0, sizeof(addr));
-	addr.sin_addr.s_addr = host.s_addr;
+	addr.sin_addr.s_addr = host;
 	addr.sin_family = AF_INET;
 #ifdef WIN32
 	ctx->port = 0;

+ 1 - 1
components/raop/raop.h

@@ -11,7 +11,7 @@
 #include "platform.h"
 #include "raop_sink.h"
 
-struct raop_ctx_s* raop_create(struct in_addr host, char *name, unsigned char mac[6], int latency,
+struct raop_ctx_s* raop_create(uint32_t host, char *name, unsigned char mac[6], int latency,
 							     raop_cmd_cb_t cmd_cb, raop_data_cb_t data_cb);
 void  		  raop_delete(struct raop_ctx_s *ctx);
 void		  raop_abort(struct raop_ctx_s *ctx);

+ 2 - 5
components/raop/raop_sink.c

@@ -161,7 +161,6 @@ static bool raop_sink_start(raop_cmd_vcb_t cmd_cb, raop_data_cb_t data_cb) {
     const char *hostname = NULL;
 	char sink_name[64-6] = CONFIG_AIRPLAY_NAME;
 	tcpip_adapter_ip_info_t ipInfo = { }; 
-	struct in_addr host;
 	tcpip_adapter_if_t ifs[] = { TCPIP_ADAPTER_IF_ETH, TCPIP_ADAPTER_IF_STA, TCPIP_ADAPTER_IF_AP };
    	
 	// get various IP info
@@ -175,8 +174,6 @@ static bool raop_sink_start(raop_cmd_vcb_t cmd_cb, raop_data_cb_t data_cb) {
 		LOG_INFO( "no hostname/IP found, can't start AirPlay");
 		return false;
 	}
-	
-	host.s_addr = ipInfo.ip.addr;
 
     // initialize mDNS
     ESP_ERROR_CHECK( mdns_init() );
@@ -189,13 +186,13 @@ static bool raop_sink_start(raop_cmd_vcb_t cmd_cb, raop_data_cb_t data_cb) {
     	free(sink_name_buffer);
     }
 
-	LOG_INFO( "mdns hostname for ip %s set to: [%s] with servicename %s", inet_ntoa(host), hostname, sink_name);
+	LOG_INFO( "mdns hostname for ip %s set to: [%s] with servicename %s", inet_ntoa(ipInfo.ip.addr), hostname, sink_name);
 
     // create RAOP instance, latency is set by controller
 	uint8_t mac[6];	
     esp_read_mac(mac, ESP_MAC_WIFI_STA);
 	cmd_handler_chain = cmd_cb;
-	raop = raop_create(host, sink_name, mac, 0, cmd_handler, data_cb);
+	raop = raop_create(ipInfo.ip.addr, sink_name, mac, 0, cmd_handler, data_cb);
 	
 	return true;
 }