- Shared memory areas are no longer restricted to 64K. We now
detect the maximal size of a shared memory area at runtime.
- cleanup of the internal uptime API.
+ - para_server prefaults the mmapped audio file to avoid
+ delays on slow media.
--------------------------------------
0.4.8 (2011-08-19) "nested assignment"
{
float tmp = mp4ASC->sbr_present_flag == 1? 2047 : 1023;
struct timeval total;
- long unsigned ms = 1000.0 * afhi->chunks_total * tmp
- / mp4ASC->samplingFrequency;
+ long unsigned ms;
if (!mp4ASC->samplingFrequency)
return -E_MP4ASC;
* command. This function allows to pass such a structure together with a list
* of further arguments (often a list of audio files) to the parent process.
*
+ * \return The return value of the underlying call to \ref
+ * send_callback_request().
+ *
* \sa send_standard_callback_request(), send_callback_request().
*/
int send_option_arg_callback_request(struct osl_object *options,
* \param pb Unused.
* \param data Unused.
*
- * This table does not honor events.
+ * \return The images table does not honor events, so this handler always
+ * returns success.
*/
__a_const int images_event_handler(__a_unused enum afs_events event,
__a_unused struct para_buffer *pb, __a_unused void *data)
* \param pb Unused.
* \param data Unused.
*
- * This table does not honor events.
+ * \return The lyrics table does not honor events, so this handler always
+ * returns success.
*/
__a_const int lyrics_event_handler(__a_unused enum afs_events event,
__a_unused struct para_buffer *pb, __a_unused void *data)
* up-to-date afs status items directly. Therefore the usual callback mechanism
* is used to pass the status items from the afs process to the command handler
* via a shared memory area and a pipe.
+ *
+ * \return The return value of the underyling call to \ref send_callback_request().
*/
int send_afs_status(struct stream_cipher_context *scc, int parser_friendly)
{
ret = -E_AUTH_REQUEST;
goto net_err;
}
- numbytes = ret;
ret = -E_AUTH_REQUEST;
if (strncmp(buf, AUTH_REQUEST_MSG, strlen(AUTH_REQUEST_MSG)))
goto net_err;
p = buf + strlen(AUTH_REQUEST_MSG);
PARA_DEBUG_LOG("received auth request for user %s\n", p);
- ret = -E_BAD_USER;
u = lookup_user(p);
if (u) {
get_random_bytes_or_die(rand_buf, sizeof(rand_buf));
PARA_INFO_LOG("decoding public rsa-ssh key %s\n", key_file);
ret = -ERRNO_TO_PARA_ERROR(EOVERFLOW);
if (map_size > INT_MAX / 4)
- goto out;
+ goto out_unmap;
blob_size = 2 * map_size;
blob = para_malloc(blob_size);
ret = uudecode(cp, blob, blob_size);
if (ret < 0)
- goto out;
+ goto out_unmap;
decoded_size = ret;
ret = check_ssh_key_header(blob, decoded_size);
if (ret < 0)
- goto out;
+ goto out_unmap;
ret = read_rsa_bignums(blob + ret, decoded_size - ret, &key->rsa);
if (ret < 0)
- goto out;
+ goto out_unmap;
ret = RSA_size(key->rsa);
-out:
+out_unmap:
ret2 = para_munmap(map, map_size);
if (ret >= 0 && ret2 < 0)
ret = ret2;
+out:
if (ret < 0) {
free(key);
*result = NULL;
static void dccp_recv_close(struct receiver_node *rn)
{
-
struct private_dccp_recv_data *pdd = rn->private_data;
- if (pdd && pdd->fd > 0)
+ if (!pdd)
+ return;
+ if (pdd->fd > 0)
close(pdd->fd);
btr_pool_free(pdd->btrp);
- free(rn->private_data);
+ free(pdd);
rn->private_data = NULL;
}
fft(&s->fft, z);
/* post rotation + reordering */
- output += n4;
for (k = 0; k < n8; k++) {
fftsample_t r0, i0, r1, i1;
CMUL(r0, i1, z[n8 - k - 1].im, z[n8 - k - 1].re,
# undef SYSCTL_SHMMAX_VARIABLE
# endif
+/**
+ * Get the maximal size of a shared memory area.
+ *
+ * The value is only computed once when the function is called for the first
+ * time. Subsequent calls return the number which was computed during the
+ * first call.
+ *
+ * \return A number suitable as an argument to \ref shm_new().
+ */
size_t shm_get_shmmax(void)
{
static size_t shmmax;
/**
* Get the maximum transport-layer message size (MMS_S).
*
- * The socket must be connected. See RFC 1122, 3.3.3.
+ * \param sockfd The socket file descriptor.
*
- * \return If the protocol familiy could not be determined, \p AF_INET is
- * assumed.
+ * The socket must be connected. See RFC 1122, 3.3.3. If the protocol familiy
+ * could not be determined, \p AF_INET is assumed.
+ *
+ * \return The maximum message size of the address family type.
*/
int generic_max_transport_msg_size(int sockfd)
{
/** \file net.h exported symbols from net.c */
/**
- * the buffer size of the sun_path component of struct sockaddr_un
+ * The buffer size of the sun_path component of struct sockaddr_un.
*
- * While glibc doesn't define \p UNIX_PATH_MAX, it
- * documents it has being limited to 108 bytes.
+ * While glibc doesn't define \p UNIX_PATH_MAX, it documents it has being
+ * limited to 108 bytes. On NetBSD it is only 104 bytes though. We trust \p
+ * UNIX_PATH_MAX if it is defined and use the size of the ->sun_path member
+ * otherwise. This should be safe everywhere.
*/
#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX 108
+#define UNIX_PATH_MAX (sizeof(((struct sockaddr_un *)0)->sun_path))
#endif
/* Userland defines for Linux DCCP support. */
return 0;
if (packet_num == 0) {
ogg_stream_init(&vghd->os, serial);
- ret = -E_OGG_PACKET_IN;
ret = ogg_stream_packetin(&vghd->os, packet);
if (ret < 0)
goto out;
pod->converted = 0;
fn->min_iqs = 0;
pod->vf = vf;
+ pod->have_more = true;
}
return ret;
}
* \param barrier Absolute time before select() should return.
* \param s Pointer to the scheduler struct.
*
- * If \a barrier is in the past, this function requests a minimal timeout and
- * returns zero. Otherwise it returns one.
+ * \return If \a barrier is in the past, this function requests a minimal
+ * timeout and returns zero. Otherwise it returns one.
*
* \sa sched_min_delay(), sched_request_barrier().
*/
uint16_t slice_bytes;
};
+/** A FEC client is always in one of these states. */
enum fec_client_state {
FEC_STATE_NONE = 0, /**< not initialized and not enabled */
FEC_STATE_DISABLED, /**< temporarily disabled */
return 1;
}
+#ifndef MAP_POPULATE
+#define MAP_POPULATE 0
+#endif
+
static void recv_afs_result(struct vss_task *vsst, fd_set *rfds)
{
int ret, passed_fd, shmid;
}
mmd->size = statbuf.st_size;
mmd->mtime = statbuf.st_mtime;
- ret = para_mmap(mmd->size, PROT_READ, MAP_PRIVATE, passed_fd,
- 0, &vsst->map);
+ ret = para_mmap(mmd->size, PROT_READ, MAP_PRIVATE | MAP_POPULATE,
+ passed_fd, 0, &vsst->map);
if (ret < 0)
goto err;
close(passed_fd);
}
mmd->chunks_sent++;
mmd->current_chunk++;
+ /*
+ * Prefault next chunk(s)
+ *
+ * If the backing device of the memory-mapped audio file is
+ * slow and read-ahead is turned off or prevented for some
+ * reason, e.g. due to memory pressure, it may take much longer
+ * than the chunk interval to get the next chunk on the wire,
+ * causing buffer underruns on the client side. Mapping the
+ * file with MAP_POPULATE seems to help a bit, but it does not
+ * eliminate the delays completely. Moreover, it is supported
+ * only on Linux. So we do our own read-ahead here.
+ */
+ buf += len;
+ for (i = 0; i < 5 && buf < vsst->map + mmd->size; i++) {
+ __a_unused volatile char x = *buf;
+ buf += 4096;
+ }
}
}
* \param pattern_len The length of the pattern in bytes.
* \param buf The buffer to search for the pattern.
* \param buf_size The number of bytes in \a buf.
+ *
+ * \return A pointer into \a buf or \p NULL if the pattern was not found.
*/
const char *search_pattern(const char *pattern, int pattern_len,
const char *buf, int buf_size)
*coefs++ = 0.0;
continue;
}
- mult1 = mult;
n1 = pwd->exponent_high_sizes[bsize];
/* compute power of high bands */
exponents = pwd->exponents[ch] +
mult1 = sqrt(exp_power[j]
/ exp_power[last_high_band]);
/* XXX: use a table */
- mult1 = mult1 * pow(10,
- pwd->high_band_values[ch][j] * 0.05);
+ mult1 *= pow(10, pwd->high_band_values[ch][j] * 0.05);
mult1 /= (pwd->max_exponent[ch] * pwd->noise_mult);
mult1 *= mdct_norm;
for (i = 0; i < n; i++) {
for (ch = 0; ch < pwd->ahi.channels; ch++) {
int n4, idx;
- n = pwd->block_len;
n4 = pwd->block_len / 2;
if (pwd->channel_coded[ch])
imdct(pwd->mdct_ctx[bsize], pwd->output, pwd->coefs[ch]);