[xiph-commits] r3029 - in liboggplay/trunk: . include/oggplay
plugin src/liboggplay src/tests src/tools
shans at svn.annodex.net
shans at svn.annodex.net
Sun Jun 24 05:54:01 PDT 2007
Author: shans
Date: 2007-06-24 05:54:01 -0700 (Sun, 24 Jun 2007)
New Revision: 3029
Modified:
liboggplay/trunk/configure.ac
liboggplay/trunk/include/oggplay/oggplay.h
liboggplay/trunk/plugin/plugin.cpp
liboggplay/trunk/plugin/plugin_oggplay.c
liboggplay/trunk/plugin/plugin_oggplay.h
liboggplay/trunk/src/liboggplay/Version_script.in
liboggplay/trunk/src/liboggplay/oggplay_buffer.c
liboggplay/trunk/src/liboggplay/oggplay_buffer.h
liboggplay/trunk/src/liboggplay/oggplay_callback.c
liboggplay/trunk/src/liboggplay/oggplay_callback_info.c
liboggplay/trunk/src/liboggplay/oggplay_file_reader.c
liboggplay/trunk/src/liboggplay/oggplay_private.h
liboggplay/trunk/src/liboggplay/oggplay_seek.c
liboggplay/trunk/src/tests/Makefile.am
liboggplay/trunk/src/tools/Makefile.am
liboggplay/trunk/src/tools/glut-player.c
Log:
Seeking changes
---------------
- CallbackInfo structs now contain a pointer to their buffer. To make this
work I also needed to:
* remove oggplay_buffer_free_info
* change oggplay_buffer_release_next to oggplay_buffer_release
* fix plugin and glut-player to deal with this
- I've moved the semaphore for # free frames into oggplay.
- The OggPlayBuffer has been marked volatile
- there's some heap op dumping functions in oggplay_private.h now. They're
not compiled in by default
Other
-----
- guarded implementation of executeCmmlCallback to not compile on linux
(declaration already guarded)
Modified: liboggplay/trunk/configure.ac
===================================================================
--- liboggplay/trunk/configure.ac 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/configure.ac 2007-06-24 12:54:01 UTC (rev 3029)
@@ -220,7 +220,7 @@
dnl XXX: On MacOSX, assume we have GLUT and OpenGL frameworks
if test "x$HAVE_FRAMEWORKS" = "xyes" ; then
HAVE_GLUT=yes
- GLUT_LIBS="-lm -lpthread"
+ GLUT_LIBS="-lm"
GLUT_FRAMEWORKS="-framework GLUT -framework OpenGL"
AC_SUBST(GLUT_LIBS)
AC_SUBST(GLUT_FRAMEWORKS)
@@ -248,6 +248,9 @@
fi
AM_CONDITIONAL(HAVE_GLUT, [test "x$HAVE_GLUT" = "xyes"])
+SEMAPHORE_LIBS="-lpthread"
+AC_SUBST(SEMAPHORE_LIBS)
+
dnl Use -Wall if we have gcc.
dnl changequote(,)dnl
if test "x$ac_cv_prog_gcc" = xyes ; then
Modified: liboggplay/trunk/include/oggplay/oggplay.h
===================================================================
--- liboggplay/trunk/include/oggplay/oggplay.h 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/include/oggplay/oggplay.h 2007-06-24 12:54:01 UTC (rev 3029)
@@ -117,12 +117,9 @@
oggplay_buffer_retrieve_next(OggPlay *player);
OggPlayErrorCode
-oggplay_buffer_free_info(OggPlayCallbackInfo **track_info);
+oggplay_buffer_release(OggPlay *player, OggPlayCallbackInfo **track_info);
OggPlayErrorCode
-oggplay_buffer_release_next(OggPlay *player);
-
-OggPlayErrorCode
oggplay_close(OggPlay *player);
#ifdef __cplusplus
Modified: liboggplay/trunk/plugin/plugin.cpp
===================================================================
--- liboggplay/trunk/plugin/plugin.cpp 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/plugin/plugin.cpp 2007-06-24 12:54:01 UTC (rev 3029)
@@ -682,6 +682,7 @@
SEM_SIGNAL(mEndPlaySem);
}
+#if defined (XP_MACOSX) || defined(XP_WIN)
void
nsPluginInstance::executeCmmlCallback() {
// (since this function is called very frequently, we don't want to grab
@@ -699,6 +700,7 @@
SEM_SIGNAL(mCmmlSem);
}
}
+#endif
#if defined(XP_WIN)
VOID CALLBACK
Modified: liboggplay/trunk/plugin/plugin_oggplay.c
===================================================================
--- liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-24 12:54:01 UTC (rev 3029)
@@ -320,6 +320,7 @@
frame_data->frame = NULL;
frame_data->samples = NULL;
frame_data->cmml_strings = NULL;
+ frame_data->oggplay_info = NULL;
/*
* player not yet ready
@@ -332,6 +333,8 @@
return;
}
+ frame_data->oggplay_info = (void *)track_info;
+
/* testing red field
{
int i;
@@ -397,7 +400,6 @@
}
}
- oggplay_buffer_free_info(track_info);
return;
}
@@ -464,7 +466,8 @@
}
frame_data->size = 0;
- oggplay_buffer_release_next(player);
+ oggplay_buffer_release(player,
+ (OggPlayCallbackInfo **)(frame_data->oggplay_info));
SEM_SIGNAL(pointers->sem);
Modified: liboggplay/trunk/plugin/plugin_oggplay.h
===================================================================
--- liboggplay/trunk/plugin/plugin_oggplay.h 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/plugin/plugin_oggplay.h 2007-06-24 12:54:01 UTC (rev 3029)
@@ -58,6 +58,7 @@
// cmml data related
char ** cmml_strings;
int cmml_size;
+ void * oggplay_info;
} PluginOggFrame;
void *
Modified: liboggplay/trunk/src/liboggplay/Version_script.in
===================================================================
--- liboggplay/trunk/src/liboggplay/Version_script.in 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/liboggplay/Version_script.in 2007-06-24 12:54:01 UTC (rev 3029)
@@ -46,8 +46,7 @@
oggplay_callback_info_get_stream_info;
oggplay_buffer_retrieve_next;
- oggplay_buffer_free_info;
- oggplay_buffer_release_next;
+ oggplay_buffer_release;
oggplay_use_buffer;
oggplay_callback_info_lock_item;
Modified: liboggplay/trunk/src/liboggplay/oggplay_buffer.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_buffer.c 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/liboggplay/oggplay_buffer.c 2007-06-24 12:54:01 UTC (rev 3029)
@@ -69,15 +69,19 @@
buffer->last_filled = -1;
buffer->last_emptied = -1;
+ SEM_CREATE(buffer->frame_sem, size);
+
return buffer;
}
void
-oggplay_buffer_shutdown(OggPlay *me, OggPlayBuffer *buffer) {
+oggplay_buffer_shutdown(OggPlay *me, volatile OggPlayBuffer *vbuffer) {
int i;
int j;
+
+ OggPlayBuffer *buffer = (OggPlayBuffer *)vbuffer;
for (i = 0; i < buffer->buffer_size; i++) {
if (buffer->buffer_mirror[i] != NULL) {
@@ -91,11 +95,12 @@
free(buffer->buffer_list);
free(buffer->buffer_mirror);
+ SEM_CLOSE(buffer->frame_sem);
free(buffer);
}
int
-oggplay_buffer_is_full(OggPlayBuffer *buffer) {
+oggplay_buffer_is_full(volatile OggPlayBuffer *buffer) {
return
(
@@ -120,10 +125,14 @@
OggPlayCallbackInfo * ptr = track_info[0];
int required;
- if (me->buffer == NULL) {
+ buffer = (OggPlayBuffer *)me->buffer;
+
+ if (buffer == NULL) {
return -1;
}
-
+
+ SEM_WAIT(buffer->frame_sem);
+
/*
* lock the item going into the buffer so that it doesn't get cleaned up
*/
@@ -135,8 +144,6 @@
}
}
- buffer = me->buffer;
-
/*
* check for and clean up empties
*/
@@ -174,6 +181,11 @@
*/
buffer->last_filled = WRAP_INC(buffer->last_filled, buffer->buffer_size);
+
+ /*
+ * set the buffer pointer in the first record
+ */
+ ptr->buffer = buffer;
buffer->buffer_mirror[buffer->last_filled] = ptr;
buffer->buffer_list[buffer->last_filled] = ptr;
@@ -203,7 +215,7 @@
return NULL;
}
- buffer = me->buffer;
+ buffer = (OggPlayBuffer *)me->buffer;
if (buffer == NULL) {
return NULL;
@@ -212,7 +224,6 @@
next_loc = WRAP_INC(buffer->last_emptied, buffer->buffer_size);
if (buffer->buffer_list[next_loc] == NULL) {
-
return NULL;
}
@@ -230,27 +241,15 @@
}
OggPlayErrorCode
-oggplay_buffer_free_info(OggPlayCallbackInfo **track_info) {
+oggplay_buffer_release(OggPlay *me, OggPlayCallbackInfo **track_info) {
- if (track_info == NULL) {
- return E_OGGPLAY_BAD_CALLBACK_INFO;
- }
-
- free(track_info);
-
- return E_OGGPLAY_OK;
-}
-
-OggPlayErrorCode
-oggplay_buffer_release_next(OggPlay *me) {
-
OggPlayBuffer *buffer;
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
- buffer = me->buffer;
+ buffer = (OggPlayBuffer *)track_info[0]->buffer;
if (buffer == NULL) {
return E_OGGPLAY_CALLBACK_MODE;
@@ -260,7 +259,11 @@
return E_OGGPLAY_UNINITIALISED;
}
+ free(track_info);
+
buffer->buffer_list[buffer->last_emptied] = NULL;
+
+ SEM_SIGNAL(buffer->frame_sem);
return E_OGGPLAY_OK;
@@ -301,8 +304,6 @@
int i;
- printf("preparing buffer\n");
-
oggplay_set_data_callback_force(me, &oggplay_buffer_callback, NULL);
for (i = 0; i < me->num_tracks; i++) {
Modified: liboggplay/trunk/src/liboggplay/oggplay_buffer.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_buffer.h 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/liboggplay/oggplay_buffer.h 2007-06-24 12:54:01 UTC (rev 3029)
@@ -43,10 +43,10 @@
oggplay_buffer_new_buffer(int size);
int
-oggplay_buffer_is_full(OggPlayBuffer *buffer);
+oggplay_buffer_is_full(volatile OggPlayBuffer *buffer);
void
-oggplay_buffer_shutdown(OggPlay *me, OggPlayBuffer *buffer);
+oggplay_buffer_shutdown(OggPlay *me, volatile OggPlayBuffer *buffer);
void
oggplay_buffer_prepare(OggPlay *me);
Modified: liboggplay/trunk/src/liboggplay/oggplay_callback.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_callback.c 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/liboggplay/oggplay_callback.c 2007-06-24 12:54:01 UTC (rev 3029)
@@ -389,6 +389,7 @@
ogg_int64_t denom;
OggPlayDecode * decoder = malloc (callbacks[content_type].size);
+ printf("decoder now %p\n", decoder);
decoder->serialno = serialno;
decoder->content_type = content_type;
@@ -488,7 +489,6 @@
* set up all the other callbacks
*/
for (i = 0; i < me->num_tracks; i++) {
-
serialno = me->decode_data[i]->serialno;
content_type = oggz_stream_get_content (me->oggz, serialno);
oggz_set_read_callback(me->oggz, serialno,
Modified: liboggplay/trunk/src/liboggplay/oggplay_callback_info.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_callback_info.c 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/liboggplay/oggplay_callback_info.c 2007-06-24 12:54:01 UTC (rev 3029)
@@ -143,8 +143,8 @@
}
- printf("%d: %d/%d\t", i,
- track_info->required_records, count);
+ //printf("%d: %d/%d\t", i,
+ // track_info->required_records, count);
/*
if (q != NULL) {
printf("fst: %lld lst: %lld sz: %lld pt: %lld\n",
@@ -165,7 +165,7 @@
}
- printf("\n");
+ //printf("\n");
/*
* there are no required records! This means that we need to advance the
@@ -211,13 +211,11 @@
* indicate that we need to go through another round of fragment collection
* and callback creation
*/
- printf("\tnull return\n");
(*info) = NULL;
}
if (tcount == 0) {
- printf("\tnull return\n");
(*info) = NULL;
}
Modified: liboggplay/trunk/src/liboggplay/oggplay_file_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_file_reader.c 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/liboggplay/oggplay_file_reader.c 2007-06-24 12:54:01 UTC (rev 3029)
@@ -82,13 +82,7 @@
ogg_int64_t milliseconds) {
ogg_int64_t new_pos;
- printf("old time: %lld\n", oggz_tell_units(oggz));
- printf("old_pos: %d\n", ((OggPlayFileReader *)handle)->current_position);
- printf("seeking to %lld\n", milliseconds);
new_pos = oggz_seek_units(oggz, milliseconds, SEEK_SET);
- printf("new time: %lld\n", new_pos);
- printf("tell sez: %lld\n", oggz_tell_units(oggz));
- printf("new pos: %d\n", ((OggPlayFileReader *)handle)->current_position);
if (new_pos == -1)
return E_OGGPLAY_CANT_SEEK;
Modified: liboggplay/trunk/src/liboggplay/oggplay_private.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_private.h 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/liboggplay/oggplay_private.h 2007-06-24 12:54:01 UTC (rev 3029)
@@ -45,6 +45,8 @@
#include <theora/theora.h>
#include <fishsound/fishsound.h>
+#include "std_semaphore.h"
+
/**
*
* has_been_presented: 0 until the data has been added as a "required" element,
@@ -75,12 +77,22 @@
struct _OggPlay;
+typedef struct {
+ void ** buffer_list;
+ void ** buffer_mirror;
+ int buffer_size;
+ int last_filled;
+ int last_emptied;
+ semaphore frame_sem;
+} OggPlayBuffer;
+
struct _OggPlayCallbackInfo {
OggPlayDataType data_type;
int available_records;
int required_records;
OggPlayStreamInfo stream_info;
- OggPlayDataHeader ** records;
+ OggPlayDataHeader ** records;
+ OggPlayBuffer * buffer;
};
/**
@@ -156,32 +168,25 @@
} OggPlaySkeletonDecode;
typedef struct {
- void ** buffer_list;
- void ** buffer_mirror;
- int buffer_size;
- int last_filled;
- int last_emptied;
-} OggPlayBuffer;
-
-typedef struct {
OggPlayDataHeader * old_data;
OggPlayBuffer * old_buffer;
} OggPlaySeekTrash;
struct _OggPlay {
- OggPlayReader * reader;
- OGGZ * oggz;
- OggPlayDecode ** decode_data;
- OggPlayCallbackInfo * callback_info;
- int num_tracks;
- int all_tracks_initialised;
- ogg_int64_t callback_period;
- OggPlayDataCallback * callback;
- void * callback_user_ptr;
- ogg_int64_t target;
- int active_tracks;
- OggPlayBuffer * buffer;
- ogg_int64_t presentation_time;
+ OggPlayReader * reader;
+ OGGZ * oggz;
+ OggPlayDecode ** decode_data;
+ OggPlayCallbackInfo * callback_info;
+ int num_tracks;
+ int all_tracks_initialised;
+ ogg_int64_t callback_period;
+ OggPlayDataCallback * callback;
+ void * callback_user_ptr;
+ ogg_int64_t target;
+ int active_tracks;
+ volatile OggPlayBuffer * buffer;
+ ogg_int64_t presentation_time;
+ OggPlaySeekTrash * trash;
};
void
@@ -192,6 +197,45 @@
#include "oggplay_data.h"
#include "oggplay_buffer.h"
+#if 0
+static inline void _free(void *x) {
+ printf("%p\n", x);
+ free(x);
+}
+
+static inline void *_malloc(int s) {
+ void *x;
+ printf("%d ", s);
+ x = malloc(s);
+ printf("%p\n", x);
+ return x;
+}
+
+static inline void *_realloc(void *x, int s) {
+ void *y;
+ printf("%p %d ", x, s);
+ y = realloc(x, s);
+ printf("%p\n", y);
+ return y;
+}
+
+static inline void *_calloc(int n, int s) {
+ void *x;
+ printf("%d %d ", n, s);
+ x = calloc(n, s);
+ printf("%p\n", x);
+ return x;
+}
+
+#define free(x) {printf("FREE %s %d ", __FILE__, __LINE__); _free(x);}
+#define malloc(s) (printf("MALLOC %s %d ", __FILE__, __LINE__), \
+ _malloc(s))
+#define realloc(x, s) (printf("REALLOC %s %d ", __FILE__, __LINE__), \
+ _realloc(x, s))
+#define calloc(n, s) (printf("CALLOC %s %d ", __FILE__, __LINE__), \
+ _calloc(n, s))
+#endif
+
#ifdef _WIN32
#include "config_win32.h"
#ifdef HAVE_WINSOCK2
Modified: liboggplay/trunk/src/liboggplay/oggplay_seek.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_seek.c 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/liboggplay/oggplay_seek.c 2007-06-24 12:54:01 UTC (rev 3029)
@@ -70,14 +70,13 @@
/*
* store the old buffer in it next.
*/
- trash->old_buffer = me->buffer;
+ trash->old_buffer = (OggPlayBuffer *)me->buffer;
/*
* replace the buffer with a new one. From here on, the presentation thread
* will start using this buffer instead.
*/
me->buffer = oggplay_buffer_new_buffer(me->buffer->buffer_size);
- printf("installed buffer %p\n", me->buffer);
/*
* strip all of the data packets out of the streams and put them into the
Modified: liboggplay/trunk/src/tests/Makefile.am
===================================================================
--- liboggplay/trunk/src/tests/Makefile.am 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/tests/Makefile.am 2007-06-24 12:54:01 UTC (rev 3029)
@@ -7,7 +7,7 @@
OGGPLAYDIR = ../liboggplay
OGGPLAY_LIBS = $(OGGPLAYDIR)/liboggplay.la @OGGZ_LIBS@ @THEORA_LIBS@ \
- @FISHSOUND_LIBS@
+ @FISHSOUND_LIBS@ @SEMAPHORE_LIBS@
# Test programs
Modified: liboggplay/trunk/src/tools/Makefile.am
===================================================================
--- liboggplay/trunk/src/tools/Makefile.am 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/tools/Makefile.am 2007-06-24 12:54:01 UTC (rev 3029)
@@ -15,7 +15,7 @@
OGGPLAYDIR = ../liboggplay
OGGPLAY_LIBS = $(OGGPLAYDIR)/liboggplay.la @OGGZ_LIBS@ @THEORA_LIBS@ \
- @FISHSOUND_LIBS@
+ @FISHSOUND_LIBS@ @SEMAPHORE_LIBS@
if HAVE_GLUT
glut_tools = glut-player
@@ -31,17 +31,17 @@
noinst_PROGRAMS = get-stream-info $(glut_tools) $(sndfile_tools)
oggplay_info_SOURCES = oggplay-info.c
-oggplay_info_LDADD = $(OGGPLAY_LIBS)
+oggplay_info_LDADD = $(OGGPLAY_LIBS)
get_stream_info_SOURCES = get-stream-info.c
-get_stream_info_LDADD = $(OGGPLAY_LIBS)
+get_stream_info_LDADD = $(OGGPLAY_LIBS)
dump_all_streams_SOURCES = dump-all-streams.c
dump_all_streams_CFLAGS = @SNDFILE_CFLAGS@
-dump_all_streams_LDADD = $(OGGPLAY_LIBS) @SNDFILE_LIBS@
+dump_all_streams_LDADD = $(OGGPLAY_LIBS) @SNDFILE_LIBS@
glut_player_SOURCES = glut-player.c
-glut_player_LDADD = $(OGGPLAY_LIBS) @GLUT_LIBS@
+glut_player_LDADD = $(OGGPLAY_LIBS) @GLUT_LIBS@
if MACOS
# Automake 1.6 doesn't recoginze -framework arguments as libraries
# so we must pass them through LDFLAGS
Modified: liboggplay/trunk/src/tools/glut-player.c
===================================================================
--- liboggplay/trunk/src/tools/glut-player.c 2007-06-24 10:29:05 UTC (rev 3028)
+++ liboggplay/trunk/src/tools/glut-player.c 2007-06-24 12:54:01 UTC (rev 3029)
@@ -57,7 +57,6 @@
static OggPlay * player = NULL;
-static sem_t sem;
static sem_t stop_sem;
@@ -311,10 +310,7 @@
glutPostRedisplay();
//show_window();
#endif
- oggplay_buffer_free_info(track_info);
- oggplay_buffer_release_next (player);
-
- sem_post(&sem);
+ oggplay_buffer_release (player, track_info);
//}
}
@@ -383,19 +379,15 @@
while (1) {
OggPlayErrorCode r;
- sem_wait(&sem);
-
if (sem_trywait(&msg_sem) == 0) {
if (msg == SEEK_FORWARD) {
if (oggplay_seek(player, ld_time + 5000) == E_OGGPLAY_CANT_SEEK) {
printf("can't seek forwards!\n");
}
- sem_init(&sem, 1, buf_size);
} else if (msg == SEEK_BACKWARD) {
if (oggplay_seek(player, ld_time - 5000) == E_OGGPLAY_CANT_SEEK) {
printf("cant seek backwards!\n");
}
- sem_init(&sem, 1, buf_size);
}
msg = 0;
}
@@ -491,8 +483,7 @@
#endif
oggplay_use_buffer(player, 20);
- sem_init(&sem, 1, buf_size);
- // create a semaphore used for proper player cleanup
+
sem_init(&stop_sem, 1, 1);
sem_wait(&stop_sem);
@@ -521,9 +512,19 @@
glutMainLoop();
#else
+ while (1) {
for (i = 0; i < 100; i++) {
display_frame();
}
+ key_pressed('l', 0, 0);
+ for (i = 0; i < 10; i++) {
+ display_frame();
+ }
+ key_pressed('k', 0, 0);
+ }
+ for (i = 0; i < 100; i++) {
+ display_frame();
+ }
key_pressed('q', 0, 0);
#endif
More information about the commits
mailing list