[MPlayer-dev-eng] [PATCH] audio file truncation

Uoti Urpala uoti.urpala at pp1.inet.fi
Thu Jun 8 12:30:01 CEST 2006


On Thu, 2006-06-08 at 11:45 +0200, Clemens Ladisch wrote:
> > > Uoti Urpala wrote:
> > > > [...] This does raise a question though:
> > > > if it's OK for the ao to play 0 bytes on this call, how do we
> > > > distinguish cases where the ao will accept data later (presumably after
> > > > some sound has played and buffers have emptied), and cases where it will
> > > > never succeed in playing the remaining bytes (assuming this is a
> > > > significant possibility)?
> > > 
> > > (USB device unplugged, network down, sound server killed, ...)

> I just wanted to illustrate that there actually is a significant
> possibility of play() never succeeding.

Yes but in those other error cases MPlayer can hang and it's (somewhat)
OK in that situation, whereas it would be quite bad if some aos always
fail to play the last partial chunk and that always makes MPlayer hang
at the end of an audio file. 

> > > My understanding of the API is that play() guarantees to accept at least
> > > as much data as indicated by get_space().
> > 
> > I haven't seen such a requirement mentioned anywhere, nor does it match
> > what the code does (it clearly expects to handle play() accepting less
> > data).
> 
> Sorry, I wasn't very clear.  play() guarantees that the _exact_ amount
> returned by get_space() can be accepted.  play() can accept less data

Was there some reason to think I had misunderstood what you meant? I was
talking about exactly the kind of guarantee you now mention again. I
have not seen such a requirement mentioned anywhere before, the current
code calling ao functions does not rely on such guarantees about ao
behavior, and I see no reason why such a guarantee would be needed.

> This means that the truncation problem could be solved^H^H^H^H^H^Hworked
> around by padding the last output to the size last returned by
> get_space().

That might be an unnecessarily large amount of padding. I think it would
be better to have the ao do the padding instead if it can't play partial
chunks and the flag indicating last chunk is set.




More information about the MPlayer-dev-eng mailing list