From: Andre Noll Date: Sun, 26 Apr 2015 12:11:56 +0000 (+0200) Subject: Merge branch 'refs/heads/t/immediate-si-update' X-Git-Tag: v0.5.5~40 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=1a8e3628040a94a8c06027335962a6cb2f827a63;hp=f3623744f5b28e0df91323cf5069f1932df7848d Merge branch 'refs/heads/t/immediate-si-update' Cooking in next for four weeks. * aft: Store resolved paths when adding files. * aft: Update mtime and file size on afhi changes. * aft: Update status items on afs events. * aft.c: Pass struct ls_data pointer to make_status_items(). * afs: Simplify open_next_audio_file(). Conflicts: aft.c --- diff --git a/.gitignore b/.gitignore index 6df2e505..2889d20d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,8 @@ TODO paraslash-*.tar.bz2 web/dia/overview.pdf *.swp +*.rej +*~ error2.h web_sync confdefs.h diff --git a/INSTALL b/INSTALL index 4a814dc1..4cc4b1fe 100644 --- a/INSTALL +++ b/INSTALL @@ -1,15 +1,21 @@ Any knowledge of how to work with mouse and icons is not required. -From tarball: - +Installing osl +~~~~~~~~~~~~~~ + git clone git://git.tuebingen.mpg.de/osl + cd osl && make && sudo make install + (see http://people.tuebingen.mpg.de/maan/osl/) + +Installing paraslash from tarball +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./configure && make && sudo make install -From git: - - ./autogen.sh && sudo make install - -Example for cross-compiling: +Installing paraslash from git +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + autoconf && autoheader && make && sudo make install +Example for cross-compiling +~~~~~~~~~~~~~~~~~~~~~~~~~~~ export CROSS_COMPILE='armv6j-hardfloat-linux-gnueabi-' export PATH="/usr/cross/arm/bin:$PATH" export CC=${CROSS_COMPILE}gcc diff --git a/Makefile.in b/Makefile.in index 8e7e7760..14015c9b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,10 +44,13 @@ ogg_cppflags := @ogg_cppflags@ mad_cppflags := @mad_cppflags@ faad_cppflags := @faad_cppflags@ curses_cppflags := @curses_cppflags@ +pthread_cppflags := @pthread_cppflags@ ao_cppflags := @ao_cppflags@ flac_cppflags := @flac_cppflags@ samplerate_cppflags := @samplerate_cppflags@ readline_cppflags := @readline_cppflags@ +alsa_cppflags := @alsa_cppflags@ +oss_cppflags := @oss_cppflags@ clock_gettime_ldflags := @clock_gettime_ldflags@ id3tag_ldflags := @id3tag_ldflags@ @@ -60,15 +63,15 @@ mad_ldflags := @mad_ldflags@ flac_ldflags := @flac_ldflags@ oss_ldflags := @oss_ldflags@ alsa_ldflags := @alsa_ldflags@ +pthread_ldflags := @pthread_ldflags@ ao_ldflags := @ao_ldflags@ readline_ldflags := @readline_ldflags@ samplerate_ldflags := @samplerate_ldflags@ osl_ldflags := @osl_ldflags@ -openssl_ldflags := @openssl_ldflags@ -gcrypt_ldflags := @gcrypt_ldflags@ socket_ldflags := @socket_ldflags@ nsl_ldflags := @nsl_ldflags@ curses_ldflags := @curses_ldflags@ core_audio_ldflags := @core_audio_ldflags@ +crypto_ldflags := @crypto_ldflags@ include Makefile.real diff --git a/Makefile.real b/Makefile.real index 6c7b38f2..c5d64058 100644 --- a/Makefile.real +++ b/Makefile.real @@ -196,7 +196,7 @@ $(object_dir)/flac%.o $(dep_dir)/flac%.d: CPPFLAGS += $(flac_cppflags) $(object_dir)/mp3_afh.o $(dep_dir)/mp3_afh.d: CPPFLAGS += $(id3tag_cppflags) $(object_dir)/crypt.o $(dep_dir)/crypt.d: CPPFLAGS += $(openssl_cppflags) $(object_dir)/gcrypt.o $(dep_dir)/gcrypt.d: CPPFLAGS += $(gcrypt_cppflags) -$(object_dir)/ao_write.o $(dep_dir)/ao_write.d: CPPFLAGS += $(ao_cppflags) +$(object_dir)/alsa%.o $(dep_dir)/alsa%.d: CPPFLAGS += $(alsa_cppflags) $(object_dir)/interactive.o $(dep_dir)/interactive.d \ : CPPFLAGS += $(readline_cppflags) @@ -204,6 +204,12 @@ $(object_dir)/interactive.o $(dep_dir)/interactive.d \ $(object_dir)/resample_filter.o $(dep_dir)/resample_filter.d \ : CPPFLAGS += $(samplerate_cppflags) +$(object_dir)/oss_write.o $(dep_dir)/oss_write.d \ +: CPPFLAGS += $(oss_cppflags) + +$(object_dir)/ao_write.o $(dep_dir)/ao_write.d \ +: CPPFLAGS += $(ao_cppflags) $(pthread_cppflags) + $(object_dir)/mp3dec_filter.o $(dep_dir)/mp3dec_filter.d \ : CPPFLAGS += $(mad_cppflags) @@ -264,7 +270,8 @@ $(dep_dir)/%.d: %.c error2.h | $(dep_dir) -e "s@ \([a-zA-Z0-9_]\{1,\}\.completion.h\)@ $(cmdlist_dir)/\1@g" > $@ para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags) -para_write para_play para_audiod: LDFLAGS += $(ao_ldflags) $(core_audio_ldflags) +para_write para_play para_audiod \ +: LDFLAGS += $(ao_ldflags) $(pthread_ldflags) $(core_audio_ldflags) para_client para_audioc para_play : LDFLAGS += $(readline_ldflags) para_server: LDFLAGS += $(osl_ldflags) para_gui: LDFLAGS += $(curses_ldflags) @@ -272,8 +279,7 @@ para_server \ para_client \ para_audiod \ :LDFLAGS += \ - $(openssl_ldflags) \ - $(gcrypt_ldflags) + $(crypto_ldflags) para_audiod \ para_filter \ diff --git a/NEWS b/NEWS index b29d4b82..22e16ebe 100644 --- a/NEWS +++ b/NEWS @@ -7,8 +7,12 @@ current master branch "magnetic momentum" - On Linux systems, local sockets are now created in the abstract name space by default. This allows to get rid of the socket specials in /var/paraslash. + - New autoconf macros to avoid duplication in configure.ac. + - Status items (as shown by para_gui) are updated correctly + when the meta information of the current audio changes. Download: ./releases/paraslash-git.tar.bz2 (tarball) + ------------------------------------------ 0.5.4 (2015-01-23) "exponential alignment" ------------------------------------------ diff --git a/afh_common.c b/afh_common.c index edfc8d1d..08bcde90 100644 --- a/afh_common.c +++ b/afh_common.c @@ -42,7 +42,7 @@ static struct audio_format_handler afl[] = { }, { .name = "ogg", -#ifdef HAVE_OGGVORBIS +#if defined(HAVE_OGG) && defined(HAVE_VORBIS) .init = ogg_init, #endif }, @@ -58,7 +58,7 @@ static struct audio_format_handler afl[] = { }, { .name = "spx", -#ifdef HAVE_SPEEX +#if defined(HAVE_OGG) && defined(HAVE_SPEEX) .init = spx_afh_init, #endif }, @@ -70,7 +70,7 @@ static struct audio_format_handler afl[] = { }, { .name = "opus", -#ifdef HAVE_OPUS +#if defined(HAVE_OGG) && defined(HAVE_OPUS) .init = opus_afh_init, #endif }, diff --git a/afs.c b/afs.c index a16252cd..ea0a9f9f 100644 --- a/afs.c +++ b/afs.c @@ -195,7 +195,7 @@ static int dispatch_result(int result_shmid, callback_result_handler *handler, * copied. It then notifies the afs process that the callback function \a f * should be executed by sending the shared memory identifier (shmid) to the * socket. - + * * If the callback produces a result, it sends any number of shared memory * identifiers back via the socket. For each such identifier received, \a * result_handler is called. The contents of the sma identified by the received @@ -236,8 +236,8 @@ int send_callback_request(callback_function *f, struct osl_object *query, if (ret < 0) goto out; - *(uint32_t *) buf = afs_socket_cookie; - *(int *) (buf + sizeof(afs_socket_cookie)) = query_shmid; + *(uint32_t *)buf = afs_socket_cookie; + *(int *)(buf + sizeof(afs_socket_cookie)) = query_shmid; ret = connect_local_socket(conf.afs_socket_arg); if (ret < 0) @@ -595,8 +595,9 @@ static void com_select_callback(int fd, const struct osl_object *query) activate_mood_or_playlist(NULL, &num_admissible); } } else - ret2 = para_printf(&pb, "activated %s (%d admissible files)\n", current_mop? - current_mop : "dummy mood", num_admissible); + ret2 = para_printf(&pb, "activated %s (%d admissible files)\n", + current_mop? current_mop : "dummy mood", + num_admissible); out: if (ret2 >= 0 && pb.offset) pass_buffer_as_shm(fd, SBD_OUTPUT, pb.buf, pb.offset); @@ -998,7 +999,13 @@ static void create_tables_callback(int fd, const struct osl_object *query) { uint32_t table_mask = *(uint32_t *)query->data; int i, ret; - struct para_buffer pb = {.buf = NULL}; + struct para_buffer pb = { + .max_size = shm_get_shmmax(), + .private_data = &(struct afs_max_size_handler_data) { + .fd = fd, + .band = SBD_OUTPUT + } + }; close_afs_tables(); for (i = 0; i < NUM_AFS_TABLES; i++) { diff --git a/aft.c b/aft.c index fb0d4fd2..acf75156 100644 --- a/aft.c +++ b/aft.c @@ -669,16 +669,13 @@ err: int load_afd(int shmid, struct audio_file_data *afd) { void *shm_afd; - char *buf; int ret; ret = shm_attach(shmid, ATTACH_RO, &shm_afd); if (ret < 0) return ret; *afd = *(struct audio_file_data *)shm_afd; - buf = shm_afd; - buf += sizeof(*afd); - load_chunk_table(&afd->afhi, buf); + load_chunk_table(&afd->afhi, shm_afd + sizeof(*afd)); shm_detach(shm_afd); return 1; } @@ -1121,13 +1118,13 @@ again: return ret; ret = mmap_full_file(d->path, O_RDONLY, &map.data, &map.size, &afd->fd); if (ret < 0) - goto err; + goto out; hash_function(map.data, map.size, file_hash); ret = hash_compare(file_hash, d->hash); para_munmap(map.data, map.size); if (ret) { ret = -E_HASH_MISMATCH; - goto err; + goto out; } new_afsi = d->afsi; new_afsi.num_played++; @@ -1144,7 +1141,7 @@ again: */ afs_event(AFSI_CHANGE, NULL, &aced); ret = save_afd(afd); -err: +out: free(afd->afhi.chunk_table); osl_close_disk_object(&chunk_table_obj); if (ret < 0) { @@ -2103,7 +2100,10 @@ static void com_touch_callback(int fd, const struct osl_object *query) struct touch_action_data tad = {.cto = query->data, .pb = { .max_size = shm_get_shmmax(), - .private_data = &fd, + .private_data = &(struct afs_max_size_handler_data) { + .fd = fd, + .band = SBD_OUTPUT + }, .max_size_handler = afs_max_size_handler } }; @@ -2244,7 +2244,10 @@ static void com_rm_callback(int fd, const struct osl_object *query) struct com_rm_action_data crd = {.flags = *(uint32_t *)query->data, .pb = { .max_size = shm_get_shmmax(), - .private_data = &fd, + .private_data = &(struct afs_max_size_handler_data) { + .fd = fd, + .band = SBD_OUTPUT + }, .max_size_handler = afs_max_size_handler } }; @@ -2386,7 +2389,10 @@ static void com_cpsi_callback(int fd, const struct osl_object *query) .flags = *(unsigned *)query->data, .pb = { .max_size = shm_get_shmmax(), - .private_data = &fd, + .private_data = &(struct afs_max_size_handler_data) { + .fd = fd, + .band = SBD_OUTPUT + }, .max_size_handler = afs_max_size_handler } }; diff --git a/alsa_mix.c b/alsa_mix.c index 5a46963e..cad58af0 100644 --- a/alsa_mix.c +++ b/alsa_mix.c @@ -100,11 +100,13 @@ static bool channel_has_playback(snd_mixer_selem_channel_id_t chn, static char *alsa_mix_get_channels(struct mixer_handle *handle) { + int ret; char *list = NULL; snd_mixer_selem_id_t *sid; snd_mixer_elem_t *elem; - snd_mixer_selem_id_alloca(&sid); + ret = snd_mixer_selem_id_malloc(&sid); + assert(ret >= 0); elem = snd_mixer_first_elem(handle->mixer); for (; elem; elem = snd_mixer_elem_next(elem)) { char *tmp = list; @@ -122,6 +124,7 @@ static char *alsa_mix_get_channels(struct mixer_handle *handle) name); free(tmp); } + snd_mixer_selem_id_free(sid); return list; } @@ -133,7 +136,8 @@ static int alsa_mix_set_channel(struct mixer_handle *h, if (!mixer_channel) mixer_channel = "Master"; - snd_mixer_selem_id_alloca(&sid); + ret = snd_mixer_selem_id_malloc(&sid); + assert(ret >= 0); snd_mixer_selem_id_set_index(sid, selem_id); snd_mixer_selem_id_set_name(sid, mixer_channel); h->elem = snd_mixer_find_selem(h->mixer, sid); @@ -141,21 +145,27 @@ static int alsa_mix_set_channel(struct mixer_handle *h, PARA_NOTICE_LOG("unable to find simple control '%s',%i\n", snd_mixer_selem_id_get_name(sid), snd_mixer_selem_id_get_index(sid)); - return -E_BAD_CHANNEL; + ret = -E_BAD_CHANNEL; + goto out; } ret = snd_mixer_selem_get_playback_volume_range(h->elem, &h->pmin, &h->pmax); if (ret < 0) { PARA_NOTICE_LOG("unable to get %s range (%s): %s\n", mixer_channel, h->card, snd_strerror(ret)); - return -E_ALSA_MIX_RANGE; + ret = -E_ALSA_MIX_RANGE; + goto out; } if (h->pmin >= h->pmax) { PARA_NOTICE_LOG("alsa reported %s range %ld-%ld (%s)\n", mixer_channel, h->pmin, h->pmax, h->card); - return -E_ALSA_MIX_RANGE; + ret = -E_ALSA_MIX_RANGE; + goto out; } - return 1; + ret = 1; +out: + snd_mixer_selem_id_free(sid); + return ret; } static int alsa_mix_get(struct mixer_handle *h) diff --git a/alsa_write.c b/alsa_write.c index b0b21f2b..63a7055b 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -74,8 +74,8 @@ static snd_pcm_format_t get_alsa_pcm_format(enum sample_format sf) static int alsa_init(struct private_alsa_write_data *pad, struct alsa_write_args_info *conf) { - snd_pcm_hw_params_t *hwparams; - snd_pcm_sw_params_t *swparams; + snd_pcm_hw_params_t *hwparams = NULL; + snd_pcm_sw_params_t *swparams = NULL; snd_pcm_uframes_t start_threshold, stop_threshold; snd_pcm_uframes_t buffer_size, period_size; snd_output_t *output_log; @@ -89,7 +89,8 @@ static int alsa_init(struct private_alsa_write_data *pad, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); if (ret < 0) goto fail; - snd_pcm_hw_params_alloca(&hwparams); + ret = snd_pcm_hw_params_malloc(&hwparams); + assert(ret >= 0); msg = "Broken alsa configuration"; ret = snd_pcm_hw_params_any(pad->handle, hwparams); if (ret < 0) @@ -140,7 +141,8 @@ static int alsa_init(struct private_alsa_write_data *pad, goto fail; /* software parameter setup */ - snd_pcm_sw_params_alloca(&swparams); + ret = snd_pcm_sw_params_malloc(&swparams); + assert(ret >= 0); snd_pcm_sw_params_current(pad->handle, swparams); snd_pcm_sw_params_set_avail_min(pad->handle, swparams, period_size); if (buffer_size < 1) @@ -190,13 +192,18 @@ static int alsa_init(struct private_alsa_write_data *pad, } snd_output_close(output_log); } - return 1; + ret = 1; + goto out; fail: if (ret < 0) PARA_ERROR_LOG("%s: %s\n", msg, snd_strerror(-ret)); else PARA_ERROR_LOG("%s\n", msg); - return -E_ALSA; + ret = -E_ALSA; +out: + snd_pcm_hw_params_free(hwparams); + snd_pcm_sw_params_free(swparams); + return ret; } static void alsa_write_pre_select(struct sched *s, void *context) diff --git a/audiod.c b/audiod.c index 8f246ba5..1f226265 100644 --- a/audiod.c +++ b/audiod.c @@ -68,6 +68,30 @@ struct audio_format_info { struct timeval restart_barrier; }; +/* Describes one instance of a receiver-filter-writer chain. */ +struct slot_info { + /* Number of the audio format in this slot. */ + int format; + /* The stream_start status item announced by para_server. */ + struct timeval server_stream_start; + /* The offset status item announced by para_server. */ + unsigned offset_seconds; + /* The seconds_total status item announced by para_server. */ + unsigned seconds_total; + /* The receiver info associated with this slot. */ + struct receiver_node *receiver_node; + /* The array of filter nodes. */ + struct filter_node *fns; + /* The array of writers attached to the last filter. */ + struct writer_node *wns; +}; + +/** Maximal number of simultaneous instances. */ +#define MAX_STREAM_SLOTS 5 + +/** Iterate over all slots. */ +#define FOR_EACH_SLOT(_slot) for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++) + /** * para_audiod uses \p MAX_STREAM_SLOTS different slots, each of which may * be associated with a receiver/filter/writer triple. This array holds all @@ -198,6 +222,35 @@ static int get_audio_format_num(const char *name) return -E_UNSUPPORTED_AUDIO_FORMAT; } +/** + * Return the flags for the \a decoder_flags status item. + * + * Allocates a string which contains one octal digit per slot. Bit zero (value + * 1) is set if a receiver is active. Bit one (value 2) and bit three (value 4) + * have the analogous meaning for filter and writer, respectively. + * + * \return String that must be freed by the caller. + */ +__malloc char *audiod_get_decoder_flags(void) +{ + int i; + char flags[MAX_STREAM_SLOTS + 1]; + + FOR_EACH_SLOT(i) { + struct slot_info *s = &slot[i]; + char flag = '0'; + if (s->receiver_node) + flag += 1; + if (s->fns) + flag += 2; + if (s->wns) + flag += 4; + flags[i] = flag; + } + flags[MAX_STREAM_SLOTS] = '\0'; + return para_strdup(flags); +} + static int get_matching_audio_format_nums(const char *re) { int i, ret; @@ -214,28 +267,44 @@ static int get_matching_audio_format_nums(const char *re) return ret; } +static int get_play_time_slot_num(void) +{ + int i, oldest_slot = -1; + struct timeval oldest_wstime = {0, 0}; + + FOR_EACH_SLOT(i) { + struct slot_info *s = &slot[i]; + struct timeval wstime; + if (!s->wns || !s->wns[0].btrn) + continue; + btr_get_node_start(s->wns[0].btrn, &wstime); + if (oldest_slot >= 0 && tv_diff(&wstime, &oldest_wstime, NULL) > 0) + continue; + oldest_wstime = wstime; + oldest_slot = i; + } + return oldest_slot; +} + /** - * Compute the play time based on information of the given slot. - * - * \param slot_num The slot number (negative means: no slot). + * Compute the play time based on information of the current slot. * * This computes a string of the form "0:07 [3:33] (3%/3:40)" using information * from the status items received from para_server and the start time of the - * (first) writer of the given slot. + * (first) writer of the current slot. * * It has to take into account that the stream was probably not started at * the beginning of the file, that the clock between the server and the client * host may differ and that playback of the stream was delayed, e.g. because - * the prebuffer filter is used in the filter configuration of the given slot. + * the prebuffer filter is used in the filter configuration. * - * If no writer is active in the given slot, or \a slot_num is negative - * (indicating that para_audiod runs in standby mode), an approximation based - * only on the status items is computed and the returned string is prefixed - * with "~". + * If no writer is active, for example because para_audiod runs in standby + * mode, an approximation based only on the status items is computed and the + * returned string is prefixed with "~". * * \return A string that must be freed by the caller. */ -char *get_time_string(int slot_num) +char *get_time_string(void) { int ret, seconds = 0, length; struct timeval *tmp, sum, sss, /* server stream start */ @@ -243,6 +312,7 @@ char *get_time_string(int slot_num) wstime, /* writer start time */ wtime, /* now - writer start */ rskip; /* receiver start - sss */ + int slot_num = get_play_time_slot_num(); struct slot_info *s = slot_num < 0? NULL : &slot[slot_num]; char *msg; diff --git a/audiod.h b/audiod.h index c86b6659..94288eec 100644 --- a/audiod.h +++ b/audiod.h @@ -13,9 +13,6 @@ enum {AUDIOD_AUDIO_FORMATS_ENUM}; /** array of audio format names supported by para_audiod */ extern const char *audio_formats[]; -/** maximal number of simultaneous instances */ -#define MAX_STREAM_SLOTS 5 - /** * the possible modes of operation * @@ -39,41 +36,15 @@ struct audiod_command { const char *help; }; -/** - * Describes one instance of a receiver-filter-writer chain. - * - * \sa receiver_node, receiver, filter, filter_node, writer, writer_node, - * writer_node_group. - */ -struct slot_info { - /** Number of the audio format in this slot. */ - int format; - /** The stream_start status item announced by para_server. */ - struct timeval server_stream_start; - /** The offset status item announced by para_server. */ - unsigned offset_seconds; - /** The seconds_total status item announced by para_server. */ - unsigned seconds_total; - /** The receiver info associated with this slot. */ - struct receiver_node *receiver_node; - /** The array of filter nodes. */ - struct filter_node *fns; - /** The array of writers attached to the last filter. */ - struct writer_node *wns; -}; - -extern struct slot_info slot[MAX_STREAM_SLOTS]; +__malloc char *audiod_get_decoder_flags(void); extern struct audiod_args_info conf; extern int audiod_status; int handle_connect(int accept_fd, fd_set *rfds); void audiod_status_dump(bool force); -char *get_time_string(int slot_num); +char *get_time_string(void); struct btr_node *audiod_get_btr_root(void); void stat_client_write_item(int item_num); void clear_and_dump_items(void); void close_stat_clients(void); - -/** iterate over all slots */ -#define FOR_EACH_SLOT(_slot) for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++) diff --git a/audiod_command.c b/audiod_command.c index 7e68d2d2..b847e5aa 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -216,46 +216,6 @@ __malloc static char *audiod_status_string(void) return para_strdup(status); } -static int get_play_time_slot_num(void) -{ - int i, oldest_slot = -1; - struct timeval oldest_wstime = {0, 0}; - - FOR_EACH_SLOT(i) { - struct slot_info *s = &slot[i]; - struct timeval wstime; - if (!s->wns || !s->wns[0].btrn) - continue; - btr_get_node_start(s->wns[0].btrn, &wstime); - if (oldest_slot >= 0 && tv_diff(&wstime, &oldest_wstime, NULL) > 0) - continue; - oldest_wstime = wstime; - oldest_slot = i; - } - //PARA_CRIT_LOG("oldest slot: %d\n", oldest_slot); - return oldest_slot; -} - -__malloc static char *decoder_flags(void) -{ - int i; - char flags[MAX_STREAM_SLOTS + 1]; - - FOR_EACH_SLOT(i) { - struct slot_info *s = &slot[i]; - char flag = '0'; - if (s->receiver_node) - flag += 1; - if (s->fns) - flag += 2; - if (s->wns) - flag += 4; - flags[i] = flag; - } - flags[MAX_STREAM_SLOTS] = '\0'; - return para_strdup(flags); -} - static int dump_commands(int fd) { char *buf = para_strdup(""), *tmp = NULL; @@ -513,11 +473,10 @@ out: */ void audiod_status_dump(bool force) { - int slot_num = get_play_time_slot_num(); char *old, *new; old = stat_item_values[SI_PLAY_TIME]; - new = get_time_string(slot_num); + new = get_time_string(); if (new) { if (force || !old || strcmp(old, new)) { free(old); @@ -546,7 +505,7 @@ void audiod_status_dump(bool force) free(new); old = stat_item_values[SI_DECODER_FLAGS]; - new = decoder_flags(); + new = audiod_get_decoder_flags(); if (force || !old || strcmp(old, new)) { free(old); stat_item_values[SI_DECODER_FLAGS] = new; diff --git a/command.c b/command.c index 0baad5dc..175b496c 100644 --- a/command.c +++ b/command.c @@ -772,7 +772,7 @@ static int com_tasks(struct command_context *cc) * check if perms are sufficient to exec a command having perms cmd_perms. * Returns 0 if perms are sufficient, -E_PERM otherwise. */ -static int check_perms(unsigned int perms, struct server_command *cmd_ptr) +static int check_perms(unsigned int perms, const struct server_command *cmd_ptr) { PARA_DEBUG_LOG("checking permissions\n"); return (cmd_ptr->perms & perms) < cmd_ptr->perms ? -E_PERM : 0; diff --git a/command.h b/command.h index 6d220207..d28db038 100644 --- a/command.h +++ b/command.h @@ -11,7 +11,7 @@ struct command_context { /** Argument vector. */ char **argv; /** The command being executed. */ - struct server_command *cmd; + const struct server_command *cmd; /** File descriptor and crypto keys. */ struct stream_cipher_context scc; }; diff --git a/configure.ac b/configure.ac index 79b41a3a..8095d33a 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,46 @@ AC_DEFUN([objlist_to_errlist],[ \ make_errlist_defines($@) \ [const char **para_errlist[[]]] = {make_para_errlists($@)} \ ]) +AC_DEFUN([LIB_ARG_WITH], [ + AC_ARG_WITH($1-headers, [AS_HELP_STRING(--with-$1-headers=dir, + [look for $1 headers in dir])]) + AC_ARG_WITH($1-libs, [AS_HELP_STRING(--with-$1-libs=dir, + [look for $1 libraries in dir])]) + if test -n "$with_$1_headers"; then + $1_cppflags="-I$with_$1_headers" + CPPFLAGS="$CPPFLAGS $$1_cppflags" + fi + if test -n "$with_$1_libs"; then + $1_ldflags="-L$with_$1_libs $2" + else + $1_ldflags="$2" + fi + LDFLAGS="$LDFLAGS $$1_ldflags" +]) + +AC_DEFUN([STASH_FLAGS], [ + OLD_CPPFLAGS="$CPPFLAGS" + OLD_LDFLAGS="$LDFLAGS" + OLD_LIBS="$LIBS" +]) + +AC_DEFUN([UNSTASH_FLAGS], [ + CPPFLAGS="$OLD_CPPFLAGS" + LDFLAGS="$OLD_LDFLAGS" + LIBS="$OLD_LIBS" +]) +AC_DEFUN([LIB_SUBST_FLAGS], [ + if test "$HAVE_[]m4_toupper([$1])" == 'yes'; then + AC_DEFINE(HAVE_[]m4_toupper([$1]), 1, + define to 1 to turn on $1 support) + else + $1_cppflags= + $1_ldflags= + fi + AC_SUBST(HAVE_[]m4_toupper([$1])) + AC_SUBST($1_cppflags) + AC_SUBST($1_ldflags) +]) AC_PATH_PROG(UNAMEPATH, uname, no) if test "$UNAMEPATH" = "no"; then @@ -69,42 +109,32 @@ fi if test "$clock_gettime_lib" = "rt"; then AC_SUBST(clock_gettime_ldflags, -lrt) fi -########################################################################### osl -have_osl=yes -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" -AC_ARG_WITH(osl_headers, [AS_HELP_STRING(--with-osl-headers=dir, - [look for osl.h also in dir])]) -if test -n "$with_osl_headers"; then - osl_cppflags="-I$with_osl_headers" - CPPFLAGS="$CPPFLAGS $osl_cppflags" -fi -AC_ARG_WITH(osl_libs, [AS_HELP_STRING(--with-osl-libs=dir, - [look for libosl also in dir])]) -if test -n "$with_osl_libs"; then - osl_libs="-L$with_osl_libs" - LDFLAGS="$LDFLAGS $osl_libs" -fi -AC_CHECK_HEADER(osl.h, [], have_osl=no) -AC_CHECK_LIB([osl], [osl_open_table], [], have_osl=no) -if test "$have_osl" = "yes"; then - AC_SUBST(osl_cppflags) - osl_ldflags="$osl_libs -losl" - AC_SUBST(osl_ldflags) -else - AC_MSG_WARN([libosl not found, can not build para_server. -Download libosl at - http://people.tuebingen.mpg.de/maan/osl/ -or execute - git clone git://git.tuebingen.mpg.de/osl - ]) -fi -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" -########################################################################### crypto +########################################################################### osl +STASH_FLAGS +LIB_ARG_WITH([osl], [-losl]) +HAVE_OSL=yes +AC_CHECK_HEADER(osl.h, [], [HAVE_OSL=no]) +AC_CHECK_LIB([osl], [osl_open_table], [], [HAVE_OSL=no]) +LIB_SUBST_FLAGS(osl) +UNSTASH_FLAGS +######################################################################## openssl +STASH_FLAGS +HAVE_OPENSSL=yes +LIB_ARG_WITH([openssl], [-lssl -lcrypto]) +AC_CHECK_HEADER(openssl/ssl.h, [], [HAVE_OPENSSL=no]) +AC_CHECK_LIB([crypto], [RAND_bytes], [], [HAVE_OPENSSL=no]) +LIB_SUBST_FLAGS(openssl) +UNSTASH_FLAGS +######################################################################### gcrypt +STASH_FLAGS +HAVE_GCRYPT=yes +LIB_ARG_WITH([gcrypt], [-lgcrypt]) +AC_CHECK_HEADER(gcrypt.h, [], [HAVE_GCRYPT=no]) +AC_CHECK_LIB([gcrypt], [gcry_randomize], [], [HAVE_GCRYPT=no]) +LIB_SUBST_FLAGS(gcrypt) +UNSTASH_FLAGS +######################################################################### crypto AC_ARG_ENABLE(cryptolib, [AS_HELP_STRING(--enable-cryptolib=lib, [ Force using crypto library "lib". This package requires either openssl or libgcrypt being installed. Possible values for "lib" @@ -112,96 +142,32 @@ AC_ARG_ENABLE(cryptolib, [AS_HELP_STRING(--enable-cryptolib=lib, [ openssl is tried first. If openssl was not found, gcrypt is tried next.])]) +CRYPTOLIB="$enable_cryptolib" case "$enable_cryptolib" in - "openssl") check_openssl="yes"; check_gcrypt="no";; - "gcrypt") check_openssl="no"; check_gcrypt="yes";; - "") check_openssl="yes"; check_gcrypt="yes";; - *) AC_MSG_ERROR([invalid value "$enable_cryptolib" for --enable-cryptolib]);; -esac -###################################################################### openssl -if test "$check_openssl" = "yes"; then - OLD_CPPFLAGS="$CPPFLAGS" - OLD_LDFLAGS="$LDFLAGS" - OLD_LIBS="$LIBS" - have_openssl="yes" - AC_ARG_WITH(openssl_headers, [AS_HELP_STRING(--with-openssl-headers=dir, - [look for openssl headers also in dir])]) - if test -n "$with_openssl_headers"; then - openssl_cppflags="-I$with_openssl_headers" - CPPFLAGS="$CPPFLAGS $openssl_cppflags" - fi - AC_ARG_WITH(openssl_libs, [AS_HELP_STRING(--with-openssl-libs=dir, - [look for openssl libraries also in dir])]) - if test -n "$with_openssl_libs"; then - openssl_libs="-L$with_openssl_libs" - LDFLAGS="$LDFLAGS $openssl_libs" +"openssl") + test $HAVE_OPENSSL = no && AC_MSG_ERROR(openssl not found) + crypto_ldflags="$openssl_ldflags" + ;; +"gcrypt") + test $HAVE_GCRYPT = no && AC_MSG_ERROR(gcrypt not found) + crypto_ldflags="$gcrypt_ldflags" + ;; +"") + crypto_ldflags= + if test $HAVE_GCRYPT = yes; then + CRYPTOLIB=gcrypt + crypto_ldflags="$gcrypt_ldflags" fi - AC_CHECK_HEADER(openssl/ssl.h, [], [have_openssl="no"]) - AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"]) - if test "$have_openssl" = "no" -a -z "$with_openssl_headers$with_openssl_libs"; then - # try harder: openssl is sometimes installed in /usr/local/ssl - openssl_cppflags="-I/usr/local/ssl/include" - CPPFLAGS="$CPPFLAGS $openssl_cppflags" - openssl_libs="-L/usr/local/ssl/lib" - LDFLAGS="$LDFLAGS $openssl_libs" - # clear cache - unset ac_cv_header_openssl_ssl_h 2> /dev/null - unset ac_cv_lib_crypto_RAND_bytes 2> /dev/null - AC_CHECK_HEADER(openssl/ssl.h, [have_openssl="yes"], []) - if test "$have_openssl" = "yes"; then - AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"]) - fi + if test $HAVE_OPENSSL = yes; then + CRYPTOLIB=openssl + crypto_ldflags="$openssl_ldflags" fi - if test "$have_openssl" = "yes"; then - AC_DEFINE(HAVE_OPENSSL, 1, [define to 1 to turn on openssl support]) - AC_SUBST(openssl_cppflags) - openssl_ldflags="$openssl_libs -lssl -lcrypto" - AC_SUBST(openssl_ldflags) - - check_gcrypt="no" - else - AC_MSG_WARN([openssl libraries not found]) - fi - CPPFLAGS="$OLD_CPPFLAGS" - LDFLAGS="$OLD_LDFLAGS" - LIBS="$OLD_LIBS" -else - have_openssl="no" -fi -########################################################################### gcrypt -if test "$check_gcrypt" = "yes"; then - OLD_CPPFLAGS="$CPPFLAGS" - OLD_LDFLAGS="$LDFLAGS" - OLD_LIBS="$LIBS" - have_gcrypt="yes" - AC_ARG_WITH(gcrypt_headers, [AS_HELP_STRING(--with-gcrypt-headers=dir, - [look for gcrypt headers also in dir])]) - if test -n "$with_gcrypt_headers"; then - gcrypt_cppflags="-I$with_gcrypt_headers" - CPPFLAGS="$CPPFLAGS $gcrypt_cppflags" - fi - AC_ARG_WITH(gcrypt_libs, [AS_HELP_STRING(--with-gcrypt-libs=dir, - [look for libgcrypt also in dir])]) - if test -n "$with_gcrypt_libs"; then - gcrypt_libs="-L$with_gcrypt_libs" - LDFLAGS="$LDFLAGS $gcrypt_libs" - fi - AC_CHECK_HEADER(gcrypt.h, [], [have_gcrypt="no"]) - AC_CHECK_LIB([gcrypt], [gcry_randomize], [], [have_gcrypt="no"]) - if test "$have_gcrypt" = "yes"; then - AC_DEFINE(HAVE_GCRYPT, 1, [define to 1 to turn on gcrypt support]) - AC_SUBST(gcrypt_cppflags) - gcrypt_ldflags="$gcrypt_libs -lgcrypt" - AC_SUBST(gcrypt_ldflags) - else - AC_MSG_WARN([gcrypt library not found]) - fi - CPPFLAGS="$OLD_CPPFLAGS" - LDFLAGS="$OLD_LDFLAGS" - LIBS="$OLD_LIBS" -else - have_gcrypt="no" -fi + ;; +*) + AC_MSG_ERROR([invalid value "$enable_cryptolib" for --enable-cryptolib]) + ;; +esac +AC_SUBST(crypto_ldflags) ########################################################################### libsocket AC_CHECK_LIB([c], [socket], [socket_ldlflags=], @@ -237,39 +203,14 @@ AC_CHECK_DECL( ) AC_SUBST(ggo_descriptions_declared) ########################################################################### curses -have_curses="yes" -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" -AC_ARG_WITH(curses_headers, [AS_HELP_STRING(--with-curses-headers=dir, - [look for curses.h also in dir])]) -if test -n "$with_curses_headers"; then - curses_cppflags="-I$with_curses_headers" - CPPFLAGS="$CPPFLAGS $curses_cppflags" -fi -AC_ARG_WITH(curses_libs, [AS_HELP_STRING(--with-curses-libs=dir, - [look for libcurses also in dir])]) -if test -n "$with_curses_libs"; then - curses_libs="-L$with_curses_libs" - LDFLAGS="$LDFLAGS $curses_libs" -fi -AC_CHECK_HEADER(curses.h, [], [ - have_curses="no" -]) -curses_ldflags="$curses_libs" -AC_CHECK_LIB([ncursesw], [initscr], - [curses_ldflags="$curses_libs -lncursesw"], [ - AC_CHECK_LIB([curses], [initscr], - [curses_ldflags="$curses_libs -lcurses"], - [have_curses="no"] - ) - ] -) -AC_SUBST(curses_cppflags) -AC_SUBST(curses_ldflags) -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" +STASH_FLAGS +LIB_ARG_WITH([curses], []) +HAVE_CURSES=yes +AC_CHECK_HEADER(curses.h, [], [HAVE_CURSES=no]) +AC_SEARCH_LIBS([initscr], [ncursesw curses], [], [HAVE_CURSES=no]) +curses_ldflags="$curses_ldflags $LIBS" +LIB_SUBST_FLAGS(curses) +UNSTASH_FLAGS ########################################################################### ip_mreqn AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast)) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ @@ -301,488 +242,152 @@ if test ${have_core_audio} = yes; then AC_SUBST(core_audio_ldflags) AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X) fi -####################################################### ogg/vorbis/speex/opus -have_ogg="yes" -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" -AC_ARG_WITH(ogg_headers, [AS_HELP_STRING(--with-ogg-headers=dir, - [look for ogg headers also in dir])]) -AC_ARG_WITH(ogg_libs, [AS_HELP_STRING(--with-ogg-libs=dir, - [look for ogg libs also in dir])]) -AC_ARG_WITH(vorbis_headers, [AS_HELP_STRING(--with-vorbis-headers=dir, - [look for vorbis headers also in dir])]) -AC_ARG_WITH(vorbis_libs, [AS_HELP_STRING(--with-vorbis-libs=dir, - [look for vorbis libs also in dir])]) -AC_ARG_WITH(speex_headers, [AS_HELP_STRING(--with-speex-headers=dir, - [look for speex headers also in dir])]) -AC_ARG_WITH(speex_libs, [AS_HELP_STRING(--with-speex-libs=dir, - [look for speex libs also in dir])]) -AC_ARG_WITH(opus_headers, [AS_HELP_STRING(--with-opus-headers=dir, - [look for opus headers also in dir])]) -AC_ARG_WITH(opus_libs, [AS_HELP_STRING(--with-opus-libs=dir, - [look for opus libs also in dir])]) - -if test -n "$with_ogg_headers"; then - ogg_cppflags="-I$with_ogg_headers" - CPPFLAGS="$CPPFLAGS $ogg_cppflags" -fi -if test -n "$with_ogg_libs"; then - ogg_libs="-L$with_ogg_libs" - LDFLAGS="$LDFLAGS $ogg_libs" -fi -AC_CHECK_HEADERS([ogg/ogg.h], [], [ have_ogg="no"; ]) -AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ]) -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" - -have_vorbis="yes" -have_speex="yes" -have_opus="yes" -if test "$have_ogg" = "yes"; then - OLD_CPPFLAGS="$CPPFLAGS" - OLD_LDFLAGS="$LDFLAGS" - OLD_LIBS="$LIBS" - # vorbis - if test -n "$with_vorbis_headers"; then - vorbis_cppflags="-I$with_vorbis_headers" - CPPFLAGS="$CPPFLAGS $vorbis_cppflags" - fi - if test -n "$with_vorbis_libs"; then - vorbis_libs="-L$with_vorbis_libs" - LDFLAGS="$LDFLAGS $vorbis_libs" - fi - AC_CHECK_HEADERS([vorbis/codec.h], [], [ have_vorbis="no" ]) - AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_vorbis="no" ]) - CPPFLAGS="$OLD_CPPFLAGS" - LDFLAGS="$OLD_LDFLAGS" - LIBS="$OLD_LIBS" - - # speex - OLD_CPPFLAGS="$CPPFLAGS" - OLD_LDFLAGS="$LDFLAGS" - OLD_LIBS="$LIBS" - if test -n "$with_speex_headers"; then - speex_cppflags="-I$with_speex_headers" - CPPFLAGS="$CPPFLAGS $speex_cppflags" - fi - if test -n "$with_speex_libs"; then - speex_libs="-L$with_speex_libs" - LDFLAGS="$LDFLAGS $speex_libs" - fi - AC_CHECK_LIB([speex], [speex_decoder_init], [], [ have_speex="no" ]) - AC_CHECK_HEADERS([speex/speex.h], [], [ have_speex="no" ]) - CPPFLAGS="$OLD_CPPFLAGS" - LDFLAGS="$OLD_LDFLAGS" - LIBS="$OLD_LIBS" - - # opus - OLD_CPPFLAGS="$CPPFLAGS" - OLD_LDFLAGS="$LDFLAGS" - OLD_LIBS="$LIBS" - if test -n "$with_opus_headers"; then - opus_cppflags="-I$with_opus_headers" - CPPFLAGS="$CPPFLAGS $opus_cppflags" - fi - if test -n "$with_opus_libs"; then - opus_libs="-L$with_opus_libs" - LDFLAGS="$LDFLAGS $opus_libs" - fi - AC_CHECK_LIB([opus], [opus_multistream_decode], [], [ have_opus="no" ]) - AC_CHECK_HEADERS([opus/opus.h], [], [ have_opus="no" ]) - CPPFLAGS="$OLD_CPPFLAGS" - LDFLAGS="$OLD_LDFLAGS" - LIBS="$OLD_LIBS" -else - AC_MSG_WARN([vorbis/speex/opus depend on libogg, which was not detected]) - have_vorbis="no" - have_speex="no" - have_opus="no" -fi +########################################################################### ogg +STASH_FLAGS +LIB_ARG_WITH([ogg], [-logg]) +HAVE_OGG=yes +AC_CHECK_HEADERS([ogg/ogg.h], [], [HAVE_OGG=no]) +AC_CHECK_LIB([ogg], [ogg_stream_init], [], [HAVE_OGG=no]) +LIB_SUBST_FLAGS(ogg) +UNSTASH_FLAGS +######################################################################### vorbis +STASH_FLAGS +LIB_ARG_WITH([vorbis], [-lvorbis -lvorbisfile]) +HAVE_VORBIS=yes +AC_CHECK_HEADERS([vorbis/codec.h], [], [HAVE_VORBIS=no]) +AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [HAVE_VORBIS=no]) +LIB_SUBST_FLAGS(vorbis) +UNSTASH_FLAGS +######################################################################### speex +STASH_FLAGS +LIB_ARG_WITH([speex], [-lspeex]) +HAVE_SPEEX=yes +AC_CHECK_HEADERS([speex/speex.h], [], [HAVE_SPEEX=no]) +AC_CHECK_LIB([speex], [speex_decoder_init], [], [HAVE_SPEEX=no]) +LIB_SUBST_FLAGS(speex) +UNSTASH_FLAGS +######################################################################### opus +STASH_FLAGS +LIB_ARG_WITH([opus], [-lopus]) +HAVE_OPUS=yes +AC_CHECK_HEADERS([opus/opus.h], [], [HAVE_OPUS=no]) +AC_CHECK_LIB([opus], [opus_multistream_decode], [], [HAVE_OPUS=no]) +LIB_SUBST_FLAGS(opus) +UNSTASH_FLAGS +########################################################################### flac +STASH_FLAGS +LIB_ARG_WITH([flac], [-lFLAC -lm]) +HAVE_FLAC=yes +AC_CHECK_HEADER(FLAC/stream_decoder.h, [], HAVE_FLAC=no) +AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], HAVE_FLAC=no) +LIB_SUBST_FLAGS(flac) +UNSTASH_FLAGS -msg="support in para_server/para_filter/para_afh" -if test "$have_vorbis" = "yes" || \ - test "$have_speex" = "yes" || \ - test "$have_opus" = "yes"; then - AC_SUBST(ogg_cppflags) - ogg_ldflags="$ogg_libs -logg" - if test "$OSTYPE" = "Darwin"; then - ogg_ldflags="-Wl,-bind_at_load $ogg_ldflags" - fi - AC_SUBST(ogg_ldflags) -fi -if test "$have_vorbis" = "yes"; then - AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg/vorbis support) - AC_SUBST(vorbis_cppflags) - vorbis_ldflags="$vorbis_libs -lvorbis -lvorbisfile" - AC_SUBST(vorbis_ldflags) -fi -if test "$have_speex" = "yes"; then - AC_DEFINE(HAVE_SPEEX, 1, define to 1 to turn on ogg/speex support) - AC_SUBST(speex_cppflags) - speex_ldflags="$speex_libs -lspeex" - AC_SUBST(speex_ldflags) -else - AC_MSG_WARN([no ogg/speex $msg]) -fi -if test "$have_opus" = "yes"; then - AC_DEFINE(HAVE_OPUS, 1, define to 1 to turn on ogg/opus support) - AC_SUBST(opus_cppflags) - opus_ldflags="$opus_libs -lopus" - AC_SUBST(opus_ldflags) - audio_format_handlers="$audio_format_handlers opus" -else - AC_MSG_WARN([no ogg/opus $msg]) -fi +# some helper functions for codecs which use the ogg container format +AC_DEFUN([NEED_OGG_OBJECTS], [{ + test "$HAVE_OGG" = 'yes' -a \( \ + "$HAVE_VORBIS" = 'yes' \ + -o "$HAVE_SPEEX" = 'yes' \ + -o "$HAVE_OPUS" = 'yes' \ + -o "$HAVE_FLAC" = 'yes' \ + \) +}]) +AC_DEFUN([NEED_VORBIS_OBJECTS], [{ + test "$HAVE_OGG" = 'yes' -a "$HAVE_VORBIS" = 'yes' +}]) +AC_DEFUN([NEED_SPEEX_OBJECTS], [{ + test "$HAVE_OGG" = 'yes' -a "$HAVE_SPEEX" = 'yes' +}]) +AC_DEFUN([NEED_OPUS_OBJECTS], [{ + test "$HAVE_OGG" = 'yes' -a "$HAVE_OPUS" = 'yes' +}]) +AC_DEFUN([NEED_FLAC_OBJECTS], [{ + test "$HAVE_OGG" = 'yes' -a "$HAVE_FLAC" = 'yes' +}]) ########################################################################### faad -have_faad=yes -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" -AC_ARG_WITH(faad_headers, [AS_HELP_STRING(--with-faad-headers=dir, - [look for neaacdec.h also in dir])]) -if test -n "$with_faad_headers"; then - faad_cppflags="-I$with_faad_headers" - CPPFLAGS="$CPPFLAGS $faad_cppflags" -fi -AC_ARG_WITH(faad_libs, [AS_HELP_STRING(--with-faad-libs=dir, - [look for libfaad also in dir])]) -if test -n "$with_faad_libs"; then - faad_libs="-L$with_faad_libs" - LDFLAGS="$LDFLAGS $faad_libs" -fi -AC_CHECK_HEADER(neaacdec.h, [], have_faad=no) -AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no) -if test "$have_faad" = "yes"; then - AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter) - AC_SUBST(faad_cppflags) - faad_ldflags="$faad_libs -lfaad" - AC_SUBST(faad_ldflags) -fi -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" +STASH_FLAGS +LIB_ARG_WITH([faad], [-lfaad]) +HAVE_FAAD=yes +AC_CHECK_HEADER(neaacdec.h, [], HAVE_FAAD=no) +AC_CHECK_LIB([faad], [NeAACDecOpen], [], HAVE_FAAD=no) +LIB_SUBST_FLAGS(faad) +UNSTASH_FLAGS ########################################################################### mad -have_mad="yes" -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" - -AC_ARG_WITH(mad_headers, [AS_HELP_STRING(--with-mad-headers=dir, - [look for mad.h also in dir])]) -if test -n "$with_mad_headers"; then - mad_cppflags="-I$with_mad_headers" - CPPFLAGS="$CPPFLAGS $mad_cppflags" -fi -AC_ARG_WITH(mad_libs, [AS_HELP_STRING(--with-mad-libs=dir, - [look for libmad also in dir])]) -if test -n "$with_mad_libs"; then - mad_libs="-L$with_mad_libs" - LDFLAGS="$LDFLAGS $mad_libs" -fi -AC_CHECK_HEADERS([mad.h], [], [ - have_mad="no" -]) -AC_CHECK_LIB([mad], [mad_stream_init], [], [ - have_mad="no" -]) -if test "$have_mad" = "yes"; then - AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter) - AC_SUBST(mad_cppflags) - mad_ldflags="$mad_libs -lmad" - AC_SUBST(mad_ldflags) -else - AC_MSG_WARN([no mp3dec support in para_audiod/para_filter]) -fi -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" +STASH_FLAGS +LIB_ARG_WITH([mad], [-lmad]) +HAVE_MAD=yes +AC_CHECK_HEADER(mad.h, [], HAVE_MAD=no) +AC_CHECK_LIB([mad], [mad_stream_init], [], HAVE_MAD=no) +LIB_SUBST_FLAGS(mad) +UNSTASH_FLAGS ###################################################################### libid3tag -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" - -have_libid3tag="yes" -AC_ARG_WITH(id3tag_headers, [AS_HELP_STRING(--with-id3tag-headers=dir, - [look for id3tag header files also in dir])]) -if test -n "$with_id3tag_headers"; then - id3tag_cppflags="-I$with_id3tag_headers" - CPPFLAGS="$CPPFLAGS $id3tag_cppflags" -fi -AC_ARG_WITH(id3tag_libs, [AS_HELP_STRING(--with-id3tag-libs=dir, - [look for id3tag libs also in dir])]) -if test -n "$with_id3tag_libs"; then - id3tag_libs="-L$with_id3tag_libs" - LDFLAGS="$LDFLAGS $id3tag_libs" -fi - -AC_MSG_CHECKING(for libid3tag) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include -]], [[ - struct id3_tag t = {.flags = 0}; -]])],[],[have_libid3tag=no]) -AC_MSG_RESULT($have_libid3tag) - -if test ${have_libid3tag} = yes; then - AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag) - AC_SUBST(id3tag_cppflags) - AC_SUBST(id3tag_ldflags, "$id3tag_libs -lid3tag -lz") -fi -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" -########################################################################### flac -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" - -have_flac="yes" -AC_ARG_WITH(flac_headers, [AS_HELP_STRING(--with-flac-headers=dir, - [look for flac headers also in dir])]) -if test -n "$with_flac_headers"; then - flac_cppflags="-I$with_flac_headers" - CPPFLAGS="$CPPFLAGS $flac_cppflags" -fi -AC_ARG_WITH(flac_libs, [AS_HELP_STRING(--with-flac-libs=dir, - [look for flac libs also in dir])]) -if test -n "$with_flac_libs"; then - flac_libs="-L$with_flac_libs" - LDFLAGS="$LDFLAGS $flac_libs" -fi -AC_CHECK_HEADER(FLAC/stream_decoder.h, [], have_flac=no) -AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], [ - # nope, try again with -logg - AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], - have_flac=no, -lm -logg) - ], -lm) -if test "$have_flac" = "yes"; then - AC_DEFINE(HAVE_FLAC, 1, define to 1 if you want to build the flacdec filter) - AC_SUBST(flac_cppflags) - flac_ldflags="$flac_libs -lFLAC" - AC_SUBST(flac_ldflags) -else - AC_MSG_WARN([no flac support in para_audiod/para_filter/para_afh/para_server]) -fi -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" +STASH_FLAGS +LIB_ARG_WITH([id3tag], [-lid3tag -lz]) +HAVE_ID3TAG=yes +AC_CHECK_HEADER(id3tag.h, [], HAVE_ID3TAG=no) +AC_CHECK_LIB([id3tag], [id3_file_fdopen], [], HAVE_ID3TAG=no) +LIB_SUBST_FLAGS(id3tag) +UNSTASH_FLAGS ########################################################################### oss -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" - -have_oss="yes" -msg="=> will not build oss writer" - -AC_CHECK_HEADER(sys/soundcard.h, [ - AC_CHECK_LIB(ossaudio, _oss_ioctl, [ - oss_ldflags="-lossaudio" - AC_SUBST(oss_ldflags) - ] - ) - ], +STASH_FLAGS +LIB_ARG_WITH([oss], []) +AC_CHECK_HEADER(sys/soundcard.h, [HAVE_OSS=yes], [HAVE_OSS=no]) +AC_CHECK_LIB(ossaudio, _oss_ioctl, [oss_ldflags="$oss_ldflags -lossaudio"], []) +LIB_SUBST_FLAGS(oss) +UNSTASH_FLAGS +########################################################################### alsa +STASH_FLAGS +LIB_ARG_WITH([alsa], [-lasound]) +HAVE_ALSA=yes +AC_CHECK_HEADER(alsa/asoundlib.h, [], HAVE_ALSA=no) +AC_CHECK_LIB([asound], [snd_pcm_open], [], HAVE_ALSA=no) +LIB_SUBST_FLAGS(alsa) +UNSTASH_FLAGS +######################################################################### pthread +STASH_FLAGS +LIB_ARG_WITH([pthread], [-lpthread]) +HAVE_PTHREAD=yes +AC_CHECK_HEADER(pthread.h, [], HAVE_PTHREAD=no) +AC_CHECK_LIB([pthread], [pthread_create], [], HAVE_PTHREAD=no) +LIB_SUBST_FLAGS(pthread) +UNSTASH_FLAGS +########################################################################### libao +STASH_FLAGS +LIB_ARG_WITH([ao], [-lao]) +HAVE_AO=yes +AC_CHECK_HEADER(ao/ao.h, [], HAVE_AO=no) +AC_CHECK_LIB([ao], [ao_initialize], [], HAVE_AO=no) +LIB_SUBST_FLAGS(ao) +UNSTASH_FLAGS +AC_DEFUN([NEED_AO_OBJECTS], [{ test $HAVE_AO = yes -a $HAVE_PTHREAD = yes; }]) +######################################################################## readline +STASH_FLAGS +AC_SEARCH_LIBS([tgetent], [tinfo curses terminfo termcap]) +LIB_ARG_WITH([readline], [-lreadline $LIBS]) +HAVE_READLINE=yes +AC_CHECK_HEADER([readline/readline.h], [], [HAVE_READLINE=no]) +AC_CHECK_LIB([readline], [rl_free_keymap], [], HAVE_READLINE=no) +AC_CHECK_DECL( + [rl_free_keymap], + [AC_DEFINE(RL_FREE_KEYMAP_DECLARED, 1, readline >= 6.3)], + [], [ - have_oss="no" - AC_MSG_WARN([no sys/soundcard.h $msg]) + #include + #include ] ) -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" - -########################################################################### alsa -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" - -msg="=> no alsa support for para_audiod/para_write" -if test "$OSTYPE" != "Linux"; then - have_alsa="no" -else - have_alsa="yes" -fi -if test "$have_alsa" = "yes"; then - AC_CHECK_HEADERS([alsa/asoundlib.h], [], [ - have_alsa="no" - AC_MSG_WARN([no alsa/asoundlib $msg]) - ]) -fi - -if test "$have_alsa" = "yes"; then - AC_CHECK_LIB([asound], [snd_pcm_open], [], [ - have_alsa="no" - AC_MSG_WARN([no libasound $msg]) - ]) -fi - -if test "$have_alsa" = "yes"; then - alsa_ldflags="-lasound" - AC_SUBST(alsa_ldflags) -fi - -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" -########################################################################### libao -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" - -have_ao="yes" -AC_ARG_WITH(ao_headers, [AS_HELP_STRING(--with-ao-headers=dir, - [look for ao/ao.h also in dir])]) -if test -n "$with_ao_headers"; then - ao_cppflags="-I$with_ao_headers" - CPPFLAGS="$CPPFLAGS $ao_cppflags" -fi -AC_ARG_WITH(ao_libs, [AS_HELP_STRING(--with-ao-libs=dir, - [look for libao also in dir])]) -if test -n "$with_ao_libs"; then - ao_libs="-L$with_ao_libs" - LDFLAGS="$LDFLAGS $ao_libs" -fi -msg="no libao support for para_audiod/para_write" -AC_CHECK_HEADERS([ao/ao.h], [ - ], [ - have_ao="no" - AC_MSG_WARN([ao.h not found, $msg]) -]) -if test "$have_ao" = "yes"; then - AC_CHECK_LIB([ao], [ao_initialize], [], [ - have_ao="no" - AC_MSG_WARN([ao lib not found or not working, $msg]) - ]) -fi -if test "$have_ao" = "yes"; then - AC_CHECK_HEADERS([pthread.h], [ - ], [ - have_ao="no" - AC_MSG_WARN([pthread.h not found, $msg]) - ]) -fi -if test "$have_ao" = "yes"; then - AC_CHECK_LIB([pthread], [pthread_create], [], [ - have_ao="no" - AC_MSG_WARN([pthread lib not found or not working, $msg]) - ]) -fi -if test "$have_ao" = "yes"; then - AC_SUBST(ao_cppflags) - ao_ldflags="$ao_libs -lao -lpthread" - AC_SUBST(ao_ldflags) -fi - -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" -############################################################# readline -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" - -have_readline="yes" -AC_ARG_WITH(readline_headers, [AS_HELP_STRING(--with-readline-headers=dir, - [look for libreadline header files also in dir])]) -if test -n "$with_readline_headers"; then - readline_cppflags="-I$with_readline_headers" - CPPFLAGS="$CPPFLAGS $readline_cppflags" -fi - -AC_ARG_WITH(readline_libs, [AS_HELP_STRING(--with-readline-libs=dir, - [look for readline library also in dir])]) -if test -n "$with_readline_libs"; then - readline_libs="-L$with_readline_libs" - LDFLAGS="$LDFLAGS $readline_libs" -fi -msg="no interactive cli support" -AC_CHECK_HEADERS([readline/readline.h], [ - ], [ - have_readline="no" - AC_MSG_WARN([readline/readline.h not found, $msg]) -]) - -if test "$have_readline" = "yes"; then - readline_ldflags="$readline_libs" - AC_SEARCH_LIBS([rl_free_keymap], [readline], [ - readline_ldflags="$readline_ldflags -lreadline" - ], [have_readline="no"]) - if test "$have_readline" = "no"; then # try with -lcurses - # clear cache - AC_MSG_NOTICE([trying again with -lcurses]) - unset ac_cv_search_rl_free_keymap 2> /dev/null - AC_SEARCH_LIBS([rl_free_keymap], [readline], [ - have_readline=yes - readline_ldflags="$readline_ldflags -lreadline -lcurses" - ], [], [-lcurses]) - fi - if test "$have_readline" = "no"; then # try with -ltermcap - # clear cache - AC_MSG_NOTICE([trying again with -ltermcap]) - unset ac_cv_search_rl_free_keymap 2> /dev/null - AC_SEARCH_LIBS([rl_free_keymap], [readline], [ - have_readline=yes - readline_ldflags="$readline_ldflags -lreadline -ltermcap" - ], [], [-ltermcap]) - fi -fi - -if test "$have_readline" = "yes"; then - AC_CHECK_DECL( - [rl_free_keymap], - [AC_DEFINE(RL_FREE_KEYMAP_DECLARED, 1, readline >= 6.3)], - [], - [ - #include - #include - ] - ) - AC_SUBST(readline_cppflags) - AC_SUBST(readline_ldflags) - AC_DEFINE(HAVE_READLINE, 1, define to 1 to turn on readline support) -else - AC_MSG_WARN([libreadline not found or unusable]) -fi -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" +LIB_SUBST_FLAGS(readline) +UNSTASH_FLAGS ############################################################# libsamplerate -OLD_CPPFLAGS="$CPPFLAGS" -OLD_LDFLAGS="$LDFLAGS" -OLD_LIBS="$LIBS" - -have_samplerate="yes" -AC_ARG_WITH(samplerate_headers, [AS_HELP_STRING(--with-samplerate-headers=dir, - [look for samplerate headers also in dir])]) -if test -n "$with_samplerate_headers"; then - samplerate_cppflags="-I$with_samplerate_headers" - CPPFLAGS="$CPPFLAGS $samplerate_cppflags" -fi -AC_ARG_WITH(samplerate_libs, [AS_HELP_STRING(--with-samplerate-libs=dir, - [look for samplerate libs also in dir])]) -if test -n "$with_samplerate_libs"; then - samplerate_libs="-L$with_samplerate_libs" - LDFLAGS="$LDFLAGS $samplerate_libs" -fi - -AC_CHECK_HEADER(samplerate.h, [], have_samplerate=no) -AC_CHECK_LIB([samplerate], [src_process], [], have_samplerate=no, []) - -if test "$have_samplerate" = "yes"; then - AC_SUBST(samplerate_cppflags) - samplerate_ldflags="$samplerate_libs -lsamplerate" - AC_SUBST(samplerate_ldflags) -else - AC_MSG_WARN([no resample support in para_audiod/para_filter]) -fi -CPPFLAGS="$OLD_CPPFLAGS" -LDFLAGS="$OLD_LDFLAGS" -LIBS="$OLD_LIBS" +STASH_FLAGS +LIB_ARG_WITH([samplerate], [-lsamplerate]) +HAVE_SAMPLERATE=yes +AC_CHECK_HEADER(samplerate.h, [], HAVE_SAMPLERATE=no) +AC_CHECK_LIB([samplerate], [src_process], [], HAVE_SAMPLERATE=no) +LIB_SUBST_FLAGS(samplerate) +UNSTASH_FLAGS ######################################################################### server -if test \( "$have_openssl" = "yes" -o "$have_gcrypt" = "yes" \) \ - -a "$have_osl" = "yes" ; then - +if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes; then build_server="yes" executables="$executables server" server_cmdline_objs="server" @@ -825,32 +430,17 @@ if test \( "$have_openssl" = "yes" -o "$have_gcrypt" = "yes" \) \ version ggo " - if test "$have_openssl" = "yes"; then + if test "$CRYPTOLIB" = openssl; then server_errlist_objs="$server_errlist_objs crypt" - fi - if test "$have_gcrypt" = "yes"; then + else server_errlist_objs="$server_errlist_objs gcrypt" fi - if test "$have_vorbis" = "yes" || \ - test "$have_speex" = "yes" || \ - test "$have_opus" = "yes"; then - server_errlist_objs="$server_errlist_objs ogg_afh_common" - fi - if test "$have_vorbis" = "yes"; then - server_errlist_objs="$server_errlist_objs ogg_afh" - fi - if test "$have_speex" = "yes"; then - server_errlist_objs="$server_errlist_objs spx_afh spx_common" - fi - if test "$have_opus" = "yes"; then - server_errlist_objs="$server_errlist_objs opus_afh opus_common" - fi - if test "$have_faad" = "yes"; then - server_errlist_objs="$server_errlist_objs aac_afh aac_common" - fi - if test "$have_flac" = "yes"; then - server_errlist_objs="$server_errlist_objs flac_afh" - fi + NEED_OGG_OBJECTS() && server_errlist_objs="$server_errlist_objs ogg_afh_common" + NEED_VORBIS_OBJECTS() && server_errlist_objs="$server_errlist_objs ogg_afh" + NEED_SPEEX_OBJECTS() && server_errlist_objs="$server_errlist_objs spx_afh spx_common" + NEED_OPUS_OBJECTS() && server_errlist_objs="$server_errlist_objs opus_afh opus_common" + NEED_FLAC_OBJECTS && server_errlist_objs="$server_errlist_objs flac_afh" + test $HAVE_FAAD = yes && server_errlist_objs="$server_errlist_objs aac_afh aac_common" server_objs="add_cmdline($server_cmdline_objs) $server_errlist_objs" AC_SUBST(server_objs, add_dot_o($server_objs)) AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS, @@ -859,7 +449,7 @@ else build_server="no" fi ############################################################# client -if test "$have_openssl" = "yes" -o "$have_gcrypt" = "yes"; then +if test -n "$CRYPTOLIB"; then build_client="yes" executables="$executables client" client_cmdline_objs="client" @@ -879,13 +469,12 @@ if test "$have_openssl" = "yes" -o "$have_gcrypt" = "yes"; then version ggo " - if test "$have_openssl" = "yes"; then + if test "$CRYPTOLIB" = openssl; then client_errlist_objs="$client_errlist_objs crypt" - fi - if test "$have_gcrypt" = "yes"; then + else client_errlist_objs="$client_errlist_objs gcrypt" fi - if test "$have_readline" = "yes"; then + if test $HAVE_READLINE = yes; then client_errlist_objs="$client_errlist_objs interactive" fi client_objs="add_cmdline($client_cmdline_objs) $client_errlist_objs" @@ -896,7 +485,7 @@ else build_client="no" fi ############################################################# audiod -if test "$have_openssl" = "yes" -o "$have_gcrypt" = "yes"; then +if test -n "$CRYPTOLIB"; then build_audiod="yes" executables="$executables audiod" audiod_audio_formats="wma" @@ -950,54 +539,53 @@ if test "$have_openssl" = "yes" -o "$have_gcrypt" = "yes"; then buffer_tree sync_filter " - if test "$have_openssl" = "yes"; then + if test "$CRYPTOLIB" = openssl; then audiod_errlist_objs="$audiod_errlist_objs crypt" - fi - if test "$have_gcrypt" = "yes"; then + else audiod_errlist_objs="$audiod_errlist_objs gcrypt" fi if test "$have_core_audio" = "yes"; then audiod_errlist_objs="$audiod_errlist_objs osx_write ipc" audiod_cmdline_objs="$audiod_cmdline_objs osx_write" fi - if test "$have_vorbis" = "yes"; then + NEED_VORBIS_OBJECTS && { audiod_errlist_objs="$audiod_errlist_objs oggdec_filter" audiod_audio_formats="$audiod_audio_formats ogg" - fi - if test "$have_speex" = "yes"; then + } + NEED_SPEEX_OBJECTS && { audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common" audiod_audio_formats="$audiod_audio_formats spx" - fi - if test "$have_opus" = "yes"; then + } + NEED_OPUS_OBJECTS && { audiod_errlist_objs="$audiod_errlist_objs opusdec_filter opus_common" audiod_audio_formats="$audiod_audio_formats opus" - fi - if test "$have_faad" = "yes"; then + } + NEED_FLAC_OBJECTS && { + audiod_errlist_objs="$audiod_errlist_objs flacdec_filter" + audiod_audio_formats="$audiod_audio_formats flac" + } + if test $HAVE_FAAD = yes; then audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common" audiod_audio_formats="$audiod_audio_formats aac" fi - if test "$have_mad" = "yes"; then + if test $HAVE_MAD = yes; then audiod_audio_formats="$audiod_audio_formats mp3" audiod_cmdline_objs="$audiod_cmdline_objs mp3dec_filter" audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter" fi - if test "$have_flac" = "yes"; then - audiod_errlist_objs="$audiod_errlist_objs flacdec_filter" - audiod_audio_formats="$audiod_audio_formats flac" - fi - if test "$have_oss" = "yes"; then + if test $HAVE_OSS = yes; then audiod_errlist_objs="$audiod_errlist_objs oss_write" audiod_cmdline_objs="$audiod_cmdline_objs oss_write" fi - if test "$have_alsa" = "yes"; then + if test $HAVE_ALSA = yes; then audiod_errlist_objs="$audiod_errlist_objs alsa_write" audiod_cmdline_objs="$audiod_cmdline_objs alsa_write" fi - if test "$have_ao" = "yes"; then + NEED_AO_OBJECTS && { audiod_errlist_objs="$audiod_errlist_objs ao_write" audiod_cmdline_objs="$audiod_cmdline_objs ao_write" - fi - if test "$have_samplerate" = "yes"; then + } + if test $HAVE_SAMPLERATE = yes; then audiod_errlist_objs="$audiod_errlist_objs resample_filter check_wav" audiod_cmdline_objs="$audiod_cmdline_objs resample_filter" fi @@ -1015,17 +603,17 @@ else build_audiod="no" fi ########################################################################### fade -if test "$have_oss" = "yes" -o "$have_alsa" = "yes"; then +if test $HAVE_OSS = yes -o $HAVE_ALSA = yes; then build_fade="yes" executables="$executables fade" fade_cmdline_objs="fade" fade_errlist_objs="fade exec string fd version ggo" - if test "$have_oss" = "yes"; then + if test $HAVE_OSS = yes; then fade_errlist_objs="$fade_errlist_objs oss_mix" mixers="${mixers}oss " default_mixer="OSS_MIX" fi - if test "$have_alsa" = "yes"; then + if test $HAVE_ALSA = yes; then fade_errlist_objs="$fade_errlist_objs alsa_mix" mixers="${mixers}alsa " default_mixer="ALSA_MIX" @@ -1060,7 +648,7 @@ else AC_MSG_WARN([no mixer support]) fi ########################################################################### gui -if test "$have_curses" = "yes"; then +if test $HAVE_CURSES = yes; then build_gui="yes" executables="$executables gui" gui_cmdline_objs="gui" @@ -1128,33 +716,32 @@ filter_cmdline_objs=" prebuffer_filter sync_filter " - -if test "$have_vorbis" = "yes"; then +NEED_VORBIS_OBJECTS && { filters="$filters oggdec" filter_errlist_objs="$filter_errlist_objs oggdec_filter" -fi -if test "$have_speex" = "yes"; then +} +NEED_SPEEX_OBJECTS && { filters="$filters spxdec" filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common" -fi -if test "$have_opus" = "yes"; then +} +NEED_OPUS_OBJECTS && { filters="$filters opusdec" filter_errlist_objs="$filter_errlist_objs opusdec_filter opus_common" -fi -if test "$have_faad" = "yes"; then +} +NEED_FLAC_OBJECTS && { + filter_errlist_objs="$filter_errlist_objs flacdec_filter" + filters="$filters flacdec" +} +if test $HAVE_FAAD = yes; then filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common" filters="$filters aacdec" fi -if test "$have_mad" = "yes"; then +if test $HAVE_MAD = yes; then filter_cmdline_objs="$filter_cmdline_objs mp3dec_filter" filter_errlist_objs="$filter_errlist_objs mp3dec_filter" filters="$filters mp3dec" fi -if test "$have_flac" = "yes"; then - filter_errlist_objs="$filter_errlist_objs flacdec_filter" - filters="$filters flacdec" -fi -if test "$have_samplerate" = "yes"; then +if test $HAVE_SAMPLERATE = yes; then filter_errlist_objs="$filter_errlist_objs resample_filter check_wav" filter_cmdline_objs="$filter_cmdline_objs resample_filter" filters="$filters resample" @@ -1204,26 +791,15 @@ recv_errlist_objs=" mp3_afh version " -if test "$have_vorbis" = "yes" || \ - test "$have_speex" = "yes" || \ - test "$have_opus" = "yes"; then - recv_errlist_objs="$recv_errlist_objs ogg_afh_common" -fi -if test "$have_vorbis" = "yes"; then - recv_errlist_objs="$recv_errlist_objs ogg_afh" -fi -if test "$have_speex" = "yes"; then - recv_errlist_objs="$recv_errlist_objs spx_afh spx_common" -fi -if test "$have_opus" = "yes"; then - recv_errlist_objs="$recv_errlist_objs opus_afh opus_common" -fi -if test "$have_faad" = "yes"; then +NEED_OGG_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh_common" +NEED_VORBIS_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh" +NEED_SPEEX_OBJECTS && recv_errlist_objs="$recv_errlist_objs spx_afh spx_common" +NEED_OPUS_OBJECTS && recv_errlist_objs="$recv_errlist_objs opus_afh opus_common" +NEED_FLAC_OBJECTS && recv_errlist_objs="$recv_errlist_objs flac_afh" + +if test $HAVE_FAAD = yes; then recv_errlist_objs="$recv_errlist_objs aac_afh aac_common" fi -if test "$have_flac" = "yes"; then - recv_errlist_objs="$recv_errlist_objs flac_afh" -fi recv_objs="add_cmdline($recv_cmdline_objs) $recv_errlist_objs" AC_SUBST(receivers, "http dccp udp afh") AC_SUBST(recv_objs, add_dot_o($recv_objs)) @@ -1244,30 +820,26 @@ afh_errlist_objs=" version ggo " -if test "$have_vorbis" = "yes" || \ - test "$have_speex" = "yes" || \ - test "$have_opus" = "yes"; then - afh_errlist_objs="$afh_errlist_objs ogg_afh_common" -fi -if test "$have_vorbis" = "yes"; then +NEED_OGG_OBJECTS && afh_errlist_objs="$afh_errlist_objs ogg_afh_common" +NEED_VORBIS_OBJECTS && { afh_errlist_objs="$afh_errlist_objs ogg_afh" audio_format_handlers="$audio_format_handlers ogg" -fi -if test "$have_speex" = "yes"; then +} +NEED_SPEEX_OBJECTS && { afh_errlist_objs="$afh_errlist_objs spx_afh spx_common" audio_format_handlers="$audio_format_handlers spx" -fi -if test "$have_opus" = "yes"; then +} +NEED_OPUS_OBJECTS && { afh_errlist_objs="$afh_errlist_objs opus_afh opus_common" audio_format_handlers="$audio_format_handlers opus" -fi -if test "$have_faad" = "yes"; then - afh_errlist_objs="$afh_errlist_objs aac_common aac_afh" - audio_format_handlers="$audio_format_handlers aac" -fi -if test "$have_flac" = "yes"; then +} +NEED_FLAC_OBJECTS && { afh_errlist_objs="$afh_errlist_objs flac_afh" audio_format_handlers="$audio_format_handlers flac" +} +if test $HAVE_FAAD = yes; then + afh_errlist_objs="$afh_errlist_objs aac_common aac_afh" + audio_format_handlers="$audio_format_handlers aac" fi afh_objs="add_cmdline($afh_cmdline_objs) $afh_errlist_objs" @@ -1325,46 +897,45 @@ if test "$have_core_audio" = "yes"; then play_errlist_objs="$play_errlist_objs osx_write ipc" play_cmdline_objs="$play_cmdline_objs osx_write" fi -if test "$have_vorbis" = "yes" || \ - test "$have_speex" = "yes" || \ - test "$have_opus" = "yes"; then - play_errlist_objs="$play_errlist_objs ogg_afh_common" -fi -if test "$have_vorbis" = "yes"; then +NEED_OGG_OBJECTS && play_errlist_objs="$play_errlist_objs ogg_afh_common" +NEED_VORBIS_OBJECTS && { play_errlist_objs="$play_errlist_objs oggdec_filter ogg_afh" -fi -if test "$have_speex" = "yes"; then +} +NEED_SPEEX_OBJECTS && { play_errlist_objs="$play_errlist_objs spxdec_filter spx_afh spx_common" -fi -if test "$have_opus" = "yes"; then - play_errlist_objs="$play_errlist_objs opusdec_filter opus_afh opus_common" -fi -if test "$have_faad" = "yes"; then +} +NEED_OPUS_OBJECTS && + play_errlist_objs="$play_errlist_objs + opusdec_filter + opus_afh + opus_common + " +NEED_FLAC_OBJECTS && { + play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh" +} +if test $HAVE_FAAD = yes; then play_errlist_objs="$play_errlist_objs aacdec_filter aac_afh aac_common" fi -if test "$have_mad" = "yes"; then +if test $HAVE_MAD = yes; then play_cmdline_objs="$play_cmdline_objs mp3dec_filter" play_errlist_objs="$play_errlist_objs mp3dec_filter" fi -if test "$have_flac" = "yes"; then - play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh" -fi -if test "$have_oss" = "yes"; then +if test $HAVE_OSS = yes; then play_errlist_objs="$play_errlist_objs oss_write" play_cmdline_objs="$play_cmdline_objs oss_write" fi -if test "$have_alsa" = "yes"; then +if test $HAVE_ALSA = yes; then play_errlist_objs="$play_errlist_objs alsa_write" play_cmdline_objs="$play_cmdline_objs alsa_write" fi -if test "$have_ao" = "yes"; then +NEED_AO_OBJECTS && { play_errlist_objs="$play_errlist_objs ao_write" play_cmdline_objs="$play_cmdline_objs ao_write" -fi -if test "$have_readline" = "yes"; then +} +if test $HAVE_READLINE = yes; then play_errlist_objs="$play_errlist_objs interactive" fi -if test "$have_samplerate" = "yes"; then +if test $HAVE_SAMPLERATE = yes; then play_errlist_objs="$play_errlist_objs resample_filter check_wav" play_cmdline_objs="$play_cmdline_objs resample_filter" fi @@ -1401,19 +972,19 @@ if test "$have_core_audio" = "yes"; then writers="$writers osx" default_writer="OSX_WRITE" fi -if test "$have_ao" = "yes"; then +NEED_AO_OBJECTS && { write_errlist_objs="$write_errlist_objs ao_write" write_cmdline_objs="$write_cmdline_objs ao_write" writers="$writers ao" default_writer="AO_WRITE" -fi -if test "$have_oss" = "yes"; then +} +if test $HAVE_OSS = yes; then write_errlist_objs="$write_errlist_objs oss_write" write_cmdline_objs="$write_cmdline_objs oss_write" writers="$writers oss" default_writer="OSS_WRITE" fi -if test "$have_alsa" = "yes"; then +if test $HAVE_ALSA = yes; then write_errlist_objs="$write_errlist_objs alsa_write" write_cmdline_objs="$write_cmdline_objs alsa_write" writers="$writers alsa" @@ -1444,7 +1015,7 @@ audioc_errlist_objs=" version ggo " -if test "$have_readline" = "yes"; then +if test $HAVE_READLINE = yes; then audioc_errlist_objs="$audioc_errlist_objs buffer_tree interactive @@ -1533,10 +1104,11 @@ AC_OUTPUT AC_MSG_NOTICE([ paraslash configuration: ~~~~~~~~~~~~~~~~~~~~~~~~ +crypto lib: ${CRYPTOLIB:-[none]} unix socket credentials: $have_ucred -readline (interactive CLIs): $have_readline +readline (interactive CLIs): $HAVE_READLINE audio formats handlers: $audio_format_handlers -id3 version2 support: $have_libid3tag +id3 version 2 support: $HAVE_ID3TAG filters: $filters writers: $writers diff --git a/gcrypt.c b/gcrypt.c index 62b95def..45a1c67d 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -87,7 +87,7 @@ void init_random_seed_or_die(void) } /** S-expression for the public part of an RSA key. */ -#define RSA_PUBKEY_SEXP "(public-key (rsa (n %m) (e %m)))" +#define RSA_PUBKEY_SEXP "(public-key (rsa (n %m) (e %m)))" /** S-expression for a private RSA key. */ #define RSA_PRIVKEY_SEXP "(private-key (rsa (n %m) (e %m) (d %m) (p %m) (q %m) (u %m)))" @@ -239,7 +239,6 @@ static int decode_key(const char *key_file, const char *header_str, key[j++] = begin[i]; } key[j] = '\0'; - //PARA_CRIT_LOG("key: %s\n", key); blob_size = key_size * 2; blob = para_malloc(blob_size); ret = base64_decode(key, blob, blob_size); @@ -275,14 +274,14 @@ enum asn1_types { /* bit 6 has value 0 */ static inline bool is_primitive(unsigned char c) { - return ((c & (1<<6)) == 0); + return (c & (1<<6)) == 0; } static inline bool is_primitive_integer(unsigned char c) { if (!is_primitive(c)) return false; - return ((c & 0x1f) == ASN1_TYPE_INTEGER); + return (c & 0x1f) == ASN1_TYPE_INTEGER; } /* Bit 8 is zero (and bits 7-1 give the length) */ @@ -305,7 +304,7 @@ static int find_pubkey_bignum_offset(const unsigned char *data, int len) { const unsigned char *p = data, *end = data + len; - /* the whole thing istarts with one sequence */ + /* the whole thing starts with one sequence */ if (*p != ASN1_TYPE_SEQUENCE) return -E_ASN1_PARSE; p++; @@ -429,7 +428,7 @@ static int find_privkey_bignum_offset(const unsigned char *data, int len) if (p >= end) return -E_ASN1_PARSE; - /* Skip next integer */ + /* skip next integer */ if (*p != ASN1_TYPE_INTEGER) return -E_ASN1_PARSE; p++; @@ -583,6 +582,7 @@ static int get_asn_public_key(const char *key_file, struct asymmetric_key **resu } key = para_malloc(sizeof(*key)); key->sexp = sexp; + key->num_bytes = n_size; *result = key; ret = n_size; PARA_INFO_LOG("successfully read %u bit asn public key\n", n_size * 8); @@ -604,7 +604,7 @@ static int get_ssh_public_key(unsigned char *data, int size, gcry_sexp_t *result size_t nr_scanned, erroff, decoded_size; gcry_mpi_t e = NULL, n = NULL; - PARA_DEBUG_LOG("decoding %d byte public rsa-ssh key\n", size); + PARA_DEBUG_LOG("decoding %d byte public rsa-ssh key\n", size); if (size > INT_MAX / 4) return -ERRNO_TO_PARA_ERROR(EOVERFLOW); blob = para_malloc(2 * size); diff --git a/mp3_afh.c b/mp3_afh.c index 3b540c0b..ccd28dad 100644 --- a/mp3_afh.c +++ b/mp3_afh.c @@ -68,7 +68,7 @@ static const int mp3info_bitrate[2][3][14] = { static const int frame_size_index[] = {24000, 72000, 72000}; static const char *mode_text[] = {"stereo", "joint stereo", "dual channel", "mono", "invalid"}; -#ifdef HAVE_LIBID3TAG +#ifdef HAVE_ID3TAG #include @@ -183,7 +183,7 @@ static int mp3_get_id3(unsigned char *map, size_t numbytes, __a_unused int fd, return ret; } -#else /* HAVE_LIBID3TAG */ +#else /* HAVE_ID3TAG */ /* * Remove trailing whitespace from the end of a string @@ -233,7 +233,7 @@ static int mp3_get_id3(unsigned char *map, size_t numbytes, __a_unused int fd, tags->comment = para_strdup(comment); return 1; } -#endif /* HAVE_LIBID3TAG */ +#endif /* HAVE_ID3TAG */ static int header_frequency(struct mp3header *h) { diff --git a/server.h b/server.h index 287614c8..93fd558c 100644 --- a/server.h +++ b/server.h @@ -10,12 +10,12 @@ #define MMD_INFO_SIZE 16384 /** The maximum length of the host component in an URL */ -#define MAX_HOSTLEN 256 +#define MAX_HOSTLEN 256 -/** Holds the arguments for the para_server's sender command. */ -struct sender_command_data{ - /** Greater than 0 indicates that a sender cmd is already queued. */ +/** Arguments for the sender command. */ +struct sender_command_data { + /** Greater than zero indicates that a sender cmd is already queued. */ int cmd_num; /** The number of the sender in question. */ int sender_num; diff --git a/version.c b/version.c index c9a329c3..69567561 100644 --- a/version.c +++ b/version.c @@ -43,7 +43,7 @@ const char *version_text(const char *pfx) static char buf[512]; snprintf(buf, sizeof(buf) - 1, "%s\n" - "Copyright (C) 2014 Andre Noll\n" + "Copyright (C) 2002-2015 Andre Noll\n" "This is free software with ABSOLUTELY NO WARRANTY." " See COPYING for details.\n" "Report bugs to .\n"