Package list squeezelite / 3ad55e4
freebsd port Adrian Smith 7 years ago
9 changed file(s) with 56 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
0 CPPFLAGS = -I/usr/local/include
1 LDFLAGS = -L/usr/local/lib -lportaudio -lpthread -lm
2
3 include Makefile
148148
149149 mutex_create(decode.mutex);
150150
151 #if LINUX || OSX
151 #if LINUX || OSX || FREEBSD
152152 pthread_attr_t attr;
153153 pthread_attr_init(&attr);
154154 pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + DECODE_THREAD_STACK_SIZE);
177177 }
178178 running = false;
179179 UNLOCK_D;
180 #if LINUX || OSX
180 #if LINUX || OSX || FREEBSD
181181 pthread_join(thread, NULL);
182182 #endif
183183 mutex_destroy(decode.mutex);
7272 #if VISEXPORT
7373 " -v \t\t\tVisulizer support\n"
7474 #endif
75 #if LINUX
75 #if LINUX || FREEBSD
7676 " -z \t\t\tDaemonize\n"
7777 #endif
7878 " -t \t\t\tLicense terms\n"
8686 #endif
8787 #if OSX
8888 " OSX"
89 #endif
90 #if FREEBSD
91 " FREEBSD"
8992 #endif
9093 #if ALSA
9194 " ALSA"
161164 unsigned rate_delay = 0;
162165 char *resample = NULL;
163166 char *output_params = NULL;
164 #if LINUX
167 #if LINUX || FREEBSD
165168 bool daemonize = false;
166169 #endif
167170 #if ALSA
349352 visexport = true;
350353 break;
351354 #endif
352 #if LINUX
355 #if LINUX || FREEBSD
353356 case 'z':
354357 daemonize = true;
355358 break;
397400 }
398401 }
399402
400 #if LINUX
403 #if LINUX || FREEBSD
401404 if (daemonize) {
402405 if (daemon(0, logfile ? 1 : 0)) {
403406 fprintf(stderr, "error daemonizing: %s\n", strerror(errno));
324324 // if default setting used and nothing in buffer attempt to resize to provide full crossfade support
325325 LOG_INFO("resize outputbuf for crossfade");
326326 _buf_resize(outputbuf, OUTPUTBUF_SIZE_CROSSFADE);
327 #if LINUX
327 #if LINUX || FREEBSD
328328 touch_memory(outputbuf->buf, outputbuf->size);
329329 #endif
330330 }
264264 LOG_WARN("error setting finish callback: %s", Pa_GetErrorText(err));
265265 }
266266
267 UNLOCK; // StartStream can call pa_callback in a sychronised thread on freebsd, remove lock while it is called
268
267269 if ((err = Pa_StartStream(pa.stream)) != paNoError) {
268270 LOG_WARN("error starting stream: %s", Pa_GetErrorText(err));
269271 }
272
273 LOCK;
270274 }
271275
272276 if (err && !monitor_thread_running) {
273277 vis_stop();
274278
275279 // create a thread to check for output state change or device return
276 #if LINUX || OSX
280 #if LINUX || OSX || FREEBSD
277281 pthread_create(&monitor_thread, NULL, pa_monitor, NULL);
278282 #endif
279283 #if WIN
150150
151151 output_init_common(level, "-", output_buf_size, rates);
152152
153 #if LINUX || OSX
153 #if LINUX || OSX || FREEBSD
154154 pthread_attr_t attr;
155155 pthread_attr_init(&attr);
156156 pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + OUTPUT_THREAD_STACK_SIZE);
2626 #define LINUX 1
2727 #define OSX 0
2828 #define WIN 0
29 #define FREEBSD 0
2930 #elif defined (__APPLE__)
3031 #define LINUX 0
3132 #define OSX 1
3233 #define WIN 0
34 #define FREEBSD 0
3335 #elif defined (_MSC_VER)
3436 #define LINUX 0
3537 #define OSX 0
3638 #define WIN 1
39 #define FREEBSD 0
40 #elif defined(__FreeBSD__)
41 #define LINUX 0
42 #define OSX 0
43 #define WIN 0
44 #define FREEBSD 1
3745 #else
3846 #error unknown target
3947 #endif
5159 #define SELFPIPE 0
5260 #define WINEVENT 0
5361 #endif
54 #if (LINUX && !EVENTFD) || OSX
62 #if (LINUX && !EVENTFD) || OSX || FREEBSD
5563 #define EVENTFD 0
5664 #define SELFPIPE 1
5765 #define WINEVENT 0
146154 #define LIBSOXR "libsoxr.dll"
147155 #endif
148156
157 #if FREEBSD
158 #define LIBFLAC "libFLAC.so.11"
159 #define LIBMAD "libmad.so.2"
160 #define LIBMPG "libmpg123.so.0"
161 #define LIBVORBIS "libvorbisfile.so.6"
162 #define LIBTREMOR "libvorbisidec.so.1"
163 #define LIBFAAD "libfaad.so.2"
164 #define LIBAVUTIL "libavutil.so.%d"
165 #define LIBAVCODEC "libavcodec.so.%d"
166 #define LIBAVFORMAT "libavformat.so.%d"
167 #endif
168
149169 #endif // !LINKALL
150170
151171 // config options
171191 #include <limits.h>
172192 #include <sys/types.h>
173193
174 #if LINUX || OSX
194 #if LINUX || OSX || FREEBSD
175195 #include <unistd.h>
176196 #include <stdbool.h>
177197 #include <netinet/in.h>
295315 #endif
296316
297317 // printf/scanf formats for u64_t
298 #if LINUX && __WORDSIZE == 64
318 #if (LINUX && __WORDSIZE == 64) || (FREEBSD && __LP64__)
299319 #define FMT_u64 "%lu"
300320 #define FMT_x64 "%lx"
301321 #elif __GLIBC_HAVE_LONG_LONG || defined __GNUC__ || WIN
353373 char *dlerror(void);
354374 int poll(struct pollfd *fds, unsigned long numfds, int timeout);
355375 #endif
356 #if LINUX
376 #if LINUX || FREEBSD
357377 void touch_memory(u8_t *buf, size_t size);
358378 #endif
359379
301301
302302 fd = -1;
303303
304 #if LINUX
304 #if LINUX || FREEBSD
305305 touch_memory(streambuf->buf, streambuf->size);
306306 #endif
307307
308 #if LINUX || OSX
308 #if LINUX || OSX || FREEBSD
309309 pthread_attr_t attr;
310310 pthread_attr_init(&attr);
311311 pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + STREAM_THREAD_STACK_SIZE);
322322 LOCK;
323323 running = false;
324324 UNLOCK;
325 #if LINUX || OSX
325 #if LINUX || OSX || FREEBSD
326326 pthread_join(thread, NULL);
327327 #endif
328328 free(stream.header);
1919
2020 #include "squeezelite.h"
2121
22 #if LINUX || OSX
22 #if LINUX || OSX || FREEBSD
2323 #include <sys/ioctl.h>
2424 #include <net/if.h>
2525 #include <netdb.h>
26 #if FREEBSD
27 #include <ifaddrs.h>
28 #include <net/if_dl.h>
29 #include <net/if_types.h>
30 #endif
2631 #endif
2732 #if WIN
2833 #include <iphlpapi.h>
8186 #if WIN
8287 return GetTickCount();
8388 #else
84 #if LINUX
89 #if LINUX || FREEBSD
8590 struct timespec ts;
8691 if (!clock_gettime(CLOCK_MONOTONIC, &ts)) {
8792 return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
130135 }
131136 #endif
132137
133 #if OSX
138 #if OSX || FREEBSD
134139 void get_mac(u8_t mac[]) {
135140 struct ifaddrs *addrs, *ptr;
136141 const struct sockaddr_dl *dlAddr;
372377
373378 #endif
374379
375 #if LINUX
380 #if LINUX || FREEBSD
376381 void touch_memory(u8_t *buf, size_t size) {
377382 u8_t *ptr;
378383 for (ptr = buf; ptr < buf + size; ptr += sysconf(_SC_PAGESIZE)) {