Author: fejj
Date: 2007-09-28 11:06:25 -0400 (Fri, 28 Sep 2007)
New Revision: 86579
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/font.cpp
trunk/moon/src/media.cpp
trunk/moon/src/media.h
Log:
2007-09-28 Jeffrey Stedfast <[EMAIL PROTECTED]>
* media.cpp (SingleMedia::~SingleMedia): Close the media stream.
(MediaElement::AdvanceFrame): If mplayer->AdvanceFrame() returns
false, then it signifies MediaEnded, no need to explicitly check.
(MediaElement::SetSource): Delete the current source here.
(MediaElement::~MediaElement): C++ `delete' operator doesn't
handle freeing NULL pointers.
(MediaElement::DownloaderComplete): No need to delete the source
here, done in SetSource() instead.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-09-28 15:04:44 UTC (rev 86578)
+++ trunk/moon/src/ChangeLog 2007-09-28 15:06:25 UTC (rev 86579)
@@ -1,5 +1,14 @@
2007-09-28 Jeffrey Stedfast <[EMAIL PROTECTED]>
+ * media.cpp (SingleMedia::~SingleMedia): Close the media stream.
+ (MediaElement::AdvanceFrame): If mplayer->AdvanceFrame() returns
+ false, then it signifies MediaEnded, no need to explicitly check.
+ (MediaElement::SetSource): Delete the current source here.
+ (MediaElement::~MediaElement): C++ `delete' operator doesn't
+ handle freeing NULL pointers.
+ (MediaElement::DownloaderComplete): No need to delete the source
+ here, done in SetSource() instead.
+
* font.cpp: Created my own GlyphMetrics struct which uses doubles
instead of ints for more accurate layout/rendering calculations.
(Layout): When comparing to max_width, add 1.0 to account for
Modified: trunk/moon/src/font.cpp
===================================================================
--- trunk/moon/src/font.cpp 2007-09-28 15:04:44 UTC (rev 86578)
+++ trunk/moon/src/font.cpp 2007-09-28 15:06:25 UTC (rev 86579)
@@ -662,9 +662,9 @@
FcPattern *pattern;
if (font == NULL) {
- char *str = ToString ();
- printf ("requested font: %s\n", str);
- g_free (str);
+ //char *str = ToString ();
+ //printf ("requested font: %s\n", str);
+ //g_free (str);
pattern = CreatePattern ();
font = TextFont::Load (pattern);
Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp 2007-09-28 15:04:44 UTC (rev 86578)
+++ trunk/moon/src/media.cpp 2007-09-28 15:06:25 UTC (rev 86579)
@@ -152,7 +152,7 @@
SingleMedia::~SingleMedia ()
{
- ClearTimeout ();
+ Close ();
}
bool
@@ -245,7 +245,7 @@
position *= TIMESPANTICKS_IN_SECOND / 1000;
media_element_set_position (this, position);
updating = false;
- } else if (mplayer->MediaEnded ()) {
+ } else {
if (source)
source->Stop ();
Emit (MediaEndedEvent);
@@ -278,8 +278,8 @@
downloader = NULL;
part_name = NULL;
source = NULL;
-
- TimelineMarkerCollection* col = new TimelineMarkerCollection ();
+
+ TimelineMarkerCollection *col = new TimelineMarkerCollection ();
media_element_set_markers (this, col);
col->unref ();
}
@@ -301,7 +301,9 @@
g_free (part_name);
DownloaderAbort ();
- delete source;
+ if (source)
+ delete source;
+
delete mplayer;
}
@@ -317,8 +319,6 @@
}
bounds = bounding_rect_for_transformed_rect (&absolute_xform, Rect (0,
0, w, h));
-
-// no-op bounds.GrowBy (1);
}
Point
@@ -346,7 +346,7 @@
double render_opacity = GetTotalOpacity ();
cairo_surface_t *surface;
cairo_pattern_t *pattern;
-
+
#if USE_OPT_INDIRECT_COMPOSE
pattern_opacity = render_opacity;
render_opacity = 1.0;
@@ -361,11 +361,11 @@
}
cairo_save (cr);
- if (!UseAA ())
+ if (!EnableAntiAlias ())
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
cairo_set_matrix (cr, &absolute_xform);
-
+
pattern = image_brush_create_pattern (cr, surface, mplayer->width,
mplayer->height, pattern_opacity);
if (recalculate_matrix) {
@@ -378,16 +378,16 @@
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
-
+
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_FAST);
-
+
// NOTE: Some servers seem to have extreme perfomance issues
// when paint_with_alpha (cr, 1.0) is called even accidentally
- if (render_opacity < 1.0) {
+ if (render_opacity < 1.0)
cairo_paint_with_alpha (cr, render_opacity);
- } else {
+ else
cairo_paint (cr);
- }
+
cairo_restore (cr);
}
@@ -408,7 +408,7 @@
MediaElement::DataWrite (guchar *buf, gsize offset, gsize count)
{
double progress = downloader->GetValue
(DownloadProgressProperty)->AsDouble ();
-
+
// Delay the propogating progress 1.0 until
// the downloader has notified us it is done.
if (progress < 1.0)
@@ -441,34 +441,32 @@
{
char *filename = downloader_get_response_file (downloader, part_name);
bool autoplay = media_element_get_auto_play (this);
-
+
/* the download was aborted */
if (!filename)
return;
-
+
if (!loaded) {
+ // MediaElement not yet loaded, delay till then
g_free (filename);
return;
}
- if (source)
- delete source;
-
source = MediaSource::CreateSource (this, media_base_get_source (this),
filename);
//printf ("video source changed to `%s'\n", filename);
g_free (filename);
// FIXME: specify which audio stream index the player should use
-
+
if (!source->Open ()) {
Emit (MediaElement::MediaFailedEvent);
return;
}
-
+
UpdateProgress ();
Emit (MediaElement::MediaOpenedEvent);
-
+
Invalidate ();
//printf ("DownloaderComplete: autoplay = %s\n", autoplay ? "true" :
"false");
@@ -489,14 +487,19 @@
if (downloader) {
// Abort the current downloader
DownloaderAbort ();
-
- if (source)
- source->Close ();
}
-
+
+ if (source) {
+ // FIXME: is it expected that the next source will
+ // continue playing if this source was?
+ //play_pending = mplayer->IsPlaying ();
+ delete source;
+ source = NULL;
+ }
+
downloader = (Downloader *) dl;
part_name = g_strdup (PartName);
-
+
media_element_set_current_state (this, "Opening");
media_element_set_current_state (this, "Buffering");
@@ -517,14 +520,16 @@
void
MediaElement::Pause ()
{
+ //printf ("MediaElement::Pause() requested\n");
+
play_pending = false;
if (!mplayer->CanPause ())
return;
-
+
if (!source)
return;
-
+
source->Pause ();
}
@@ -544,6 +549,8 @@
void
MediaElement::Stop ()
{
+ //printf ("MediaElement::Stop() requested\n");
+
play_pending = false;
if (!mplayer->IsPlaying () && !mplayer->IsPaused ())
Modified: trunk/moon/src/media.h
===================================================================
--- trunk/moon/src/media.h 2007-09-28 15:04:44 UTC (rev 86578)
+++ trunk/moon/src/media.h 2007-09-28 15:06:25 UTC (rev 86579)
@@ -234,7 +234,7 @@
void Play ();
void Stop ();
- virtual bool UseAA ()
+ virtual bool EnableAntiAlias ()
{
return !(absolute_xform.xx == absolute_xform.yy /* no rotation
*/
&& (absolute_xform.yx == 0 && absolute_xform.xy == 0)
/* no skew */);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches