Commit Graph
100 Commits
Author SHA1 Message Date
Mike Brady f1d4503431 Try to add proper cancellation code to all threads -- not complete, buggy. 2018-07-20 13:50:38 +01:00
Mike Brady 01f2a374b9 Use pthread_cancel to stop a player thread rather than SIGUSR1 and pthread_kill. 2018-07-15 13:54:33 +01:00
Mike Brady 768dc7759a Tidy up log output and add timers to inform statements. Move more stuff to the player thread pop function. Warn about cancellation points in debug versions of mutex lock and unlock. Ensure they are not cancellation points when debug not in use. Warn about Mac OS X cancellation points. 2018-07-15 11:54:48 +01:00
Mike Brady d3b79b965d Make more of the code amenable to pthread cancel 2018-07-14 19:34:31 +01:00
Mike Brady 0d48a3d96a improve the timed mutex lock code and make it compatible with os x, we hope. 2018-06-21 16:15:53 +01:00
Till Zimmermann 3d1086ea2e Fixed not connected bug, added version string 2018-06-20 18:58:34 +02:00
Mike Brady eee822b932 add some more debugging messages. 2018-06-01 16:00:20 +01:00
Mike Brady d224f47e37 Remove unneeded volume control mutex, adjust some timings, add wait time to slow mutex locks. 2018-06-01 11:21:16 +01:00
Mike Brady 93f410599f Add debug_mutex_unlock code in place of a regular pthread_mutex_unlock in some places. 2018-06-01 09:28:28 +01:00
Mike Brady 18b37ea254 Replace all pthread_mutex_locks with debug_mutex_lock with a message and timer. Not really tested. 2018-06-01 08:29:48 +01:00
Mike Brady d392f75c1c Add warnings to tell us if the time info might overflow, quieten some debug messages in rtp. 2018-04-11 20:56:38 +01:00
Mike Brady 89a6a7d29e Reformulate the conversion of seconds and nanoseconds into fixed point 64-bit time. 2018-04-11 20:13:53 +01:00
Mike Brady 08a7d4ffb5 Use snprintf in place of sprintf. 2018-04-08 15:36:05 +01:00
Mike Brady 1c437f1aab Rememeber the debug message of the previous request to lock the mutex. 2018-04-08 12:51:27 +01:00
Mike Brady 7fb8913532 Use snprintf in place of sprintf and initialise mutexes for debugging. 2018-04-08 12:36:00 +01:00
Mike Brady 8bf83c149f Modify latency detection to use the second word of a sync packet to decide whether to add an extra delay or not. Use all sync packets, not just one with the exception flag. Use 1024 buffers -- a bit profligate, but hey. 2018-04-02 16:42:46 +01:00
Mike Brady 69b3b5d776 Send rtsp events to the metadata thteread for handling. Begin to clean up signals. 2018-03-31 12:39:26 +01:00
Mike Brady 340e365a62 Format after adding a few new elements ot the native dbus interface 2018-03-23 21:29:38 +00:00
Mike Brady 6dc30c6ca9 Add a few new elements ot the native dbus interface 2018-03-23 21:28:28 +00:00
Mike Brady d692fab9e4 Clean up native dbus interface files and associated changes to existing files. 2018-03-20 16:31:59 +00:00
Mike Brady fba40733f3 Add more basic remote control stuff, but SPS gets confused about who it can control. 2018-03-18 19:10:45 +00:00
Mike Brady 13931664ed Check if locks are already acquired. 2018-03-16 15:57:35 +00:00
Mike Brady 9d9b0a1824 Add a Shairport Sync Diagnostics DBus Onject, only part working 2018-03-10 17:01:42 +00:00
Mike Brady c36a7822a3 Tidy up using clang-format 2018-03-07 14:35:25 +00:00
Mike Brady 07e46565ca Eliminate almost all warnings from -Wall 2018-03-07 14:29:14 +00:00
Mike Brady a7d82ae823 Begin to avoid strict aliasing violations -- not finished yet. 2018-03-07 08:58:23 +00:00
Mike Brady 71a9a0cb81 Add timings to warnings and die messages if debugging is enabled. 2018-02-20 09:20:21 +00:00
Mike Brady 283e4930e8 Add support for OpenBSD compilation 2018-02-09 21:11:39 +00:00
Mike Brady a89742e3a0 Quieten some debug messages. 2018-02-05 18:10:49 +00:00
Mike Brady a0bb2993df Add timing to debug messages, make timing sender wait interruptable eveyr 20 ms, thus making TEARDOWN faster. 2018-02-03 20:24:58 +00:00
Mike Brady f83b86ec23 Add the option to use a flat volume control profile. 2018-01-29 22:28:22 +00:00
Mike Brady 86b72a981a Fix small compilation bug evident in FreeBSD 2018-01-23 10:18:02 +00:00
Mike Brady 7a73e8fd2a Brown bag update. Fix compilation errors when neither mpris nor dbus is selected. 2018-01-17 10:32:31 +00:00
Mike Brady 4aaa8d19fe Implement a rudimentary cover art file writing facility. 2018-01-16 22:22:03 +00:00
Belbo b98e6a9ac0 Fixed race condition when stopping other threads with SIGUSR1
Many threads have a main loop that checks some exit variable in the loop condition. To stop a thread, another thread sets that exit variable, sends a SIGUSR1 to that thread to get it out of blocking calls like read(), write() or select(), and finally joins it.

There was a race condition though: if the signal arrived after the loop condition was checked but before the blocking system function was entered, the target thread essentially ignored the signal, made the blocking call anyway, and could get stuck forever there.

The only way around this race condition is to block SIGUSR1 in the destination thread during the critical time interval. This requires that the blocking system call and the call to unblock SIGUSR1 be an atomic unit. There is only one system call that makes this possible: pselect(), which takes a signal mask to replace the current signal mask with, but only while pselect() runs. Other functions like read(), recv(), write() and sendto() may only be called if we can be sure that they don't block. For this purpose, the file descriptors must be set to non-blocking mode and we must prepend the call to them with a call to pselect() to block until the socket becomes readable/writable.
2017-11-01 20:46:05 +01:00
Belbo 3e54765193 Fixed loop condition in non_blocking_write()
The while loop should be repeated, if the last write attempt was a partial write only. In this case, however, rc is greater than 0 (should be 1), not equal to 0.
2017-10-31 23:19:22 +01:00
Belbo 19ff6042cf Prevent buffer overflow in log functions
die(), warn(), debug() and inform() write the string into a limited internal buffer first. They now use vsnprintf() instead of vsprintf() to prevent an overflow of that buffer.
2017-10-31 23:19:21 +01:00
Mike Brady 3001f39bc5 3.1.2 pretty-print using clang-format 2017-09-07 12:02:00 +01:00
Mike Brady 48c1d3eb20 Add fixes suggested by using "infer" 2017-09-03 22:46:57 +01:00
Mike Brady 31a09bb368 Fix some silent issues that were highlighted by "infer" 2017-09-03 15:08:13 +01:00
Mike Brady d3148eb464 Improve handling of player lock and simplify handling of loss of connection and improve some debug messages 2017-08-27 12:43:42 +01:00
Mike Brady e513e5330c Tidy up source using clang-format 2017-07-31 11:57:57 +02:00
Cody Cutrer 3e9e228564 read stdout from the on-start command to choose ALSA output device
refs GH-452
2017-06-24 19:46:03 -06:00
Mike Brady e37c277b0a Add a "run_this_when_volume_is_set" facility to call a program when the volume is set. The AirPlay volume is passed. 2017-04-23 12:37:11 +01:00
Mike Brady a53b4c5c36 Fix some warnings from clang on FreeBSD. One was significant -- the randarray stuff didn't look right. 2017-04-16 16:52:43 +01:00
Tobias Kortkamp c9e378f515 FreeBSD doesn't have ETIME but both FreeBSD and Linux know ETIMEDOUT 2017-04-15 02:28:57 +02:00
Mike Brady 5855264eff Improve error reporting in non-blocking write code 2017-04-07 18:45:28 +01:00
Yann Pomarede 2ab2a84c14 change function die, warn, inform and debug
change funcions die, warn, inform and debug argument from `char*` to `const char*` to prevent a warning in C==
2017-02-28 12:47:03 +01:00
Mike Brady cf29625d2c Clang Format 2017-02-11 12:12:07 +00:00
Mike Brady 2a4a4ed22b Add volume_max_db setting which works on the hw mixer if it exists or the sw attenuator otherwise. 2017-02-05 16:18:05 +00:00