[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/noseek_fd_adapter.cpp
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/noseek_fd_adapter.cpp |
Date: |
Tue, 03 Oct 2006 13:33:22 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/10/03 13:33:22
Modified files:
. : ChangeLog
libbase : noseek_fd_adapter.cpp
Log message:
* libbase/noseek_fd_adapter.cpp: fixed named-cache operation (cache
file was not opened for read)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1010&r2=1.1011
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/noseek_fd_adapter.cpp?cvsroot=gnash&r1=1.5&r2=1.6
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1010
retrieving revision 1.1011
diff -u -b -r1.1010 -r1.1011
--- ChangeLog 3 Oct 2006 12:14:17 -0000 1.1010
+++ ChangeLog 3 Oct 2006 13:33:22 -0000 1.1011
@@ -1,3 +1,8 @@
+2006-10-03 Sandro Santilli <address@hidden>
+
+ * libbase/noseek_fd_adapter.cpp: fixed named-cache operation
+ (cache file was not opened for read)
+
2006-10-03 Patrice Dumas <address@hidden>
* macros/ffmpeg.m4: Fixed failure.
Index: libbase/noseek_fd_adapter.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/noseek_fd_adapter.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libbase/noseek_fd_adapter.cpp 3 Oct 2006 11:08:41 -0000 1.5
+++ libbase/noseek_fd_adapter.cpp 3 Oct 2006 13:33:22 -0000 1.6
@@ -34,7 +34,7 @@
// forward this exception.
//
-/* $Id: noseek_fd_adapter.cpp,v 1.5 2006/10/03 11:08:41 strk Exp $ */
+/* $Id: noseek_fd_adapter.cpp,v 1.6 2006/10/03 13:33:22 strk Exp $ */
#if defined(_WIN32) || defined(WIN32)
#define snprintf _snprintf
@@ -81,6 +81,9 @@
*
* NoSeekFile definition
*
+ * TODO: optimize this class, it makes too many unneeded allocs/deallocs
+ * and calls fstat far too often.
+ *
**********************************************************************/
class NoSeekFile
@@ -160,13 +163,28 @@
size_t
NoSeekFile::cache(void *from, size_t sz)
{
+
+#ifdef GNASH_NOSEEK_FD_VERBOSE
+ fprintf(stderr, "cache(%p, " SIZET_FMT ") called\n", from, sz);
+#endif
// take note of current position
long curr_pos = ftell(_cache);
+#ifdef GNASH_NOSEEK_FD_VERBOSE
+ fprintf(stderr, " current position: %ld\n", curr_pos);
+#endif
+
// seek to the end
fseek(_cache, 0, SEEK_END);
+#ifdef GNASH_NOSEEK_FD_VERBOSE
+ fprintf(stderr, " after SEEK_END, position: %ld\n", ftell(_cache));
+#endif
+
size_t wrote = fwrite(from, 1, sz, _cache);
+#ifdef GNASH_NOSEEK_FD_VERBOSE
+ fprintf(stderr, " write " SIZET_FMT " bytes\n", wrote);
+#endif
if ( wrote < 1 )
{
char errmsg[256];
@@ -178,9 +196,19 @@
throw gnash::GnashException(errmsg);
}
+#ifdef GNASH_NOSEEK_FD_VERBOSE
+ fprintf(stderr, " after write, position: %ld\n", ftell(_cache));
+#endif
+
// reset position for next read
fseek(_cache, curr_pos, SEEK_SET);
+#ifdef GNASH_NOSEEK_FD_VERBOSE
+ fprintf(stderr, " after seek-back, position: %ld\n", ftell(_cache));
+#endif
+
+ clearerr(_cache);
+
return wrote;
}
@@ -209,6 +237,9 @@
// Let's see how many bytes are left to read
size_t bytes_needed = size-statbuf.st_size;
+#ifdef GNASH_NOSEEK_FD_VERBOSE
+ fprintf(stderr, " bytes needed = " SIZET_FMT "\n", bytes_needed);
+#endif
char* buf = new char[bytes_needed];
@@ -251,7 +282,7 @@
{
if ( _cachefilename )
{
- _cache = fopen(_cachefilename, "w");
+ _cache = fopen(_cachefilename, "w+b");
if ( ! _cache )
{
throw gnash::GnashException("Could not create cache
file " + std::string(_cachefilename));
@@ -289,19 +320,47 @@
size_t
NoSeekFile::read_cache(void *dst, size_t bytes)
{
- if ( eof() ) return 0;
-
#ifdef GNASH_NOSEEK_FD_VERBOSE
fprintf(stderr, "read_cache(%d) called\n", bytes);
#endif
+ if ( eof() )
+ {
+#ifdef GNASH_NOSEEK_FD_VERBOSE
+ fprintf(stderr, "read_cache: at eof!\n");
+#endif
+ return 0;
+ }
+
+
fill_cache(tell()+bytes);
#ifdef GNASH_NOSEEK_FD_VERBOSE
printInfo();
#endif
- return fread(dst, 1, bytes, _cache);
+ size_t ret = fread(dst, 1, bytes, _cache);
+
+ if ( ret == 0 )
+ {
+ if ( ferror(_cache) )
+ {
+ fprintf(stderr, "an error occurred while reading from cache\n");
+ }
+#if GNASH_NOSEEK_FD_VERBOSE
+ if ( feof(_cache) )
+ {
+ fprintf(stderr, "EOF reached while reading from cache\n");
+ }
+#endif
+ }
+
+#ifdef GNASH_NOSEEK_FD_VERBOSE
+ fprintf(stderr, "fread from _cache returned " SIZET_FMT "\n", ret);
+#endif
+
+ return ret;
+
}
- [Gnash-commit] gnash ChangeLog libbase/noseek_fd_adapter.cpp,
Sandro Santilli <=