/*
* 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
* 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) 1993-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <AudioTypeChannel.h>
// This is a conversion class for channel conversions
// It handles mono->multi-channel and multi-channel->mono (mixing)
// class AudioTypeChannel methods
// Constructor
{
}
// Destructor
{
}
// Test conversion possibilities.
{
// XXX - This is misleading. Multi-channel->mono conversions
// must be linear format, but mono->multi-channel is
// ok in any format.
return (TRUE);
}
// Convert buffer to the specified type
// May replace the buffer with a new one, if necessary
{
int i;
int j;
int k;
int chans;
char *cin;
char *cout;
short *sin;
short *sout;
long smix;
// Make sure we're not being asked to do the impossible or trivial
return (err);
return (AUDIO_ERR_HDRINVAL);
return (AUDIO_SUCCESS);
return (AUDIO_ERR_HDRINVAL);
return (AUDIO_ERR_BADARG);
// setup header for output buffer
// XXX - If multi-channel -> mono, must be linear to mix
// We need to test for this before trying the conversion!
return (AUDIO_ERR_HDRINVAL);
}
// Allocate a new buffer
if (outbuf == 0)
return (AUDIO_UNIXERROR);
delete outbuf;
return (err);
}
// Get the number of sample frames and the size of each
// multi-channel -> mono conversion
switch (inhdr.bytes_per_unit) {
case 1:
for (i = 0; i < nsamps; i++) {
smix = 0;
for (j = 0; j < chans; j++) {
}
if (smix < -0x7f) {
smix = -0x7f;
} else if (smix > 0x7f) {
smix = 0x7f;
}
}
break;
case 2:
for (i = 0; i < nsamps; i++) {
smix = 0;
for (j = 0; j < chans; j++) {
}
if (smix < -0x7fff) {
smix = -0x7fff;
} else if (smix > 0x7fff) {
smix = 0x7fff;
}
}
break;
default:
}
// mono -> multi-channel
// XXX - this could be optimized by special-casing stuff
for (i = 0; i < nsamps; i++) {
for (j = 0; j < chans; j++) {
for (k = 0; k < nbytes; k++)
}
}
}
if (err) {
delete outbuf;
return (err);
}
// This will delete the buffer
inbuf->Dereference();
// Set the valid data length
return (AUDIO_SUCCESS);
}
AudioBuffer*& /* buf */)
{
return (AUDIO_SUCCESS);
}