Modify latency calculation -- default 88,200 and only use 99,400 for iTunes V 10 or later
This commit is contained in:
@@ -447,24 +447,39 @@ static void handle_setup(rtsp_conn_info *conn,
|
||||
// debug(1,"Active Remote is %u.",active_remote);
|
||||
}
|
||||
|
||||
if (config.userSuppliedLatency==0) {
|
||||
char * ua = msg_get_header(req,"User-Agent");
|
||||
if (!ua) {
|
||||
debug(1,"No User-Agent string found in the SETUP message and no user-supplied latency. Using AirPlay latency of %d frames.",config.AirPlayLatency);
|
||||
return;
|
||||
}
|
||||
if (strstr(ua,"iTunes")==ua) {
|
||||
//debug(1,"User-Agent is iTunes; selecting the iTunes latency of %d frames.",config.iTunesLatency);
|
||||
config.latency=config.iTunesLatency;
|
||||
} else if (strstr(ua,"AirPlay")==ua) {
|
||||
//debug(1,"User-Agent is AirPlay; selecting the AirPlay latency of %d frames.",config.AirPlayLatency);
|
||||
config.latency=config.AirPlayLatency;
|
||||
}
|
||||
} else {
|
||||
//debug(1,"Selecting the latency of %d frames supplied with the -L option.",config.userSuppliedLatency);
|
||||
// select latency
|
||||
// if iTunes V10 or later is detected, use the iTunes latency setting
|
||||
// if AirPlay is detected, use the AirPlay latency setting
|
||||
// for everything else, use the general latency setting, if given, or
|
||||
// else use the default latency setting
|
||||
|
||||
if (config.userSuppliedLatency)
|
||||
config.latency=config.userSuppliedLatency;
|
||||
|
||||
char * ua = msg_get_header(req,"User-Agent");
|
||||
// if (ua==0) {
|
||||
// debug(1,"No User-Agent string found in the SETUP message. Using latency of %d frames.",config.latency);
|
||||
// } else {
|
||||
if (ua) {
|
||||
if (strstr(ua,"iTunes")==ua) {
|
||||
int iTunesVersion=0;
|
||||
// now check it's version 10 or later
|
||||
char *pp = strchr(ua,'/') + 1;
|
||||
if (pp)
|
||||
iTunesVersion=atoi(pp);
|
||||
// else
|
||||
// debug(1,"iTunes Version Number not found.");
|
||||
if (iTunesVersion>=10) {
|
||||
// debug(1,"User-Agent is iTunes 10 or better, (actual version is %d); selecting the iTunes latency of %d frames.",iTunesVersion,config.iTunesLatency);
|
||||
config.latency=config.iTunesLatency;
|
||||
}
|
||||
} else if (strstr(ua,"AirPlay")==ua) {
|
||||
// debug(1,"User-Agent is AirPlay; selecting the AirPlay latency of %d frames.",config.AirPlayLatency);
|
||||
config.latency=config.AirPlayLatency;
|
||||
} // else {
|
||||
// debug(1,"Unrecognised User-Agent. Using latency of %d frames.",config.latency);
|
||||
// }
|
||||
}
|
||||
|
||||
char *hdr = msg_get_header(req, "Transport");
|
||||
if (!hdr)
|
||||
return;
|
||||
|
||||
+2
-2
@@ -335,9 +335,9 @@ int main(int argc, char **argv) {
|
||||
|
||||
// set defaults
|
||||
config.statistics_requested - 0; // don't print stats in the log
|
||||
config.latency = 99400; // iTunes
|
||||
config.latency = 88200; // AirPlay
|
||||
config.userSuppliedLatency = 0; // zero means none supplied
|
||||
config.iTunesLatency = 99400; // this seems to work pretty well for iTunes -- two left-ear headphones, one from the iMac jack, one from an NSLU2 running a cheap "3D Sound" USB Soundcard
|
||||
config.iTunesLatency = 99400; // this seems to work pretty well for iTunes from Version 10 (?) upwards-- two left-ear headphones, one from the iMac jack, one from an NSLU2 running a cheap "3D Sound" USB Soundcard
|
||||
config.AirPlayLatency = 88200; // this seems to work pretty well for AirPlay -- Syncs sound and vision on AppleTV, but also used for iPhone/iPod/iPad sources
|
||||
config.resyncthreshold = 441*5; // this number of frames is 50 ms
|
||||
config.timeout = 120; // this number of seconds to wait for [more] audio before switching to idle.
|
||||
|
||||
Reference in New Issue
Block a user