[xiph-commits] r3066 - in liboggplay/trunk: include/oggplay plugin
src/liboggplay
shans at svn.annodex.net
shans at svn.annodex.net
Tue Jun 26 04:57:27 PDT 2007
Author: shans
Date: 2007-06-26 04:57:27 -0700 (Tue, 26 Jun 2007)
New Revision: 3066
Modified:
liboggplay/trunk/include/oggplay/oggplay.h
liboggplay/trunk/include/oggplay/oggplay_reader.h
liboggplay/trunk/plugin/plugin_oggplay.c
liboggplay/trunk/src/liboggplay/oggplay.c
liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h
Log:
Modified get_duration interface to be sane (return an integral number of
milliseconds)
Improved get_available algorithm (now maxes out at duration)
Detect remote socket closure
Modified: liboggplay/trunk/include/oggplay/oggplay.h
===================================================================
--- liboggplay/trunk/include/oggplay/oggplay.h 2007-06-26 11:38:36 UTC (rev 3065)
+++ liboggplay/trunk/include/oggplay/oggplay.h 2007-06-26 11:57:27 UTC (rev 3066)
@@ -125,6 +125,12 @@
OggPlayErrorCode
oggplay_close(OggPlay *player);
+int
+oggplay_get_available(OggPlay *player);
+
+int
+oggplay_get_duration(OggPlay * player);
+
#ifdef __cplusplus
}
#endif
Modified: liboggplay/trunk/include/oggplay/oggplay_reader.h
===================================================================
--- liboggplay/trunk/include/oggplay/oggplay_reader.h 2007-06-26 11:38:36 UTC (rev 3065)
+++ liboggplay/trunk/include/oggplay/oggplay_reader.h 2007-06-26 11:57:27 UTC (rev 3066)
@@ -54,7 +54,7 @@
int (*available)(struct _OggPlayReader *me,
ogg_int64_t current_bytes,
ogg_int64_t current_time);
- double (*duration)(struct _OggPlayReader *me);
+ int (*duration)(struct _OggPlayReader *me);
/* low-level io functions for oggz */
size_t (*io_read)(void *user_handle, void *buf, size_t n);
Modified: liboggplay/trunk/plugin/plugin_oggplay.c
===================================================================
--- liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-26 11:38:36 UTC (rev 3065)
+++ liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-26 11:57:27 UTC (rev 3066)
@@ -226,6 +226,10 @@
}
r = oggplay_step_decoding(pointers->player);
+
+ printf("available content: %d duration: %d\n",
+ oggplay_get_available(player), oggplay_get_duration(player));
+
}
if (r != E_OGGPLAY_CONTINUE && r != E_OGGPLAY_USER_INTERRUPT) {
Modified: liboggplay/trunk/src/liboggplay/oggplay.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay.c 2007-06-26 11:38:36 UTC (rev 3065)
+++ liboggplay/trunk/src/liboggplay/oggplay.c 2007-06-26 11:57:27 UTC (rev 3066)
@@ -561,7 +561,7 @@
}
-double
+int
oggplay_get_duration(OggPlay *me) {
if (me == NULL) {
Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-26 11:38:36 UTC (rev 3065)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-26 11:57:27 UTC (rev 3066)
@@ -367,7 +367,7 @@
dpos = strstr((char *)me->buffer, "X-Content-Duration:");
if (dpos != NULL) {
- me->duration = strtod(dpos + 20, NULL);
+ me->duration = (int)(strtod(dpos + 20, NULL) * 1000);
}
pos = strstr((char *)(me->buffer), "OggS");
@@ -479,6 +479,8 @@
int remaining;
int r;
+ if (me->socket == INVALID_SOCKET) return E_OGGPLAY_OK;
+
/*
* see if we can grab some more data
* if we're not blocking, make sure there's some available data
@@ -506,6 +508,11 @@
r = read(me->socket, me->buffer + me->amount_in_memory, remaining);
#endif
+ if (!block && r <= 0) {
+ close(me->socket);
+ me->socket = INVALID_SOCKET;
+ }
+
fwrite(me->buffer, 1, r, me->backing_store);
me->stored_offset += r;
@@ -523,12 +530,16 @@
me = (OggPlayTCPReader *)opr;
+ if (me->socket == INVALID_SOCKET) {
+ return me->duration;
+ }
+
grab_some_data(me, 0);
return (int)((tpb * me->stored_offset) >> 16);
}
-double
+int
oggplay_tcp_reader_duration(OggPlayReader * opr) {
OggPlayTCPReader *me = (OggPlayTCPReader *)opr;
return me->duration;
Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h 2007-06-26 11:38:36 UTC (rev 3065)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h 2007-06-26 11:57:27 UTC (rev 3066)
@@ -80,7 +80,7 @@
FILE * backing_store;
int stored_offset;
dataLocation mode;
- float duration;
+ int duration;
} OggPlayTCPReader;
#endif
More information about the commits
mailing list