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_AUDIOFILE_H
28 #define _MULTIMEDIA_AUDIOFILE_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
38 #endif /* NO_EXTERN_C */
40 #include <AudioUnixfile.h>
41 #include <sys/types.h>
44 // A 'primitive type' for memory mapped file access types
46 NormalAccess
= 0, RandomAccess
= 1, SequentialAccess
= 2
51 vmaccess_t type
; // combined mode
53 VMAccess(vmaccess_t x
= NormalAccess
): type(x
) { } // Constructor
54 inline operator vmaccess_t() // Cast to enum
56 inline operator int() { // Cast to integer
58 case NormalAccess
: return (MADV_NORMAL
);
59 case RandomAccess
: return (MADV_RANDOM
);
60 case SequentialAccess
: return (MADV_SEQUENTIAL
);
66 // This is the 'base' class for regular files containing audio data
67 class AudioFile
: public AudioUnixfile
{
69 static const FileAccess defmode
; // Default access mode
70 static const char *AUDIO_PATH
; // Default path env name
72 off_t hdrsize
; // length of file header
73 off_t seekpos
; // current system file pointer
74 Double origlen
; // initial length of file
76 caddr_t mapaddr
; // for mmaping RO files
77 off_t maplen
; // length of mmaped region
78 VMAccess vmaccess
; // vm (mmap) access type
80 AudioFile
operator=(AudioFile
); // Assignment is illegal
84 virtual AudioError
tryopen(
87 virtual AudioError
createfile(
88 const char *path
); // filename
90 // class AudioUnixfile methods specialized here
91 // Seek in input stream
92 virtual AudioError
seekread(
93 Double pos
, // position to seek to
94 off_t
& offset
); // returned byte offset
95 // Seek in output stream
96 virtual AudioError
seekwrite(
97 Double pos
, // position to seek to
98 off_t
& offset
); // returned byte offset
101 AudioFile(); // Constructor w/no args
103 // Constructor with path
105 const char *path
, // filename
106 const FileAccess acc
= defmode
); // access mode
107 virtual ~AudioFile(); // Destructor
109 // Set tmpfile location
110 static AudioError
SetTempPath(
111 const char *path
); // directory path
113 // class AudioUnixfile methods specialized here
114 virtual void SetBlocking(Boolean
) { } // No-op for files
116 // front end to madvise
117 AudioError
SetAccessType(
118 VMAccess vmacc
); // (normal, random, seq access)
120 inline VMAccess
GetAccessType() const { // get vm access type
124 virtual AudioError
Create(); // Create file
125 virtual AudioError
Open(); // Open file
127 // ... with search path
128 virtual AudioError
OpenPath(
129 const char *path
= AUDIO_PATH
);
130 virtual AudioError
Close(); // Close file
132 // Read from position
133 virtual AudioError
ReadData(
134 void* buf
, // buffer to fill
135 size_t& len
, // buffer length (updated)
136 Double
& pos
); // start position (updated)
139 virtual AudioError
WriteData(
140 void* buf
, // buffer to copy
141 size_t& len
, // buffer length (updated)
142 Double
& pos
); // start position (updated)
144 // copy to another audio obj.
145 virtual AudioError
AsyncCopy(
146 Audio
* ap
, // dest audio object
151 // class Audio methods specialized here
152 virtual Boolean
isFile() const { return (TRUE
); }
161 #endif /* NO_EXTERN_C */
163 #endif /* !_MULTIMEDIA_AUDIOFILE_H */