1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1990-2001 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #ifndef _MULTIMEDIA_AUDIOSTREAM_H 28 #define _MULTIMEDIA_AUDIOSTREAM_H 29 30 #include <Audio.h> 31 #include <AudioHdr.h> 32 #include <stdlib.h> 33 #include <AudioDebug.h> 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 // This is the abstract base class for all audio data sources/sinks. 40 // It is invalid to create an object of type AudioStream. 41 42 class AudioStream : public Audio { 43 private: 44 AudioHdr hdr; // data encoding info 45 Double length; // length of data, in secs 46 47 protected: 48 49 Boolean hdrset() const; // TRUE if header valid 50 51 // Set header (always) 52 AudioError updateheader( 53 const AudioHdr& h); // header to copy 54 55 // Set data length 56 void setlength( 57 Double len); // new length, in secs 58 59 virtual Boolean opened() const = 0; // TRUE if stream 'open' 60 61 public: 62 AudioStream(const char *path = ""); // Constructor 63 64 // Set header 65 virtual AudioError SetHeader( 66 const AudioHdr& h); // header to copy 67 68 // Set data length 69 virtual void SetLength( 70 Double len); // new length, in secs 71 72 // XXX - is this needed? do we need time->sample frames? 73 virtual size_t GetByteCount() const; // Get length, in bytes 74 75 // class Audio methods specialized here 76 virtual AudioHdr GetHeader(); // Get header 77 78 virtual Double GetLength() const; // Get length, in secs 79 80 // Make sure endian of the data matches the current processor. 81 AudioError coerceEndian(unsigned char *buf, size_t len, 82 AudioEndian en); 83 84 virtual Boolean isEndianSensitive() const; localByteOrder()85 AudioEndian localByteOrder() const 86 { 87 return (hdr.localByteOrder()); 88 } 89 }; 90 91 #include <AudioStream_inline.h> 92 93 #ifdef __cplusplus 94 } 95 #endif 96 97 #endif /* !_MULTIMEDIA_AUDIOSTREAM_H */ 98