AudioTypeSampleRate.cc revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 <AudioDebug.h>
#include <AudioTypeSampleRate.h>
// This is the first stab at a conversion class for Sample Rate conversions
// class AudioTypeSampleRate methods
// Constructor
{
}
// Destructor
{
}
// Test conversion possibilities.
AudioHdr h) const // target header
{
if ((input_rate <= 0) || (output_rate <= 0))
return (FALSE);
(h.bytes_per_unit != 2) ||
(h.channels != 1)) {
return (FALSE);
}
return (TRUE);
}
// Convert buffer to the specified type
// May replace the buffer with a new one, if necessary
{
int i;
return (AUDIO_ERR_BADARG);
}
// Make sure we're not being asked to do the impossible
// XXX - need a better error code
return (err);
}
// If the requested conversion is different than what was initially
// established, then return an error.
// XXX - Maybe one day flush and re-init the filter
return (AUDIO_ERR_BADARG);
}
// If conversion is a no-op, just return success
return (AUDIO_SUCCESS);
}
// If nothing in the buffer, do the simple thing
if (length == 0.) {
return (AUDIO_SUCCESS);
}
// Add some padding to the output buffer
// Allocate a new buffer
if (outbuf == 0)
return (AUDIO_UNIXERROR);
delete outbuf;
return (err);
}
// here's where the guts go ...
(short *)outbuf->GetAddress());
// do a sanity check. did we write more bytes then we had
// available in the output buffer?
insamps = (unsigned int)
(char *)"resample filter corrupted the heap");
}
// set output size appropriately
// This will delete the buffer
inbuf->Dereference();
return (AUDIO_SUCCESS);
}
{
AudioHdr h;
int nsamp;
unsigned char *tmpbuf;
return (AUDIO_SUCCESS);
if (nsamp > 0) {
// this does a flush
// Copy to the supplied buffer
if (nsamp > 0) {
if (err)
return (err);
}
delete tmpbuf;
}
return (AUDIO_SUCCESS);
}