/** -*- Mode: c++ -*-
 *  Class ASIChannel
 */

// MythTV includes
#include "mythlogging.h"
#include "mpegtables.h"
#include "asichannel.h"

#define LOC     QString("ASIChan[%1](%2): ").arg(GetInputID()).arg(GetDevice())

ASIChannel::ASIChannel(TVRec *parent, const QString &device) :
    DTVChannel(parent), m_device(device), m_isopen(false)
{
    m_tuner_types.push_back(DTVTunerType(DTVTunerType::kTunerTypeASI));
}

ASIChannel::~ASIChannel(void)
{
    if (IsOpen())
        Close();
}

bool ASIChannel::Open(void)
{
    LOG(VB_CHANNEL, LOG_INFO, LOC + "Open()");

    if (m_device.isEmpty())
        return false;

    if (m_isopen)
        return true;

    if (!InitializeInput())
        return false;

    if (!m_inputid)
        return false;

    m_isopen = true;

    return true;
}

void ASIChannel::Close()
{
    LOG(VB_CHANNEL, LOG_INFO, LOC + "Close()");
    m_isopen = false;
}
