1 /* 2 * CDDL HEADER START 3 * 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. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1990-2001 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #ifndef _MULTIMEDIA_AUDIOTYPEPCM_H 28 #define _MULTIMEDIA_AUDIOTYPEPCM_H 29 30 #include <AudioTypeConvert.h> 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 // This is the class for a linear PCM conversion module 37 38 class AudioTypePcm : public AudioTypeConvert { 39 protected: 40 typedef unsigned char ulaw; 41 typedef unsigned char alaw; 42 43 // Conversion routines inline'd in the source file 44 double char2dbl(char); 45 double short2dbl(short); 46 double long2dbl(long); 47 long dbl2long(double, long); 48 49 void char2short(char *&, short *&); 50 void char2long(char *&, long *&); 51 void char2float(char *&, float *&); 52 void char2double(char *&, double *&); 53 void char2ulaw(char *&, ulaw *&); 54 void char2alaw(char *&, alaw *&); 55 56 void short2char(short *&, char *&); 57 void short2long(short *&, long *&); 58 void short2float(short *&, float *&); 59 void short2double(short *&, double *&); 60 void short2ulaw(short *&, ulaw *&); 61 void short2alaw(short *&, alaw *&); 62 63 void long2char(long *&, char *&); 64 void long2short(long *&, short *&); 65 void long2float(long *&, float *&); 66 void long2double(long *&, double *&); 67 void long2ulaw(long *&, ulaw *&); 68 void long2alaw(long *&, alaw *&); 69 70 void float2char(float *&, char *&); 71 void float2short(float *&, short *&); 72 void float2long(float *&, long *&); 73 void float2double(float *&, double *&); 74 void float2ulaw(float *&, ulaw *&); 75 void float2alaw(float *&, alaw *&); 76 77 void double2char(double *&, char *&); 78 void double2short(double *&, short *&); 79 void double2long(double *&, long *&); 80 void double2float(double *&, float *&); 81 void double2ulaw(double *&, ulaw *&); 82 void double2alaw(double *&, alaw *&); 83 84 void ulaw2char(ulaw *&, char *&); 85 void ulaw2short(ulaw*&, short *&); 86 void ulaw2long(ulaw*&, long *&); 87 void ulaw2float(ulaw *&, float *&); 88 void ulaw2double(ulaw *&, double *&); 89 void ulaw2alaw(ulaw *&, alaw *&); 90 91 void alaw2ulaw(alaw *&, ulaw *&); 92 void alaw2char(alaw *&, char *&); 93 void alaw2short(alaw *&, short *&); 94 void alaw2long(alaw *&, long *&); 95 void alaw2float(alaw *&, float *&); 96 void alaw2double(alaw *&, double *&); 97 98 public: 99 AudioTypePcm(); // Constructor 100 101 // Class AudioTypeConvert methods specialized here 102 103 // TRUE if conversion ok 104 virtual Boolean CanConvert( 105 AudioHdr h) const; // type to check against 106 107 // Convert buffer to the specified type 108 // Either the input or output type must be handled by this class 109 110 // Convert to new type 111 virtual AudioError Convert( 112 AudioBuffer*& inbuf, // data buffer to process 113 AudioHdr outhdr); // target header 114 115 virtual AudioError Flush(AudioBuffer*& buf); 116 }; 117 118 #ifdef __cplusplus 119 } 120 #endif 121 122 #endif /* !_MULTIMEDIA_AUDIOTYPEPCM_H */ 123