From 9e45aa1adacbf7edc5c35f72eddac4bcb7b5642a Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 11 Nov 2002 22:03:00 +0000 Subject: [PATCH] Introduced the SoundX11::closeDevice() method so that the SoundX11 and SoundSDL classes are drop-in replacements for each other. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@136 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/ui/x11/SoundX11.cxx | 34 ++++++++++++++++++++++------------ stella/src/ui/x11/SoundX11.hxx | 9 +++++++-- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/stella/src/ui/x11/SoundX11.cxx b/stella/src/ui/x11/SoundX11.cxx index cc160071a..2db059a60 100644 --- a/stella/src/ui/x11/SoundX11.cxx +++ b/stella/src/ui/x11/SoundX11.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundX11.cxx,v 1.1 2002-10-09 04:38:12 bwmott Exp $ +// $Id: SoundX11.cxx,v 1.2 2002-11-11 22:02:59 stephena Exp $ //============================================================================ #include @@ -127,23 +127,34 @@ SoundX11::SoundX11() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SoundX11::~SoundX11() { - if(myMixerFd != -1) + closeDevice(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void SoundX11::closeDevice() +{ + if(myIsInitializedFlag) { - if(myOriginalVolume != -1) + if(myMixerFd != -1) { - if(ioctl(myMixerFd, MIXER_WRITE(SOUND_MIXER_PCM), - &myOriginalVolume) == -1) + if(myOriginalVolume != -1) { - perror(MIXER_DEVICE); + if(ioctl(myMixerFd, MIXER_WRITE(SOUND_MIXER_PCM), + &myOriginalVolume) == -1) + { + perror(MIXER_DEVICE); + } } + + close(myMixerFd); } - close(myMixerFd); - } + if(myDspFd != -1) + { + close(myDspFd); + } - if(myDspFd != -1) - { - close(myDspFd); + myIsInitializedFlag = false; } } @@ -226,4 +237,3 @@ void SoundX11::updateSound(MediaSource& mediaSource) } } } - diff --git a/stella/src/ui/x11/SoundX11.hxx b/stella/src/ui/x11/SoundX11.hxx index 56895f01d..2da011a05 100644 --- a/stella/src/ui/x11/SoundX11.hxx +++ b/stella/src/ui/x11/SoundX11.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SoundX11.hxx,v 1.1 2002-10-09 04:38:12 bwmott Exp $ +// $Id: SoundX11.hxx,v 1.2 2002-11-11 22:03:00 stephena Exp $ //============================================================================ #ifndef SOUNDX11_HXX @@ -27,7 +27,7 @@ Open Sound System (OSS) API is currently supported. @author Bradford W. Mott - @version $Id: SoundX11.hxx,v 1.1 2002-10-09 04:38:12 bwmott Exp $ + @version $Id: SoundX11.hxx,v 1.2 2002-11-11 22:03:00 stephena Exp $ */ class SoundX11 { @@ -43,6 +43,11 @@ class SoundX11 virtual ~SoundX11(); public: + /** + Closes the sound device + */ + void closeDevice(); + /** Return the playback sample rate for the sound device.