#pragma once

#include <tqobject.h>
#include <tqstring.h>

class OssDevice : public TQObject
{
    TQ_OBJECT
public:
    enum Category { Output, Input };

    OssDevice( Category cat, int cardIdx, const TQString &cardPath,
               int fd, int channelIdx, const TQString &name, bool stereo,
               TQObject *parent = 0 );

    TQString  name()      const { return m_name; }
    TQString  cardPath()  const { return m_cardPath; }
    int      cardIndex() const { return m_cardIdx; }
    Category category()  const { return m_category; }
    int      volume()    const { return m_volume; }
    bool     muted()     const { return m_muted; }
    int      pan()       const { return m_pan; }
    bool     stereo()    const { return m_stereo; }
    bool     hasMute()   const { return true; }

    void setVolume( int v );
    void setMuted( bool m );
    void setPan( int p );

    void syncFromOss();

signals:
    void volumeChanged( int v );
    void muteChanged( bool m );
    void panChanged( int p );

private:
    void pushVolume();

    int      m_fd;       // borrowed from OssModel — do not close
    int      m_cardIdx;
    TQString  m_cardPath;
    int      m_channelIdx;
    TQString  m_name;
    Category m_category;
    bool     m_stereo;
    int      m_volume;
    int      m_savedVol; // pre-mute volume for fake-mute
    bool     m_muted;
    int      m_pan;
};
