summaryrefslogtreecommitdiff
path: root/slinfactory.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2006-08-21 02:11:39 +0000
committerKevin P. Fleming <kpfleming@digium.com>2006-08-21 02:11:39 +0000
commit0a27d8bfe5fa36d8cb600b5b520f9b5c7fbf0ed6 (patch)
tree270b9c46c1e644483d6d2a35b509f43218ba3252 /slinfactory.c
parentf60ada0be22cd646454278e102d384a5dbaf7d59 (diff)
merge new_loader_completion branch, including (at least):
- restructured build tree and makefiles to eliminate recursion problems - support for embedded modules - support for static builds - simpler cross-compilation support - simpler module/loader interface (no exported symbols) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@40722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'slinfactory.c')
-rw-r--r--slinfactory.c157
1 files changed, 0 insertions, 157 deletions
diff --git a/slinfactory.c b/slinfactory.c
deleted file mode 100644
index 62a863d87..000000000
--- a/slinfactory.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 2005, Anthony Minessale II.
- *
- * Anthony Minessale <anthmct@yahoo.com>
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
- */
-
-/*! \file
- *
- * \brief A machine to gather up arbitrary frames and convert them
- * to raw slinear on demand.
- *
- * \author Anthony Minessale <anthmct@yahoo.com>
- */
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include <string.h>
-
-#include "asterisk/frame.h"
-#include "asterisk/slinfactory.h"
-#include "asterisk/logger.h"
-#include "asterisk/translate.h"
-
-void ast_slinfactory_init(struct ast_slinfactory *sf)
-{
- memset(sf, 0, sizeof(*sf));
- sf->offset = sf->hold;
- sf->queue = NULL;
-}
-
-void ast_slinfactory_destroy(struct ast_slinfactory *sf)
-{
- struct ast_frame *f;
-
- if (sf->trans) {
- ast_translator_free_path(sf->trans);
- sf->trans = NULL;
- }
-
- while ((f = sf->queue)) {
- sf->queue = f->next;
- ast_frfree(f);
- }
-}
-
-int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
-{
- struct ast_frame *frame, *frame_ptr;
- unsigned int x;
-
- if (f->subclass != AST_FORMAT_SLINEAR) {
- if (sf->trans && f->subclass != sf->format) {
- ast_translator_free_path(sf->trans);
- sf->trans = NULL;
- }
- if (!sf->trans) {
- if ((sf->trans = ast_translator_build_path(AST_FORMAT_SLINEAR, f->subclass)) == NULL) {
- ast_log(LOG_WARNING, "Cannot build a path from %s to slin\n", ast_getformatname(f->subclass));
- return 0;
- } else {
- sf->format = f->subclass;
- }
- }
- }
-
- if (sf->trans)
- frame = ast_translate(sf->trans, f, 0);
- else
- frame = ast_frdup(f);
-
- if (!frame)
- return 0;
-
- for (x = 0, frame_ptr = sf->queue; frame_ptr && frame_ptr->next; frame_ptr = frame_ptr->next)
- x++;
-
- if (frame_ptr)
- frame_ptr->next = frame;
- else
- sf->queue = frame;
-
- frame->next = NULL;
- sf->size += frame->samples;
-
- return x;
-}
-
-int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples)
-{
- struct ast_frame *frame_ptr;
- unsigned int sofar = 0, ineed, remain;
- short *frame_data, *offset = buf;
-
- while (sofar < samples) {
- ineed = samples - sofar;
-
- if (sf->holdlen) {
- if ((sofar + sf->holdlen) <= ineed) {
- memcpy(offset, sf->hold, sf->holdlen * sizeof(*offset));
- sofar += sf->holdlen;
- offset += sf->holdlen;
- sf->holdlen = 0;
- sf->offset = sf->hold;
- } else {
- remain = sf->holdlen - ineed;
- memcpy(offset, sf->offset, ineed * sizeof(*offset));
- sofar += ineed;
- sf->offset += ineed;
- sf->holdlen = remain;
- }
- continue;
- }
-
- if ((frame_ptr = sf->queue)) {
- sf->queue = frame_ptr->next;
- frame_data = frame_ptr->data;
-
- if ((sofar + frame_ptr->samples) <= ineed) {
- memcpy(offset, frame_data, frame_ptr->samples * sizeof(*offset));
- sofar += frame_ptr->samples;
- offset += frame_ptr->samples;
- } else {
- remain = frame_ptr->samples - ineed;
- memcpy(offset, frame_data, ineed * sizeof(*offset));
- sofar += ineed;
- frame_data += ineed;
- memcpy(sf->hold, frame_data, remain * sizeof(*offset));
- sf->holdlen = remain;
- }
- ast_frfree(frame_ptr);
- } else {
- break;
- }
- }
-
- sf->size -= sofar;
- return sofar;
-}
-
-unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf)
-{
- return sf->size;
-}