mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	raop: Use the port supplied by avahi when connecting to RAOP devices.
The Apple TV for example uses a non-default port, but we previously ignored this. We now correctly parse the server string but in so doing, we end up parsing the address twice. As we need a pure IP/hostname of the device itself to use in our requests, this is somewhat unavoidable. Sadly there are still other problems with Apple TVs, but this is still one step closer. Fixes part of #950
This commit is contained in:
		
							parent
							
								
									8e298848be
								
							
						
					
					
						commit
						d36a9df63c
					
				
					 3 changed files with 20 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -186,24 +186,18 @@ static void resolver_cb(
 | 
			
		|||
        }
 | 
			
		||||
        pa_xfree(dname);
 | 
			
		||||
 | 
			
		||||
        /*
 | 
			
		||||
         TODO: allow this syntax of server name in things....
 | 
			
		||||
        args = pa_sprintf_malloc("server=[%s]:%u "
 | 
			
		||||
                                 "sink_name=%s",
 | 
			
		||||
                                 avahi_address_snprint(at, sizeof(at), a), port,
 | 
			
		||||
                                 vname);*/
 | 
			
		||||
        if (nicename) {
 | 
			
		||||
            args = pa_sprintf_malloc("server=%s "
 | 
			
		||||
            args = pa_sprintf_malloc("server=[%s]:%u "
 | 
			
		||||
                                     "sink_name=%s "
 | 
			
		||||
                                     "sink_properties=device.description=\"%s\"",
 | 
			
		||||
                                     avahi_address_snprint(at, sizeof(at), a),
 | 
			
		||||
                                     avahi_address_snprint(at, sizeof(at), a), port,
 | 
			
		||||
                                     vname,
 | 
			
		||||
                                     nicename);
 | 
			
		||||
 | 
			
		||||
        } else {
 | 
			
		||||
            args = pa_sprintf_malloc("server=%s "
 | 
			
		||||
            args = pa_sprintf_malloc("server=[%s]:%u "
 | 
			
		||||
                                     "sink_name=%s",
 | 
			
		||||
                                     avahi_address_snprint(at, sizeof(at), a),
 | 
			
		||||
                                     avahi_address_snprint(at, sizeof(at), a), port,
 | 
			
		||||
                                     vname);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,6 +47,7 @@
 | 
			
		|||
#include <pulsecore/iochannel.h>
 | 
			
		||||
#include <pulsecore/socket-util.h>
 | 
			
		||||
#include <pulsecore/log.h>
 | 
			
		||||
#include <pulsecore/parseaddr.h>
 | 
			
		||||
#include <pulsecore/macro.h>
 | 
			
		||||
#include <pulsecore/memchunk.h>
 | 
			
		||||
#include <pulsecore/random.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -67,10 +68,13 @@
 | 
			
		|||
#define VOLUME_MIN -144
 | 
			
		||||
#define VOLUME_MAX 0
 | 
			
		||||
 | 
			
		||||
#define RAOP_PORT 5000
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct pa_raop_client {
 | 
			
		||||
    pa_core *core;
 | 
			
		||||
    char *host;
 | 
			
		||||
    uint16_t port;
 | 
			
		||||
    char *sid;
 | 
			
		||||
    pa_rtsp_client *rtsp;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -363,14 +367,23 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
pa_raop_client* pa_raop_client_new(pa_core *core, const char* host) {
 | 
			
		||||
    pa_parsed_address a;
 | 
			
		||||
    pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
 | 
			
		||||
 | 
			
		||||
    pa_assert(core);
 | 
			
		||||
    pa_assert(host);
 | 
			
		||||
 | 
			
		||||
    if (pa_parse_address(host, &a) < 0 || a.type == PA_PARSED_ADDRESS_UNIX)
 | 
			
		||||
        return NULL;
 | 
			
		||||
 | 
			
		||||
    c->core = core;
 | 
			
		||||
    c->fd = -1;
 | 
			
		||||
    c->host = pa_xstrdup(host);
 | 
			
		||||
 | 
			
		||||
    c->host = pa_xstrdup(a.path_or_host);
 | 
			
		||||
    if (a.port)
 | 
			
		||||
        c->port = a.port;
 | 
			
		||||
    else
 | 
			
		||||
        c->port = RAOP_PORT;
 | 
			
		||||
 | 
			
		||||
    if (pa_raop_connect(c)) {
 | 
			
		||||
        pa_raop_client_free(c);
 | 
			
		||||
| 
						 | 
				
			
			@ -407,7 +420,7 @@ int pa_raop_connect(pa_raop_client* c) {
 | 
			
		|||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    c->rtsp = pa_rtsp_client_new(c->core->mainloop, c->host, 5000, "iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 | 
			
		||||
    c->rtsp = pa_rtsp_client_new(c->core->mainloop, c->host, c->port, "iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 | 
			
		||||
 | 
			
		||||
    /* Initialise the AES encryption system */
 | 
			
		||||
    pa_random(c->aes_iv, sizeof(c->aes_iv));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -324,6 +324,7 @@ int pa_rtsp_connect(pa_rtsp_client *c) {
 | 
			
		|||
    pa_xfree(c->session);
 | 
			
		||||
    c->session = NULL;
 | 
			
		||||
 | 
			
		||||
    pa_log_debug("Attempting to connect to server '%s:%d'", c->hostname, c->port);
 | 
			
		||||
    if (!(c->sc = pa_socket_client_new_string(c->mainloop, TRUE, c->hostname, c->port))) {
 | 
			
		||||
        pa_log("failed to connect to server '%s:%d'", c->hostname, c->port);
 | 
			
		||||
        return -1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue