xref: /titanic_52/usr/src/cmd/audio/include/AudioList.h (revision c40d696f8f0e05103b3795dd37198e00ae7ef955)
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_AUDIOLIST_H
28 #define	_MULTIMEDIA_AUDIOLIST_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <Audio.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 // This is the 'base' class for a list of extents of audio objects
39 class AudioList : public Audio {
40 
41 	// Define a linked list nested class
42 	class AudioListEntry {
43 	private:
44 		void operator=(AudioListEntry);	// Assignment is illegal
45 	public:
46 		Audio*		aptr;		// pointer to audio object
47 		AudioListEntry*	next;		// pointer to next in list
48 		AudioListEntry*	prev;		// pointer to previous
49 
50 		// Constructor w/obj
51 		AudioListEntry(
52 		    Audio* obj);		// referenced audio object
53 		~AudioListEntry();		// Destructor
54 
55 		void newptr(Audio* newa);	// Reset extent
56 
57 		// Link in new extent
58 		void link(
59 		    AudioListEntry* after);	// link after this one
60 
61 		// Split an extent
62 		void split(
63 		    Double pos);		// split at offset
64 	};
65 
66 private:
67 	AudioListEntry		head;		// list head
68 
69 	AudioListEntry* first() const;		// Return first extent
70 
71 	// Locate extent/offset
72 	virtual Boolean getposition(
73 	    Double& pos,			// target position (updated)
74 	    AudioListEntry*& ep) const;		// returned entry pointer
75 
76 	AudioList operator=(AudioList);		// Assignment is illegal
77 
78 public:
79 	AudioList(const char *name = "[list]");	// Constructor
80 	virtual ~AudioList();			// Destructor
81 
82 	// class Audio methods specialized here
83 	virtual Double GetLength() const;	// Get length, in secs
84 	virtual char *GetName() const;		// Get name string
85 	virtual AudioHdr GetHeader();		// Get header
86 	virtual AudioHdr GetHeader(Double pos);	// Get header at pos
87 
88 	// Read from position
89 	virtual AudioError ReadData(
90 	    void* buf,				// buffer to fill
91 	    size_t& len,			// buffer length (updated)
92 	    Double& pos);			// start position (updated)
93 
94 	// Write is prohibited
95 	virtual AudioError WriteData(
96 	    void* buf,				// buffer to copy
97 	    size_t& len,			// buffer length (updated)
98 	    Double& pos);			// start position (updated)
99 
100 	virtual Boolean isList() const { return (TRUE); }
101 
102 	// list manipulation methods
103 	// Insert an entry
104 	virtual AudioError Insert(
105 	    Audio* obj);			// object to insert
106 
107 	// Insert an entry
108 	virtual AudioError Insert(
109 	    Audio* obj,				// object to insert
110 	    Double pos);			// insertion offset, in seconds
111 
112 	// Append an entry
113 	virtual AudioError Append(
114 	    Audio* obj);			// object to append
115 
116 	// copy to another audio obj.
117 	virtual AudioError AsyncCopy(
118 	    Audio* ap,				// dest audio object
119 	    Double& frompos,
120 	    Double& topos,
121 	    Double& limit);
122 };
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif /* !_MULTIMEDIA_AUDIOLIST_H */
129