int metadata_running = 0;
-
// always lock this when accessing the principal conn value
// use a read lock when consulting and holding it
// use a write lock if you want to change it
(stream_category == conns[i]->airplay_stream_category))) {
pthread_join(conns[i]->thread, NULL);
debug(1, "Connection %d: joined.", conns[i]->connection_number);
-
+
free(conns[i]);
conns[i] = NULL;
}
void release_play_lock(rtsp_conn_info *conn) {
// no need thread cancellation points in here
pthread_rwlock_wrlock(&principal_conn_lock);
- if (principal_conn == conn) { // if we have the player
+ if (principal_conn == conn) { // if we have the player
if (conn != NULL)
debug(2, "Connection %d: principal_conn released.", conn->connection_number);
principal_conn = NULL; // let it go
int get_play_lock(rtsp_conn_info *conn, int allow_session_interruption) {
int response = 0;
pthread_rwlock_wrlock(&principal_conn_lock);
- pthread_cleanup_push(rwlock_unlock,(void *)&principal_conn_lock);
+ pthread_cleanup_push(rwlock_unlock, (void *)&principal_conn_lock);
if (principal_conn != NULL)
debug(1, "Connection %d: is requested to relinquish principal_conn.",
principal_conn->connection_number);
die("msg_init -- can not allocate memory for rtsp_message %d.", msg_indexes);
}
// debug(1,"msg_init -- create item %d.", msg->index_number);
-
+
rc = pthread_mutex_unlock(&reference_counter_lock);
if (rc)
debug(1, "Error %d unlocking reference counter lock");
} else {
void *qualifier_response_data = NULL;
size_t qualifier_response_data_length = 0;
-
-
+
pthread_rwlock_rdlock(&principal_conn_lock); // don't let the principal_conn be changed
- pthread_cleanup_push(rwlock_unlock,(void *)&principal_conn_lock);
+ pthread_cleanup_push(rwlock_unlock, (void *)&principal_conn_lock);
-
-
-
if (add_pstring_to_malloc("acl=0", &qualifier_response_data,
&qualifier_response_data_length) == 0)
debug(1, "Problem");
get_category_string(conn->airplay_stream_category));
teardown_phase_one(conn); // try to do phase one anyway
teardown_phase_two(conn);
-
+
// only update these things if you're (still) the principal conn
pthread_rwlock_rdlock(&principal_conn_lock); // don't let the principal_conn be changed
- pthread_cleanup_push(rwlock_unlock,(void *)&principal_conn_lock);
+ pthread_cleanup_push(rwlock_unlock, (void *)&principal_conn_lock);
if ((principal_conn == conn) && (conn->airplay_stream_category == ptp_stream)) {
config.airplay_statusflags &= (0xffffffff - (1 << 11)); // DeviceSupportsRelay
build_bonjour_strings(conn);
#ifdef CONFIG_AIRPLAY_2
// only update these things if you're (still) the principal conn
pthread_rwlock_rdlock(&principal_conn_lock); // don't let the principal_conn be changed
- pthread_cleanup_push(rwlock_unlock,(void *)&principal_conn_lock);
+ pthread_cleanup_push(rwlock_unlock, (void *)&principal_conn_lock);
if (principal_conn == conn) {
config.airplay_statusflags &= (0xffffffff - (1 << 11)); // DeviceSupportsRelay
build_bonjour_strings(conn);
}
pthread_cleanup_pop(1); // release the principal_conn lock
#endif
-
+
release_play_lock(conn);
resp->respcode = 200;
listeners
*/
// only update these things if you're (still) the principal conn
- pthread_rwlock_wrlock(&principal_conn_lock); // don't let the principal_conn be changed
- pthread_cleanup_push(rwlock_unlock,(void *)&principal_conn_lock);
+ pthread_rwlock_wrlock(
+ &principal_conn_lock); // don't let the principal_conn be changed
+ pthread_cleanup_push(rwlock_unlock, (void *)&principal_conn_lock);
if (principal_conn == conn) {
- config.airplay_statusflags |= 1 << 11; // DeviceSupportsRelay
- build_bonjour_strings(conn);
- debug(2, "Connection %d: SETUP mdns_update on %s.", conn->connection_number,
- get_category_string(conn->airplay_stream_category));
- mdns_update(NULL, secondary_txt_records);
+ config.airplay_statusflags |= 1 << 11; // DeviceSupportsRelay
+ build_bonjour_strings(conn);
+ debug(2, "Connection %d: SETUP mdns_update on %s.", conn->connection_number,
+ get_category_string(conn->airplay_stream_category));
+ mdns_update(NULL, secondary_txt_records);
}
pthread_cleanup_pop(1); // release the principal_conn lock
} else {
#endif
pthread_rwlock_rdlock(&principal_conn_lock); // don't let the principal_conn be changed
- pthread_cleanup_push(rwlock_unlock,(void *)&principal_conn_lock);
+ pthread_cleanup_push(rwlock_unlock, (void *)&principal_conn_lock);
if (principal_conn == conn) {
player_volume(volume, conn);
}
free(conn->airplay_gid);
conn->airplay_gid = NULL;
}
-
+
// only update these things if you're (still) the principal conn
pthread_rwlock_rdlock(&principal_conn_lock); // don't let the principal_conn be changed
- pthread_cleanup_push(rwlock_unlock,(void *)&principal_conn_lock);
+ pthread_cleanup_push(rwlock_unlock, (void *)&principal_conn_lock);
if (principal_conn == conn) {
config.airplay_statusflags |= 1 << 11; // DeviceSupportsRelay -- should this be on?
build_bonjour_strings(conn);
debug(1, "Connection %d: Classic AirPlay connection from %s:%u to self at %s:%u.",
conn->connection_number, conn->client_ip_string, conn->client_rtsp_port,
- conn->self_ip_string, conn->self_rtsp_port);
+ conn->self_ip_string, conn->self_rtsp_port);
#endif
conn->stream.type = ast_unknown;
while (conn->stop == 0) {
int debug_level = 2; // for printing the request and response
-
-// check to see if a conn has been zeroed
+ // check to see if a conn has been zeroed
debug_mutex_lock(&conns_lock, 1000000, 3);
int i;
}
}
debug_mutex_unlock(&conns_lock, 3);
-
+
reply = rtsp_read_request(conn, &req);
if (reply == rtsp_read_request_response_ok) {
pthread_cleanup_push(msg_cleanup_function, (void *)&req);
if (acceptfd < 0) // timeout
continue;
- int release_conn = 1; // on exit, deallocate the buffer unless everything was okay
-
-
+ int release_conn = 1; // on exit, deallocate the buffer unless everything was okay
+
rtsp_conn_info *conn = malloc(sizeof(rtsp_conn_info));
if (conn == 0)
die("Couldn't allocate memory for an rtsp_conn_info record.");
debug(1, "Connection %d: New connection on port %d not accepted:", conn->connection_number,
config.port);
perror("failed to accept connection");
- } else {
+ } else {
size_of_reply = sizeof(SOCKADDR);
if (getsockname(conn->fd, (struct sockaddr *)&conn->local, &size_of_reply) == 0) {