
/*
 * --- GSMP-COPYRIGHT-NOTE-BEGIN ---
 * 
 * This copyright note is auto-generated by ./scripts/Create-CopyPatch.
 * Please add additional copyright information _after_ the line containing
 * the GSMP-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
 * the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
 * 
 * GSMP: pcm/include/BasicIOStream.hh
 * General Sound Manipulation Program is Copyright (C) 2000 - 2004
 *   Valentin Ziegler and René Rebe
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2. A copy of the GNU General
 * Public License can be found in the file LICENSE.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT-
 * ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 * 
 * --- GSMP-COPYRIGHT-NOTE-END ---
 */

/* Short Description:
 *   IO architecture, basic IOStream.
 */

#ifndef LOWLEVEL__BASICIOSTREAM_HH__
#define LOWLEVEL__BASICIOSTREAM_HH__

#include "Types.hh"

#include "BasicStream.hh"

#include <string>
#include <vector>

namespace GSMP
{
  class BasicIOStream
  {
  public:
    
    class IOParams
    {
    public:
      channel_index min_pl_channels;
      channel_index max_pl_channels;
      channel_index cur_pl_channels;
      
      channel_index min_ca_channels;
      channel_index max_ca_channels;
      channel_index cur_ca_channels;
      
      sample_rate min_rate;
      sample_rate max_rate;
      sample_rate cur_rate;
      
      int min_depth;
      int max_depth;
      int cur_depth;
      
      int min_period_time;
      int max_period_time;
      int cur_period_time;
      
      int min_periods;
      int max_periods;
      int cur_periods;
    };
    
    virtual ~BasicIOStream () {};
    
    // must be called after construcing the class, to do some init
    // stuff (e.g. might init some interface and search cards ...)
    virtual bool Init () = 0;
    
    // return (all) valid interface names
    virtual const std::vector<std::string>& Interfaces () = 0;
    virtual const std::string& Interface () = 0;
    virtual bool SetInterface (const std::string& n_interface) = 0;
    
    virtual const IOParams& Params ();
   
    virtual channel_index SetPlaybackChannels (channel_index n_pl_channels);
    virtual channel_index SetCaptureChannels (channel_index n_ca_channels);
    virtual sample_rate SetRate (sample_rate n_rate);
    virtual int SetDepth (int n_depth);
    virtual int SetPeriodTime (int n_period_time);
    virtual int SetPeriods (int n_periods);
    
    virtual int PlaybackXRuns () = 0;
    virtual int CaptureXRuns () = 0;
    
    virtual void SetPlayback (bool state) = 0;
    virtual void SetCapture (bool state) = 0;
    
    virtual bool Playback () = 0;
    virtual bool Capture () = 0;
    
    virtual bool StartIO () = 0;
    virtual bool StopIO () = 0;
    
    virtual bool IORunning () = 0;
    
    virtual global_index CurrentPos () = 0;
    
    /* Operations */
    virtual local_index Write (BasicStream* dest, local_index start_index = 0) = 0;
    virtual local_index Read (BasicStream* dest) = 0;
    
  protected:
    std::vector<std::string> m_interfaces;
    IOParams m_params;
  };
    
} // end namespace GSMP

#endif // LOWLEVEL__BASICIO_HH__
