/*  This file is part of the KDE project
    Copyright (C) 2007 Matthias Kretz <kretz@kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License version 2 as published by the Free Software Foundation.

    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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.

*/

#ifndef PHONON_PCMIODEVICE_P_H
#define PHONON_PCMIODEVICE_P_H

#include "pcmiodevice.h"
#include "format_p.h"
#include <QtCore/QSet>
#ifdef Q_OS_UNIX
#ifdef HAS_LIBASOUND
#include "alsaclasses.h"
#endif
#endif
#include "converter_p.h"

namespace Phonon
{

class PcmIODevicePrivate
{
    Q_DECLARE_PUBLIC(PcmIODevice)
    protected:
        PcmIODevice *q_ptr;

    private:
        void updateDevices();
        bool open(QIODevice::OpenMode openMode);
        void close();
        qint64 readData(char *data, qint64 maxSize);
        qint64 writeData(const char *data, qint64 maxSize);

        Phonon::Category category;
        QSet<Format> formats;
        Format formatInUse;
        AudioOutputDevice outputDevice;
        //AudioCaptureDevice inputDevice;
        PcmIODevice::PcmIOMode mode;
        Converter *converter;
        inline void ensureConverter() { if (!converter) converter = new Converter; }
        unsigned int latency;
#ifdef Q_OS_UNIX
        bool setHwAndSwParams(AlsaPcm &pcm);
#ifdef HAS_LIBASOUND
        AlsaPcm alsaPlayback;
        AlsaPcm alsaCapture;
#endif
#endif
};

} // namespace Phonon

#endif // PHONON_PCMIODEVICE_P_H
