/*
 *  Copyright (C) 2014 Yunfeng Liu <yliu@espial.com>
 *
 *  Espial License
 */

#ifndef AUDIOOUTPUT_H
#define AUDIOOUTPUT_H

#include <wtf/FastAllocBase.h>

namespace WebCore {

class AudioFormat {
public:
    int m_channels;
    float m_sample_rate;

};

class AudioInput {
	WTF_MAKE_FAST_ALLOCATED;
public:
	virtual ~AudioInput() { }

    /* @param nb_frames is the number of frames of each channel, buf size has to be channel_size*nb_frames min. */
    virtual int readInterleaved (float* buf, int nb_frames, bool& isSilent) = 0;
};

class AudioOutput {
	WTF_MAKE_FAST_ALLOCATED;
public:
    static AudioOutput* create ();
    virtual ~AudioOutput() { }

    virtual void Open (const AudioFormat& fmt) = 0;
    virtual void Start (AudioInput* input) = 0;
    virtual void Stop () = 0;
    virtual void Close () = 0;

};
}

using WebCore::AudioOutput;
using WebCore::AudioInput;
using WebCore::AudioFormat;

#endif // AUDIOOUTPUT_H
