freebsd port
Adrian Smith
9 years ago
|
0 |
CPPFLAGS = -I/usr/local/include
|
|
1 |
LDFLAGS = -L/usr/local/lib -lportaudio -lpthread -lm
|
|
2 |
|
|
3 |
include Makefile
|
148 | 148 |
|
149 | 149 |
mutex_create(decode.mutex);
|
150 | 150 |
|
151 | |
#if LINUX || OSX
|
|
151 |
#if LINUX || OSX || FREEBSD
|
152 | 152 |
pthread_attr_t attr;
|
153 | 153 |
pthread_attr_init(&attr);
|
154 | 154 |
pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + DECODE_THREAD_STACK_SIZE);
|
|
177 | 177 |
}
|
178 | 178 |
running = false;
|
179 | 179 |
UNLOCK_D;
|
180 | |
#if LINUX || OSX
|
|
180 |
#if LINUX || OSX || FREEBSD
|
181 | 181 |
pthread_join(thread, NULL);
|
182 | 182 |
#endif
|
183 | 183 |
mutex_destroy(decode.mutex);
|
324 | 324 |
// if default setting used and nothing in buffer attempt to resize to provide full crossfade support
|
325 | 325 |
LOG_INFO("resize outputbuf for crossfade");
|
326 | 326 |
_buf_resize(outputbuf, OUTPUTBUF_SIZE_CROSSFADE);
|
327 | |
#if LINUX
|
|
327 |
#if LINUX || FREEBSD
|
328 | 328 |
touch_memory(outputbuf->buf, outputbuf->size);
|
329 | 329 |
#endif
|
330 | 330 |
}
|
264 | 264 |
LOG_WARN("error setting finish callback: %s", Pa_GetErrorText(err));
|
265 | 265 |
}
|
266 | 266 |
|
|
267 |
UNLOCK; // StartStream can call pa_callback in a sychronised thread on freebsd, remove lock while it is called
|
|
268 |
|
267 | 269 |
if ((err = Pa_StartStream(pa.stream)) != paNoError) {
|
268 | 270 |
LOG_WARN("error starting stream: %s", Pa_GetErrorText(err));
|
269 | 271 |
}
|
|
272 |
|
|
273 |
LOCK;
|
270 | 274 |
}
|
271 | 275 |
|
272 | 276 |
if (err && !monitor_thread_running) {
|
273 | 277 |
vis_stop();
|
274 | 278 |
|
275 | 279 |
// create a thread to check for output state change or device return
|
276 | |
#if LINUX || OSX
|
|
280 |
#if LINUX || OSX || FREEBSD
|
277 | 281 |
pthread_create(&monitor_thread, NULL, pa_monitor, NULL);
|
278 | 282 |
#endif
|
279 | 283 |
#if WIN
|
150 | 150 |
|
151 | 151 |
output_init_common(level, "-", output_buf_size, rates);
|
152 | 152 |
|
153 | |
#if LINUX || OSX
|
|
153 |
#if LINUX || OSX || FREEBSD
|
154 | 154 |
pthread_attr_t attr;
|
155 | 155 |
pthread_attr_init(&attr);
|
156 | 156 |
pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + OUTPUT_THREAD_STACK_SIZE);
|
26 | 26 |
#define LINUX 1
|
27 | 27 |
#define OSX 0
|
28 | 28 |
#define WIN 0
|
|
29 |
#define FREEBSD 0
|
29 | 30 |
#elif defined (__APPLE__)
|
30 | 31 |
#define LINUX 0
|
31 | 32 |
#define OSX 1
|
32 | 33 |
#define WIN 0
|
|
34 |
#define FREEBSD 0
|
33 | 35 |
#elif defined (_MSC_VER)
|
34 | 36 |
#define LINUX 0
|
35 | 37 |
#define OSX 0
|
36 | 38 |
#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
|
37 | 45 |
#else
|
38 | 46 |
#error unknown target
|
39 | 47 |
#endif
|
|
51 | 59 |
#define SELFPIPE 0
|
52 | 60 |
#define WINEVENT 0
|
53 | 61 |
#endif
|
54 | |
#if (LINUX && !EVENTFD) || OSX
|
|
62 |
#if (LINUX && !EVENTFD) || OSX || FREEBSD
|
55 | 63 |
#define EVENTFD 0
|
56 | 64 |
#define SELFPIPE 1
|
57 | 65 |
#define WINEVENT 0
|
|
146 | 154 |
#define LIBSOXR "libsoxr.dll"
|
147 | 155 |
#endif
|
148 | 156 |
|
|
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 |
|
149 | 169 |
#endif // !LINKALL
|
150 | 170 |
|
151 | 171 |
// config options
|
|
171 | 191 |
#include <limits.h>
|
172 | 192 |
#include <sys/types.h>
|
173 | 193 |
|
174 | |
#if LINUX || OSX
|
|
194 |
#if LINUX || OSX || FREEBSD
|
175 | 195 |
#include <unistd.h>
|
176 | 196 |
#include <stdbool.h>
|
177 | 197 |
#include <netinet/in.h>
|
|
295 | 315 |
#endif
|
296 | 316 |
|
297 | 317 |
// printf/scanf formats for u64_t
|
298 | |
#if LINUX && __WORDSIZE == 64
|
|
318 |
#if (LINUX && __WORDSIZE == 64) || (FREEBSD && __LP64__)
|
299 | 319 |
#define FMT_u64 "%lu"
|
300 | 320 |
#define FMT_x64 "%lx"
|
301 | 321 |
#elif __GLIBC_HAVE_LONG_LONG || defined __GNUC__ || WIN
|
|
353 | 373 |
char *dlerror(void);
|
354 | 374 |
int poll(struct pollfd *fds, unsigned long numfds, int timeout);
|
355 | 375 |
#endif
|
356 | |
#if LINUX
|
|
376 |
#if LINUX || FREEBSD
|
357 | 377 |
void touch_memory(u8_t *buf, size_t size);
|
358 | 378 |
#endif
|
359 | 379 |
|
19 | 19 |
|
20 | 20 |
#include "squeezelite.h"
|
21 | 21 |
|
22 | |
#if LINUX || OSX
|
|
22 |
#if LINUX || OSX || FREEBSD
|
23 | 23 |
#include <sys/ioctl.h>
|
24 | 24 |
#include <net/if.h>
|
25 | 25 |
#include <netdb.h>
|
|
26 |
#if FREEBSD
|
|
27 |
#include <ifaddrs.h>
|
|
28 |
#include <net/if_dl.h>
|
|
29 |
#include <net/if_types.h>
|
|
30 |
#endif
|
26 | 31 |
#endif
|
27 | 32 |
#if WIN
|
28 | 33 |
#include <iphlpapi.h>
|
|
81 | 86 |
#if WIN
|
82 | 87 |
return GetTickCount();
|
83 | 88 |
#else
|
84 | |
#if LINUX
|
|
89 |
#if LINUX || FREEBSD
|
85 | 90 |
struct timespec ts;
|
86 | 91 |
if (!clock_gettime(CLOCK_MONOTONIC, &ts)) {
|
87 | 92 |
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
|
130 | 135 |
}
|
131 | 136 |
#endif
|
132 | 137 |
|
133 | |
#if OSX
|
|
138 |
#if OSX || FREEBSD
|
134 | 139 |
void get_mac(u8_t mac[]) {
|
135 | 140 |
struct ifaddrs *addrs, *ptr;
|
136 | 141 |
const struct sockaddr_dl *dlAddr;
|
|
372 | 377 |
|
373 | 378 |
#endif
|
374 | 379 |
|
375 | |
#if LINUX
|
|
380 |
#if LINUX || FREEBSD
|
376 | 381 |
void touch_memory(u8_t *buf, size_t size) {
|
377 | 382 |
u8_t *ptr;
|
378 | 383 |
for (ptr = buf; ptr < buf + size; ptr += sysconf(_SC_PAGESIZE)) {
|