gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/rtmp r9821: add constructor to builds from


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9821: add constructor to builds from Buffer.
Date: Mon, 01 Dec 2008 08:43:33 -0700
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9821
committer: address@hidden
branch nick: rtmp
timestamp: Mon 2008-12-01 08:43:33 -0700
message:
  add constructor to builds from Buffer.
modified:
  libnet/diskstream.cpp
  libnet/diskstream.h
=== modified file 'libnet/diskstream.cpp'
--- a/libnet/diskstream.cpp     2008-11-30 22:20:09 +0000
+++ b/libnet/diskstream.cpp     2008-12-01 15:43:33 +0000
@@ -114,6 +114,39 @@
 #endif
 }
 
+DiskStream::DiskStream(const string &str, boost::uint8_t *data, size_t size)
+    : _state(DiskStream::NO_STATE),
+      _filefd(0),
+      _netfd(0),
+      _dataptr(0),
+      _max_memload(0),
+      _pagesize(0),
+      _offset(0)
+{
+//    GNASH_REPORT_FUNCTION;
+    
+    /// \brief get the pagesize and cache the value
+#ifdef HAVE_SYSCONF
+    _pagesize = sysconf(_SC_PAGESIZE);
+    _max_memload = _pagesize * MAX_PAGES;    
+#else
+#error "Need to define the memory page size without sysconf()!"
+#endif
+
+    _dataptr = new boost::uint8_t[size];
+    // Note that this is a copy operation, which may effect performance. We do 
this for now
+    // incase the top level pointer gets deleted. This should really be using
+    // boost::scoped_array, but we don't want that complexity till this code 
stabalizes.
+    std::copy(data, data + size, _dataptr);
+    _filespec = str;
+    _filesize = size;
+    
+#ifdef USE_STATS_CACHE
+    clock_gettime (CLOCK_REALTIME, &_last_access);
+    _accesses = 1;
+#endif    
+}
+
 DiskStream::DiskStream(const string &str, amf::Buffer &buf)
     : _state(DiskStream::NO_STATE),
       _filefd(0),
@@ -341,7 +374,7 @@
 DiskStream::writeToDisk(const std::string &filespec, amf::Buffer &data)
 {
 //    GNASH_REPORT_FUNCTION;
-    return writeToDisk(filespec, data.reference(), data.size());
+    return writeToDisk(filespec, data.reference(), data.allocated());
 }
 
 bool
@@ -351,10 +384,10 @@
 
     int fd = ::open(filespec.c_str() ,O_WRONLY|O_CREAT, S_IRWXU);
     if (fd < 0) {
-        perror("open");
+        log_error(strerror(errno));
     }
-    cout << "Writing packet to disk: \"outbuf.raw\"" << endl;
-    write(fd, data, size);
+    log_debug("Writing data (%d bytes) to disk: \"%s\"", size, filespec);
+    ::write(fd, data, size);
     ::close(fd);
 
     return true;

=== modified file 'libnet/diskstream.h'
--- a/libnet/diskstream.h       2008-11-30 22:17:45 +0000
+++ b/libnet/diskstream.h       2008-12-01 15:43:33 +0000
@@ -85,6 +85,7 @@
     DiskStream();
     DiskStream(const std::string &filespec);
     DiskStream(const std::string &filespec, amf::Buffer &buf);
+    DiskStream(const std::string &filespec, boost::uint8_t *data, size_t size);
     DiskStream(const std::string &filespec, int netfd);
     ~DiskStream();
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]