/*
* 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) 1992-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 <AudioTypeMux.h>
// This is a conversion class for channel multiplex/demultiplex
// class AudioTypeMux methods
// Constructor
{
}
// Destructor
~AudioTypeMux()
{
}
// Test conversion possibilities.
{
// XXX - The test is whether we're converting 1->many or many->1
// XXX - What if the format doesn't have fixed-size sample units?
return (TRUE);
}
// Multiplex or demultiplex.
// The buffer pointer should be a NULL-terminated array of buffers if 1-channel
{
unsigned int channels;
unsigned char **inptrs;
unsigned char *in;
unsigned char *out;
int i;
int j;
int k;
if (channels == 1) {
} else {
}
// 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);
// Get the number of sample frames and the size of each
// Figure out if we're multiplexing or demultiplexing
if (channels == 1) {
// Demultiplex multi-channel data into several mono channels
// Allocate buffer pointer array and each buffer
multibuf = (AudioBuffer**)
for (i = 0; i < channels; i++) {
"(Demultiplex conversion buffer)");
if (multibuf[i] == 0) {
goto cleanup;
}
delete multibuf[i];
cleanup: while (--i >= 0) {
delete multibuf[i];
}
delete multibuf;
return (err);
}
}
for (i = 0; i < channels; i++) {
// Get output pointer and input channel pointer
// Copy a sample unit and bump the input pointer
for (j = 0; j < nsamps; j++) {
for (k = 0; k < unitsz; k++) {
}
}
// Set the valid data length
}
// Release the input buffer
inbuf->Dereference();
// Return the array pointer (callers beware!)
} else {
// Multiplex several mono channels into multi-channel data
// Allocate an output buffer
"(Multiplex conversion buffer)");
if (outbuf == 0)
return (AUDIO_UNIXERROR);
delete outbuf;
return (err);
}
// Verify the input pointer is an array of buffer pointers
// Look for NULL termination
break;
return (AUDIO_ERR_BADARG);
}
return (AUDIO_ERR_BADARG);
// Allocate a bunch of input pointers
inptrs = (unsigned char **)
for (i = 0; i < channels; i++) {
}
// Get output pointer
for (i = 0; i < nsamps; i++) {
// Copy a sample frame from each input buffer
for (j = 0; j < channels; j++) {
for (k = 0; k < nbytes; k++) {
}
}
}
// Set the valid data length
// Release the input buffers and pointer arrays
for (i = 0; i < channels; i++) {
multibuf[i]->Dereference();
}
delete multibuf;
delete inptrs;
// Set the valid data length and return the new pointer
}
return (AUDIO_SUCCESS);
}
AudioBuffer*& /* buf */)
{
return (AUDIO_SUCCESS);
}