MIN and MAX are already defined on MacOS.
fprintf(stderr, "loaded: %d\n", loaded);
if (loaded < conf.bufsize_arg) {
FD_SET(fd, &rfd);
- max_fileno = MAX(max_fileno, fd);
+ max_fileno = PARA_MAX(max_fileno, fd);
}
if (loaded > 0) {
FD_SET(STDOUT_FILENO, &wfd);
- max_fileno = MAX(max_fileno, STDOUT_FILENO);
+ max_fileno = PARA_MAX(max_fileno, STDOUT_FILENO);
check_write = 1;
}
ret = -E_OVERRUN;
free(cmd);
/* filters */
filter_init(filters);
- nf = MAX(2, conf.filter_given) + 1;
+ nf = PARA_MAX(2, conf.filter_given) + 1;
PARA_INFO_LOG("allocating space for %d filters\n", nf);
FOR_EACH_AUDIO_FORMAT(i) {
afi[i].filter_conf = para_malloc(nf * sizeof(char *));
a = &afi[s->format];
ret = a->receiver->pre_select(rn, rfds, wfds, tv);
// PARA_NOTICE_LOG("%s preselect: %d\n", a->receiver->name, ret);
- *max_fileno = MAX(*max_fileno, ret);
+ *max_fileno = PARA_MAX(*max_fileno, ret);
}
}
static void audiod_post_select(int select_ret, fd_set *rfds, fd_set *wfds)
static ssize_t compress(char *inbuf, size_t inbuf_len, struct filter_node *fn)
{
- size_t i, length = MIN((inbuf_len / 2) * 2, (fn->bufsize - fn->loaded) / 2 * 2);
+ size_t i, length = PARA_MIN((inbuf_len / 2) * 2,
+ (fn->bufsize - fn->loaded) / 2 * 2);
struct private_compress_data *pcd = fn->private_data;
int16_t *ip = (int16_t *)inbuf, *op = (int16_t *)(fn->buf + fn->loaded);
unsigned gain_shift = pcd->conf->inertia_arg + pcd->conf->damp_arg,
if (listen_fd < 0)
return;
FD_SET(listen_fd, rfds);
- *max_fileno = MAX(*max_fileno, listen_fd);
+ *max_fileno = PARA_MAX(*max_fileno, listen_fd);
}
static void dccp_post_select(__a_unused struct audio_format *af, fd_set *rfds,
size_t send, written = 0;
int ret;
again:
- send = MIN(1024, len - written);
+ send = PARA_MIN(1024, len - written);
ret = write(fd, buf + written, send);
if (ret < 0)
goto err_out;
void para_fd_set(int fd, fd_set *fds, int *max_fileno)
{
FD_SET(fd, fds);
- *max_fileno = MAX(*max_fileno, fd);
+ *max_fileno = PARA_MAX(*max_fileno, fd);
}
for (i = 0; audio_formats[i]; i++) {
PARA_INFO_LOG("%s filter chain length: %d\n", audio_formats[i],
num_filters(i));
- ret = MAX(ret, num_filters(i));
+ ret = PARA_MAX(ret, num_filters(i));
}
PARA_INFO_LOG("maximal filter chain length: %d\n", ret);
return ret;
/* audiod pipe */
if (audiod_pipe < 0)
audiod_pipe = open_audiod_pipe();
+ /* FIXME: para_fd_set */
if (audiod_pipe >= 0) {
FD_SET(audiod_pipe, &rfds);
- max_fileno = MAX(max_fileno, audiod_pipe);
+ max_fileno = PARA_MAX(max_fileno, audiod_pipe);
}
/* signal pipe */
FD_SET(signal_pipe, &rfds);
- max_fileno = MAX(max_fileno, signal_pipe);
+ max_fileno = PARA_MAX(max_fileno, signal_pipe);
/* command pipe only for COMMAND_MODE */
if (command_pipe >= 0 && mode == COMMAND_MODE) {
FD_SET(command_pipe, &rfds);
- max_fileno = MAX(max_fileno, command_pipe);
+ max_fileno = PARA_MAX(max_fileno, command_pipe);
}
if (curses_active)
FD_SET(STDIN_FILENO, &rfds);
free(hc);
}
+/* FIXME: use para_fdset */
static void http_pre_select(struct audio_format *af, int *max_fileno, fd_set *rfds,
fd_set *wfds)
{
if (server_fd < 0)
return;
FD_SET(server_fd, rfds);
- *max_fileno = MAX(*max_fileno, server_fd);
+ *max_fileno = PARA_MAX(*max_fileno, server_fd);
list_for_each_entry_safe(hc, tmp, &clients, node) {
//PARA_DEBUG_LOG("hc %p on fd %d: status %d\n", hc, hc->fd, hc->status);
hc->check_r = 0;
break;
case HTTP_CONNECTED: /* need to recv get request */
FD_SET(hc->fd, rfds);
- *max_fileno = MAX(*max_fileno, hc->fd);
+ *max_fileno = PARA_MAX(*max_fileno, hc->fd);
hc->check_r = 1;
break;
case HTTP_GOT_GET_REQUEST: /* need to send ok msg */
case HTTP_INVALID_GET_REQUEST: /* need to send err msg */
FD_SET(hc->fd, wfds);
- *max_fileno = MAX(*max_fileno, hc->fd);
+ *max_fileno = PARA_MAX(*max_fileno, hc->fd);
hc->check_w = 1;
break;
case HTTP_SENT_OK_MSG:
if (!af || !afs_playing())
break; /* wait until server starts playing */
FD_SET(hc->fd, wfds);
- *max_fileno = MAX(*max_fileno, hc->fd);
+ *max_fileno = PARA_MAX(*max_fileno, hc->fd);
hc->check_w = 1;
break;
}
{
int i, ret;
struct private_mp3dec_data *pmd = fn->private_data;
- size_t copy = MIN(len, 4096);
+ size_t copy = PARA_MIN(len, 4096);
if (fn->loaded > fn->bufsize * 4 / 5)
return 0;
break;
pos = ov_raw_tell(oggvorbis_file);
diff = pos - old_pos;
- max_chunk_len = MAX(max_chunk_len, diff);
- min = (i == 1)? diff : MIN(min, diff);
+ max_chunk_len = PARA_MAX(max_chunk_len, diff);
+ min = (i == 1)? diff : PARA_MIN(min, diff);
chunk_table[i] = pos;
if (i < 11 || !((i - 1) % 1000)|| i > num - 11)
PARA_DEBUG_LOG("chunk #%d: %g secs, pos: %zd, "
errno = EAGAIN;
return -1;
}
- ret = MIN(nmemb, have / size) * size;
+ ret = PARA_MIN(nmemb, have / size) * size;
memcpy(buf, p, ret);
pod->converted += ret;
return ret;
#define MAXLINE 255
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#define ABS(a) ((a) > 0 ? (a) : -(a))
+#define PARA_MIN(a,b) ((a) < (b) ? (a) : (b))
+#define PARA_MAX(a,b) ((a) > (b) ? (a) : (b))
+#define PARA_ABS(a) ((a) > 0 ? (a) : -(a))
/* Loglevels */
#define DEBUG 1
char **file_list;
unsigned i;
- num = MIN(num, playlist_len);
+ num = PARA_MIN(num, playlist_len);
if (!num)
return NULL;
file_list = para_malloc((num + 1) * sizeof(char *));
goto out;
/* careful, files might got deleted underneath */
num_audio_files = audio_file_count; /* can only decrease */
- len = MIN(num, num_audio_files);
+ len = PARA_MIN(num, num_audio_files);
ret = -E_NOTHING_FOUND;
if (!len) /* nothing found, return NULL */
goto out;
timeout.tv_usec = 1000 * 1000;
max = -1;
ret = r->pre_select(&rn, &rfds, &wfds, &timeout);
- max = MAX(max, ret);
+ max = PARA_MAX(max, ret);
PARA_DEBUG_LOG("timeout: %lums\n", tv2ms(&timeout));
ret = para_select(max + 1, &rfds, &wfds, &timeout);
FD_SET(sockfd, &rfds);
max_fileno = sockfd;
FD_SET(signal_pipe, &rfds);
- max_fileno = MAX(max_fileno, signal_pipe);
+ max_fileno = PARA_MAX(max_fileno, signal_pipe);
timeout = afs_preselect();
status_refresh();
}
if (selectors[mmd->selector_num].pre_select) {
ret = selectors[mmd->selector_num].pre_select(&rfds, &wfds);
- max_fileno = MAX(max_fileno, ret);
+ max_fileno = PARA_MAX(max_fileno, ret);
}
mmd_unlock();
ret = para_select(max_fileno + 1, &rfds, &wfds, timeout);
{
struct timeval tmp1, tmp2, tmp3;
int ret = 1, subtract = ((a > 0 && b < 0) || (a < 0 && b > 0));
- unsigned long a1 = ABS(a), b1 = ABS(b);
+ unsigned long a1 = PARA_ABS(a), b1 = PARA_ABS(b);
tv_scale(a1, tv1, &tmp1);
tv_scale(b1, tv2, &tmp2);
*bof = 0;
// return 0;
}
- copy = MIN(len, fn->bufsize - fn->loaded);
+ copy = PARA_MIN(len, fn->bufsize - fn->loaded);
memmove(fn->buf + fn->loaded, inbuf, copy);
fn->loaded += copy;
// PARA_DEBUG_LOG("len = %d, copy = %d\n", len, copy);