Hey,
cool to see someone working on Swfdec. :)
The code looks fine (apart from GMail not using a monospaced font :/)
with two issues, one minor, one likely more important.
The more important issue is that milliseconds are 1/1000th of a
second, not one millionth. So likely the not-CPU-intensive movies run
1000x too fast for you at the moment. :)
The not-so-important thing is that (I assume) you don't yet have a
proper priorization of events. So if you redraw after every frame -
likely the whole screen because you don't do invalidation tracking yet
- you will end up eating up all the CPU instead of advancing the
movie. This is likely what causes the slow movies.
So what you wanna do next is keep a Region of invalidated areas and
cause them to only repaint when you don't need to advance the movie.
No clue how the APIs look for that on OS X, but in Gtk we keep a
GdkRegion with all invalidated areas and g_idle_add() an idle function
that causes a repaint. As the idle function has a lower priority than
the advancement handler, advancing always happens first.
As for the repository, if you have something that you wanna push out
to the world, we'll get you an account and a git repository for
freedesktop. If you want to share the code with the world right now,
I'd suggest you host it yourself for now or mail dumps here to the
list.
Cheers,
Benjamin
PS: IRC #swfdec on freenode has way lower latency usually :)
On Mon, Sep 1, 2008 at 6:20 PM, Nick Zitzmann <seiryu at comcast.net>
wrote:> Hi all:
>
> I've been working on porting Swfdec to Mac OS X on my own time. So far
> I'm making some progress; stuff is displaying and events are working.
> I still have a bit of work to do, but in the meantime, I have some
> questions:
>
> 1. How does one get the ability to commit things to the repository? I
> don't expect this right away; I'll probably just distribute the Mac
OS
> X specific files separately at first, but it would be nice to be able
> to use the repository at some point in the future...
>
> 2. I also have a question about timing. Here is my current timer code;
> it's written in Objective-C but should be quite readable:
>
> - (void)scheduleNextEvent
> {
> glong millisecondsToNextEvent =
swfdec_player_get_next_event(_private-
> >_player);
>
> [_private->_nextEventTimer release];
> _private->_nextEventTimer = nil;
>
> if (millisecondsToNextEvent == -1) // nothing's going on,
so do nothing
> return;
> else if (millisecondsToNextEvent == 0) // we need to trigger the
next
> event immediately
> {
> swfdec_player_advance(_private->_player,
millisecondsToNextEvent);
> if (swfdec_player_is_initialized(_private->_player))
> {
> unsigned int width, height;
>
> swfdec_player_get_default_size(_private->_player,
&width, &height);
> [self setBounds:NSMakeRect(0.0, 0.0, width,
height)];
> [self setNeedsDisplay:YES];
> }
> [[NSRunLoop currentRunLoop]
> performSelector:@selector(scheduleNextEvent) target:self argument:nil
> order:100 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
> }
> else
> {
> NSTimeInterval fMillisecondsToNextEvent =
millisecondsToNextEvent;
>
> fMillisecondsToNextEvent /= 1000000.0; // translate to
seconds so we
> can use NSTimer
> _private->_timeOfLastTimer = CFAbsoluteTimeGetCurrent();
> _private->_nextEventTimer = [[NSTimer
> scheduledTimerWithTimeInterval:fMillisecondsToNextEvent target:self
> selector:@selector(triggerNextEvent:) userInfo:nil repeats:NO] retain];
> }
> }
>
>
> - (void)triggerNextEvent:(NSTimer *)timer
> {
> CFAbsoluteTime timeElapsed = CFAbsoluteTimeGetCurrent()-_private-
> >_timeOfLastTimer;
>
> swfdec_player_advance(_private->_player, timeElapsed*1000000.0);
> if (swfdec_player_is_initialized(_private->_player))
> [self setNeedsDisplay:YES];
> [self scheduleNextEvent];
> }
>
> Here's what the code does:
>
> a. When -scheduleNextEvent is called, it gets the time to the next
> event. If it is 0, then it triggers the next event immediately, and
> schedules itself to run again the next time the run loop cycles around.
> b. If it is a positive number, then it converts the time to seconds,
> and schedules a timer to trigger after the given time has elapsed.
> c. The timer calls -triggerNextEvent:, which triggers the next event
> using the time that elapsed between -scheduleNextEvent and -
> triggerNextEvent:, updates the display, and calls -scheduleNextEvent
> to schedule the next event.
>
> I get the feeling that I'm doing this way wrong, though, because
> everything happens either way too fast or way too slowly, depending on
> the size of the drawing view. How do I do this correctly? What did I
> not understand?
>
> Nick Zitzmann
> <http://seiryu.home.comcast.net/>
> S/MIME signature available upon request
>
>
>
>
> _______________________________________________
> Swfdec mailing list
> Swfdec at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/swfdec
>