Author: fejj
Date: 2008-01-23 13:01:55 -0500 (Wed, 23 Jan 2008)
New Revision: 93680
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/media.cpp
trunk/moon/src/pipeline.cpp
Log:
2008-01-23 Jeffrey Stedfast <[EMAIL PROTECTED]>
* media.cpp (SetSource): Initialize the ProgressiveSource.
* pipeline.cpp (ProgressiveSource::Seek): Simplified by calling
parent class's implementation.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2008-01-23 17:59:08 UTC (rev 93679)
+++ trunk/moon/src/ChangeLog 2008-01-23 18:01:55 UTC (rev 93680)
@@ -1,5 +1,12 @@
2008-01-23 Jeffrey Stedfast <[EMAIL PROTECTED]>
+ * media.cpp (SetSource): Initialize the ProgressiveSource.
+
+ * pipeline.cpp (ProgressiveSource::Seek): Simplified by calling
+ parent class's implementation.
+
+2008-01-23 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
* pipeline.cpp|h: ProgressiveSource now inherits from FileSource.
2008-01-23 Jeffrey Stedfast <[EMAIL PROTECTED]>
Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp 2008-01-23 17:59:08 UTC (rev 93679)
+++ trunk/moon/src/media.cpp 2008-01-23 18:01:55 UTC (rev 93680)
@@ -946,14 +946,17 @@
TryOpen ();
} else {
downloaded_file = new ProgressiveSource (mplayer->media);
+
+ // FIXME: error check Initialize()
+ downloaded_file->Initialize ();
+
downloader->SetWriteFunc (data_write, size_notify, this);
// This is what actually triggers the download
downloader->Send ();
}
- if (!download_complete) {
+ if (!download_complete)
downloader->AddHandler (downloader->CompletedEvent,
downloader_complete, this);
- }
Invalidate ();
}
Modified: trunk/moon/src/pipeline.cpp
===================================================================
--- trunk/moon/src/pipeline.cpp 2008-01-23 17:59:08 UTC (rev 93679)
+++ trunk/moon/src/pipeline.cpp 2008-01-23 18:01:55 UTC (rev 93680)
@@ -1828,6 +1828,7 @@
return true;
default:
+ // invalid 'whence' argument
return false;
}
}
@@ -2145,59 +2146,52 @@
bool
ProgressiveSource::Seek (int64_t offset, int mode)
{
- bool result = false;
+ bool need_wait;
- if (fd == -1) {
- media->AddMessage (MEDIA_INVALID_ARGUMENT, "File has not been
opened.");
+ if (fd == -1)
return false;
- }
- Lock ();
-
- // Calculate the position from the mode and offset.
- int64_t position;
-
switch (mode) {
- case SEEK_CUR: position = GetPosition () + offset; break;
- case SEEK_SET: position = offset; break;
+ case SEEK_SET:
+ // no-op, offset is already relative to BOF
+ break;
+ case SEEK_CUR:
+ offset += pos;
+ break;
+ case SEEK_END:
+ if (size == -1) {
+ // we don't know the stream size, so cannot perform
this seek
+ return false;
+ }
+
+ if (offset > 0) {
+ // attempting to seek beyond eof
+ return false;
+ }
+
+ offset += size;
+ break;
default:
- // Due to the fact that many times we do not know the size of
the file, it does not make sense to support SEEK_END
- media->AddMessage (MEDIA_FAIL, g_strdup_printf ("Invalid seek
mode: %i", mode));
+ // invalid 'whence' argument
return false;
}
- // Seeked beyond end of file?
- if (size >= 0 && position > size) {
- media->AddMessage (MEDIA_FAIL, "Seek beyond eof.");
- result = false;
- goto cleanup;
+ if (offset < 0) {
+ // attempting to seek to an invalid position
+ return false;
}
- // If the requested position isn't downloaded yet, wait for it to be.
- if (position > write_pos) {
- printf ("ProgressiveSource::Seek (%lld): Seeked beyond written
size (%lld)\n", position, write_pos);
- Unlock ();
- if (!(WaitForPosition (position)))
+ Lock ();
+ need_wait = offset > write_pos;
+ Unlock ();
+
+ if (need_wait) {
+ /* wait for all of the requested data to become available */
+ if (!(WaitForPosition (offset)))
return false;
- Lock ();
}
- // Finally seek to where we want to be
- if ((result = lseek (fd, position, SEEK_SET) != -1)) {
- /* update state */
- pos = position;
-
- bufptr = buffer;
- buflen = 0;
-
- eof = false;
- }
-
-cleanup:
-
- Unlock ();
-
- return result;
+ return FileSource::Seek (offset, SEEK_SET);
}
bool
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches