[xiph-cvs] cvs commit: ogg-tools/oggplay oggplay.c
Ralph Giles
giles at xiph.org
Sun Jun 22 14:43:03 PDT 2003
giles 03/06/22 17:43:03
Modified: oggplay oggplay.c
Log:
Fixes for OggMNG playback. Actually works when we manage not to trip over our own
dangling pointers.
Revision Changes Path
1.3 +19 -12 ogg-tools/oggplay/oggplay.c
Index: oggplay.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggplay/oggplay.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- oggplay.c 3 Sep 2001 19:11:33 -0000 1.2
+++ oggplay.c 22 Jun 2003 21:43:03 -0000 1.3
@@ -3,9 +3,9 @@
a testbed player for ogg multimedia
- $Date: 2001/09/03 19:11:33 $
+ $Date: 2003/06/22 21:43:03 $
- Ralph Giles <giles at thaumas.net>
+ Ralph Giles <giles at xiph.org>
This program my be redistributed under the terms of the
GNU General Public Licence, version 2, or at your preference,
@@ -138,10 +138,14 @@
fprintf(stderr, " submitting %d bytes to the mng decoder\n", copybytes);
/* copy it into the mng decode buffer */
- memcpy(buffer, stuff->op_last->packet, copybytes);
+ memcpy(buffer, stuff->op_last->packet + stuff->op_bytes, copybytes);
+ stuff->op_bytes += copybytes;
*bytesread += copybytes;
- stuff->op_last = NULL;
+ if (stuff->op_bytes == stuff->op_last->bytes) {
+ stuff->op_last = NULL;
+ stuff->op_bytes = 0;
+ }
/* are we done? */
if (*bytesread >= byteswanted)
@@ -151,10 +155,11 @@
/* we still need more data, so look for more packets in the saved page */
if (stuff->og_last) {
while (ogg_stream_packetout(stuff->os, op) > 0) {
- fprintf(stderr, " got packet %ld\n", op->packetno);
+ fprintf(stderr, " got packet %ld", op->packetno);
+ fprintf(stderr, " (%d bytes)\n", op->bytes);
/* copy it into the mng decode buffer */
- copybytes = MIN(byteswanted - *bytesread, stuff->op_last->bytes - stuff->op_bytes);
+ copybytes = MIN(byteswanted - *bytesread, op->bytes);
fprintf(stderr, " submitting %d bytes to the mng decoder\n", copybytes);
memcpy(buffer + (*bytesread), op->packet, copybytes);
*bytesread += copybytes;
@@ -198,7 +203,7 @@
fprintf(stderr, "looking for ogg pages...\n");
/* process any pages we found */
- while (rc = ogg_sync_pageout(stuff->oy, og) > 0) {
+ while ((rc = ogg_sync_pageout(stuff->oy, og)) > 0) {
fprintf(stderr, " got page %x:%ld\n",
ogg_page_serialno(og), ogg_page_pageno(og));
/* have we seen this (or any) substream before? */
@@ -218,7 +223,8 @@
/* packetize it */
ogg_stream_pagein(stuff->os, og);
while (ogg_stream_packetout(stuff->os, op) > 0) {
- fprintf(stderr, " got packet %ld\n", op->packetno);
+ fprintf(stderr, " got packet %ld", op->packetno);
+ fprintf(stderr, " (%d bytes)\n", op->bytes);
/* check for overflow -- should never happen */
if (*bytesread >= byteswanted) {
fprintf(stderr, "error: packet data bigger than we thought!\n");
@@ -269,7 +275,7 @@
SDL_Surface *screen;
char title[256];
-// fprintf(stderr, "our mng is %dx%d\n", width,height);
+ fprintf(stderr, "our mng is %dx%d\n", width,height);
screen = SDL_SetVideoMode(width,height, 32, SDL_SWSURFACE);
if (screen == NULL) {
@@ -286,7 +292,7 @@
snprintf(title, 256, "mngplay: %s", stuff->filename);
SDL_WM_SetCaption(title, "mngplay");
- /* in necessary, lock the drawing surface to the decoder
+ /* if necessary, lock the drawing surface to the decoder
can safely fill it. We'll unlock elsewhere before display */
if (SDL_MUSTLOCK(stuff->surface)) {
if ( SDL_LockSurface(stuff->surface) < 0 ) {
@@ -327,7 +333,7 @@
mng_uint32 ticks;
ticks = (mng_uint32)SDL_GetTicks();
-// fprintf(stderr, " %d\t(returning tick count)\n",ticks);
+ //fprintf(stderr, " %d\t(returning tick count)\n",ticks);
return(ticks);
}
@@ -346,6 +352,8 @@
/* dereference our structure */
stuff = (stuff_t*)mng_get_userdata(mng);
+ //fprintf(stderr, "refreshing display\n");
+
/* if necessary, unlock the display */
if (SDL_MUSTLOCK(stuff->surface)) {
SDL_UnlockSurface(stuff->surface);
@@ -362,7 +370,6 @@
}
}
-
return MNG_TRUE;
}
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list