17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 1992-2002 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _MULTIMEDIA_AUDIO_H 287c478bd9Sstevel@tonic-gate #define _MULTIMEDIA_AUDIO_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <AudioTypes.h> 317c478bd9Sstevel@tonic-gate #include <AudioError.h> 327c478bd9Sstevel@tonic-gate #include <AudioHdr.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate // Error-handling function declaration 397c478bd9Sstevel@tonic-gate class Audio; 407c478bd9Sstevel@tonic-gate typedef Boolean (*AudioErrfunc)(const Audio*, AudioError, AudioSeverity, 41*779d9599SToomas Soome const char *); 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate // Data transfer subcodes. 457c478bd9Sstevel@tonic-gate // Returned from ReadData(), WriteData(), AsyncCopy(), Copy() in err.sys 467c478bd9Sstevel@tonic-gate enum AudioCopyFlag { 477c478bd9Sstevel@tonic-gate AUDIO_COPY_SHORT_INPUT = 100, // AUDIO_SUCCESS: input would block 487c478bd9Sstevel@tonic-gate AUDIO_COPY_ZERO_LIMIT = 101, // AUDIO_SUCCESS: length was zero 497c478bd9Sstevel@tonic-gate AUDIO_COPY_SHORT_OUTPUT = 102, // AUDIO_SUCCESS: only partial output 507c478bd9Sstevel@tonic-gate AUDIO_COPY_INPUT_EOF = 103, // AUDIO_EOF: eof on input 517c478bd9Sstevel@tonic-gate AUDIO_COPY_OUTPUT_EOF = 104 // AUDIO_EOF: eof on output 527c478bd9Sstevel@tonic-gate }; 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate // This is the abstract base class from which all audio data types derive. 577c478bd9Sstevel@tonic-gate // It is invalid to create an object of type Audio. 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate class Audio { 607c478bd9Sstevel@tonic-gate private: 617c478bd9Sstevel@tonic-gate static int idctr; // id seed value 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate int id; // object id number 647c478bd9Sstevel@tonic-gate int refcnt; // reference count 657c478bd9Sstevel@tonic-gate char *name; // name 667c478bd9Sstevel@tonic-gate Double readpos; // current read position ptr 677c478bd9Sstevel@tonic-gate Double writepos; // current write position ptr 687c478bd9Sstevel@tonic-gate AudioErrfunc errorfunc; // address of error function 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate protected: 717c478bd9Sstevel@tonic-gate void SetName(const char *str); // Set name string 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate // Set position 747c478bd9Sstevel@tonic-gate Double setpos( 757c478bd9Sstevel@tonic-gate Double& pos, // position field to update 767c478bd9Sstevel@tonic-gate Double newpos, // new position 777c478bd9Sstevel@tonic-gate Whence w = Absolute); // Absolute || Relative 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate // XXX - should these be protected? 807c478bd9Sstevel@tonic-gate public: 817c478bd9Sstevel@tonic-gate int getid() const; // Get id value 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate // Raise error code 847c478bd9Sstevel@tonic-gate virtual AudioError RaiseError( 857c478bd9Sstevel@tonic-gate AudioError code, // error code 867c478bd9Sstevel@tonic-gate AudioSeverity sev = Error, // error severity 87*779d9599SToomas Soome const char *msg = "unknown error") const; // error message 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate // Raise error msg 907c478bd9Sstevel@tonic-gate virtual void PrintMsg( 917c478bd9Sstevel@tonic-gate char *msg, // error code 927c478bd9Sstevel@tonic-gate AudioSeverity sev = Message) const; // error severity 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate public: 957c478bd9Sstevel@tonic-gate Audio(const char *str = ""); // Constructor 967c478bd9Sstevel@tonic-gate virtual ~Audio(); // Destructor 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate void Reference(); // Increment ref count 997c478bd9Sstevel@tonic-gate void Dereference(); // Decrement ref count 1007c478bd9Sstevel@tonic-gate Boolean isReferenced() const; // TRUE if referenced 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate virtual char *GetName() const; // Get name string 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate // Set user error func 1057c478bd9Sstevel@tonic-gate virtual void SetErrorFunction( 1067c478bd9Sstevel@tonic-gate AudioErrfunc func); // return TRUE if non-fatal 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate virtual Double ReadPosition() const; // Get read position 1097c478bd9Sstevel@tonic-gate virtual Double WritePosition() const; // Get write position 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate // Set read position 1127c478bd9Sstevel@tonic-gate virtual Double SetReadPosition( 1137c478bd9Sstevel@tonic-gate Double pos, // new position 1147c478bd9Sstevel@tonic-gate Whence w = Absolute); // Absolute || Relative 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate // Set write position 1177c478bd9Sstevel@tonic-gate virtual Double SetWritePosition( 1187c478bd9Sstevel@tonic-gate Double pos, // new position 1197c478bd9Sstevel@tonic-gate Whence w = Absolute); // Absolute || Relative 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate // Read from current pos 1227c478bd9Sstevel@tonic-gate virtual AudioError Read( 1237c478bd9Sstevel@tonic-gate void* buf, // buffer to fill 1247c478bd9Sstevel@tonic-gate size_t& len); // buffer length (updated) 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate // Write to current pos 1277c478bd9Sstevel@tonic-gate virtual AudioError Write( 1287c478bd9Sstevel@tonic-gate void* buf, // buffer to copy 1297c478bd9Sstevel@tonic-gate size_t& len); // buffer length (updated) 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate // XXX - no Append() method for now because of name clashes 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate // methods specialized by inherited classes 1347c478bd9Sstevel@tonic-gate virtual AudioHdr GetHeader() = 0; // Get header 1357c478bd9Sstevel@tonic-gate virtual AudioHdr GetDHeader(Double); // Get header at pos 1367c478bd9Sstevel@tonic-gate virtual Double GetLength() const = 0; // Get length, in secs 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate // Read from position 1397c478bd9Sstevel@tonic-gate virtual AudioError ReadData( 1407c478bd9Sstevel@tonic-gate void* buf, // buffer to fill 1417c478bd9Sstevel@tonic-gate size_t& len, // buffer length (updated) 1427c478bd9Sstevel@tonic-gate Double& pos) = 0; // start position (updated) 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate // Write at position 1457c478bd9Sstevel@tonic-gate virtual AudioError WriteData( 1467c478bd9Sstevel@tonic-gate void* buf, // buffer to copy 1477c478bd9Sstevel@tonic-gate size_t& len, // buffer length (updated) 1487c478bd9Sstevel@tonic-gate Double& pos) = 0; // start position (updated) 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate // Write and extend 1517c478bd9Sstevel@tonic-gate virtual AudioError AppendData( 1527c478bd9Sstevel@tonic-gate void* buf, // buffer to copy 1537c478bd9Sstevel@tonic-gate size_t& len, // buffer length (updated) 1547c478bd9Sstevel@tonic-gate Double& pos); // start position (updated) 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate // copy to another audio obj. 1577c478bd9Sstevel@tonic-gate virtual AudioError Copy( 1587c478bd9Sstevel@tonic-gate Audio* ap); // dest audio object 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate // copy to another audio obj. 1617c478bd9Sstevel@tonic-gate virtual AudioError Copy( 1627c478bd9Sstevel@tonic-gate Audio* ap, // dest audio object 1637c478bd9Sstevel@tonic-gate Double& frompos, 1647c478bd9Sstevel@tonic-gate Double& topos, 1657c478bd9Sstevel@tonic-gate Double& limit); 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate // copy to another audio obj. 1687c478bd9Sstevel@tonic-gate virtual AudioError AsyncCopy( 1697c478bd9Sstevel@tonic-gate Audio* ap, // dest audio object 1707c478bd9Sstevel@tonic-gate Double& frompos, 1717c478bd9Sstevel@tonic-gate Double& topos, 1727c478bd9Sstevel@tonic-gate Double& limit); 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate // Define default classification routines 1757c478bd9Sstevel@tonic-gate // The appropriate routine should be specialized by each leaf class. isFile()1767c478bd9Sstevel@tonic-gate virtual Boolean isFile() const { return (FALSE); } isDevice()1777c478bd9Sstevel@tonic-gate virtual Boolean isDevice() const { return (FALSE); } isDevicectl()1787c478bd9Sstevel@tonic-gate virtual Boolean isDevicectl() const { return (FALSE); } isPipe()1797c478bd9Sstevel@tonic-gate virtual Boolean isPipe() const { return (FALSE); } isBuffer()1807c478bd9Sstevel@tonic-gate virtual Boolean isBuffer() const { return (FALSE); } isExtent()1817c478bd9Sstevel@tonic-gate virtual Boolean isExtent() const { return (FALSE); } isList()1827c478bd9Sstevel@tonic-gate virtual Boolean isList() const { return (FALSE); } 1837c478bd9Sstevel@tonic-gate }; 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate #include <Audio_inline.h> 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1887c478bd9Sstevel@tonic-gate } 1897c478bd9Sstevel@tonic-gate #endif 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate #endif /* !_MULTIMEDIA_AUDIO_H */ 192