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_AUDIOUNIXFILE_H
28 #define _MULTIMEDIA_AUDIOUNIXFILE_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <AudioStream.h>
38 // This is the abstract base class for all file descriptor based audio i/o.
39 // It is invalid to create an object of type AudioUnixfile.
41 class AudioUnixfile
: public AudioStream
{
43 FileAccess mode
; // access mode
44 Boolean block
; // FALSE if fd set non-blocking
45 Boolean filehdrset
; // TRUE if file hdr read/written
46 int fd
; // file descriptor
47 char *infostring
; // Info string from header
48 unsigned int infolength
; // Info string length
50 AudioUnixfile() {} // Constructor w/no args
55 const char *path
, // pathname
56 const FileAccess acc
); // access mode
58 int getfd() const; // Return descriptor
59 void setfd(int d
); // Set descriptor
61 virtual AudioError
decode_filehdr(); // Get header from file
62 virtual AudioError
encode_filehdr(); // Write file header
64 // Seek in input stream
65 virtual AudioError
seekread(
66 Double pos
, // position to seek to
67 off_t
& offset
); // returned byte offset
69 // Seek in output stream
70 virtual AudioError
seekwrite(
71 Double pos
, // position to seek to
72 off_t
& offset
); // returned byte offset
74 virtual Boolean
isfdset() const; // TRUE if fd is valid
75 virtual Boolean
isfilehdrset() const; // TRUE if file hdr r/w
77 // class AudioStream methods specialized here
78 virtual Boolean
opened() const; // TRUE, if open
81 virtual ~AudioUnixfile(); // Destructor
83 virtual FileAccess
GetAccess() const; // Get mode
84 virtual Boolean
GetBlocking() const; // TRUE, if blocking i/o
85 virtual void SetBlocking(Boolean b
); // Set block/non-block
87 virtual AudioError
Create() = 0; // Create file
88 virtual AudioError
Open() = 0; // Open file
90 // ... with search path
91 virtual AudioError
OpenPath(
92 const char *path
= 0);
93 virtual AudioError
Close(); // Close file
95 // Methods specific to the audio file format
97 virtual char *const GetInfostring(
98 int& len
) const; // return length
101 virtual void SetInfostring(
102 const char *str
, // ptr to info data
103 int len
= -1); // optional length
105 // class Audio methods specialized here
106 // Read from position
107 virtual AudioError
ReadData(
108 void* buf
, // buffer to fill
109 size_t& len
, // buffer length (updated)
110 Double
& pos
); // start position (updated)
113 virtual AudioError
WriteData(
114 void* buf
, // buffer to copy
115 size_t& len
, // buffer length (updated)
116 Double
& pos
); // start position (updated)
119 #include <AudioUnixfile_inline.h>
125 #endif /* !_MULTIMEDIA_AUDIOUNIXFILE_H */