diff options
author | gd78059 <none@none> | 2008-06-11 19:20:43 -0700 |
---|---|---|
committer | gd78059 <none@none> | 2008-06-11 19:20:43 -0700 |
commit | d8d4fa8f33f737d82c7dcd7ddd11b4342ce4fbca (patch) | |
tree | 03da5da0fd7382b58428487249c8db8f5b48e9bc /usr/src | |
parent | 43d5cd3d2ec5c3a1e2b2a9155ae4042c14a99011 (diff) | |
download | illumos-joyent-d8d4fa8f33f737d82c7dcd7ddd11b4342ce4fbca.tar.gz |
PSARC 2008/261 EOF: Sound Blaster Pro driver sbpro
6709032 EOF sbpro driver
6709321 audio utilities library libaudio.a has unused/unreferenced source files
--HG--
rename : usr/src/cmd/audio/include/AudioDetect.h => deleted_files/usr/src/cmd/audio/include/AudioDetect.h
rename : usr/src/cmd/audio/include/AudioDevice.h => deleted_files/usr/src/cmd/audio/include/AudioDevice.h
rename : usr/src/cmd/audio/include/AudioDevicectl.h => deleted_files/usr/src/cmd/audio/include/AudioDevicectl.h
rename : usr/src/cmd/audio/utilities/AudioDetect.cc => deleted_files/usr/src/cmd/audio/utilities/AudioDetect.cc
rename : usr/src/cmd/audio/utilities/AudioDevice.cc => deleted_files/usr/src/cmd/audio/utilities/AudioDevice.cc
rename : usr/src/cmd/audio/utilities/AudioDevicectl.cc => deleted_files/usr/src/cmd/audio/utilities/AudioDevicectl.cc
rename : usr/src/pkgdefs/SUNWpsdir/preinstall => deleted_files/usr/src/pkgdefs/SUNWpsdir/preinstall
Diffstat (limited to 'usr/src')
21 files changed, 38 insertions, 2582 deletions
diff --git a/usr/src/cmd/audio/include/AudioDetect.h b/usr/src/cmd/audio/include/AudioDetect.h deleted file mode 100644 index 9474240ed5..0000000000 --- a/usr/src/cmd/audio/include/AudioDetect.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1990-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _MULTIMEDIA_AUDIODETECT_H -#define _MULTIMEDIA_AUDIODETECT_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <Audio.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* Audio sound/silence detection structures and routines */ - -/* - * An array of AudioDetectPts is returned by the detection algorithms. - * 'Pos' gives the start time of a region. 'Type' give the type of data - * detected in that particular region. The end time of the region is equal - * to the start time of the next region. - * The last entry in the array has type DETECT_EOF. - */ - -enum AudioDetectType { - DETECT_EOF, /* end of file marker */ - DETECT_SILENCE, /* region of silence */ - DETECT_SOUND /* region of detected sound */ - /* XXX - may be extended to include */ - /* touch-tone and speech detection. */ -}; -struct AudioDetectPts { - double pos; /* start time of audio region */ - enum AudioDetectType type; /* type of audio region */ -}; - -/* Audio detection algorithm tuning parameters */ -enum AudioDetectConfig { - DETECT_MINIMUM_SILENCE, /* (double) minimum pause time */ - DETECT_MINIMUM_SOUND, /* (double) minimum sound time */ - DETECT_THRESHOLD_SCALE, /* (double) 0.(low) - 4.(hi) */ - DETECT_NOISE_RATIO /* (double) 0.(low) - 1.(hi) */ -}; - -// Array of detection points -class AudioDetectArray { -private: - unsigned int count; // number of valid points in array - unsigned int size; // number of entries in array - - void operator=(AudioDetectArray); // Assignment is illegal -public: - AudioDetectPts* pts; // array ptr - - AudioDetectArray(unsigned int cnt = 0); // Constructor - ~AudioDetectArray(); // Destructor - - // Append points - AudioError appendpts( - AudioDetectPts* newpts, // array to append - unsigned int cnt = -1); // number of points to append - void reduce(); // Eliminate redundancy - AudioError duparray(AudioDetectPts*& cp); // Copy array -}; - - -// Audio detection state structure -class AudioDetect { -private: - void* state; // detection algorithm state - Double min_silence; // length of minimum silence segment - Double min_sound; // length of minimum sound segment - Double thresh_scale; // silence threshold scale - Double noise_ratio; // silence threshold noise ratio - - void operator=(AudioDetect); // Assignment is illegal - - // Analyze main loop - AudioError analyzeappend( - AudioDetectArray*& aptr, // value array to modify - Audio* obj, // AudioList, or whatever - Double from, // starting offset - Double to, // ending offset - Double mintime); // minimum analysis buffer size -public: - AudioDetect(); // Constructor - ~AudioDetect(); // Destructor - - // Get detection params - AudioError GetParam( - AudioDetectConfig type, // type flag - Double& val); // return value - - // Set detection params - AudioError SetParam( - AudioDetectConfig type, // type flag - Double val); // value - - // Analyze silence - AudioError SetNoiseFloor( - Audio* obj); // AudioExtent, or whatever - - // Analyze gain level - AudioError AnalyzeGain( - Audio* obj, // AudioExtent, or whatever - Double& val); // return value - - // Process data - AudioError Analyze( - AudioDetectPts*& pts, // value array to modify - Audio* obj); // AudioList, or whatever - - // Process data - AudioError Analyze( - AudioDetectPts*& pts, // value array to modify - Audio* obj, // AudioList, or whatever - Double from); // starting offset - - // Process data - AudioError Analyze( - AudioDetectPts*& pts, // value array to modify - Audio* obj, // AudioList, or whatever - Double from, // starting offset - Double to); // ending offset -}; - -#ifdef __cplusplus -} -#endif - -#endif /* !_MULTIMEDIA_AUDIODETECT_H */ diff --git a/usr/src/cmd/audio/include/AudioDevice.h b/usr/src/cmd/audio/include/AudioDevice.h deleted file mode 100644 index 9f7881537e..0000000000 --- a/usr/src/cmd/audio/include/AudioDevice.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MULTIMEDIA_AUDIODEVICE_H -#define _MULTIMEDIA_AUDIODEVICE_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef NO_EXTERN_C - -#ifdef __cplusplus -extern "C" { -#endif - -#endif /* NO_EXTERN_C */ - -#include <sys/ioccom.h> -#include <sys/audioio.h> -#include <AudioUnixfile.h> - -// Enumerate known device types -enum AudioDeviceType { - AudioDeviceUnknown, // unknown device type - AudioDeviceAMD, // AM79C30 - AudioDeviceSBPRO, // SoundBlaster Pro - AudioDeviceSB16, // SoundBlaster 16 - AudioDeviceSPECTRUM, // MediaVision Audio Spectrum 16 - AudioDeviceMULTISOUND, // Turtle Beach MultiSound - AudioDeviceCODEC // MMCodec with no DBRI -}; - -// The audio information structure is defined as a class so that -// it is automatically initialized whenever allocated. -class AudioInfo { -private: - audio_info_t info; // device info structure -public: - AudioInfo(); // Constructor - audio_info_t *operator ->() // Cast to info ptr - { return (&info); } - void Clear(); // Reset -}; - -// Audio device encoding structure (play/record state) -typedef audio_prinfo_t AudioPRinfo; - - -// This is the 'base' class for audio devices -// -// Since audio devices can theoretically have separate input and output -// encoding formats, there are separate methods for input and output headers. -// For compatibility with other AudioStream classes, GetHeader() gets the -// input data encoding and SetHeader() sets the output data encoding. - -class AudioDevice : public AudioUnixfile { -private: - static const FileAccess defmode; // Default access mode - static const char *AUDIO_ENV; // Default device env name - static const char *AUDIO_DEV; // Default device name - - AudioHdr readhdr; // input data encoding - AudioDeviceType devtype; // device type - - AudioDevice operator=(AudioDevice); // Assignment is illegal - -protected: - // open with a given pathname - virtual AudioError tryopen( - const char *, int); - virtual void decode_devtype(); // figure out the device type - virtual void clearhdr(); // clear cached readhdr - virtual AudioError info_to_hdr( - const AudioPRinfo& prinfo, // device encoding info - AudioHdr& h) const; // header to set - virtual AudioError hdr_to_info( - const AudioHdr& h, // header to encode - AudioPRinfo& prinfo) const; // output device encoding info - - virtual Double scale_gain(unsigned int); // gain -> float - virtual unsigned int unscale_gain(Double); // float -> gain - virtual Double scale_balance(unsigned int); // balance -> float - virtual unsigned int unscale_balance(Double); // float -> balance - - // Turn SIGPOLL on/off - virtual AudioError incr_volume( - Boolean, // true to raise, false to lower - AudioInfo&, // info structure - unsigned int *); // ptr to gain field in info - - // Check rate tolerance - virtual Boolean rate_match( - unsigned int, unsigned int); - - // class AudioUnixfile methods specialized here - virtual AudioError decode_filehdr() // No-op for devices - { return (AUDIO_ERR_BADARG); } - virtual AudioError encode_filehdr() // No-op for devices - { return (AUDIO_ERR_BADARG); } - - // class AudioStream methods specialized here - virtual Boolean opened() const; // TRUE, if open - -public: - // Constructor with path - AudioDevice( - const char *path = "", // device name - const FileAccess acc = defmode); // access mode - virtual ~AudioDevice(); // Destructor - - // class AudioUnixfile methods specialized here - virtual AudioError Create(); // Create file - virtual AudioError Open(); // Open file - - // ... with search path - virtual AudioError OpenPath( - const char *path = AUDIO_ENV); - - // Read from position - virtual AudioError ReadData( - void* buf, // buffer to fill - size_t& len, // buffer length (updated) - Double& pos); // start position (updated) - - // Write at position - virtual AudioError WriteData( - void* buf, // buffer to copy - size_t& len, // buffer length (updated) - Double& pos); // start position (updated) - - // class AudioStream methods specialized here - // Set header - virtual AudioError SetHeader( - const AudioHdr& h); // header to copy - - // class Audio methods specialized here - virtual AudioHdr GetHeader(); // Get header - - virtual Boolean isDevice() const { return (TRUE); } - - // Device control and status functions - virtual AudioDeviceType GetDeviceType() const; // Get device type - - // Get device state - virtual AudioError GetState( - AudioInfo& info) const; - - // Set device state - virtual AudioError SetState( - AudioInfo& info); - - // Turn SIGPOLL on/off - virtual AudioError SetSignal( - Boolean on); - - // TRUE if device-compatible hdr - virtual Boolean CanSetHeader( - AudioHdr& h); // header to check - - // Set input encoding - virtual AudioError SetReadHeader( - AudioHdr& h); // header to copy (updated) - - // Set output encoding - virtual AudioError SetWriteHeader( - AudioHdr& h); // header to copy (updated) - virtual AudioHdr GetReadHeader(); // Get input encoding - virtual AudioHdr GetWriteHeader(); // Get output encoding - - virtual AudioError WriteEof(); // Write eof sync flag - virtual AudioError Flush(const FileAccess); // Flush data - virtual AudioError DrainOutput(); // Wait for output - - virtual AudioError Pause(const FileAccess); // Set pause flags - virtual AudioError Resume(const FileAccess); // Clear pause flags - - virtual AudioError SetPlayEof(unsigned&); // Play eof counter - virtual AudioError SetPlaySamples(unsigned&); // Play sample count - virtual AudioError SetRecSamples(unsigned&); // Record sample count - virtual AudioError SetPlayError(Boolean&); // Play error flag - virtual AudioError SetRecError(Boolean&); // Record error flag - virtual AudioError SetPlayWaiting(); // Set Play waiting - virtual AudioError SetRecWaiting(); // Set Record waiting - virtual AudioError SetRecDelay(Double&); // Set Record delay - - virtual AudioError SetPlayVolume(Double&); // Play volume - virtual AudioError PlayVolumeUp(); // Raise volume a notch - virtual AudioError PlayVolumeDown(); // Lower volume a notch - virtual AudioError SetRecVolume(Double&); // Record volume - virtual AudioError RecVolumeUp(); // Raise volume a notch - virtual AudioError RecVolumeDown(); // Lower volume a notch - virtual AudioError SetMonVolume(Double&); // Monitor volume - virtual AudioError MonVolumeUp(); // Raise volume a notch - virtual AudioError MonVolumeDown(); // Lower volume a notch - virtual AudioError SetPlayBalance(Double&); // Set balance - virtual AudioError SetRecBalance(Double&); // Set balance - - virtual Double GetPlayVolume(AudioInfo* = 0); // Play volume - virtual Double GetRecVolume(AudioInfo* = 0); // Record volume - virtual Double GetMonVolume(AudioInfo* = 0); // Monitor volume - virtual Double GetPlayBalance(AudioInfo* = 0); // Play balance - virtual Double GetRecBalance(AudioInfo* = 0); // Record balance - virtual unsigned GetPlaySamples(AudioInfo* = 0); // Play sample count - virtual unsigned GetRecSamples(AudioInfo* = 0); // Record sample count - virtual Boolean GetPlayOpen(AudioInfo* = 0); // Get Play open flag - virtual Boolean GetRecOpen(AudioInfo* = 0); // Get Record open flag - virtual Boolean GetPlayWaiting(AudioInfo* = 0); // Get Play waiting - virtual Boolean GetRecWaiting(AudioInfo* = 0); // Get Record waiting -}; - -#ifdef NO_EXTERN_C - -#ifdef __cplusplus -} -#endif - -#endif /* NO_EXTERN_C */ - -#endif /* !_MULTIMEDIA_AUDIODEVICE_H */ diff --git a/usr/src/cmd/audio/include/AudioDevicectl.h b/usr/src/cmd/audio/include/AudioDevicectl.h deleted file mode 100644 index f090fcd746..0000000000 --- a/usr/src/cmd/audio/include/AudioDevicectl.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1992-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _MULTIMEDIA_AUDIODEVICECTL_H -#define _MULTIMEDIA_AUDIODEVICECTL_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <AudioDevice.h> - -#ifdef __cplusplus -extern "C" { -#endif - -// This is the audio control device class -// -// The audio control device cannot be read or written. - -class AudioDevicectl : public AudioDevice { -private: - AudioDevicectl operator=(AudioDevicectl); // Assignment is illegal - -protected: - -public: - // Constructor with path - AudioDevicectl( - const char *path = ""); // default device - virtual ~AudioDevicectl() {} // Destructor - - // class AudioDevice methods specialized here - virtual AudioError tryopen( - const char *, int); // open with a given pathname - - // class Audio methods specialized here - virtual AudioHdr GetReadHeader(); // Get header - - // Device control and status functions - // Turn SIGPOLL on/off - virtual AudioError SetSignal( - Boolean on); - - - // No-op methods - virtual AudioError Create() - { return (RaiseError(AUDIO_ERR_NOEFFECT)); } - virtual AudioError ReadData(void*, size_t&, Double&) - { return (RaiseError(AUDIO_ERR_NOEFFECT)); } - virtual AudioError WriteData(void*, size_t&, Double&) - { return (RaiseError(AUDIO_ERR_NOEFFECT)); } - virtual AudioError SetHeader(const AudioHdr&) - { return (RaiseError(AUDIO_ERR_NOEFFECT)); } - virtual AudioError SetReadHeader(AudioHdr&) - { return (RaiseError(AUDIO_ERR_NOEFFECT)); } - virtual AudioError SetWriteHeader(AudioHdr&) - { return (RaiseError(AUDIO_ERR_NOEFFECT)); } - virtual AudioError WriteEof() - { return (RaiseError(AUDIO_ERR_NOEFFECT)); } - virtual AudioError Flush(const FileAccess) - { return (RaiseError(AUDIO_ERR_NOEFFECT)); } - virtual AudioError DrainOutput() - { return (RaiseError(AUDIO_ERR_NOEFFECT)); } - - virtual Boolean isDevice() const { return (TRUE); } // XXX ?? - virtual Boolean isDevicectl() const { return (TRUE); } -}; - -#ifdef __cplusplus -} -#endif - -#endif /* !_MULTIMEDIA_AUDIODEVICECTL_H */ diff --git a/usr/src/cmd/audio/utilities/AudioDetect.cc b/usr/src/cmd/audio/utilities/AudioDetect.cc deleted file mode 100644 index 37a7cff80c..0000000000 --- a/usr/src/cmd/audio/utilities/AudioDetect.cc +++ /dev/null @@ -1,563 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <malloc.h> -#include <stdlib.h> -#include <memory.h> -#include <AudioBuffer.h> -#include <AudioLib.h> -#include <AudioDetect.h> -#include <silence_detect.h> - -// XXX - temporary: manual data conversion -#include <AudioTypePcm.h> - -// class AudioDetectArray methods - -// Allocation increment for array -static const unsigned int ARRAY_INCR = 50; - -// Minimum time for detection algorithm is 250 milliseconds -static const double MIN_DURATION = .250; -// The detection algorithm needs at least 20 msecs more than silence duration -static const double DURATION_INCR = .022; -// Minimum silence for detection algorithm is fine grain -// XXX - not used for now -static const double MIN_SILENCE = .05; - -// Constructor -AudioDetectArray:: -AudioDetectArray( - unsigned int cnt): // start size of array - count(0) -{ - size = cnt; - if (size == 0) - size = ARRAY_INCR; // set default size - pts = (AudioDetectPts*)malloc(size * sizeof (*pts)); -} - -// Destructor -AudioDetectArray:: -~AudioDetectArray() -{ - if (pts != NULL) - (void) free((char *)pts); -} - -// Append a list of detection points to the array -AudioError AudioDetectArray:: -appendpts( - AudioDetectPts* newpts, // new array to append - unsigned int cnt) // number of points to append -{ - // If cnt == -1, append until eof - if (cnt == -1) { - AudioDetectPts* cp; - - cnt = 1; - cp = newpts; - while (cp->type != DETECT_EOF) { - cnt++; - cp++; - } - } - - // Loop through, appending each new point in turn - while (cnt-- > 0) { - if (count == size) { - // Time to allocate more space in array - size += ARRAY_INCR; - pts = (AudioDetectPts*) - realloc((char *)pts, (size * sizeof (*pts))); - if (pts == NULL) - return (AUDIO_UNIXERROR); - } - pts[count++] = *newpts++; - } - return (AUDIO_SUCCESS); -} - -// Process the detection array, eliminating eofs and collapsing adjacent entries -void AudioDetectArray:: -reduce() -{ - AudioDetectPts* ip; // input pointer - AudioDetectPts* op; // output pointer - unsigned int ocnt; // output counter - - // Start input and output pointers together - ip = pts; - op = pts; - ocnt = 0; - - // If no entries in the array, make at least one - if (count == 0) { - op->pos = 0.; - op->type = DETECT_EOF; - count = 1; - return; - } - - // Get a legitimate starting point - while ((ip->type == DETECT_EOF) && (count-- > 0)) { - *op = *ip++; // copy eof, in case it's the last - } - if (count <= 0) { - count = 1; // already copied final eof - return; - } - - // Copy first entry - *op++ = *ip++; - ocnt++; - count--; - - // Collapse the array - while (count-- > 0) { - if (ip->type == op[-1].type) { - // Eliminate adjacent entries of same type - ip++; - } else if ((ip->type == DETECT_EOF) && (count > 0)) { - // Remove non-final eofs - ip++; - } else { - *op++ = *ip++; - ocnt++; - } - } - count = ocnt; // set final count -} - -// Copy the detection array to a new array -AudioError AudioDetectArray:: -duparray( - AudioDetectPts*& cp) // set pointer to new array -{ - // Allocate new array of adequate size - cp = (AudioDetectPts*)malloc(count * sizeof (*pts)); - if (cp == NULL) - return (AUDIO_UNIXERROR); - - // Copy array - (void) memcpy((char *)cp, (char *)pts, (count * sizeof (*pts))); - return (AUDIO_SUCCESS); -} - - -// class AudioDetect methods - - -// Constructor -AudioDetect:: -AudioDetect() -{ - min_sound = .3; - min_silence = .2; - state = (void*)silence_create_state(8000, min_silence); - thresh_scale = silence_get_thr_scale((SIL_STATE*)state); - noise_ratio = silence_get_noise_ratio((SIL_STATE*)state); -} - -// Destructor -AudioDetect:: -~AudioDetect() -{ - silence_destroy_state((SIL_STATE*)state); -} - - -// Get parameters for the audio detection algorithm. -// Each call retrieves one parameter. The parameter is identified -// by the 'type' argument. 'Valp' is a pointer to the new value. -AudioError AudioDetect:: -GetParam( - AudioDetectConfig type, // type flag - Double& val) // address of value -{ - switch (type) { - case DETECT_MINIMUM_SILENCE: - val = min_silence; - break; - case DETECT_MINIMUM_SOUND: - val = min_sound; - break; - case DETECT_THRESHOLD_SCALE: - val = thresh_scale; - break; - case DETECT_NOISE_RATIO: - val = noise_ratio; - break; - default: - return (AUDIO_ERR_BADARG); - } - return (AUDIO_SUCCESS); -} - -// Set parameters for the audio detection algorithm. -// Each call adjusts one parameter. The parameter is identified -// by the 'type' argument. 'Valp' is a pointer to the new value. -AudioError AudioDetect:: -SetParam( - AudioDetectConfig type, // type flag - Double val) // value -{ - if (val < 0.) - return (AUDIO_ERR_BADARG); - - switch (type) { - case DETECT_MINIMUM_SILENCE: - min_silence = val; - break; - case DETECT_MINIMUM_SOUND: - min_sound = val; - break; - case DETECT_THRESHOLD_SCALE: - thresh_scale = val; - break; - case DETECT_NOISE_RATIO: - if (val > 1.) - return (AUDIO_ERR_BADARG); - noise_ratio = val; - break; - default: - return (AUDIO_ERR_BADARG); - } - return (AUDIO_SUCCESS); -} - -// Entry stubs for invocations with missing arguments -AudioError AudioDetect:: -Analyze( - AudioDetectPts*& pts, // value array to modify - Audio* obj) // AudioList, or whatever -{ - Double from; // starting offset - Double to; // ending offset - - return (Analyze(pts, obj, from = 0., to = AUDIO_UNKNOWN_TIME)); -} - -AudioError AudioDetect:: -Analyze( - AudioDetectPts*& pts, // value array to modify - Audio* obj, // AudioList, or whatever - Double from) // starting offset -{ - Double to; // ending offset - - return (Analyze(pts, obj, from, to = AUDIO_UNKNOWN_TIME)); -} - -// Process data from a given Audio object, filling in the 'vals' structure. -// If from and to identify a subset region for which there are -// already valid markers in the 'vals' structure, 'vals' is updated. -// For instance, suppose a 60 second file has already been mapped out. -// Now a PASTE operation inserts 10 seconds right in the middle. -// Step through the vals structure, adding 10 (the insert length) to -// every time greater than 30 (the insert point). Then call this routine -// with (from, to) set to (30, 40). The vals structure will be -// updated by reading the minimum required amount of data (which will, -// however, be a little longer than 10 seconds in order to get the -// transitions right). -// Returns audio error code or AUDIO_SUCCESS. -// This routine deallocates the input copy of 'pts', so make sure -// it is a copy of non-volatile storage, if necessary. -AudioError AudioDetect:: -Analyze( - AudioDetectPts*& pts, // value array to modify - Audio* obj, // AudioList, or whatever - Double from, // starting offset [0.] - Double to) // ending offset [AUDIO_UNKNOWN_TIME] -{ - Double maxdur; // length of minimum sample interval - AudioDetectArray* ap; // new value array - AudioDetectPts* oldpts; // saved input array - AudioDetectPts* list; - AudioDetectPts* aptr; - unsigned int cnt; - AudioError err; - - ap = new AudioDetectArray; - if (ap == NULL) - return (AUDIO_UNIXERROR); - oldpts = pts; - pts = NULL; - - // Get largest of the minimum time parameters - maxdur = min_silence; - if (min_sound > maxdur) - maxdur = min_sound; - maxdur += DURATION_INCR; - if (maxdur < MIN_DURATION) - maxdur = MIN_DURATION; - - // Adjust starting time - from -= maxdur; - if (from < 0.) - from = 0.; - - // Adjust ending time - if (!Undefined(to)) - to += maxdur; - - // If replacing virtually the whole array, skip trying to update - if ((oldpts != NULL) && - ((oldpts->type == DETECT_EOF) || - ((from < MIN_DURATION) && (Undefined(to))))) { - (void) free((char *)oldpts); - oldpts = NULL; - from = 0.; - } - - // If time is a subset of an existing list, copy out the first entries - list = oldpts; - if ((list != NULL) && (from > 0.)) { - cnt = 0; - while ((list->type != DETECT_EOF) && (from > list->pos)) { - cnt++; - list++; - } - if (err = ap->appendpts(oldpts, cnt)) - goto error_ret; - } - - // Analyze the specified region of data - if (err = analyzeappend(ap, obj, from, to, maxdur)) - goto error_ret; - - // If time is a subset of an existing list, copy out the last entries - if ((list != NULL) && (!Undefined(to))) { - while (list->type != DETECT_EOF) { - if (list->pos >= to) { - ap->appendpts(list, 1); - list++; - } - } - } - - // Compress and copy the list - ap->reduce(); - - - // Eliminate silence segments that are under their length threshold - for (aptr = ap->pts; aptr->type != DETECT_EOF; aptr++) { - if ((aptr->type == DETECT_SILENCE) && - ((aptr[1].pos - aptr->pos) < min_silence)) - aptr->type = DETECT_SOUND; - } - ap->reduce(); - - // Eliminate sound segments that are under their length threshold - for (aptr = ap->pts; aptr->type != DETECT_EOF; aptr++) { - if ((aptr->type == DETECT_SOUND) && - ((aptr[1].pos - aptr->pos) < min_sound)) - aptr->type = DETECT_SILENCE; - } - ap->reduce(); - - // Caller must free the returned array - // XXX - maybe can arrange for caller to dup it instead - err = ap->duparray(pts); - -error_ret: - // Throw away interim structures - if (oldpts != NULL) - (void) free((char *)oldpts); - delete ap; - return (err); -} - -// Audio detection main anaylze loop -AudioError AudioDetect:: -analyzeappend( - AudioDetectArray*& aptr, // value array to modify - Audio* obj, // AudioList, or whatever - Double from, // starting offset - Double to, // ending offset - Double mintime) // minimum analysis buffer size -{ - AudioBuffer* buf; - AudioBuffer* abp; - AudioHdr hdr; - Double start; - Double len; - Double minbuf; - Double tmpend = 0.; - unsigned int bufsiz; - off_t offset; - unsigned int npts; - int i; - int valid; - END_POINTS* ep; - AudioDetectPts apt; - AudioError err; - - buf = NULL; - abp = NULL; - offset = 0; - start = from; - minbuf = mintime * 10.; // Process buffer length - - // Start out assuming non-silence - apt.type = DETECT_SOUND; - apt.pos = from; - if (err = aptr->appendpts(&apt, 1)) - return (err); - - // If eof, set an eof marker - if (!Undefined(obj->GetLength()) && (from >= obj->GetLength())) { - goto no_data; - } - - hdr = obj->GetDHeader(from); - hdr.sample_rate = 0; // dummy value for now - - // Init detection state - silence_set_min_sil_dur(min_silence, (SIL_STATE*)state); - silence_set_thr_scale(thresh_scale, (SIL_STATE*)state); - silence_set_noise_ratio(noise_ratio, (SIL_STATE*)state); - silence_init_state((SIL_STATE*)state); - - // Loop while there is data to read - do { - // If eof, we're done - if (!Undefined(obj->GetLength()) && - (from >= obj->GetLength())) { - break; - } - - // If the current sample rate does not match the old, re-init - if (obj->GetDHeader(from).sample_rate != hdr.sample_rate) { - hdr.sample_rate = obj->GetDHeader(from).sample_rate; - if (buf != NULL) - buf->Dereference(); - - // Allocate a new holding buffer - buf = new AudioBuffer(minbuf); - if (buf == NULL) - return (AUDIO_UNIXERROR); - buf->Reference(); - if (err = buf->SetHeader(hdr)) - goto error_ret; - - // Update algorithm state - silence_set_rate(hdr.sample_rate, (SIL_STATE*)state); - } - - // Limit the copy to the buffer length or remaining data time - len = minbuf; - if (!Undefined(to)) { - if (len > (to - from)) { - len = to - from; - } - } - - // Copy one region of data - // XXX - Duplicate bufptr to hold onto it (for now) - // tmpend should = 0. from initialization area - - // tmpend should be cleared each time before calling. - // Bug ID 4034048 DPT 24-Feb-97 - tmpend = 0.; - err = AudioAsyncCopy(obj, buf, from, tmpend, len); - - // XXX - Temporary: Convert to linear manually - if (!err) { - AudioTypePcm conv; // XXX - temporary - AudioHdr newhdr = hdr; - - abp = buf; - // only convert if not LINEAR pcm - if (buf->GetHeader().encoding != LINEAR) { - newhdr.bytes_per_unit = 2; - newhdr.encoding = LINEAR; - err = conv.Convert(abp, newhdr); - if (!err) - abp->Reference(); - } else { - abp->Reference(); - } - } - - if (!err) { - // Process data through signal detection routine - bufsiz = (unsigned int) hdr.Time_to_Samples(len); - npts = bufsiz; - i = silence_detect((short *)abp->GetAddress(), &ep, - &npts, &valid, (SIL_STATE*)state); - abp->Dereference(); // XXX - temporary - if (i == SILENCE_ERR_BUFFER_TOO_SMALL) { - // If buffer too small, go on - err = AUDIO_SUCCESS; - } else if (i == SILENCE_ERR_REALLOC_FAILED) { - err = AUDIO_UNIXERROR; - } - - // Convert endpoints to AudioDetectPts - if (!err) { - // First, add byte offset to all 'times' - // Then, create entries for silence regions - for (i = 0; i < npts; i++) { - ep[i].ep_start += (int)offset; - apt.pos = start + - hdr.Samples_to_Time(ep[i].ep_start); - apt.type = DETECT_SILENCE; - if (err = aptr->appendpts(&apt, 1)) - goto error_ret; - - // If the end of silence is the same - // as the end of processed data, - // don't start sound yet - if (ep[i].ep_end == valid) - break; - ep[i].ep_end += (int)offset; - apt.pos = start + - hdr.Samples_to_Time(ep[i].ep_end); - apt.type = DETECT_SOUND; - if (err = aptr->appendpts(&apt, 1)) - goto error_ret; - } - offset += bufsiz; - } - } - } while (!err); - -no_data: - // Set end-of-file marker to latest position - if (!err || (err == AUDIO_EOF)) { - apt.type = DETECT_EOF; - apt.pos = from; - err = aptr->appendpts(&apt, 1); - } - -error_ret: - if (buf != NULL) - buf->Dereference(); - return (err); -} diff --git a/usr/src/cmd/audio/utilities/AudioDevice.cc b/usr/src/cmd/audio/utilities/AudioDevice.cc deleted file mode 100644 index a4b701bf00..0000000000 --- a/usr/src/cmd/audio/utilities/AudioDevice.cc +++ /dev/null @@ -1,1325 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <errno.h> -#include <string.h> -#include <math.h> -#include <unistd.h> -#include <stdlib.h> -#include <stropts.h> -#include <sys/ioctl.h> -#include <sys/stat.h> - -#include <AudioDebug.h> -#include <AudioDevice.h> - -#define irint(d) ((int)(d)) - -// class AudioDevice methods - - -// class AudioInfo Constructor -AudioInfo:: -AudioInfo() -{ - Clear(); -} - -// Reset the info structure -void AudioInfo:: -Clear() -{ - AUDIO_INITINFO(&info); -} - - -// Initialize default device access mode, used when no mode is supplied -const FileAccess AudioDevice::defmode = WriteOnly; - -// Default audio device and environment variable names -const char *AudioDevice::AUDIO_ENV = "AUDIODEV"; -const char *AudioDevice::AUDIO_DEV = "/dev/audio"; - - -// Constructor with optional path and mode arguments -AudioDevice:: -AudioDevice( - const char *path, // filename - const FileAccess acc): // access mode - AudioUnixfile(path, acc), - devtype(AudioDeviceUnknown) -{ -} - -// Destructor must call the local Close() routine -AudioDevice:: -~AudioDevice() -{ - // If the device was open, close it - if (opened()) { - (void) Close(); - } -} - -// Return TRUE if stream is open -Boolean AudioDevice:: -opened() const -{ - return (isfdset()); -} - -// Get the audio device type -AudioDeviceType AudioDevice:: -GetDeviceType() const -{ - return (devtype); -} - -// Get the device information structure -AudioError AudioDevice:: -GetState( - AudioInfo& info) const // info to set -{ - // Get the device information - if (ioctl(getfd(), AUDIO_GETINFO, &info) < 0) - return (RaiseError(AUDIO_UNIXERROR, Warning)); - return (AUDIO_SUCCESS); -} - -// Set the device information structure (and return it updated) -AudioError AudioDevice:: -SetState( - AudioInfo& info) // info to set -{ - int i; - AudioHdr hdr_local; - AudioError err; - - if (!opened()) - return (RaiseError(AUDIO_ERR_NOEFFECT, Warning)); - - // Set the device information - // Try a couple of times if interrupted by a signal - for (i = 0; i < 3; i++) { - if (ioctl(getfd(), AUDIO_SETINFO, &info) >= 0) { - // Save the new encoding - err = info_to_hdr(info->record, hdr_local); - if (!err) - readhdr = hdr_local; - return (err); - } - if (errno != EINTR) - break; - } - return (AUDIO_UNIXERROR); -} - -// Enable/disable SIGPOLL for the device -// The normal device receives signals only on i/o conditions -// For state change notification, open the control device -AudioError AudioDevice:: -SetSignal( - Boolean on) // True to enable -{ - int flag; - - // Flag of zero disables SIGPOLL - flag = 0; - if (on) { - // Enable signals for the accessed streams - if (GetAccess().Readable()) - flag |= S_INPUT; - if (GetAccess().Writeable()) - flag |= S_OUTPUT; - } - // Set the streams flag - if (ioctl(getfd(), I_SETSIG, flag) < 0) - return (RaiseError(AUDIO_UNIXERROR)); - return (AUDIO_SUCCESS); -} - -// Clear the cached read header -void AudioDevice:: -clearhdr() -{ - readhdr.Clear(); -} - -// Decode a device info structure into an audio file header -AudioError AudioDevice:: -info_to_hdr( - const AudioPRinfo& prinfo, // info structure to decode - AudioHdr& h) const // header to fill in -{ - AudioHdr hdr_local; // local copy of header - AudioError err; - - hdr_local.sample_rate = prinfo.sample_rate; - hdr_local.channels = prinfo.channels; - - switch (prinfo.encoding) { - case AUDIO_ENCODING_ULAW: - hdr_local.encoding = ULAW; - hdr_local.samples_per_unit = 1; - hdr_local.bytes_per_unit = prinfo.precision / 8; - break; - case AUDIO_ENCODING_ALAW: - hdr_local.encoding = ALAW; - hdr_local.samples_per_unit = 1; - hdr_local.bytes_per_unit = prinfo.precision / 8; - break; - case AUDIO_ENCODING_LINEAR: - hdr_local.encoding = LINEAR; - hdr_local.samples_per_unit = 1; - hdr_local.bytes_per_unit = prinfo.precision / 8; - break; - default: - return (RaiseError(AUDIO_ERR_ENCODING)); - } - - err = RaiseError(hdr_local.Validate()); - if (err == AUDIO_SUCCESS) - h = hdr_local; - return (err); -} - -// Decode an audio file header into a device info structure -AudioError AudioDevice:: -hdr_to_info( - const AudioHdr& h, // header to decode - AudioPRinfo& prinfo) const // info structure to fill in -{ - AudioInfo info; // local copy of info - AudioError err; - - // Validate header before converting - err = RaiseError(h.Validate()); - if (err != AUDIO_SUCCESS) - return (err); - - info->play.sample_rate = h.sample_rate; - info->play.channels = h.channels; - - switch (h.encoding) { - case ULAW: - info->play.encoding = AUDIO_ENCODING_ULAW; - info->play.precision = h.bytes_per_unit * 8; - break; - case ALAW: - info->play.encoding = AUDIO_ENCODING_ALAW; - info->play.precision = h.bytes_per_unit * 8; - break; - case LINEAR: - info->play.encoding = AUDIO_ENCODING_LINEAR; - info->play.precision = h.bytes_per_unit * 8; - break; - default: - return (RaiseError(AUDIO_ERR_ENCODING)); - } - - prinfo = info->play; - return (AUDIO_SUCCESS); -} - -// Figure out what kind of audio device is connected -// XXX - this should be replaced by a capabilities database lookup -void AudioDevice:: -decode_devtype() -{ -#ifdef MAX_AUDIO_DEV_LEN - struct audio_device adev; -#else /* 4.1.3 */ - int adev; -#endif /* 4.1.3 */ - -/* - * Spectrum 16, MultiSound and SB16 are all place holders for - * x86 devices. - */ - if (ioctl(getfd(), AUDIO_GETDEV, &adev) >= 0) { -#ifdef MAX_AUDIO_DEV_LEN - if (strcmp(adev.name, "SUNW,CS4231") == 0) - devtype = AudioDeviceCODEC; - else if (strcmp(adev.name, "SUNW,audiots") == 0) - devtype = AudioDeviceCODEC; - else if (strcmp(adev.name, "SUNW,am79c30") == 0) - devtype = AudioDeviceAMD; - else if (strcmp(adev.name, "SUNW,sbpro") == 0) - devtype = AudioDeviceSBPRO; - else if (strcmp(adev.name, "SUNW,spectrum") == 0) - devtype = AudioDeviceSPECTRUM; - else if (strcmp(adev.name, "SUNW,multisound") == 0) - devtype = AudioDeviceMULTISOUND; - else if (strcmp(adev.name, "SUNW,sb16") == 0) - devtype = AudioDeviceSB16; - else - devtype = AudioDeviceUnknown; -#else /* 4.1.3 */ - switch (adev) { - case AUDIO_DEV_AMD: - devtype = AudioDeviceAMD; - break; - default: - devtype = AudioDeviceUnknown; - break; - } -#endif /* 4.1.3 */ - } else { - // AUDIO_GETDEV not supported. Assume AMD. - devtype = AudioDeviceAMD; - } -} - -// Return TRUE if the sample rates are within a close tolerance (1%) -Boolean AudioDevice:: -rate_match( - unsigned int rate1, - unsigned int rate2) -{ - Double tol; - - tol = ((double)rate2 - (double)rate1) / (double)rate2; - if (fabs(tol) > .01) - return (FALSE); - return (TRUE); -} - -// Return TRUE if the device supports the audio format -// If the sample rate does not match, but is within tolerance, rewrite it. -// XXX - this should *really* be replaced by a capabilities database lookup -Boolean AudioDevice:: -CanSetHeader( - AudioHdr& h) -{ - if (RaiseError(h.Validate()) || !opened()) - return (FALSE); - - switch (devtype) { - default: // if unknown type, assume AMD - case AudioDeviceAMD: - if ((h.encoding != ULAW) && (h.encoding != ALAW)) - return (FALSE); - if (!rate_match(h.sample_rate, 8000) || (h.channels != 1)) - return (FALSE); - h.sample_rate = 8000; - break; - - case AudioDeviceCODEC: - if (h.channels > 2) - return (FALSE); - switch (h.encoding) { - case ULAW: - case ALAW: - case LINEAR: - break; - default: - return (FALSE); - } - if (rate_match(h.sample_rate, 5510)) { - h.sample_rate = 5510; - } else if (rate_match(h.sample_rate, 6620)) { - h.sample_rate = 6620; - } else if (rate_match(h.sample_rate, 8000)) { - h.sample_rate = 8000; - } else if (rate_match(h.sample_rate, 9600)) { - h.sample_rate = 9600; - } else if (rate_match(h.sample_rate, 11025)) { - h.sample_rate = 11025; - } else if (rate_match(h.sample_rate, 16000)) { - h.sample_rate = 16000; - } else if (rate_match(h.sample_rate, 18900)) { - h.sample_rate = 18900; - } else if (rate_match(h.sample_rate, 22050)) { - h.sample_rate = 22050; - } else if (rate_match(h.sample_rate, 27420)) { - h.sample_rate = 27420; - } else if (rate_match(h.sample_rate, 32000)) { - h.sample_rate = 32000; - } else if (rate_match(h.sample_rate, 33075)) { - h.sample_rate = 33075; - } else if (rate_match(h.sample_rate, 37800)) { - h.sample_rate = 37800; - } else if (rate_match(h.sample_rate, 44100)) { - h.sample_rate = 44100; - } else if (rate_match(h.sample_rate, 48000)) { - h.sample_rate = 48000; - } else { - return (FALSE); - } - break; - case AudioDeviceSBPRO: - if (h.encoding != ULAW) // For now only supports ULAW - return (FALSE); - if (h.channels > 2) - return (FALSE); - if (h.sample_rate < 4000 || h.sample_rate > 44100) - return (FALSE); - break; - case AudioDeviceSB16: - /* - * Place holders for x86 devices, these are treated as if they - * are equivelant to the SB16 for now. - */ - case AudioDeviceSPECTRUM: - case AudioDeviceMULTISOUND: - if (h.channels > 2) - return (FALSE); - switch (h.encoding) { - /* - * The SBPro driver does not do ALAW - */ - case ULAW: - break; - case LINEAR: - // We don't support 8bit linear as this should - // be unsigned linear and we have assumed signed all - // along. Must change this in XAL - if (h.bytes_per_unit != 2) // LINEAR must be 16 bit - return (FALSE); - break; - default: - return (FALSE); - } - // I don't know if this is correct - sdy check it out please - if (h.sample_rate < 4000 || h.sample_rate > 44100) - return (FALSE); - break; - } - return (TRUE); -} - -// Set input encoding -AudioError AudioDevice:: -SetReadHeader( - AudioHdr& h) // header (updated) -{ - AudioInfo info; - AudioError err; - - // Convert header to encoding fields - err = hdr_to_info(h, info->record); - if (err == AUDIO_SUCCESS) { - // Set the device encoding - err = SetState(info); - if (!err) - h = readhdr; - } - return (err); -} - -// Set output encoding -AudioError AudioDevice:: -SetWriteHeader( - AudioHdr& h) // header (updated) -{ - AudioInfo info; - AudioError err; - - // Convert header to encoding fields - err = hdr_to_info(h, info->play); - if (err == AUDIO_SUCCESS) { - // Set the device encoding - err = SetState(info); - if (err == AUDIO_SUCCESS) { - // Save (and return) the new encoding - err = info_to_hdr(info->play, h); - if (!err) - (void) AudioStream::updateheader(h); - } - } - return (err); -} - -// Get input encoding -AudioHdr AudioDevice:: -GetReadHeader() -{ - AudioInfo info; - AudioHdr h; - - // If the cached header is valid, use it. - // XXX - If a state change determines the encoding changed, we had - // XXX - better invalidate the cache and call this routine again. - if (readhdr.Validate() == AUDIO_SUCCESS) - return (readhdr); - - // Get the device state - if (GetState(info) == AUDIO_SUCCESS) { - (void) info_to_hdr(info->record, h); - readhdr = h; - } - return (h); -} - -// Get output encoding -AudioHdr AudioDevice:: -GetWriteHeader() -{ - AudioInfo info; - AudioHdr h; - - // Get the device state - if (GetState(info) == AUDIO_SUCCESS) { - (void) info_to_hdr(info->play, h); - (void) AudioStream::updateheader(h); - } - return (h); -} - -// SetHeader function sets the output encoding -AudioError AudioDevice:: -SetHeader( - const AudioHdr& h) // header -{ - AudioError err; - AudioHdr tmphdr; - - // Set the output header in the cached structure - err = AudioStream::updateheader(h); - if (!opened() || (err != AUDIO_SUCCESS)) { - if ((err == AUDIO_UNIXERROR) && (err.sys == EBUSY)) - err = AUDIO_ERR_FORMATLOCK; - return (err); - } - - // If the device is open, set the output header - return (SetWriteHeader(tmphdr = AudioStream::GetHeader())); -} - -// GetHeader returns the cached input encoding -AudioHdr AudioDevice:: -GetHeader() -{ - if (GetPlayOpen()) { - return (GetWriteHeader()); - } else { - return (GetReadHeader()); - } -} - -// Open an audio device for output -// Open the device and set the output encoding -AudioError AudioDevice:: -Create() -{ - AudioError err; - AudioHdr tmphdr; - - if (!hdrset()) - return (RaiseError(AUDIO_ERR_BADHDR)); - err = Open(); - if (err == AUDIO_SUCCESS) - err = SetWriteHeader(tmphdr = AudioStream::GetHeader()); - return (err); -} - -// Open an audio device -AudioError AudioDevice:: -Open() -{ - // If name was NULL, use default search path - return (OpenPath()); -} - -// Open an audio device, with a path environment as a fall-back -AudioError AudioDevice:: -OpenPath( - const char *path) -{ - char *str; - char *wrk; - char *component; - int openmode; - AudioError err; - - // Convert the open mode to an int argument for open() - openmode = GetAccess(); - - // Can't open if already opened or if mode not set - if ((openmode == -1) || opened()) - return (RaiseError(AUDIO_ERR_NOEFFECT, Warning)); - - // If non-blocking set, this counts for open(), too - if (!GetBlocking()) - openmode |= O_NONBLOCK; - - // Search path: - // 1) try name, if supplied: fail if no good - // 2) if no name, try to find 'path' in the environment: - // if not found, assume 'path' is the path string itself - // first try the path as a deivce name - // then, try every colon-separated path component in it - // 3) try "/dev/audio" - - if (strlen(GetName()) != 0) - return (RaiseError(tryopen(GetName(), openmode))); - - // Try path as environment variable name, else assume it is a path - str = (path == NULL) ? NULL : getenv(path); - if (str == NULL) - str = (char *)path; - - if (str != NULL) { - // Make a copy of the path, in case we have to parse it - wrk = new char[strlen(str) + 1]; - (void) strcpy(wrk, str); - str = wrk; - - // Try the whole string, then every component - for (component = str; component[0] != '\0'; ) { - err = tryopen(component, openmode); - switch (err) { - case AUDIO_SUCCESS: // found a device - case AUDIO_ERR_DEVICEBUSY: - delete wrk; - return (RaiseError(err)); - } - if (str == NULL) - break; - component = str; - str = strchr(str, ':'); - if (str != NULL) - *str++ = '\0'; - } - delete wrk; - } - return (RaiseError(tryopen(AUDIO_DEV, openmode))); -} - -// Attempt to open the audio device with the given name and mode -AudioError AudioDevice:: -tryopen( - const char *devname, - int openmode) -{ - struct stat st; - int desc; - AudioInfo info; - AudioError err; - - // If the name is changing, set the new one - if (devname != GetName()) - SetName(devname); - - // XXX - convert name to device name, using audio config file - - // Check the file. If non-existent, give up. - if (stat(devname, &st) < 0) { - return (AUDIO_UNIXERROR); - } - - // If not a character file, stop right there - if (!S_ISCHR(st.st_mode)) - return (AUDIO_ERR_NOTDEVICE); - - // Open the file and check that it's an audio file - desc = open(devname, openmode); - if (desc < 0) { - if (errno == EBUSY) { - return (AUDIO_ERR_DEVICEBUSY); - } else { - return (AUDIO_UNIXERROR); - } - } - - // Set the file descriptor (this marks the file open) - setfd(desc); - err = GetState(info); - if (err != AUDIO_SUCCESS) { - (void) close(desc); - setfd(-1); - return (err); - } - - // Get the device type - decode_devtype(); - - // Set up the cached versions of the current encoding format - if (GetAccess().Writeable()) - (void) GetWriteHeader(); - if (GetAccess().Readable()) - (void) GetReadHeader(); - - // Set the appropriate blocking/non-blocking mode - SetBlocking(GetBlocking()); - return (AUDIO_SUCCESS); -} - -// Read data from device into specified buffer. -// No data format translation takes place. -// Since there's no going back, the object's read position pointer is updated. -AudioError AudioDevice:: -ReadData( - void* buf, // destination buffer address - size_t& len, // buffer length (updated) - Double& pos) // start position (updated) -{ - AudioError err; - size_t svlen; - - svlen = len; - - // Call the real routine -tryagain: - len = svlen; - err = AudioUnixfile::ReadData(buf, len, pos); - - // XXX - Check for bug 1100839: short blocking reads - if (GetBlocking()) { - if (err == AUDIO_EOF) - goto tryagain; - if (!err && (len < svlen)) { - if (len == 0) { - AUDIO_DEBUG((1, - "AudioDevice: zero-length blocking read\n")); - goto tryagain; - } else { - AUDIO_DEBUG((1, - "AudioDevice: short blocking read: %d/%d\n", - len, svlen)); - } - } - } - - // Update the object's read position - if (!err) - (void) SetReadPosition(pos, Absolute); - - return (err); -} - -// Write data to device from specified buffer. -// No data format translation takes place. -// Since there's no going back, the object's write position pointer is updated. -AudioError AudioDevice:: -WriteData( - void* buf, // source buffer address - size_t& len, // buffer length (updated) - Double& pos) // start position (updated) -{ - AudioError err; - - // Call the real routine - err = AudioUnixfile::WriteData(buf, len, pos); - - // Update the object's write position - if (err == AUDIO_SUCCESS) - (void) SetWritePosition(pos, Absolute); - return (err); -} - -// Write eof sync flag -AudioError AudioDevice:: -WriteEof() -{ - Boolean EOFblock; - AudioError err; - - if (!opened()) - return (RaiseError(AUDIO_ERR_NOEFFECT, Warning)); - - // Make sure the device is set to blocking mode - if (!(EOFblock = GetBlocking())) - SetBlocking(TRUE); - - // A zero-length write represents an EOF marker - if (write(getfd(), NULL, 0) < 0) { - // A failed non-blocking request should never happen! - if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) { - err = AUDIO_ERR_NOEFFECT; - } else { - err = AUDIO_UNIXERROR; - } - } - // Restore blocking mode - if (!EOFblock) - SetBlocking(EOFblock); - return (RaiseError(err)); -} - -// Flush all queued input and output -AudioError AudioDevice:: -Flush( - const FileAccess which) -{ - int flag; - AudioInfo info; - Double pos; - - if (!opened()) - return (RaiseError(AUDIO_ERR_NOEFFECT, Warning)); - - flag = 0; - if (which.Writeable()) - flag |= FLUSHW; - if (which.Readable()) - flag |= FLUSHR; - - if (ioctl(getfd(), I_FLUSH, flag) < 0) - return (RaiseError(AUDIO_UNIXERROR)); - - if (which.Writeable()) { - // Back up the object's write position - if (!GetState(info)) { - pos = GetWriteHeader().Samples_to_Time( - info->play.samples); - (void) SetWritePosition(pos, Absolute); - } - } - return (AUDIO_SUCCESS); -} - -// Wait for output to drain -AudioError AudioDevice:: -DrainOutput() -{ - if (!opened()) - return (RaiseError(AUDIO_ERR_NOEFFECT, Warning)); - - while (ioctl(getfd(), AUDIO_DRAIN, 0) < 0) { - // If interrupted system call while fd is set blocking, retry - if ((errno == EINTR) && GetBlocking()) - continue; - return (RaiseError(AUDIO_UNIXERROR)); - } - return (AUDIO_SUCCESS); -} - -// Set the input/output pause flags on the device -AudioError AudioDevice:: -Pause( - const FileAccess which) -{ - AudioInfo info; - - if (which.Writeable()) - info->play.pause = TRUE; - if (which.Readable()) - info->record.pause = TRUE; - return (SetState(info)); -} - -// Resume input/output on the device -AudioError AudioDevice:: -Resume( - const FileAccess which) -{ - AudioInfo info; - - if (which.Writeable()) - info->play.pause = FALSE; - if (which.Readable()) - info->record.pause = FALSE; - return (SetState(info)); -} - -// Set play eof count -AudioError AudioDevice:: -SetPlayEof( - unsigned& cnt) -{ - AudioInfo info; - AudioError err; - - info->play.eof = cnt; - err = SetState(info); - if (err == AUDIO_SUCCESS) - cnt = info->play.eof; - return (err); -} - -// Set play sample count -AudioError AudioDevice:: -SetPlaySamples( - unsigned& cnt) -{ - AudioInfo info; - AudioError err; - - info->play.samples = cnt; - err = SetState(info); - if (err == AUDIO_SUCCESS) - cnt = info->play.samples; - return (err); -} - -// Set record sample count -AudioError AudioDevice:: -SetRecSamples( - unsigned& cnt) -{ - AudioInfo info; - AudioError err; - - info->record.samples = cnt; - err = SetState(info); - if (err == AUDIO_SUCCESS) - cnt = info->record.samples; - return (err); -} - -// Set play error flag, returning old state -AudioError AudioDevice:: -SetPlayError( - Boolean& flag) -{ - AudioInfo info; - AudioError err; - - info->play.error = flag; - err = SetState(info); - if (err == AUDIO_SUCCESS) - flag = info->play.error; - return (err); -} - -// Set record error flag, returning old state -AudioError AudioDevice:: -SetRecError( - Boolean& flag) -{ - AudioInfo info; - AudioError err; - - info->record.error = flag; - err = SetState(info); - if (err == AUDIO_SUCCESS) - flag = info->record.error; - return (err); -} - -// Set record input buffer delay, returning new value -AudioError AudioDevice:: -SetRecDelay( - Double& delay) -{ - unsigned int d; - AudioInfo info; - AudioError err; - - d = (unsigned int) GetHeader().Time_to_Bytes(delay); - info->record.buffer_size = d; - err = SetState(info); - if (err != AUDIO_SUCCESS) - GetState(info); - d = info->record.buffer_size; - delay = GetHeader().Bytes_to_Time(d); - return (err); -} - -// Set Play-Waiting flag -AudioError AudioDevice:: -SetPlayWaiting() -{ - AudioInfo info; - - info->play.waiting = TRUE; - return (SetState(info)); -} - -// Set Record-Waiting flag -AudioError AudioDevice:: -SetRecWaiting() -{ - AudioInfo info; - - info->record.waiting = TRUE; - return (SetState(info)); -} - - -// Scale an integer gain level to floating point (0. to 1.) -Double AudioDevice:: -scale_gain( - unsigned int val) // gain value -{ - return ((Double)(val - AUDIO_MIN_GAIN) / - (Double)(AUDIO_MAX_GAIN - AUDIO_MIN_GAIN)); -} - -// Rescale a floating point level to the correct gain -unsigned int AudioDevice:: -unscale_gain( - Double val) // floating point value -{ - return (irint((Double)(AUDIO_MAX_GAIN - AUDIO_MIN_GAIN) * val) - + AUDIO_MIN_GAIN); -} - -// Scale an integer balance level to floating point (-1. to 1.) -Double AudioDevice:: -scale_balance( - unsigned int val) // balance value -{ - return (((Double)(val - AUDIO_LEFT_BALANCE) / - (Double)(AUDIO_MID_BALANCE - AUDIO_LEFT_BALANCE)) - 1.); -} - -// Rescale a floating point level to the correct balance -unsigned int AudioDevice:: -unscale_balance( - Double val) // floating point value -{ - return (irint((val + 1.) * - (Double)(AUDIO_MID_BALANCE - AUDIO_LEFT_BALANCE)) - + AUDIO_LEFT_BALANCE); -} - -// Raise or lower a gain field by one notch -// This is useful for fields that don't have an increment/decrement ioctl -AudioError AudioDevice:: -incr_volume( - Boolean up, // true to raise, false to lower - AudioInfo& info, // info structure - unsigned int *field) // ptr to gain field in info -{ - int incr; - unsigned int oldval; - int val; - AudioError err; - - // Get the starting point - err = GetState(info); - if (err != AUDIO_SUCCESS) - return (err); - oldval = *field; // Save starting point - - // If we're already at the min or max, do nothing - if (up) { - if (oldval == AUDIO_MAX_GAIN) - return (AUDIO_SUCCESS); - incr = 1; - } else { - if (oldval == AUDIO_MIN_GAIN) - return (AUDIO_SUCCESS); - incr = -1; - } - - // Keep trying until you hit min/max or the value actually changes - for (val = (int)oldval + incr; - (val >= AUDIO_MIN_GAIN) && (val <= AUDIO_MAX_GAIN); - val += incr) { - info.Clear(); - *field = (unsigned int) val; - err = SetState(info); - if (err != AUDIO_SUCCESS) - return (err); - if (*field != oldval) - break; // the value changed! - } - return (AUDIO_SUCCESS); -} - -// Set Play volume -AudioError AudioDevice:: -SetPlayVolume( - Double& vol) -{ - AudioError err; - AudioInfo info; - - info->play.gain = unscale_gain(vol); - err = SetState(info); - vol = scale_gain(info->play.gain); - return (err); -} - -// Raise volume a notch -AudioError AudioDevice:: -PlayVolumeUp() -{ - AudioInfo info; - - return (incr_volume(TRUE, info, &info->play.gain)); -} - -// Lower volume a notch -AudioError AudioDevice:: -PlayVolumeDown() -{ - AudioInfo info; - - return (incr_volume(FALSE, info, &info->play.gain)); -} - -// Record volume -AudioError AudioDevice:: -SetRecVolume( - Double& vol) -{ - AudioError err; - AudioInfo info; - - info->record.gain = unscale_gain(vol); - err = SetState(info); - vol = scale_gain(info->record.gain); - return (err); -} - -// Raise volume a notch -AudioError AudioDevice:: -RecVolumeUp() -{ - AudioInfo info; - - return (incr_volume(TRUE, info, &info->record.gain)); -} - -// Lower volume a notch -AudioError AudioDevice:: -RecVolumeDown() -{ - AudioInfo info; - - return (incr_volume(FALSE, info, &info->record.gain)); -} - -// Monitor volume -AudioError AudioDevice:: -SetMonVolume( - Double& vol) -{ - AudioError err; - AudioInfo info; - - info->monitor_gain = unscale_gain(vol); - err = SetState(info); - vol = scale_gain(info->monitor_gain); - return (err); -} - -// Raise volume a notch -AudioError AudioDevice:: -MonVolumeUp() -{ - AudioInfo info; - - return (incr_volume(TRUE, info, &info->monitor_gain)); -} - -// Lower volume a notch -AudioError AudioDevice:: -MonVolumeDown() -{ - AudioInfo info; - - return (incr_volume(FALSE, info, &info->monitor_gain)); -} - - -// Set balance -AudioError AudioDevice:: -SetPlayBalance( - Double& bal) -{ - AudioError err; - AudioInfo info; - - info->play.balance = unscale_balance(bal); - err = SetState(info); - bal = scale_balance(info->play.balance); - return (err); -} - -// Set balance -AudioError AudioDevice:: -SetRecBalance( - Double& bal) -{ - AudioError err; - AudioInfo info; - - info->record.balance = unscale_balance(bal); - err = SetState(info); - bal = scale_balance(info->record.balance); - return (err); -} - -// Get Play volume -Double AudioDevice:: -GetPlayVolume( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - (void) GetState(info); - return (scale_gain(info->play.gain)); - } else { - return (scale_gain((*uinfo)->play.gain)); - } -} - -// Get Record volume -Double AudioDevice:: -GetRecVolume( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - (void) GetState(info); - return (scale_gain(info->record.gain)); - } else { - return (scale_gain((*uinfo)->record.gain)); - } -} - -// Get Monitor volume -Double AudioDevice:: -GetMonVolume( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - (void) GetState(info); - return (scale_gain(info->monitor_gain)); - } else { - return (scale_gain((*uinfo)->monitor_gain)); - } -} - -// Get Play balance -Double AudioDevice:: -GetPlayBalance( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - (void) GetState(info); - return (scale_balance(info->play.balance)); - } else { - return (scale_balance((*uinfo)->play.balance)); - } -} - -// Get Record balance -Double AudioDevice:: -GetRecBalance( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - (void) GetState(info); - return (scale_balance(info->record.balance)); - } else { - return (scale_balance((*uinfo)->record.balance)); - } -} - -// Get play sample count -unsigned AudioDevice:: -GetPlaySamples( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - if (GetState(info)) - return (AUDIO_UNKNOWN_SIZE); - return (info->play.samples); - } else { - return ((*uinfo)->play.samples); - } -} - -// Get record sample count -unsigned AudioDevice:: -GetRecSamples( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - if (GetState(info)) - return (AUDIO_UNKNOWN_SIZE); - return (info->record.samples); - } else { - return ((*uinfo)->record.samples); - } -} - -// Get Play-Open flag -Boolean AudioDevice:: -GetPlayOpen( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - if (!GetState(info) && info->play.open) - return (TRUE); - } else { - if ((*uinfo)->play.open) - return (TRUE); - } - return (FALSE); -} - -// Get Record-Open flag -Boolean AudioDevice:: -GetRecOpen( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - if (!GetState(info) && info->record.open) - return (TRUE); - } else { - if ((*uinfo)->record.open) - return (TRUE); - } - return (FALSE); -} - -// Get Play-Waiting flag -Boolean AudioDevice:: -GetPlayWaiting( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - if (!GetState(info) && info->play.waiting) - return (TRUE); - } else { - if ((*uinfo)->play.waiting) - return (TRUE); - } - return (FALSE); -} - -// Get Record-Waiting flag -Boolean AudioDevice:: -GetRecWaiting( - AudioInfo* uinfo) -{ - if (uinfo == 0) { - AudioInfo info; - if (!GetState(info) && info->record.waiting) - return (TRUE); - } else { - if ((*uinfo)->record.waiting) - return (TRUE); - } - return (FALSE); -} diff --git a/usr/src/cmd/audio/utilities/AudioDevicectl.cc b/usr/src/cmd/audio/utilities/AudioDevicectl.cc deleted file mode 100644 index 2b23e13134..0000000000 --- a/usr/src/cmd/audio/utilities/AudioDevicectl.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1992-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <errno.h> -#include <string.h> -#include <unistd.h> -#include <stropts.h> -#include <sys/ioctl.h> -#include <sys/stat.h> - -#include <AudioDevicectl.h> - -// class AudioDevicectl methods - - -// Constructor with optional path argument -AudioDevicectl:: -AudioDevicectl( - const char *path): // filename - AudioDevice(path, (FileAccess)ReadWrite) -{ -} - - -// Enable/disable SIGPOLL on state changes -AudioError AudioDevicectl:: -SetSignal( - Boolean on) // True to enable -{ - // Set the streams flag - if (ioctl(getfd(), I_SETSIG, (on ? S_MSG : 0)) < 0) - return (RaiseError(AUDIO_UNIXERROR)); - return (AUDIO_SUCCESS); -} - -// Get input encoding -AudioHdr AudioDevicectl:: -GetReadHeader() -{ - clearhdr(); - return (AudioDevice::GetReadHeader()); -} - - -// Open an audio control device with the given name and mode -AudioError AudioDevicectl:: -tryopen( - const char *devname, - int) -{ - struct stat st; - char *ctlname; - int desc; - AudioInfo info; - AudioError err; - - // If the name is changing, set the new one - if (devname != GetName()) - SetName(devname); - - // XXX - convert name to device name, using audio config file - // For now, append "ctl" to the device name - ctlname = new char[strlen(devname) + 4]; - (void) strcpy(ctlname, devname); - (void) strcat(ctlname, "ctl"); - - // Check and open the control device. - err = AUDIO_SUCCESS; - if (stat(ctlname, &st) < 0) { - err = AUDIO_UNIXERROR; - } else if (!S_ISCHR(st.st_mode)) { - err = AUDIO_ERR_NOTDEVICE; - } else if ((desc = open(ctlname, O_RDWR)) < 0) { - err = AUDIO_UNIXERROR; - } - delete ctlname; - if (err) - return (err); - - // Set the file descriptor (this marks the file open) - setfd(desc); - - err = GetState(info); - if (err != AUDIO_SUCCESS) { - (void) close(desc); - setfd(-1); - return (err); - } - // Get the device type - decode_devtype(); - - return (AUDIO_SUCCESS); -} diff --git a/usr/src/cmd/audio/utilities/Makefile b/usr/src/cmd/audio/utilities/Makefile index ffda9c05ee..2b6097c0e6 100644 --- a/usr/src/cmd/audio/utilities/Makefile +++ b/usr/src/cmd/audio/utilities/Makefile @@ -2,9 +2,8 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ # CDDL HEADER END # # -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #pragma ident "%Z%%M% %I% %E% SMI" @@ -56,9 +55,6 @@ LIBCCSRCS = Audio.cc \ AudioBuffer.cc \ AudioCopy.cc \ AudioDebug.cc \ - AudioDetect.cc \ - AudioDevice.cc \ - AudioDevicectl.cc \ AudioError.cc \ AudioExtent.cc \ AudioFile.cc \ diff --git a/usr/src/cmd/devfsadm/audio_link.c b/usr/src/cmd/devfsadm/audio_link.c index 75568ff46e..6b3e08a66f 100644 --- a/usr/src/cmd/devfsadm/audio_link.c +++ b/usr/src/cmd/devfsadm/audio_link.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -90,7 +90,7 @@ minor_init(void) { if (0 != regcomp(&isdn_re, ISDN_RE, REG_EXTENDED)) { devfsadm_errprint("SUNW_audio_link: minor_init: regular " - "expression bad: '%s'\n", ISDN_RE); + "expression bad: '%s'\n", ISDN_RE); return (DEVFSADM_FAILURE); } else { return (DEVFSADM_SUCCESS); @@ -172,15 +172,13 @@ audio_process(di_minor_t minor, di_node_t node) /* if this is a minor node, tack on the correct suffix */ au_mn = strchr(mn, ','); - if (strcmp(++au_mn, "audio") != 0 && - strcmp(au_mn, "sbpro") != 0) { + if (strcmp(++au_mn, "audio") != 0) { /* - * audioctl/sbproctl are special cases. They are handled - * by stripping off the audio/sbpro from the node name + * audioctl is a special case. It is handled + * by stripping off the audio from the node name */ - if (strcmp(au_mn, "audioctl") == 0 || - strcmp(au_mn, "sbproctl") == 0) + if (strcmp(au_mn, "audioctl") == 0) au_mn = strstr(au_mn, "ctl"); (void) strcat(path, au_mn); } @@ -208,7 +206,7 @@ audio_process(di_minor_t minor, di_node_t node) if (path[0] == '\0') { devfsadm_errprint("SUNW_audio_link: audio_process: can't find" - " match for'%s'\n", mn); + " match for'%s'\n", mn); return (DEVFSADM_CONTINUE); } @@ -239,7 +237,7 @@ check_audio_link(char *secondary_link, const char *primary_link_format) (void) sprintf(primary_link, primary_link_format, i); if (devfsadm_link_valid(primary_link) == DEVFSADM_TRUE) { (void) devfsadm_secondary_link(secondary_link, - primary_link, flags); + primary_link, flags); break; } } diff --git a/usr/src/pkgdefs/SUNWpsdir/postinstall b/usr/src/pkgdefs/SUNWpsdir/postinstall index 181d393652..3f02b15a96 100644 --- a/usr/src/pkgdefs/SUNWpsdir/postinstall +++ b/usr/src/pkgdefs/SUNWpsdir/postinstall @@ -2,9 +2,8 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. @@ -20,8 +19,9 @@ # CDDL HEADER END # # -# Copyright (c) 1997 Sun Microsystems, Inc. -# All Rights Reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# # # postinstall script for SUNWpsdir package. @@ -185,7 +185,6 @@ drvclasses_updates() case "${ARCH}" in i386) drvclasses_updates - check_add_drv -b "${BASEDIR}" -i '"mwss"' sbpro check_add_drv -b "${BASEDIR}" pci-ide check_add_drv -b "${BASEDIR}" -i '"ide"' ata ;; diff --git a/usr/src/pkgdefs/SUNWpsdir/postremove b/usr/src/pkgdefs/SUNWpsdir/postremove index 7dfa90f9ca..c2445d6cfe 100644 --- a/usr/src/pkgdefs/SUNWpsdir/postremove +++ b/usr/src/pkgdefs/SUNWpsdir/postremove @@ -2,9 +2,8 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. @@ -22,8 +21,8 @@ # # postremove script for SUNWpsdir package. # -# Copyright (c) 1997 by Sun Microsystems, Inc. -# All Rights Reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" # @@ -35,7 +34,6 @@ # Platform-specific drivers case "${ARCH}" in i386) - rem_drv -b "${BASEDIR}" sbpro rem_drv -b "${BASEDIR}" ata rem_drv -b "${BASEDIR}" pci-ide ;; diff --git a/usr/src/pkgdefs/SUNWpsdir/preinstall b/usr/src/pkgdefs/SUNWpsdir/preinstall deleted file mode 100644 index 8e19a65317..0000000000 --- a/usr/src/pkgdefs/SUNWpsdir/preinstall +++ /dev/null @@ -1,40 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 1995 Sun Microsystems, Inc. -# All Rights Reserved. -# -# preinstall script for SUNWpsdir package. -# -#ident "%Z%%M% %I% %E% SMI" -# - -# -# If the file exists on the system in it's pre-KBI location, move it -# to the post-KBI location so that upgrade will work. -# -if [ -f ${BASEDIR}/kernel/drv/sbpro.conf ]; then - mv ${BASEDIR}/kernel/drv/sbpro.conf \ - ${BASEDIR}/platform/i86pc/kernel/drv -fi - -exit 0 diff --git a/usr/src/pkgdefs/SUNWpsdir/prototype_i386 b/usr/src/pkgdefs/SUNWpsdir/prototype_i386 index 4501487d88..e8d6e7286e 100644 --- a/usr/src/pkgdefs/SUNWpsdir/prototype_i386 +++ b/usr/src/pkgdefs/SUNWpsdir/prototype_i386 @@ -19,7 +19,7 @@ # CDDL HEADER END # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -43,7 +43,6 @@ i i.ataconf i pkginfo i postinstall i postremove -i preinstall # # Path names are relative to the prototype root directory # @@ -56,8 +55,6 @@ f none kernel/drv/ata 755 root sys e ataconf kernel/drv/ata.conf 644 root sys f none kernel/drv/mscsi 755 root sys f none kernel/drv/mscsi.conf 644 root sys -f none kernel/drv/sbpro 755 root sys -f none kernel/drv/sbpro.conf 644 root sys d none kernel/drv/amd64 755 root sys f none kernel/drv/amd64/ata 755 root sys diff --git a/usr/src/pkgdefs/SUNWpsh/prototype_i386 b/usr/src/pkgdefs/SUNWpsh/prototype_i386 index 6c78b812e5..db14530ace 100644 --- a/usr/src/pkgdefs/SUNWpsh/prototype_i386 +++ b/usr/src/pkgdefs/SUNWpsh/prototype_i386 @@ -18,7 +18,7 @@ # # CDDL HEADER END # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" @@ -70,5 +70,4 @@ f none usr/include/sys/fdmedia.h 644 root bin f none usr/include/sys/mii.h 644 root bin f none usr/include/sys/miipriv.h 644 root bin f none usr/include/sys/mse.h 644 root bin -f none usr/include/sys/sbpro.h 644 root bin f none usr/include/sys/vuidmice.h 644 root bin diff --git a/usr/src/pkgdefs/common_files/i.minorperm_i386 b/usr/src/pkgdefs/common_files/i.minorperm_i386 index e7b002bf05..1e9533a4eb 100644 --- a/usr/src/pkgdefs/common_files/i.minorperm_i386 +++ b/usr/src/pkgdefs/common_files/i.minorperm_i386 @@ -69,8 +69,6 @@ make_chattr_list() cat > /tmp/chattr.$$ << EOF vol:volctl 0600 root sys 0666 root sys /dev/volctl clone:llc1 0600 root sys 0666 root sys /dev/llc1 -clone:sound,sbpro 0666 root sys 0600 root sys /dev/sound/* -sbpro:* 0666 root sys 0600 root sys /dev/sound/* log:conslog 0620 root sys 0666 root sys /dev/conslog sy:tty 0666 root sys 0666 root tty /dev/tty icmp:icmp 0600 root sys 0666 root sys /dev/rawip @@ -179,7 +177,9 @@ clone:ipsecesp clone:keysock clone:smc clone:tr +clone:sbpro elx:* +sbpro:* win:* cmtp:* profile:profile diff --git a/usr/src/pkgdefs/common_files/i.nametomajor b/usr/src/pkgdefs/common_files/i.nametomajor index 000093b23e..12cb51d1aa 100644 --- a/usr/src/pkgdefs/common_files/i.nametomajor +++ b/usr/src/pkgdefs/common_files/i.nametomajor @@ -21,7 +21,7 @@ # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" @@ -156,6 +156,7 @@ obsolete_i386() obs["profile"] = 1; obs["riles"] = 1; obs["rip"] = 1; + obs["sbpro"] = 1; obs["smartii"] = 1; obs["smc"] = 1; obs["smce"] = 1; diff --git a/usr/src/tools/scripts/bfu.sh b/usr/src/tools/scripts/bfu.sh index 746119681d..9e050d4488 100644 --- a/usr/src/tools/scripts/bfu.sh +++ b/usr/src/tools/scripts/bfu.sh @@ -6756,6 +6756,17 @@ mondo_loop() { fi # + # Remove EOF sbpro driver and supporting header file + # (Note that .conf file may also appear in /platform) + # + if [ $target_isa = i386 ]; then + rm -f $root/kernel/drv/sbpro + rm -f $root/kernel/drv/sbpro.conf + rm -f $root/platform/i86pc/kernel/drv/sbpro.conf + rm -f $usr/include/sys/sbpro.h + fi + + # # Diskless clients have already extracted /usr so don't delete this # Non-global zones never extracts /usr so don't delete these # diff --git a/usr/src/tools/scripts/bindrop.sh b/usr/src/tools/scripts/bindrop.sh index a94d86251a..511dbc7697 100644 --- a/usr/src/tools/scripts/bindrop.sh +++ b/usr/src/tools/scripts/bindrop.sh @@ -195,8 +195,6 @@ delete="$delete kernel/drv/ifp.conf kernel/drv/pcn kernel/drv/pcn.conf - kernel/drv/sbpro - kernel/drv/sbpro.conf kernel/drv/sparcv9/audioens kernel/drv/sparcv9/ifp kernel/drv/sparcv9/isp @@ -218,7 +216,6 @@ delete="$delete usr/include/smartcard/ usr/include/sys/audio/audioens.h usr/include/sys/phx.h - usr/include/sys/sbpro.h usr/include/sys/scsi/adapters/ifpcmd.h usr/include/sys/scsi/adapters/ifpio.h usr/include/sys/scsi/adapters/ifpmail.h diff --git a/usr/src/uts/intel/Makefile.intel.shared b/usr/src/uts/intel/Makefile.intel.shared index bd3095e4cf..552fd26a4d 100644 --- a/usr/src/uts/intel/Makefile.intel.shared +++ b/usr/src/uts/intel/Makefile.intel.shared @@ -348,7 +348,6 @@ $(CLOSED_BUILD)CLOSED_DRV_KMODS += mpt $(CLOSED_BUILD)CLOSED_DRV_KMODS_32 += ncrs $(CLOSED_BUILD)CLOSED_DRV_KMODS += pcn $(CLOSED_BUILD)CLOSED_DRV_KMODS += rtls -$(CLOSED_BUILD)CLOSED_DRV_KMODS_32 += sbpro $(CLOSED_BUILD)CLOSED_DRV_KMODS += atiatom # diff --git a/usr/src/uts/intel/os/minor_perm b/usr/src/uts/intel/os/minor_perm index fdc12ce007..352cb1d132 100644 --- a/usr/src/uts/intel/os/minor_perm +++ b/usr/src/uts/intel/os/minor_perm @@ -22,7 +22,6 @@ clone:llc1 0666 root sys clone:loop 0666 root sys clone:ptmx 0666 root sys rts:rts 0666 root sys -clone:sound,sbpro 0600 root sys tcp:tcp 0666 root sys tcp6:tcp6 0666 root sys clone:ticlts 0666 root sys @@ -73,7 +72,6 @@ sad:user 0666 root sys sgen:* 0600 root sys cmdk:* 0640 root sys st:* 0666 root sys -sbpro:* 0600 root sys sdt:sdt 0644 root sys sy:tty 0666 root tty sysmsg:msglog 0600 root sys diff --git a/usr/src/uts/intel/os/name_to_major b/usr/src/uts/intel/os/name_to_major index 96e4046eb9..1077fee3c7 100644 --- a/usr/src/uts/intel/os/name_to_major +++ b/usr/src/uts/intel/os/name_to_major @@ -53,7 +53,6 @@ ata 112 logi 114 msm 115 mouse8042 116 -sbpro 118 isa 120 eisa 121 vdi 123 diff --git a/usr/src/uts/intel/sys/Makefile b/usr/src/uts/intel/sys/Makefile index 0777bf72ec..07a709ba57 100644 --- a/usr/src/uts/intel/sys/Makefile +++ b/usr/src/uts/intel/sys/Makefile @@ -96,8 +96,7 @@ HDRS = \ xen_errno.h CLOSEDHDRS = \ - memtest.h \ - sbpro.h + memtest.h SUBHDRS = \ dktp/mscsi.h |