1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1992-2002 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _MULTIMEDIA_AUDIO_H 28*7c478bd9Sstevel@tonic-gate #define _MULTIMEDIA_AUDIO_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <AudioTypes.h> 33*7c478bd9Sstevel@tonic-gate #include <AudioError.h> 34*7c478bd9Sstevel@tonic-gate #include <AudioHdr.h> 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate // Error-handling function declaration 41*7c478bd9Sstevel@tonic-gate class Audio; 42*7c478bd9Sstevel@tonic-gate typedef Boolean (*AudioErrfunc)(const Audio*, AudioError, AudioSeverity, 43*7c478bd9Sstevel@tonic-gate char *); 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate // Data transfer subcodes. 47*7c478bd9Sstevel@tonic-gate // Returned from ReadData(), WriteData(), AsyncCopy(), Copy() in err.sys 48*7c478bd9Sstevel@tonic-gate enum AudioCopyFlag { 49*7c478bd9Sstevel@tonic-gate AUDIO_COPY_SHORT_INPUT = 100, // AUDIO_SUCCESS: input would block 50*7c478bd9Sstevel@tonic-gate AUDIO_COPY_ZERO_LIMIT = 101, // AUDIO_SUCCESS: length was zero 51*7c478bd9Sstevel@tonic-gate AUDIO_COPY_SHORT_OUTPUT = 102, // AUDIO_SUCCESS: only partial output 52*7c478bd9Sstevel@tonic-gate AUDIO_COPY_INPUT_EOF = 103, // AUDIO_EOF: eof on input 53*7c478bd9Sstevel@tonic-gate AUDIO_COPY_OUTPUT_EOF = 104 // AUDIO_EOF: eof on output 54*7c478bd9Sstevel@tonic-gate }; 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate // This is the abstract base class from which all audio data types derive. 59*7c478bd9Sstevel@tonic-gate // It is invalid to create an object of type Audio. 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate class Audio { 62*7c478bd9Sstevel@tonic-gate private: 63*7c478bd9Sstevel@tonic-gate static int idctr; // id seed value 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate int id; // object id number 66*7c478bd9Sstevel@tonic-gate int refcnt; // reference count 67*7c478bd9Sstevel@tonic-gate char *name; // name 68*7c478bd9Sstevel@tonic-gate Double readpos; // current read position ptr 69*7c478bd9Sstevel@tonic-gate Double writepos; // current write position ptr 70*7c478bd9Sstevel@tonic-gate AudioErrfunc errorfunc; // address of error function 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate protected: 73*7c478bd9Sstevel@tonic-gate void SetName(const char *str); // Set name string 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate // Set position 76*7c478bd9Sstevel@tonic-gate Double setpos( 77*7c478bd9Sstevel@tonic-gate Double& pos, // position field to update 78*7c478bd9Sstevel@tonic-gate Double newpos, // new position 79*7c478bd9Sstevel@tonic-gate Whence w = Absolute); // Absolute || Relative 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate // XXX - should these be protected? 82*7c478bd9Sstevel@tonic-gate public: 83*7c478bd9Sstevel@tonic-gate int getid() const; // Get id value 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate // Raise error code 86*7c478bd9Sstevel@tonic-gate virtual AudioError RaiseError( 87*7c478bd9Sstevel@tonic-gate AudioError code, // error code 88*7c478bd9Sstevel@tonic-gate AudioSeverity sev = Error, // error severity 89*7c478bd9Sstevel@tonic-gate char *msg = '\0') const; // error message 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate // Raise error msg 92*7c478bd9Sstevel@tonic-gate virtual void PrintMsg( 93*7c478bd9Sstevel@tonic-gate char *msg, // error code 94*7c478bd9Sstevel@tonic-gate AudioSeverity sev = Message) const; // error severity 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate public: 97*7c478bd9Sstevel@tonic-gate Audio(const char *str = ""); // Constructor 98*7c478bd9Sstevel@tonic-gate virtual ~Audio(); // Destructor 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate void Reference(); // Increment ref count 101*7c478bd9Sstevel@tonic-gate void Dereference(); // Decrement ref count 102*7c478bd9Sstevel@tonic-gate Boolean isReferenced() const; // TRUE if referenced 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate virtual char *GetName() const; // Get name string 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate // Set user error func 107*7c478bd9Sstevel@tonic-gate virtual void SetErrorFunction( 108*7c478bd9Sstevel@tonic-gate AudioErrfunc func); // return TRUE if non-fatal 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate virtual Double ReadPosition() const; // Get read position 111*7c478bd9Sstevel@tonic-gate virtual Double WritePosition() const; // Get write position 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate // Set read position 114*7c478bd9Sstevel@tonic-gate virtual Double SetReadPosition( 115*7c478bd9Sstevel@tonic-gate Double pos, // new position 116*7c478bd9Sstevel@tonic-gate Whence w = Absolute); // Absolute || Relative 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate // Set write position 119*7c478bd9Sstevel@tonic-gate virtual Double SetWritePosition( 120*7c478bd9Sstevel@tonic-gate Double pos, // new position 121*7c478bd9Sstevel@tonic-gate Whence w = Absolute); // Absolute || Relative 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate // Read from current pos 124*7c478bd9Sstevel@tonic-gate virtual AudioError Read( 125*7c478bd9Sstevel@tonic-gate void* buf, // buffer to fill 126*7c478bd9Sstevel@tonic-gate size_t& len); // buffer length (updated) 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate // Write to current pos 129*7c478bd9Sstevel@tonic-gate virtual AudioError Write( 130*7c478bd9Sstevel@tonic-gate void* buf, // buffer to copy 131*7c478bd9Sstevel@tonic-gate size_t& len); // buffer length (updated) 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate // XXX - no Append() method for now because of name clashes 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate // methods specialized by inherited classes 136*7c478bd9Sstevel@tonic-gate virtual AudioHdr GetHeader() = 0; // Get header 137*7c478bd9Sstevel@tonic-gate virtual AudioHdr GetDHeader(Double); // Get header at pos 138*7c478bd9Sstevel@tonic-gate virtual Double GetLength() const = 0; // Get length, in secs 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate // Read from position 141*7c478bd9Sstevel@tonic-gate virtual AudioError ReadData( 142*7c478bd9Sstevel@tonic-gate void* buf, // buffer to fill 143*7c478bd9Sstevel@tonic-gate size_t& len, // buffer length (updated) 144*7c478bd9Sstevel@tonic-gate Double& pos) = 0; // start position (updated) 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate // Write at position 147*7c478bd9Sstevel@tonic-gate virtual AudioError WriteData( 148*7c478bd9Sstevel@tonic-gate void* buf, // buffer to copy 149*7c478bd9Sstevel@tonic-gate size_t& len, // buffer length (updated) 150*7c478bd9Sstevel@tonic-gate Double& pos) = 0; // start position (updated) 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate // Write and extend 153*7c478bd9Sstevel@tonic-gate virtual AudioError AppendData( 154*7c478bd9Sstevel@tonic-gate void* buf, // buffer to copy 155*7c478bd9Sstevel@tonic-gate size_t& len, // buffer length (updated) 156*7c478bd9Sstevel@tonic-gate Double& pos); // start position (updated) 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate // copy to another audio obj. 159*7c478bd9Sstevel@tonic-gate virtual AudioError Copy( 160*7c478bd9Sstevel@tonic-gate Audio* ap); // dest audio object 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate // copy to another audio obj. 163*7c478bd9Sstevel@tonic-gate virtual AudioError Copy( 164*7c478bd9Sstevel@tonic-gate Audio* ap, // dest audio object 165*7c478bd9Sstevel@tonic-gate Double& frompos, 166*7c478bd9Sstevel@tonic-gate Double& topos, 167*7c478bd9Sstevel@tonic-gate Double& limit); 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate // copy to another audio obj. 170*7c478bd9Sstevel@tonic-gate virtual AudioError AsyncCopy( 171*7c478bd9Sstevel@tonic-gate Audio* ap, // dest audio object 172*7c478bd9Sstevel@tonic-gate Double& frompos, 173*7c478bd9Sstevel@tonic-gate Double& topos, 174*7c478bd9Sstevel@tonic-gate Double& limit); 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate // Define default classification routines 177*7c478bd9Sstevel@tonic-gate // The appropriate routine should be specialized by each leaf class. isFile()178*7c478bd9Sstevel@tonic-gate virtual Boolean isFile() const { return (FALSE); } isDevice()179*7c478bd9Sstevel@tonic-gate virtual Boolean isDevice() const { return (FALSE); } isDevicectl()180*7c478bd9Sstevel@tonic-gate virtual Boolean isDevicectl() const { return (FALSE); } isPipe()181*7c478bd9Sstevel@tonic-gate virtual Boolean isPipe() const { return (FALSE); } isBuffer()182*7c478bd9Sstevel@tonic-gate virtual Boolean isBuffer() const { return (FALSE); } isExtent()183*7c478bd9Sstevel@tonic-gate virtual Boolean isExtent() const { return (FALSE); } isList()184*7c478bd9Sstevel@tonic-gate virtual Boolean isList() const { return (FALSE); } 185*7c478bd9Sstevel@tonic-gate }; 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate #include <Audio_inline.h> 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 190*7c478bd9Sstevel@tonic-gate } 191*7c478bd9Sstevel@tonic-gate #endif 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate #endif /* !_MULTIMEDIA_AUDIO_H */ 194