[xiph-commits] r11047 - in trunk/speex: include/speex libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Tue Mar 21 22:47:12 PST 2006
Author: jm
Date: 2006-03-21 22:47:09 -0800 (Tue, 21 Mar 2006)
New Revision: 11047
Modified:
trunk/speex/include/speex/speex_jitter.h
trunk/speex/libspeex/jitter.c
Log:
cleaning up
Modified: trunk/speex/include/speex/speex_jitter.h
===================================================================
--- trunk/speex/include/speex/speex_jitter.h 2006-03-22 02:11:47 UTC (rev 11046)
+++ trunk/speex/include/speex/speex_jitter.h 2006-03-22 06:47:09 UTC (rev 11047)
@@ -47,16 +47,17 @@
typedef struct JitterBuffer_ JitterBuffer;
-/*typedef struct {
- void *data;
-
-} JitterBufferCallback;
-*/
+#define JITTER_BUFFER_MISSING 1
+#define JITTER_BUFFER_MISSING_START 2
+#define JITTER_BUFFER_INCOMPLETE 4
/** Initialise jitter buffer */
-void jitter_buffer_init(JitterBuffer *jitter, int tick);
+JitterBuffer *jitter_buffer_init(int tick);
+/** Reset jitter buffer */
+void jitter_buffer_reset(JitterBuffer *jitter);
+
/** Destroy jitter buffer */
void jitter_buffer_destroy(JitterBuffer *jitter);
Modified: trunk/speex/libspeex/jitter.c
===================================================================
--- trunk/speex/libspeex/jitter.c 2006-03-22 02:11:47 UTC (rev 11046)
+++ trunk/speex/libspeex/jitter.c 2006-03-22 06:47:09 UTC (rev 11047)
@@ -67,29 +67,48 @@
};
/** Initialise jitter buffer */
-void jitter_buffer_init(JitterBuffer *jitter, int tick)
+JitterBuffer *jitter_buffer_init(int tick)
{
+ JitterBuffer *jitter = speex_alloc(sizeof(JitterBuffer));
+ if (jitter)
+ {
+ int i;
+ for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
+ jitter->buf[i]=NULL;
+ jitter->tick_size = tick;
+ jitter_buffer_reset(jitter);
+ }
+ return jitter;
+}
+
+/** Reset jitter buffer */
+void jitter_buffer_reset(JitterBuffer *jitter)
+{
int i;
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
{
- jitter->buf[i]=NULL;
+ if (jitter->buf[i])
+ speex_free(jitter->buf[i]);
jitter->len[i]=-1;
jitter->timestamp[i]=-1;
jitter->span[i]=-1;
}
-
- jitter->tick_size = tick;
-
jitter->pointer_timestamp = -jitter->tick_size * 4;
jitter->reset_state = 1;
jitter->lost_count = 0;
jitter->loss_rate = 0;
+ for (i=0;i<MAX_MARGIN;i++)
+ {
+ jitter->shortterm_margin[i] = 0;
+ jitter->longterm_margin[i] = 0;
+ }
}
/** Destroy jitter buffer */
void jitter_buffer_destroy(JitterBuffer *jitter)
{
+ speex_free(jitter);
}
/** Put one packet into the jitter buffer */
@@ -102,19 +121,6 @@
{
jitter->reset_state=0;
jitter->pointer_timestamp = timestamp-jitter->tick_size * 4;
- for (i=0;i<MAX_MARGIN;i++)
- {
- jitter->shortterm_margin[i] = 0;
- jitter->longterm_margin[i] = 0;
- }
- for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
- {
- if (jitter->buf[i])
- speex_free(jitter->buf[i]);
- jitter->len[i]=-1;
- jitter->timestamp[i]=-1;
- jitter->span[i]=-1;
- }
fprintf(stderr, "reset to %d\n", timestamp);
}
@@ -132,7 +138,7 @@
/*Find an empty slot in the buffer*/
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
{
- if (jitter->len[i]==-1)
+ if (jitter->buf[i]==NULL)
break;
}
@@ -272,7 +278,7 @@
/* Search the buffer for a packet with the right timestamp */
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
{
- if (jitter->len[i]!=-1 && jitter->timestamp[i]==jitter->pointer_timestamp)
+ if (jitter->buf[i] && jitter->timestamp[i]==jitter->pointer_timestamp)
break;
}
@@ -287,7 +293,7 @@
*length = jitter->len[i];
for (j=0;j<*length;j++)
out[j] = jitter->buf[i][j];
- return;
+ return 0;
}
More information about the commits
mailing list