Author: fejj
Date: 2008-01-25 18:37:52 -0500 (Fri, 25 Jan 2008)
New Revision: 93965

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/media.cpp
   trunk/moon/src/pipeline.cpp
Log:
2008-01-25  Jeffrey Stedfast  <[EMAIL PROTECTED]>

        * pipeline.cpp (WaitForPosition): Only update wait_pos if it is
        greater than the current wait_pos.

        * media.cpp (UpdateProgress): Use the buffering_start position
        rather than the current write position to calculate buffer_size.



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2008-01-25 22:34:09 UTC (rev 93964)
+++ trunk/moon/src/ChangeLog    2008-01-25 23:37:52 UTC (rev 93965)
@@ -1,5 +1,13 @@
 2008-01-25  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
+       * pipeline.cpp (WaitForPosition): Only update wait_pos if it is
+       greater than the current wait_pos.
+
+       * media.cpp (UpdateProgress): Use the buffering_start position
+       rather than the current write position to calculate buffer_size.
+
+2008-01-25  Jeffrey Stedfast  <[EMAIL PROTECTED]>
+
        * media.cpp (TryOpen): When download is complete and we
        successfully open the media, don't set the state to Paused - this
        breaks Halo3 if the video is cached.

Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp    2008-01-25 22:34:09 UTC (rev 93964)
+++ trunk/moon/src/media.cpp    2008-01-25 23:37:52 UTC (rev 93965)
@@ -686,12 +686,14 @@
                int64_t size = downloaded_file->GetTotalSize ();
                int64_t buffer_size = BUFFERING_SIZE;
                
-               if (wait_pos > pos + buffer_size) {
+               if ((buffering_start + buffer_size) < wait_pos) {
                        // 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;
+                       buffer_size = wait_pos - buffering_start;
+               } else if (size != -1 && (buffering_start + buffer_size) < 
size) {
+                       // there's less than BUFFERING_SIZE data left to buffer
+                       buffer_size = size - buffering_start;
+               }
                
                current = GetValue 
(MediaElement::BufferingProgressProperty)->AsDouble ();
                if ((progress = ((double) (pos - buffering_start)) / 
buffer_size) > 1.0)
@@ -1108,14 +1110,14 @@
                mplayer->Seek (position * 1000 / TIMESPANTICKS_IN_SECOND);
                Invalidate ();
                
+               if (IsStopped ())
+                       SetState (Paused);
+               
                if (position != value->AsTimeSpan ()) {
                        v = Value (position, Type::TIMESPAN);
                        MediaBase::SetValue (prop, &v);
                        return;
                }
-               
-               if (IsStopped ())
-                       SetState (Paused);
        }
        
        MediaBase::SetValue (prop, value);

Modified: trunk/moon/src/pipeline.cpp
===================================================================
--- trunk/moon/src/pipeline.cpp 2008-01-25 22:34:09 UTC (rev 93964)
+++ trunk/moon/src/pipeline.cpp 2008-01-25 23:37:52 UTC (rev 93965)
@@ -52,15 +52,22 @@
 DecoderInfo *Media::registered_decoders = NULL;
 ConverterInfo *Media::registered_converters = NULL;
  
-Media::Media () :
-               queued_requests (NULL), queue_closure (NULL), 
-               file_or_url (NULL), source (NULL), 
-               demuxer (NULL), markers (NULL),
-               start_time (0), opened (false)
+Media::Media ()
 {
        pthread_attr_t attribs;
+       
        queued_requests = new List ();
+       queue_closure = NULL;
        
+       file_or_url = NULL;
+       source = NULL;
+       
+       demuxer = NULL;
+       markers = NULL;
+       
+       start_time = 0;
+       opened = false;
+       
        pthread_attr_init (&attribs);
        pthread_attr_setdetachstate (&attribs, PTHREAD_CREATE_JOINABLE);
        
@@ -224,7 +231,7 @@
 {
        if (demuxer)
                return demuxer->Seek (pts);
-
+       
        return MEDIA_FAIL;
 }
 
@@ -503,7 +510,7 @@
                MediaWork *node = NULL;
                
                LOG_FRAMEREADERLOOP ("Media::WorkerLoop (): entering mutex.\n", 
0);
-
+               
                // Wait until we have something in the queue
                pthread_mutex_lock (&queue_mutex);
                while (queued_requests != NULL && queued_requests->IsEmpty ())
@@ -513,16 +520,17 @@
                
                if (queued_requests != NULL) {
                        // Find the first audio node
-                       node = (MediaWork*) queued_requests->First ();
-
+                       node = (MediaWork *) queued_requests->First ();
+                       
                        if (node != NULL)
                                queued_requests->Unlink (node);
                        
-                       LOG_FRAMEREADERLOOP ("Media::WorkerLoop (): got a %s 
node, there are %i nodes left.\n",
+                       LOG_FRAMEREADERLOOP ("Media::WorkerLoop (): got a %s 
node, there are %d nodes left.\n",
                                             node->stream->GetType () == 
MediaTypeAudio ? "audio" :
                                             (node->stream->GetType () == 
MediaTypeVideo ? "video" : "unknown"),
                                             queued_requests->Length ());
                }
+               
                pthread_mutex_unlock (&queue_mutex);
                
                if (node == NULL)
@@ -532,7 +540,7 @@
                
                switch (node->type) {
                case WorkTypeSeek:
-                       //printf ("Media::WorkerLoop (): Seeking, current 
count: %i\n", queued_requests->Length ());
+                       //printf ("Media::WorkerLoop (): Seeking, current 
count: %d\n", queued_requests->Length ());
                        Seek (node->data.seek_pts);
                        break;
                case WorkTypeAudio:
@@ -549,8 +557,10 @@
                        }
                        break;
                }
+               
                delete node;
        }
+       
        LOG_FRAMEREADERLOOP ("Media::WorkerLoop (): exiting.\n", 0);
 }
 
@@ -621,7 +631,7 @@
                case WorkTypeVideo:
                case WorkTypeMarker:
                        // Insert the work just before work with less priority.
-                       current = (MediaWork*) queued_requests->First ();
+                       current = (MediaWork *) queued_requests->First ();
                        while (current != NULL && work->type >= current->type)
                                current = (MediaWork *) current->next;
                        
@@ -684,7 +694,6 @@
        if (reader == NULL)
                reader = new ASFFrameReader (parser);
        
-       
        // If there's any audio stream, we need to seek to that stream
        // 
        int stream_id = 0;
@@ -2146,7 +2155,10 @@
        g_atomic_int_inc (&wait_count);
        
        Lock ();
-       wait_pos = position;
+       
+       if (position > wait_pos)
+               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

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

Reply via email to