dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / audio / include / AudioUnixfile.h
blob65f6d8fc9a90078725f720cb9764eb695b745fc0
1 /*
2 * CDDL HEADER START
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.
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]
20 * CDDL HEADER END
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>
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
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 {
42 private:
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
52 protected:
53 // Constructor
54 AudioUnixfile(
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
80 public:
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
96 // Get info string
97 virtual char *const GetInfostring(
98 int& len) const; // return length
100 // Set info string
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)
112 // Write at position
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>
121 #ifdef __cplusplus
123 #endif
125 #endif /* !_MULTIMEDIA_AUDIOUNIXFILE_H */