xref: /illumos-gate/usr/src/cmd/audio/include/AudioStream.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <Audio.h>
33 #include <AudioHdr.h>
34 #include <stdlib.h>
35 #include <AudioDebug.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 // This is the abstract base class for all audio data sources/sinks.
42 // It is invalid to create an object of type AudioStream.
43 
44 class AudioStream : public Audio {
45 private:
46 	AudioHdr	hdr;			// data encoding info
47 	Double		length;			// length of data, in secs
48 
49 protected:
50 
51 	Boolean hdrset() const;			// TRUE if header valid
52 
53 	// Set header (always)
54 	AudioError updateheader(
55 	    const AudioHdr& h);			// header to copy
56 
57 	// Set data length
58 	void setlength(
59 	    Double len);			// new length, in secs
60 
61 	virtual Boolean opened() const = 0;	// TRUE if stream 'open'
62 
63 public:
64 	AudioStream(const char *path = "");	// Constructor
65 
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 	// XXX - is this needed?  do we need time->sample frames?
75 	virtual size_t GetByteCount() const;		// Get length, in bytes
76 
77 	// class Audio methods specialized here
78 	virtual AudioHdr GetHeader();			// Get header
79 
80 	virtual Double GetLength() const;		// Get length, in secs
81 
82 	// Make sure endian of the data matches the current processor.
83 	AudioError coerceEndian(unsigned char *buf, size_t len,
84 	    AudioEndian en);
85 
86 	virtual Boolean isEndianSensitive() const;
87 	AudioEndian localByteOrder() const
88 	{
89 		return (hdr.localByteOrder());
90 	}
91 };
92 
93 #include <AudioStream_inline.h>
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* !_MULTIMEDIA_AUDIOSTREAM_H */
100