|
root / base / usr / src / cmd / audio / include / AudioUnixfile.h
AudioUnixfile.h C 124 lines 3.6 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1992-2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef _MULTIMEDIA_AUDIOUNIXFILE_H
#define	_MULTIMEDIA_AUDIOUNIXFILE_H

#include <AudioStream.h>

#ifdef __cplusplus
extern "C" {
#endif

// This is the abstract base class for all file descriptor based audio i/o.
// It is invalid to create an object of type AudioUnixfile.

class AudioUnixfile : public AudioStream {
private:
	FileAccess	mode;			// access mode
	Boolean		block;			// FALSE if fd set non-blocking
	Boolean		filehdrset;		// TRUE if file hdr read/written
	int		fd;			// file descriptor
	char		*infostring;		// Info string from header
	unsigned int	infolength;		// Info string length

	AudioUnixfile() {}			// Constructor w/no args

protected:
	// Constructor
	AudioUnixfile(
	    const char *path,		// pathname
	    const FileAccess acc);	// access mode

	int getfd() const;			// Return descriptor
	void setfd(int d);			// Set descriptor

	virtual AudioError decode_filehdr();	// Get header from file
	virtual AudioError encode_filehdr();	// Write file header

	// Seek in input stream
	virtual AudioError seekread(
	    Double pos,				// position to seek to
	    off_t& offset);			// returned byte offset

	// Seek in output stream
	virtual AudioError seekwrite(
	    Double pos,				// position to seek to
	    off_t& offset);			// returned byte offset

	virtual Boolean isfdset() const;		// TRUE if fd is valid
	virtual Boolean isfilehdrset() const;		// TRUE if file hdr r/w

	// class AudioStream methods specialized here
	virtual Boolean opened() const;			// TRUE, if open

public:
	virtual ~AudioUnixfile();			// Destructor

	virtual FileAccess GetAccess() const;		// Get mode
	virtual Boolean GetBlocking() const;		// TRUE, if blocking i/o
	virtual void SetBlocking(Boolean b);		// Set block/non-block

	virtual AudioError Create() = 0;		// Create file
	virtual AudioError Open() = 0;			// Open file

	// ... with search path
	virtual AudioError OpenPath(
	    const char *path = 0);
	virtual AudioError Close();			// Close file

	// Methods specific to the audio file format
	// Get info string
	virtual char *GetInfostring(
	    int& len) const;			// return length

	// Set info string
	virtual void SetInfostring(
	    const char	*str,			// ptr to info data
	    int		len = -1);		// optional length

	// class Audio methods specialized here
	// Read from position
	virtual AudioError ReadData(
	    void* buf,				// buffer to fill
	    size_t& len,			// buffer length (updated)
	    Double& pos);			// start position (updated)

	// Write at position
	virtual AudioError WriteData(
	    void* buf,				// buffer to copy
	    size_t& len,			// buffer length (updated)
	    Double& pos);			// start position (updated)
};

#include <AudioUnixfile_inline.h>

#ifdef __cplusplus
}
#endif

#endif /* !_MULTIMEDIA_AUDIOUNIXFILE_H */