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) 1992-2001 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #ifndef _MULTIMEDIA_AUDIOBUFFER_H 28 #define _MULTIMEDIA_AUDIOBUFFER_H 29 30 #include <AudioStream.h> 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 // This is the class describing a mapped buffer of audio data. 37 // In addition to the standard Read and Write methods, the address 38 // of the buffer may be obtained and the data accessed directly. 39 40 class AudioBuffer : public AudioStream { 41 private: 42 Double buflen; // buffer size, in seconds 43 int zflag; // malloc'd with zmalloc? 44 protected: 45 size_t bufsize; // buffer size, in bytes 46 void* bufaddr; // buffer address 47 48 // class AudioStream methods specialized here 49 virtual Boolean opened() const; // TRUE, if open 50 virtual AudioError alloc(); // Allocate buffer 51 52 public: 53 // Constructor 54 AudioBuffer( 55 double len = 0., // buffer size, in seconds 56 const char *name = "(buffer)"); // name 57 ~AudioBuffer(); // Destructor 58 59 virtual void* GetAddress() const; // Get buffer address 60 virtual void* GetAddress(Double) const; // Get address at offset 61 virtual AudioError SetSize(Double len); // Change buffer size 62 virtual Double GetSize() const; // Get buffer size 63 virtual size_t GetByteCount() const; // Get size, in bytes 64 65 // class AudioStream methods specialized here 66 // Set header 67 virtual AudioError SetHeader( 68 const AudioHdr& h); // header to copy 69 70 // Set data length 71 virtual void SetLength( 72 Double len); // new length, in secs 73 74 // class Audio methods specialized here 75 76 // Read from position 77 virtual AudioError ReadData( 78 void* buf, // buffer to fill 79 size_t& len, // buffer length (updated) 80 Double& pos); // start position (updated) 81 82 // Write at position 83 virtual AudioError WriteData( 84 void* buf, // buffer to copy 85 size_t& len, // buffer length (updated) 86 Double& pos); // start position (updated) 87 88 // Append at position 89 virtual AudioError AppendData( 90 void* buf, // buffer to copy 91 size_t& len, // buffer length (updated) 92 Double& pos); // start position (updated) 93 94 // copy to another audio obj. 95 virtual AudioError AsyncCopy( 96 Audio* to, // dest audio object 97 Double& frompos, 98 Double& topos, 99 Double& limit); 100 101 virtual Boolean isBuffer() const { return (TRUE); } 102 }; 103 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif /* !_MULTIMEDIA_AUDIOBUFFER_H */ 109