Require NQPTP to be running and create the SHM interface at startup.
This commit is contained in:
+11
-4
@@ -46,7 +46,7 @@
|
||||
#include "ptp-utilities.h"
|
||||
|
||||
int shm_fd;
|
||||
void *mapped_addr = NULL;
|
||||
void *mapped_addr;
|
||||
|
||||
static pthread_mutex_t ptp_access_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
@@ -115,9 +115,13 @@ int ptp_get_clock_info(uint64_t *actual_clock_id, uint64_t *time_of_sample, uint
|
||||
return response;
|
||||
}
|
||||
|
||||
void ptp_shm_interface_init() {
|
||||
mapped_addr = NULL;
|
||||
}
|
||||
|
||||
int ptp_shm_interface_open() {
|
||||
int response = 0;
|
||||
if (mapped_addr == NULL) {
|
||||
if ((mapped_addr == NULL) || (mapped_addr == MAP_FAILED)) {
|
||||
response = -1;
|
||||
debug(1, "ptp_shm_interface_open");
|
||||
if (strcmp(config.nqptp_shared_memory_interface_name, "") != 0) {
|
||||
@@ -138,12 +142,15 @@ int ptp_shm_interface_open() {
|
||||
}
|
||||
} else {
|
||||
response = -1;
|
||||
|
||||
}
|
||||
if (response == 0)
|
||||
debug(1, "ptp_shm_interface_open successful");
|
||||
else
|
||||
debug(1, "ptp_shm_interface_open failed");
|
||||
} else {
|
||||
debug(1, "No config.nqptp_shared_memory_interface_name");
|
||||
}
|
||||
if (response != 0)
|
||||
mapped_addr = NULL; // in case we try again later...
|
||||
} else {
|
||||
debug(1, "ptp_shm_interface_open -- already open!");
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ int ptp_get_clock_info(uint64_t *actual_clock_id, uint64_t *time_of_sample, uint
|
||||
|
||||
void ptp_send_control_message_string(const char *msg);
|
||||
|
||||
void ptp_shm_interface_init();
|
||||
int ptp_shm_interface_open();
|
||||
int ptp_shm_interface_close();
|
||||
|
||||
|
||||
@@ -2686,8 +2686,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp)
|
||||
// if it's a full service PTP stream, we get groupUUID, groupContainsGroupLeader and
|
||||
// timingPeerList
|
||||
if (conn->airplay_stream_category == ptp_stream) {
|
||||
ptp_shm_interface_open(); // it should be open already, but just in case it isn't...
|
||||
ptp_send_control_message_string("T"); // remove all previous history
|
||||
ptp_send_control_message_string("T"); // incidentally create the named SHM if necessary and remove all previous history
|
||||
debug_log_rtsp_message(2, "SETUP \"PTP\" message", req);
|
||||
plist_t groupUUID = plist_dict_get_item(messagePlist, "groupUUID");
|
||||
if (groupUUID) {
|
||||
|
||||
+6
-1
@@ -2211,7 +2211,12 @@ int main(int argc, char **argv) {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_AIRPLAY_2
|
||||
ptp_shm_interface_open();
|
||||
ptp_shm_interface_init();
|
||||
ptp_send_control_message_string("T"); // incidentally create the named SHM and remove all previous history
|
||||
usleep(100000); // wait for it to get done (?)
|
||||
if (ptp_shm_interface_open() != 0) {
|
||||
debug(1,"unable to open the shm interface at startup!");
|
||||
}
|
||||
#endif
|
||||
|
||||
activity_monitor_start(); // not yet for AP2
|
||||
|
||||
Reference in New Issue
Block a user