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) 1990-2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <AudioFile.h>
31 #include <AudioList.h>
34 // Generic Audio functions
37 // Open an audio file readonly, and return an AudioList referencing it.
40 const char *path
, // input filename
41 Audio
*& ap
) // returned AudioList pointer
47 // Open file and decode the header
48 inf
= new AudioFile(path
, (FileAccess
)ReadOnly
);
50 return (AUDIO_UNIXERROR
);
57 // Create a list object and set it up to reference the file
61 return (AUDIO_UNIXERROR
);
65 return (AUDIO_SUCCESS
);
69 // Create an output file and copy an input stream to it.
70 // If an error occurs during output, leave a partially written file.
72 Audio_WriteOutputFile(
73 const char *path
, // output filename
74 const AudioHdr
& hdr
, // output data header
75 Audio
* input
) // input data stream
80 // Create output file object
81 outf
= new AudioFile(path
, (FileAccess
)WriteOnly
);
83 return (AUDIO_UNIXERROR
);
85 // Set audio file header and create file
86 if ((err
= outf
->SetHeader(hdr
)) || (err
= outf
->Create())) {
92 err
= AudioCopy(input
, outf
);
94 // Close output file and clean up. If error, leave partial file.