Author: rolf
Date: 2008-01-25 14:14:30 -0500 (Fri, 25 Jan 2008)
New Revision: 93951

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/media.cpp
   trunk/moon/src/pipeline.cpp
   trunk/moon/src/pipeline.h
Log:
* pipeline.h, pipeline.cpp: ProgressiveSource: Make the position we're
  waiting for publicly available.
* media.cpp: UpdateProgress: use the position the file is waiting for
  to calculate the buffer size (if it would exceed the default buffer
  size).

Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2008-01-25 19:07:10 UTC (rev 93950)
+++ trunk/moon/src/ChangeLog    2008-01-25 19:14:30 UTC (rev 93951)
@@ -1,5 +1,12 @@
 2008-01-25  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
+       * pipeline.h, pipeline.cpp: ProgressiveSource: Make the position we're
+         waiting for publicly available.
+       * media.cpp: UpdateProgress: use the position the file is waiting for to
+         calculate the buffer size (if it would exceed the default buffer 
size).
+
+2008-01-25  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
+
        * media.h: Add some descriptive comments.
 
 2008-01-25  Sebastien Pouliot  <[EMAIL PROTECTED]>

Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp    2008-01-25 19:07:10 UTC (rev 93950)
+++ trunk/moon/src/media.cpp    2008-01-25 19:14:30 UTC (rev 93951)
@@ -675,11 +675,16 @@
        // CHECK: if buffering, will DownloadCompletedEvent be emitted?
        
        if (IsBuffering ()) {
+               int64_t wait_pos = downloaded_file->GetWaitPosition ();
                int64_t pos = downloaded_file->GetWritePosition ();
                int64_t size = downloaded_file->GetTotalSize ();
                int64_t buffer_size = BUFFERING_SIZE;
                
-               if (size != -1 && (size - pos) < BUFFERING_SIZE)
+               if (wait_pos > pos + buffer_size) {
+                       // If the position the stream is waiting for is beyond 
the default
+                       // buffer size, use that position to calculate the 
buffer size.
+                       buffer_size = wait_pos - pos;
+               } else if (size != -1 && (size - pos) < buffer_size)
                        buffer_size = size - pos;
                
                current = GetValue 
(MediaElement::BufferingProgressProperty)->AsDouble ();

Modified: trunk/moon/src/pipeline.cpp
===================================================================
--- trunk/moon/src/pipeline.cpp 2008-01-25 19:07:10 UTC (rev 93950)
+++ trunk/moon/src/pipeline.cpp 2008-01-25 19:14:30 UTC (rev 93951)
@@ -2146,6 +2146,7 @@
        g_atomic_int_inc (&wait_count);
        
        Lock ();
+       wait_pos = position;
        while (true) {
                if (cancel_wait) {
                        // FIXME: This doesn't work if there are more than one 
thread waiting at the same time
@@ -2287,6 +2288,16 @@
 }
 
 int64_t
+ProgressiveSource::GetWaitPosition ()
+{
+       int64_t result;
+       Lock ();
+       result = wait_pos;
+       Unlock ();
+       return result;
+}
+
+int64_t
 ProgressiveSource::GetWritePosition ()
 {
        int64_t result;

Modified: trunk/moon/src/pipeline.h
===================================================================
--- trunk/moon/src/pipeline.h   2008-01-25 19:07:10 UTC (rev 93950)
+++ trunk/moon/src/pipeline.h   2008-01-25 19:14:30 UTC (rev 93951)
@@ -562,6 +562,7 @@
        int wait_count; // Counter of how many threads are waiting in 
WaitForPosition
        
        int64_t write_pos;
+       int64_t wait_pos;
        int64_t size;
        
        static void write (void *buf, int32_t offset, int32_t n, gpointer 
cb_data);
@@ -591,6 +592,7 @@
        // Cancels any pending waits
        void CancelWait (); 
        int64_t GetWritePosition ();
+       int64_t GetWaitPosition ();
        void Lock ();
        void Unlock ();
        

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to