[RFC] Reference counting on Audio objects for /dev/dsp
Thu Jul 15 18:34:00 GMT 2004
On Thu, Jul 15, 2004 at 09:44:34AM -0400, Igor Pechtchanski wrote:
>I'd really like your comments on this patch. As I reported before, it
>didn't quite work for me, but with the recent problems in testing another
>(presumably working) patch, I suspect my test procedure isn't quite
>correct anyway. The patch basically adds a (very problem-specific)
>reference count to the Audio object(s), and doesn't delete the shared ones
>until all pointers are gone. It doesn't seem to fix the bash redirection
>problem, but does allow the "dsp_dup_close" testcase to run (again, I'd
>like your opinion on whether it runs correctly).
>The ChangeLog below is just for the record -- as I said, I don't expect
>this to be checked in yet.
>2004-07-06 Igor Pechtchanski <firstname.lastname@example.org>
> * fhandler_dsp.cc (fhandler_dev_dsp::Audio::reference_count_):
> New instance variable.
> (fhandler_dev_dsp::Audio::inc): New function. Increment the
> (fhandler_dev_dsp::Audio::dec): New function. Decrement the
> reference_count_ and delete if zero.
> (fhandler_dev_dsp::close): Replace delete with a call to dec().
> (fhandler_dev_dsp::dup): Copy audio_in_ and audio_out_ and call
> inc() on each.
Thanks for the patch. I have two problems, though.
1) Some minor problems with GNU formatting:
fhc->audio_out_ = audio_out_; if (audio_out_) audio_out_->inc ()
fhc->audio_out_ = audio_out_;
nor is this:
audio_out_ -> dec ();
2) The other problem is that I find it sort of odd to see the dec()
method performing a deletion. Couldn't this be handled where, IMO,
it should logically be handled, in the close function, e.g.,
if (!audio_out_->dec ())
More information about the Cygwin-patches