At least for mp3blaster, just keeping a cache of the actual audio value we want, and invalidating it whenever something external changes the volume is quite enough.
Index: Makefile =================================================================== RCS file: /cvs/ports/audio/mp3blaster/Makefile,v retrieving revision 1.7 diff -u -p -r1.7 Makefile --- Makefile 24 Jan 2005 17:51:36 -0000 1.7 +++ Makefile 11 Aug 2005 21:20:14 -0000 @@ -3,7 +3,7 @@ COMMENT= "text console audio player with an interactive interface" DISTNAME= mp3blaster-3.2.0 -PKGNAME= ${DISTNAME}p0 +PKGNAME= ${DISTNAME}p1 CATEGORIES= audio HOMEPAGE= http://www.stack.nl/~brama/mp3blaster/ Index: patches/patch-nmixer_nmixer_h =================================================================== RCS file: patches/patch-nmixer_nmixer_h diff -N patches/patch-nmixer_nmixer_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-nmixer_nmixer_h 11 Aug 2005 21:20:14 -0000 @@ -0,0 +1,12 @@ +$OpenBSD$ +--- nmixer/nmixer.h.orig Thu Aug 11 23:14:07 2005 ++++ nmixer/nmixer.h Thu Aug 11 23:16:05 2005 +@@ -85,6 +85,8 @@ protected: + const char *Label(int device); + private: + int mixer; ++ struct volume cache; ++ int lastsetting; + }; + + #ifdef HAVE_NASPLAYER Index: patches/patch-nmixer_ossmixer_cc =================================================================== RCS file: patches/patch-nmixer_ossmixer_cc diff -N patches/patch-nmixer_ossmixer_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-nmixer_ossmixer_cc 11 Aug 2005 21:20:14 -0000 @@ -0,0 +1,31 @@ +$OpenBSD$ +--- nmixer/ossmixer.cc.orig Thu Aug 11 23:12:34 2005 ++++ nmixer/ossmixer.cc Thu Aug 11 23:17:33 2005 +@@ -49,17 +49,24 @@ OSSMixer::~OSSMixer() + + bool OSSMixer::Set(int device, struct volume *vol) + { ++ cache = *vol; + int setting = (vol->left & 0xFF) + ((vol->right & 0xFF) << 8); +- return (ioctl(mixer, MIXER_WRITE(device), &setting) >= 0); ++ if (ioctl(mixer, MIXER_WRITE(device), &setting) >= 0) ++ return ioctl(mixer, MIXER_READ(device), &lastsetting) >= 0; + } + + bool OSSMixer::Get(int device, struct volume *vol) + { + int setting; ++ + if (ioctl(mixer, MIXER_READ(device), &setting) < 0) + return false; +- vol->left = setting & 0x00FF; +- vol->right = (setting & 0xFF00) >> 8; ++ if (setting == lastsetting) ++ *vol = cache; ++ else { ++ vol->left = setting & 0x00FF; ++ vol->right = (setting & 0xFF00) >> 8; ++ } + return true; + } +