[asterisk-commits] branch oej/test-this-branch r12105 - in
/team/oej/test-this-branch: ./ channe...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Mar 6 08:38:44 MST 2006
Author: oej
Date: Mon Mar 6 09:38:40 2006
New Revision: 12105
URL: http://svn.digium.com/view/asterisk?rev=12105&view=rev
Log:
Fixes from the jitterbuffer branch. Please test.
Modified:
team/oej/test-this-branch/Makefile
team/oej/test-this-branch/abstract_jb.c
team/oej/test-this-branch/channels/chan_sip.c
team/oej/test-this-branch/include/asterisk/abstract_jb.h
team/oej/test-this-branch/scx_jitterbuf.c
Modified: team/oej/test-this-branch/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/Makefile?rev=12105&r1=12104&r2=12105&view=diff
==============================================================================
--- team/oej/test-this-branch/Makefile (original)
+++ team/oej/test-this-branch/Makefile Mon Mar 6 09:38:40 2006
@@ -87,7 +87,7 @@
TRACE_FRAMES = #-DTRACE_FRAMES
# Uncomment next one to enable the asterisk generic jitterbuffer
-GENERIC_JB = -DAST_JB
+GENERIC_JB = #-DAST_JB
# Uncomment next one to enable malloc debugging
# You can view malloc debugging with:
@@ -392,8 +392,8 @@
AUDIO_LIBS=-framework CoreAudio
ASTLINK=-Wl,-dynamic
SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
- OBJS+=poll.o
- ASTCFLAGS+=-DPOLLCOMPAT
+ #OBJS+=poll.o
+ #ASTCFLAGS+=-DPOLLCOMPAT
else
#These are used for all but Darwin
ASTLINK=-Wl,-E
Modified: team/oej/test-this-branch/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/abstract_jb.c?rev=12105&r1=12104&r2=12105&view=diff
==============================================================================
--- team/oej/test-this-branch/abstract_jb.c (original)
+++ team/oej/test-this-branch/abstract_jb.c Mon Mar 6 09:38:40 2006
@@ -23,6 +23,7 @@
*
* \brief Common implementation-independent jitterbuffer stuff.
*
+ * \author Slav Klenov <slav at securax.org>
*/
#include <stdio.h>
@@ -55,21 +56,21 @@
/* Hooks for the abstract jb implementation */
-/* Create */
+/*! \brief Create */
typedef void * (*jb_create_impl)(struct ast_jb_conf *general_config, long resynch_threshold);
-/* Destroy */
+/*! \brief Destroy */
typedef void (*jb_destroy_impl)(void *jb);
-/* Put first frame */
+/*! \brief Put first frame */
typedef int (*jb_put_first_impl)(void *jb, struct ast_frame *fin, long now);
-/* Put frame */
+/*! \brief Put frame */
typedef int (*jb_put_impl)(void *jb, struct ast_frame *fin, long now);
-/* Get frame for now */
+/*! \brief Get frame for now */
typedef int (*jb_get_impl)(void *jb, struct ast_frame **fout, long now, long interpl);
-/* Get next */
+/*! \brief Get next */
typedef long (*jb_next_impl)(void *jb);
-/* Remove first frame */
+/*! \brief Remove first frame */
typedef int (*jb_remove_impl)(void *jb, struct ast_frame **fout);
-/* Force resynch */
+/*! \brief Force resynch */
typedef void (*jb_force_resynch_impl)(void *jb);
@@ -154,7 +155,7 @@
/* JB_GET actions (used only for the frames log) */
static char *jb_get_actions[] = {"Delivered", "Dropped", "Interpolated", "No"};
-/* Macros for JB logs */
+/*! \brief Macros for JB logs */
/*#define jb_verbose(...) ast_verbose(VERBOSE_PREFIX_3 " ***[JB LOG]*** " __VA_ARGS__)*/
#define jb_verbose(...) if(1){\
char tmp[192];\
@@ -162,7 +163,7 @@
snprintf(msg, sizeof(msg), VERBOSE_PREFIX_3 "***[JB LOG]*** " __VA_ARGS__);\
ast_verbose("%s\n", term_color(tmp, msg, COLOR_BRGREEN, 0, sizeof(tmp)));}
-/* Macros for the frame log files */
+/*! \brief Macros for the frame log files */
#define jb_framelog(...) \
if(jb->logfile) \
{ \
@@ -191,15 +192,11 @@
jb->impl = &avail_impl[default_impl];
if(*jbconf->impl == '\0')
- {
return;
- }
-
- for(i=0; i<avail_impl_count; i++)
- {
+
+ for(i=0; i<avail_impl_count; i++) {
test_impl = &avail_impl[i];
- if(strcmp(jbconf->impl, test_impl->name) == 0)
- {
+ if(strcmp(jbconf->impl, test_impl->name) == 0) {
jb->impl = test_impl;
return;
}
@@ -226,46 +223,34 @@
int c1_jb_timebase_initialized = ast_test_flag(jb1, JB_TIMEBASE_INITIALIZED);
int c1_jb_created = ast_test_flag(jb1, JB_CREATED);
- if(((!c0_wants_jitter && c1_creates_jitter) || c0_force_jb) && c0_jb_enabled)
- {
+ if(((!c0_wants_jitter && c1_creates_jitter) || c0_force_jb) && c0_jb_enabled) {
ast_set_flag(jb0, JB_USE);
- if(!c0_jb_timebase_initialized)
- {
- if(c1_jb_timebase_initialized)
- {
+ if(!c0_jb_timebase_initialized) {
+ if(c1_jb_timebase_initialized) {
memcpy(&jb0->timebase, &jb1->timebase, sizeof(struct timeval));
- }
- else
- {
+ } else {
gettimeofday(&jb0->timebase, NULL);
}
ast_set_flag(jb0, JB_TIMEBASE_INITIALIZED);
}
- if(!c0_jb_created)
- {
+ if(!c0_jb_created) {
jb_choose_impl(c0);
}
}
- if(((!c1_wants_jitter && c0_creates_jitter) || c1_force_jb) && c1_jb_enabled)
- {
+ if(((!c1_wants_jitter && c0_creates_jitter) || c1_force_jb) && c1_jb_enabled) {
ast_set_flag(jb1, JB_USE);
- if(!c1_jb_timebase_initialized)
- {
- if(c0_jb_timebase_initialized)
- {
+ if(!c1_jb_timebase_initialized) {
+ if(c0_jb_timebase_initialized) {
memcpy(&jb1->timebase, &jb0->timebase, sizeof(struct timeval));
- }
- else
- {
+ } else {
gettimeofday(&jb1->timebase, NULL);
}
ast_set_flag(jb1, JB_TIMEBASE_INITIALIZED);
}
- if(!c1_jb_created)
- {
+ if(!c1_jb_created) {
jb_choose_impl(c1);
}
}
@@ -283,15 +268,13 @@
int wait, wait0, wait1;
struct timeval tv_now;
- if(time_left == 0)
- {
+ if(time_left == 0) {
/* No time left - the bridge will be retried */
/* TODO: Test disable this */
/*return 0;*/
}
- if(time_left < 0)
- {
+ if(time_left < 0) {
time_left = INT_MAX;
}
@@ -303,12 +286,9 @@
wait = wait0 < wait1 ? wait0 : wait1;
wait = wait < time_left ? wait : time_left;
- if(wait == INT_MAX)
- {
+ if(wait == INT_MAX) {
wait = -1;
- }
- else if(wait < 1)
- {
+ } else if(wait < 1) {
/* don't let wait=0, because this can cause the pbx thread to loop without any sleeping at all */
wait = 1;
}
@@ -325,15 +305,12 @@
struct ast_frame *frr;
long now = 0;
- if(!ast_test_flag(jb, JB_USE))
- {
+ if(!ast_test_flag(jb, JB_USE)) {
return -1;
}
- if(f->frametype != AST_FRAME_VOICE)
- {
- if(f->frametype == AST_FRAME_DTMF && ast_test_flag(jb, JB_CREATED))
- {
+ if(f->frametype != AST_FRAME_VOICE) {
+ if(f->frametype == AST_FRAME_DTMF && ast_test_flag(jb, JB_CREATED)) {
jb_framelog("JB_PUT {now=%ld}: Received DTMF frame. Force resynching jb...\n", now);
jbimpl->force_resync(jbobj);
}
@@ -342,31 +319,24 @@
}
/* We consider an enabled jitterbuffer should receive frames with valid timing info. */
- if(!f->has_timing_info || f->len < 2 || f->ts < 0)
- {
+ if(!f->has_timing_info || f->len < 2 || f->ts < 0) {
ast_log(LOG_WARNING, "Recieved frame with invalid timing info: "
"has_timing_info=%d, len=%ld, ts=%ld\n", f->has_timing_info, f->len, f->ts);
return -1;
}
- if(f->mallocd & AST_MALLOCD_HDR)
- {
+ if(f->mallocd & AST_MALLOCD_HDR) {
frr = ast_frdup(f);
- }
- else
- {
+ } else {
frr = ast_frisolate(f);
}
- if(frr == NULL)
- {
+ if(frr == NULL) {
ast_log(LOG_ERROR, "Failed to isolate frame for the jitterbuffer on channel '%s'\n", chan->name);
return -1;
}
- if(!ast_test_flag(jb, JB_CREATED))
- {
- if(create_jb(chan, frr))
- {
+ if(!ast_test_flag(jb, JB_CREATED)) {
+ if(create_jb(chan, frr)) {
ast_frfree(frr);
/* Disable the jitterbuffer */
ast_clear_flag(jb, JB_USE);
@@ -375,12 +345,9 @@
ast_set_flag(jb, JB_CREATED);
return 0;
- }
- else
- {
+ } else {
now = get_now(jb, NULL);
- if(jbimpl->put(jbobj, frr, now) != JB_IMPL_OK)
- {
+ if(jbimpl->put(jbobj, frr, now) != JB_IMPL_OK) {
jb_framelog("JB_PUT {now=%ld}: Dropped frame with ts=%ld and len=%ld\n", now, frr->ts, frr->len);
ast_frfree(frr);
/*return -1;*/
@@ -407,13 +374,11 @@
int c1_use_jb = ast_test_flag(jb1, JB_USE);
int c1_jb_is_created = ast_test_flag(jb1, JB_CREATED);
- if(c0_use_jb && c0_jb_is_created)
- {
+ if(c0_use_jb && c0_jb_is_created) {
jb_get_and_deliver(c0);
}
- if(c1_use_jb && c1_jb_is_created)
- {
+ if(c1_use_jb && c1_jb_is_created) {
jb_get_and_deliver(c1);
}
}
@@ -430,20 +395,17 @@
now = get_now(jb, NULL);
jb->next = jbimpl->next(jbobj);
- if(now < jb->next)
- {
+ if(now < jb->next) {
jb_framelog("\tJB_GET {now=%ld}: now < next=%ld\n", now, jb->next);
return;
}
- while(now >= jb->next)
- {
+ while(now >= jb->next) {
interpolation_len = ast_codec_interp_len(jb->last_format);
res = jbimpl->get(jbobj, &f, now, interpolation_len);
- switch(res)
- {
+ switch(res) {
case JB_IMPL_OK:
/* deliver the frame */
ast_write(chan, f);
@@ -499,8 +461,7 @@
int res;
jbobj = jb->jbobj = jbimpl->create(jbconf, jbconf->resync_threshold);
- if(jbobj == NULL)
- {
+ if(jbobj == NULL) {
ast_log(LOG_WARNING, "Failed to create jitterbuffer on channel '%s'\n", chan->name);
return -1;
}
@@ -510,8 +471,7 @@
/* The result of putting the first frame should not differ from OK. However, its possible
some implementations (i.e. stevek's when resynch_threshold is specified) to drop it. */
- if(res != JB_IMPL_OK)
- {
+ if(res != JB_IMPL_OK) {
ast_log(LOG_WARNING, "Failed to put first frame in the jitterbuffer on channel '%s'\n", chan->name);
/*
jbimpl->destroy(jbobj);
@@ -526,42 +486,34 @@
jb->last_format = frr->subclass;
/* Create a frame log file */
- if(ast_test_flag(jbconf, AST_JB_LOG))
- {
+ if(ast_test_flag(jbconf, AST_JB_LOG)) {
snprintf(name2, sizeof(name2), "%s", chan->name);
tmp = strchr(name2, '/');
- if(tmp != NULL)
- {
+ if(tmp != NULL) {
*tmp = '#';
}
bridged = ast_bridged_channel(chan);
- if(bridged == NULL)
- {
+ if(bridged == NULL) {
/* We should always have bridged chan if a jitterbuffer is in use */
CRASH;
}
snprintf(name1, sizeof(name1), "%s", bridged->name);
tmp = strchr(name1, '/');
- if(tmp != NULL)
- {
+ if(tmp != NULL) {
*tmp = '#';
}
snprintf(logfile_pathname, sizeof(logfile_pathname),
"/tmp/ast_%s_jb_%s--%s.log", jbimpl->name, name1, name2);
jb->logfile = fopen(logfile_pathname, "w+b");
- if(jb->logfile == NULL)
- {
+ if(jb->logfile == NULL) {
ast_log(LOG_WARNING, "Failed to create frame log file with pathname '%s'\n", logfile_pathname);
}
- if(res == JB_IMPL_OK)
- {
+ if(res == JB_IMPL_OK) {
jb_framelog("JB_PUT_FIRST {now=%ld}: Queued frame with ts=%ld and len=%ld\n",
now, frr->ts, frr->len);
- }
- else
- {
+ } else {
jb_framelog("JB_PUT_FIRST {now=%ld}: Dropped frame with ts=%ld and len=%ld\n",
now, frr->ts, frr->len);
}
@@ -570,8 +522,7 @@
jb_verbose("%s jitterbuffer created on channel %s", jbimpl->name, chan->name);
/* Free the frame if it has not been queued in the jb */
- if(res != JB_IMPL_OK)
- {
+ if(res != JB_IMPL_OK) {
ast_frfree(frr);
}
@@ -586,17 +537,14 @@
void *jbobj = jb->jbobj;
struct ast_frame *f;
- if(jb->logfile != NULL)
- {
+ if(jb->logfile != NULL) {
fclose(jb->logfile);
jb->logfile = NULL;
}
- if(ast_test_flag(jb, JB_CREATED))
- {
+ if(ast_test_flag(jb, JB_CREATED)) {
/* Remove and free all frames still queued in jb */
- while(jbimpl->remove(jbobj, &f) == JB_IMPL_OK)
- {
+ while(jbimpl->remove(jbobj, &f) == JB_IMPL_OK) {
ast_frfree(f);
}
@@ -614,8 +562,7 @@
{
struct timeval now;
- if(tv == NULL)
- {
+ if(tv == NULL) {
tv = &now;
gettimeofday(tv, NULL);
}
@@ -634,57 +581,42 @@
char *name;
int tmp;
- if(memcmp(AST_JB_CONF_PREFIX, varname, prefixlen) != 0)
- {
+ if(memcmp(AST_JB_CONF_PREFIX, varname, prefixlen) != 0) {
return -1;
}
name = varname + prefixlen;
- if(strcmp(name, AST_JB_CONF_ENABLE) == 0)
- {
- if(ast_true(value))
- {
+ if(strcmp(name, AST_JB_CONF_ENABLE) == 0) {
+ if(ast_true(value)) {
conf->flags |= AST_JB_ENABLED;
}
}
- else if(strcmp(name, AST_JB_CONF_FORCE) == 0)
- {
- if(ast_true(value))
- {
+ else if(strcmp(name, AST_JB_CONF_FORCE) == 0) {
+ if(ast_true(value)) {
conf->flags |= AST_JB_FORCED;
}
}
- else if(strcmp(name, AST_JB_CONF_MAX_SIZE) == 0)
- {
- if((tmp = atoi(value)) > 0)
- {
+ else if(strcmp(name, AST_JB_CONF_MAX_SIZE) == 0) {
+ if((tmp = atoi(value)) > 0) {
conf->max_size = tmp;
}
}
- else if(strcmp(name, AST_JB_CONF_RESYNCH_THRESHOLD) == 0)
- {
- if((tmp = atoi(value)) > 0)
- {
+ else if(strcmp(name, AST_JB_CONF_RESYNCH_THRESHOLD) == 0) {
+ if((tmp = atoi(value)) > 0) {
conf->resync_threshold = tmp;
}
}
- else if(strcmp(name, AST_JB_CONF_IMPL) == 0)
- {
- if(*value)
- {
+ else if(strcmp(name, AST_JB_CONF_IMPL) == 0) {
+ if(*value) {
snprintf(conf->impl, sizeof(conf->impl), "%s", value);
}
}
- else if(strcmp(name, AST_JB_CONF_LOG) == 0)
- {
- if(ast_true(value))
- {
+ else if(strcmp(name, AST_JB_CONF_LOG) == 0) {
+ if(ast_true(value)) {
conf->flags |= AST_JB_LOG;
}
- }
- else
- {
+ } else {
return -1;
}
@@ -800,14 +732,13 @@
/* stevek */
-static void * jb_create_stevek(struct ast_jb_conf *general_config, long resynch_threshold)
+static void *jb_create_stevek(struct ast_jb_conf *general_config, long resynch_threshold)
{
jb_conf jbconf;
jitterbuf *stevekjb;
stevekjb = jb_new();
- if(stevekjb != NULL)
- {
+ if(stevekjb != NULL) {
jbconf.max_jitterbuf = general_config->max_size;
jbconf.resync_threshold = general_config->resync_threshold;
jbconf.max_contig_interp = 10;
Modified: team/oej/test-this-branch/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/chan_sip.c?rev=12105&r1=12104&r2=12105&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/chan_sip.c (original)
+++ team/oej/test-this-branch/channels/chan_sip.c Mon Mar 6 09:38:40 2006
@@ -12349,15 +12349,6 @@
for (; v; v = v->next) {
if (handle_common_options(&peerflags, &mask, v))
continue;
-#ifdef AST_JB
- /* handle jb conf */
- if(ast_jb_read_conf(&global_jbconf, v->name, v->value) == 0)
- {
- v = v->next;
- continue;
- }
-#endif /* AST_JB */
-
if (realtime && !strcasecmp(v->name, "regseconds")) {
ast_get_time_t(v->value, ®seconds, 0, NULL);
} else if (realtime && !strcasecmp(v->name, "ipaddr") && !ast_strlen_zero(v->value) ) {
@@ -12663,6 +12654,13 @@
for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
if (handle_common_options(&global_flags, &dummy, v))
continue;
+#ifdef AST_JB
+ /* handle jb conf */
+ if(ast_jb_read_conf(&global_jbconf, v->name, v->value) == 0)
+ {
+ continue;
+ }
+#endif /* AST_JB */
/* Create the interface list */
if (!strcasecmp(v->name, "context")) {
Modified: team/oej/test-this-branch/include/asterisk/abstract_jb.h
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/include/asterisk/abstract_jb.h?rev=12105&r1=12104&r2=12105&view=diff
==============================================================================
--- team/oej/test-this-branch/include/asterisk/abstract_jb.h (original)
+++ team/oej/test-this-branch/include/asterisk/abstract_jb.h Mon Mar 6 09:38:40 2006
@@ -23,6 +23,7 @@
*
* \brief Common implementation-independent jitterbuffer stuff.
*
+ * \author Slav Klenov <slav at securax.org>
*/
#ifndef _ABSTRACT_JB_H_
Modified: team/oej/test-this-branch/scx_jitterbuf.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/scx_jitterbuf.c?rev=12105&r1=12104&r2=12105&view=diff
==============================================================================
--- team/oej/test-this-branch/scx_jitterbuf.c (original)
+++ team/oej/test-this-branch/scx_jitterbuf.c Mon Mar 6 09:38:40 2006
@@ -23,6 +23,7 @@
*
* \brief Jitterbuffering algorithm.
*
+ * \author Slav Klenov <slav at securax.org>
*/
#include <stdio.h>
@@ -30,9 +31,10 @@
#include <assert.h>
#include <string.h>
#include "scx_jitterbuf.h"
-
-
-/* private scx_jb structure */
+#include "asterisk/utils.h"
+
+
+/*! \brief private scx_jb structure */
struct scx_jb
{
struct scx_jb_frame *frames;
@@ -45,15 +47,14 @@
};
-static struct scx_jb_frame * alloc_jb_frame(struct scx_jb *jb);
+static struct scx_jb_frame *alloc_jb_frame(struct scx_jb *jb);
static void release_jb_frame(struct scx_jb *jb, struct scx_jb_frame *frame);
static void get_jb_head(struct scx_jb *jb, struct scx_jb_frame *frame);
static int resynch_jb(struct scx_jb *jb, void *data, long ms, long ts, long now);
-
-static struct scx_jb_frame * alloc_jb_frame(struct scx_jb *jb)
-{
- return (struct scx_jb_frame *) calloc(1, sizeof(struct scx_jb_frame));
+static struct scx_jb_frame *alloc_jb_frame(struct scx_jb *jb)
+{
+ return (struct scx_jb_frame *) ast_calloc(1, sizeof(struct scx_jb_frame));
}
@@ -70,12 +71,9 @@
/* unlink the frame */
fr = jb->frames;
jb->frames = fr->next;
- if(jb->frames != NULL)
- {
+ if(jb->frames != NULL) {
jb->frames->prev = NULL;
- }
- else
- {
+ } else {
/* the jb is empty - update tail */
jb->tail = NULL;
}
@@ -91,30 +89,27 @@
}
-struct scx_jb * scx_jb_new(struct scx_jb_conf *conf)
+struct scx_jb *scx_jb_new(struct scx_jb_conf *conf)
{
struct scx_jb *jb;
- jb = calloc(1, sizeof(struct scx_jb));
- if(jb == NULL)
- {
+ jb = ast_calloc(1, sizeof(struct scx_jb));
+ if(jb == NULL) {
return NULL;
}
/* First copy our config */
memcpy(&jb->conf, conf, sizeof(struct scx_jb_conf));
+
/* we dont need the passed config anymore - continue working with the saved one */
conf = &jb->conf;
/* validate the configuration */
if(conf->jbsize < 1)
- {
conf->jbsize = SCX_JB_SIZE_DEFAULT;
- }
+
if(conf->resync_threshold < 1)
- {
conf->resync_threshold = SCX_JB_RESYNCH_THRESHOLD_DEFAULT;
- }
/* Set the constant delay to the jitterbuf */
jb->delay = conf->jbsize;
@@ -138,8 +133,7 @@
struct scx_jb_frame *frame;
/* If jb is empty, just reinitialize the jb */
- if(jb->frames == NULL)
- {
+ if(jb->frames == NULL) {
/* debug check: tail should also be NULL */
assert(jb->tail == NULL);
@@ -158,9 +152,7 @@
/* Do we really need to resynch, or this is just a frame for dropping? */
if(!jb->force_resynch && (offset < jb->conf.resync_threshold && offset > -jb->conf.resync_threshold))
- {
return SCX_JB_DROP;
- }
/* Reset the force resynch flag */
jb->force_resynch = 0;
@@ -168,8 +160,7 @@
/* apply the offset to the jb state */
jb->rxcore -= offset;
frame = jb->frames;
- while(frame)
- {
+ while(frame) {
frame->ts += offset;
frame = frame->next;
}
@@ -213,8 +204,7 @@
delivery = jb->rxcore + jb->delay + ts;
/* check if the new frame is not too late */
- if(delivery < jb->next_delivery)
- {
+ if(delivery < jb->next_delivery) {
/* should drop the frame, but let first resynch_jb() check if this is not a jump in ts, or
the force resynch flag was not set. */
return resynch_jb(jb, data, ms, ts, now);
@@ -222,8 +212,7 @@
/* what if the delivery time is bigger than next + delay? Seems like a frame for the future.
However, allow more resync_threshold ms in advance */
- if(delivery > jb->next_delivery + jb->delay + jb->conf.resync_threshold)
- {
+ if(delivery > jb->next_delivery + jb->delay + jb->conf.resync_threshold) {
/* should drop the frame, but let first resynch_jb() check if this is not a jump in ts, or
the force resynch flag was not set. */
return resynch_jb(jb, data, ms, ts, now);
@@ -231,8 +220,7 @@
/* find the right place in the frames list, sorted by delivery time */
frame = jb->tail;
- while(frame != NULL && frame->delivery > delivery)
- {
+ while(frame != NULL && frame->delivery > delivery) {
frame = frame->prev;
}
@@ -260,17 +248,13 @@
newframe->delivery = delivery;
/* and insert it right on place */
- if(frame != NULL)
- {
+ if(frame != NULL) {
next = frame->next;
frame->next = newframe;
- if(next != NULL)
- {
+ if(next != NULL) {
newframe->next = next;
next->prev = newframe;
- }
- else
- {
+ } else {
/* insert after the last frame - should update tail */
jb->tail = newframe;
newframe->next = NULL;
@@ -278,9 +262,7 @@
newframe->prev = frame;
return SCX_JB_OK;
- }
- else if(jb->frames == NULL)
- {
+ } else if(jb->frames == NULL) {
/* the frame list is empty or thats just the first frame ever */
/* tail should also be NULL is that case */
assert(jb->tail == NULL);
@@ -289,9 +271,7 @@
newframe->prev = NULL;
return SCX_JB_OK;
- }
- else
- {
+ } else {
/* insert on a first position - should update frames head */
newframe->next = jb->frames;
newframe->prev = NULL;
@@ -308,15 +288,13 @@
assert(now >= 0);
assert(interpl >= 2);
- if(now < jb->next_delivery)
- {
+ if(now < jb->next_delivery) {
/* too early for the next frame */
return SCX_JB_NOFRAME;
}
/* Is the jb empty? */
- if(jb->frames == NULL)
- {
+ if(jb->frames == NULL) {
/* should interpolate a frame */
/* update next */
jb->next_delivery += interpl;
@@ -325,8 +303,7 @@
}
/* Isn't it too late for the first frame available in the jb? */
- if(now > jb->frames->delivery + jb->frames->ms)
- {
+ if(now > jb->frames->delivery + jb->frames->ms) {
/* yes - should drop this frame and update next to point the next frame (get_jb_head() does it) */
get_jb_head(jb, frame);
@@ -334,8 +311,7 @@
}
/* isn't it too early to play the first frame available? */
- if(now < jb->frames->delivery)
- {
+ if(now < jb->frames->delivery) {
/* yes - should interpolate one frame */
/* update next */
jb->next_delivery += interpl;
@@ -359,9 +335,7 @@
int scx_jb_remove(struct scx_jb *jb, struct scx_jb_frame *frameout)
{
if(jb->frames == NULL)
- {
return SCX_JB_NOFRAME;
- }
get_jb_head(jb, frameout);
More information about the asterisk-commits
mailing list