#ifndef AUDIOTOWAV
#define AUDIOTOWAV

/*
 * @(#)AudioToWAV.h
 *
 * This file is part of webCDwriter - Network CD/DVD Writing.
 *
 * Copyright (C) 2000-2004 Jörg P. M. Haeger
 *
 * webCDwriter is free software. See CDWserver.cpp for details.
 */

#include <stdio.h>
#include "InputStream.h"

class Process;

class AudioToWAV {
	InputStream *inStream;
	protected: Process *converter;
	private: int leftInStream,
		writeBuf0, writeBuf1, readBufN,
		waveLength;
	char writeBuf[4 * 1024], readBuf[4 * 1024];
	enum { NORMAL, CLOSEOUT, OUTCLOSED, INCLOSED } mode;
public:
	AudioToWAV(InputStream *inStream = NULL);
	virtual ~AudioToWAV();
	void end();
	int get(const char **buf);
	void put(int n);
	void setInStream(InputStream *inStream);
	void updateHeader(FILE *outStream);
private:
	void fillReadBuf();
	void fillWriteBuf();
};

#endif
