#endif
pthread_setcancelstate(oldState, NULL);
-
+
+ double initial_volume = config.airplay_volume; // default
+ if (conn->initial_airplay_volume_set) // if we have been given an initial volume
+ initial_volume = conn->initial_airplay_volume;
// set the default volume to whatever it was before, as stored in the config airplay_volume
- debug(2, "Set initial volume to %f.", config.airplay_volume);
- player_volume(config.airplay_volume, conn); // will contain a cancellation point if asked to wait
+ debug(2, "Set initial volume to %f.", initial_volume);
+ player_volume(initial_volume, conn); // will contain a cancellation point if asked to wait
debug(2, "Play begin");
while (1) {
* Copyright (c) James Laird 2013
* Modifications associated with audio synchronization, mutithreading and
- * metadata handling copyright (c) Mike Brady 2014-2020
+ * metadata handling copyright (c) Mike Brady 2014-2021
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
}
} else {
player_full_flush(conn);
- ptp_send_control_message_string("T"); // ensure an obsolete clock isn't picked up later.
+ // ptp_send_control_message_string("T"); // ensure an obsolete clock isn't picked up later.
}
}
pthread_cleanup_pop(1); // plist_free the messagePlist;
if (!strncmp(cp, "volume: ", strlen("volume: "))) {
float volume = atof(cp + strlen("volume: "));
- // debug(2, "AirPlay request to set volume to: %f.", volume);
- player_volume(volume, conn);
+ debug(2, "Connection %d: request to set AirPlay Volume to: %f.", conn->connection_number, volume);
+ // if we are playing, go ahead and change the volume
+ if (try_to_hold_play_lock(conn) == 0) {
+ player_volume(volume, conn);
+ release_hold_on_play_lock(conn);
+ } else {
+ // otherwise use the volume as the initial setting for when/if the player starts
+ conn->initial_airplay_volume = volume;
+ conn->initial_airplay_volume_set = 1;
+ }
} else
#ifdef CONFIG_METADATA
if (!strncmp(cp, "progress: ", strlen("progress: "))) {
} else
#endif
{
- debug(1, "unrecognised parameter: \"%s\" (%d)\n", cp, strlen(cp));
+ debug(1, "Connection %d, unrecognised parameter: \"%s\" (%d)\n", conn->connection_number, cp, strlen(cp));
}
cp = next;
}
if ((req->content) && (req->contentlength == strlen("volume\r\n")) &&
strstr(req->content, "volume") == req->content) {
- // debug(1,"Current volume sought");
+ debug(2,"Connection %d: Current volume (%.6f) requested", conn->connection_number, config.airplay_volume);
char *p = malloc(128); // will be automatically deallocated with the response is deleted
if (p) {
resp->content = p;
// debug(2, "received parameters in SET_PARAMETER request.");
handle_set_parameter_parameter(conn, req, resp); // this could be volume or progress
} else {
- debug(1, "received unknown Content-Type \"%s\" in SET_PARAMETER request.", ct);
+ debug(1, "Connection %d: received unknown Content-Type \"%s\" in SET_PARAMETER request.", conn->connection_number, ct);
+ debug_print_msg_headers(1,req);
}
} else {
- debug(1, "missing Content-Type header in SET_PARAMETER request.");
+ debug(1, "Connection %d: missing Content-Type header in SET_PARAMETER request.", conn->connection_number);
}
resp->respcode = 200;
}