/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAS_FILTER_H_
#define __GDAS_FILTER_H_

typedef struct _GdasFilterClass GdasFilterClass;
typedef struct _GdasFilter GdasFilter;

#include "gdassource.h"

GtkType gdas_filter_get_type();
#define GDAS_TYPE_FILTER   gdas_filter_get_type()
#define GDAS_FILTER(ptr) ((GdasFilter*) gtk_type_check_object_cast ((GtkTypeObject*) (ptr), GDAS_TYPE_FILTER))
#define GDAS_FILTER_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), GDAS_TYPE_FILTER, GdasFilterClass))
#define GDAS_IS_FILTER(obj)           (GTK_CHECK_TYPE ((obj), GDAS_TYPE_FILTER))
#define GDAS_IS_FILTER_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), GDAS_TYPE_FILTER))

struct _GdasFilterClass {
	GdasSourceClass		source_class;
	/* Only should be called we are not filtering.
	 * source_class->detach_source does the opposite. */
        void                  (*attach_filtered)(GdasFilter   *filter,
                                                 GdasSource   *new_sub);
};

struct _GdasFilter {
	GdasSource base;
	GdasSource* filtered;
};

/* Set the source.  An existing source will be detached first. */
void        gdas_filter_set_source     (GdasFilter *filter,
                                        GdasSource *sub);

/* Detach the source, returning a reference to it that
 * the caller must unref. */
GdasSource *gdas_filter_detach_source  (GdasFilter *filter);

/* Detach completely from the filtered object.  Equivalent to 
 * gdas_filter_detach_source + gtk_object_unref. */
void        gdas_filter_kill_source    (GdasFilter *filter);

/* For use with derivers: read from the subsource. */
int         gdas_filter_sub_read       (GdasFilter *filter, 
                                        GdamSample *buf,
					int         n);

#endif
