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