|
|
@ -32,12 +32,30 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
#include "asterisk/slinfactory.h"
|
|
|
|
#include "asterisk/slinfactory.h"
|
|
|
|
#include "asterisk/translate.h"
|
|
|
|
#include "asterisk/translate.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief Initialize an slinfactory
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \arg sf The slinfactory to initialize
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \return Nothing
|
|
|
|
|
|
|
|
*/
|
|
|
|
void ast_slinfactory_init(struct ast_slinfactory *sf)
|
|
|
|
void ast_slinfactory_init(struct ast_slinfactory *sf)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
memset(sf, 0, sizeof(*sf));
|
|
|
|
memset(sf, 0, sizeof(*sf));
|
|
|
|
sf->offset = sf->hold;
|
|
|
|
sf->offset = sf->hold;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief Destroy the contents of a slinfactory
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \arg sf The slinfactory that is no longer needed
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* This function will free any memory allocated for the contents of the
|
|
|
|
|
|
|
|
* slinfactory. It does not free the slinfactory itself. If the sf is
|
|
|
|
|
|
|
|
* malloc'd, then it must be explicitly free'd after calling this function.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \return Nothing
|
|
|
|
|
|
|
|
*/
|
|
|
|
void ast_slinfactory_destroy(struct ast_slinfactory *sf)
|
|
|
|
void ast_slinfactory_destroy(struct ast_slinfactory *sf)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ast_frame *f;
|
|
|
|
struct ast_frame *f;
|
|
|
@ -51,6 +69,14 @@ void ast_slinfactory_destroy(struct ast_slinfactory *sf)
|
|
|
|
ast_frfree(f);
|
|
|
|
ast_frfree(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief Feed audio into an slinfactory
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \arg sf The slinfactory to feed into
|
|
|
|
|
|
|
|
* \arg f Frame containing audio to feed in
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \return Number of frames currently in factory
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
|
|
|
|
int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ast_frame *begin_frame = f, *duped_frame = NULL, *frame_ptr;
|
|
|
|
struct ast_frame *begin_frame = f, *duped_frame = NULL, *frame_ptr;
|
|
|
@ -99,6 +125,15 @@ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
|
|
|
|
return x;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief Read samples from an slinfactory
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \arg sf The slinfactory to read from
|
|
|
|
|
|
|
|
* \arg buf Buffer to put samples into
|
|
|
|
|
|
|
|
* \arg samples Number of samples wanted
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \return Number of samples read
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples)
|
|
|
|
int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ast_frame *frame_ptr;
|
|
|
|
struct ast_frame *frame_ptr;
|
|
|
@ -150,11 +185,25 @@ int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples)
|
|
|
|
return sofar;
|
|
|
|
return sofar;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief Retrieve number of samples currently in an slinfactory
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \arg sf The slinfactory to peek into
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \return Number of samples in slinfactory
|
|
|
|
|
|
|
|
*/
|
|
|
|
unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf)
|
|
|
|
unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return sf->size;
|
|
|
|
return sf->size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief Flush the contents of an slinfactory
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \arg sf The slinfactory to flush
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \return Nothing
|
|
|
|
|
|
|
|
*/
|
|
|
|
void ast_slinfactory_flush(struct ast_slinfactory *sf)
|
|
|
|
void ast_slinfactory_flush(struct ast_slinfactory *sf)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ast_frame *fr = NULL;
|
|
|
|
struct ast_frame *fr = NULL;
|
|
|
|