[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-dev] sound_handler tweak (for release branch)

From: strk
Subject: [Gnash-dev] sound_handler tweak (for release branch)
Date: Fri, 26 Sep 2008 12:32:45 +0200

A conceptual bug in the current NetStream (ffmpeg) version
prevents dynamically loaded videos from playing if gnash
has problems opening the Audio card.

This is because the sound_handler::attach_aux_streamer
is just assumed to have as a postcondition the fact
that the callback function passed as argument will
be called on regular intervals (more specifically
by requesting it to fetch bytes at the flash-standard
audio rate, 44khz IIRC).

The SDL implementation of sound_handler currently 
returns w/out even attachin the callback if audio
card initialization fails.

This means the caller expectations won't hold, and
in particular NetStreamFfmpeg won't advance the PlayHead
cursor because it'll be wait for the audio consumer
to do it's job (consume the data prepared for it).
Failure to consume the prepared audio results in this message:
pushDecodedAudioFrames(47) : buffer overrun (21/20).

Now, I see two possibilities:

1) Make sure attach_aux_streamer *always* calls the filler
   no matter audio card errors
2) Allow attach_aux_streamer to signal a failure in doing
   so to the caller

I inspected solution (1) but it seems that the *current*
SDL implementation relies on SDL lib to take care
about the callback, that is it receives a callback
from SDL lib and dispatch to any attached aux streamer.
When audio initialization fails, SDL lib will not call
the callback.

So, to really do (1) we'll need to roll our own callback
system, which may be useful to hide threading and for reuse
in GST sound handler, but would also introduce some complexity
as of "where do we get the clock from?" and things like that.
Note that sound_handler currently exposes no information about
the actual audio clock/rate. Doesn't seems something good
for the release, but worth thinking about it for post-release

We're then left with (2) : let attach_aux_streamer signal
caller about wheter or not its request could be fullfilled.

Currently, the possible reasons for not fullfilling the request
in SDL implementation are:
        - Resource limits (memory / lack of audio card / whatever).
        - An aux streamer identified by the given pointer is already

For the first we have a real-world failure case.
For the second we have NO specification about expectances by callers.
Luckly NetStreamFfmpeg.cpp is currently the *only* caller so we
can easly adapt its expectation to what we decide. 

Now, question is: how do we want to signal such failure ?
Since we discuss this a bit on another media-related spot...

Currently attach_aux_streamer returns void. We have two options:

        1) Change signature so it returns bool
        2) Throw an exception if expected postcondition can't be met

Exception would give us more options of distinguish the two kind
of failures in the future, allows us to print the error where
it happens and doesn't force us to change the interface thus
changing all subclasses of sound_handler.

Did I answer my own question ?
Or, comments ? Concerns ? Ideas ?


 ()   ASCII Ribbon Campaign
 /\   Keep it simple! 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]