This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: Fix dup for /dev/dsp
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: Gerd Spalink <Gerd dot Spalink at t-online dot de>
- Cc: cygwin-patches at cygwin dot com
- Date: Sun, 18 Jul 2004 12:29:31 -0400 (EDT)
- Subject: Re: Fix dup for /dev/dsp
- References: <01C46CF2.ACDB11A0.Gerd.Spalink@t-online.de>
- Reply-to: cygwin-patches at cygwin dot com
On Sun, 18 Jul 2004, Gerd Spalink wrote:
> What I did:
>
> The static open_count is no longer needed because now we consistently
> use the return status from the windows API to decide if we can open or
> not. This change is not related to dup.
>
> Wave header parsing needed a small fix. It was a +/-1 problem.
>
> To fix all cases of dup, a dup_chain is maintained to keep all duped
> instances consistent. I did not understand how to apply archetypes for
> this problem, and this solution works (test suite contribution is in
> separate patch).
>
>
> ChangeLog:
>
> 2004-07-18 Gerd Spalink <Gerd.Spalink@t-online.de>
>
> * fhandler.h (class fhandler_dev_dsp): Remove static open_count,
> add members to keep track of duped instances.
> * fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::parsewav): Compare
> with <= end for the case that only the header is passed to write.
> (fhandler_dev_dsp::open): Remove open_count; instead of query use
> start/stop to get wave device status from win32.
> (fhandler_dev_dsp::fhandler_dev_dsp): Initialize new members
> dup_chain_next and dup_chain_prev.
> (fhandler_dev_dsp::write): Insert call to update_duped.
> (fhandler_dev_dsp::close): Check dup_chain before stop of audio
> device.
> (fhandler_dev_dsp::dup): Create dup_chain linked list. Copy members
> by calling dup_cpy.
> (fhandler_dev_dsp::dup_cpy): New.
> (fhandler_dev_dsp::update_duped): New.
> (fhandler_dev_dsp::ioctl): Replace all inline return statements by
> setting variable rc. At the end, reflect any changes in duped instances
> by calling update_duped ().
Gerd,
I don't have time for an in-depth analysis, but after a quick look-over,
it looks like you're effectively keeping a reference_count, though as a
full list of references instead of just a count. It looks a bit
heavyweight, but otherwise good, and I can't argue with success. Just my
2c.
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton