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
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.
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]
23 * Copyright (c) 1992-2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #ifndef _MULTIMEDIA_AUDIOBUFFER_H
28 #define _MULTIMEDIA_AUDIOBUFFER_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <AudioStream.h>
38 // This is the class describing a mapped buffer of audio data.
39 // In addition to the standard Read and Write methods, the address
40 // of the buffer may be obtained and the data accessed directly.
42 class AudioBuffer
: public AudioStream
{
44 Double buflen
; // buffer size, in seconds
45 int zflag
; // malloc'd with zmalloc?
47 size_t bufsize
; // buffer size, in bytes
48 void* bufaddr
; // buffer address
50 // class AudioStream methods specialized here
51 virtual Boolean
opened() const; // TRUE, if open
52 virtual AudioError
alloc(); // Allocate buffer
57 double len
= 0., // buffer size, in seconds
58 const char *name
= "(buffer)"); // name
59 ~AudioBuffer(); // Destructor
61 virtual void* GetAddress() const; // Get buffer address
62 virtual void* GetAddress(Double
) const; // Get address at offset
63 virtual AudioError
SetSize(Double len
); // Change buffer size
64 virtual Double
GetSize() const; // Get buffer size
65 virtual size_t GetByteCount() const; // Get size, in bytes
67 // class AudioStream methods specialized here
69 virtual AudioError
SetHeader(
70 const AudioHdr
& h
); // header to copy
73 virtual void SetLength(
74 Double len
); // new length, in secs
76 // class Audio methods specialized here
79 virtual AudioError
ReadData(
80 void* buf
, // buffer to fill
81 size_t& len
, // buffer length (updated)
82 Double
& pos
); // start position (updated)
85 virtual AudioError
WriteData(
86 void* buf
, // buffer to copy
87 size_t& len
, // buffer length (updated)
88 Double
& pos
); // start position (updated)
91 virtual AudioError
AppendData(
92 void* buf
, // buffer to copy
93 size_t& len
, // buffer length (updated)
94 Double
& pos
); // start position (updated)
96 // copy to another audio obj.
97 virtual AudioError
AsyncCopy(
98 Audio
* to
, // dest audio object
103 virtual Boolean
isBuffer() const { return (TRUE
); }
110 #endif /* !_MULTIMEDIA_AUDIOBUFFER_H */