Skip to content

Commit

Permalink
Put in a cancellation point explicitly in the player_thread main loop…
Browse files Browse the repository at this point in the history
…. Tidy up some debug messages.
  • Loading branch information
mikebrady committed Nov 20, 2018
1 parent 18497e6 commit 6e6c821
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
11 changes: 5 additions & 6 deletions player.c
Original file line number Diff line number Diff line change
Expand Up @@ -1742,9 +1742,10 @@ void *player_thread_func(void *arg) {
pthread_cleanup_push(player_thread_cleanup_handler, arg); // undo what's been done so far

// stop looking elsewhere for DACP stuff

#ifdef CONFIG_DACP_CLIENT
// debug(1, "Set dacp server info");
// this does not have pthread cancellation points in it (assuming avahi doesn't)
// may have pthread cancellation points in it -- beware
set_dacp_server_information(conn); // this will start scanning when a port is registered by the
// code initiated by the mdns_dacp_monitor
#else
Expand All @@ -1754,7 +1755,7 @@ void *player_thread_func(void *arg) {
if (conn->dapo_private_storage)
debug(1, "DACP monitor already initialised?");
else
// this does not have pthread cancellation points in it (assuming avahi doesn't)
// almost certainly, this has pthread cancellation points in it -- beware
conn->dapo_private_storage = mdns_dacp_monitor(conn->dacp_id);
#endif

Expand All @@ -1764,7 +1765,8 @@ void *player_thread_func(void *arg) {

debug(2, "Play begin");
while (1) {
abuf_t *inframe = buffer_get_frame(conn); // this has cancellation point(s)
pthread_testcancel(); // allow a pthread_cancel request to take effect.
abuf_t *inframe = buffer_get_frame(conn); // this has cancellation point(s), but it's not guaranteed that they'll aways be executed
if (inframe) {
inbuf = inframe->data;
inbuflength = inframe->length;
Expand Down Expand Up @@ -2756,9 +2758,7 @@ int player_play(rtsp_conn_info *conn) {
if (config.buffer_start_fill > BUFFER_FRAMES)
die("specified buffer starting fill %d > buffer size %d", config.buffer_start_fill,
BUFFER_FRAMES);
debug(1,"Executing the run_this_before_play_begins hook, if any.");
command_start();
debug(1,"Create a player thread...");
pthread_t *pt = malloc(sizeof(pthread_t));
if (pt == NULL)
die("Couldn't allocate space for pthread_t");
Expand All @@ -2774,7 +2774,6 @@ int player_play(rtsp_conn_info *conn) {
if (rc)
debug(1, "Error creating player_thread: %s", strerror(errno));
pthread_attr_destroy(&tattr);
debug(1,"Player thread successfully created.");
#ifdef CONFIG_METADATA
debug(2, "pbeg");
send_ssnc_metadata('pbeg', NULL, 0, 1); // contains cancellation points
Expand Down
9 changes: 2 additions & 7 deletions rtsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2131,15 +2131,10 @@ static void *rtsp_conversation_thread_func(void *pconn) {
debug(1, "rtsp_read_request error %d, packet ignored.", (int)reply);
}
if (tstop) {
debug(3, "Synchronously terminate playing thread of RTSP conversation thread %d.",
conn->connection_number);

if (conn->player_thread)
debug(1, "RTSP Channel unexpectedly closed or a serious error occured -- closing the "
"player thread.");
debug(3, "Successful termination of playing thread of RTSP conversation thread %d.",
debug(1, "RTSP Channel unexpectedly closed or a serious error occurred.");
debug(3, "Synchronously terminate playing thread of RTSP conversation thread %d.",
conn->connection_number);
debug(3, "Request termination of RTSP conversation thread %d.", conn->connection_number);
conn->stop = 1;
}
}
Expand Down
6 changes: 6 additions & 0 deletions start_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# My first script

/bin/sleep 3
/usr/bin/logger "Shairport Sync Play Script Executed!"

0 comments on commit 6e6c821

Please sign in to comment.