• 首頁
  • 文件
  • 下載
  • 狀態
  • 常見問題
  • 郵件列表
  • 應用程式
  • 外部鏈結
  • 版權
  • 志願者
  • 聯繫

導流管的繼承處理

「導流管」(Conduit)是CIOS「集智作業系統」當中的重要觀念,「集智作業系統」的運作主體是「知識」,「知識設計」與「知識運算」是「集智作業系統」的最主要操作及功能。作為感知與互動系統的一部分,「CIOS音訊核心」必須經常性地「自主性泊接」,方便選擇性地接收知識或是傳達訊息。

《Conduit/Junction》是「集智作業系統」當中處理知識信息流的最主要方式,當中「CIOS音訊核心」的出入口,即為「導流管」(Conduit)。「導流管」觀念也是CIOS Audio Core與其他音訊處理介面最大不同之處,在範例程式當中,我們也使用了少量的「集智作業系統」的《Conduit/Junction》來示範「導流管」的各層面應用。「雅典娜輸入法」的語音辨識及語音輸出,即使用這種方法實現的。

「導流管」對外還可以泊接許多不同功能的《Conduit/Junction》,例如,TTS、語音辨識及音樂倉庫輸出等等。使用「導流管」(Conduit)與「泊接」(Junction)的方法,可以使得音訊設備的應用十分地靈活。

一般的開發使用者,通常都只需要實作自己的「導流管」,將音訊從音訊設備接收進來或是輸出到音訊設備,因此,這個部分我們將詳細解釋各種應用方法。

導流管的定義



就最簡單的觀點來說,導流管只有一個資料流輸入及一個資料流輸出。就「CIOS音訊核心」系統當中,「資料流輸入」接到「音訊驅動介面」時,即為「錄音」,「資料流輸出」接到「音訊驅動介面」時,即為「播放」。

泊接頭的定義


「泊接頭」的作用是將所有類型的「導流管」泊接在一起,進行數據交換。



使用「導流管」與「泊接頭」是集智作業系統的主要知識處理方式。

「導流管」類別


「CIOS音訊核心」的「導流管」類別,宣告如下,開發者必須繼承其中三個函式(obtain, put, finish):

class Conduit
{
  public:

    typedef enum CallBackResult    {
      Continue = 0                 ,
      Complete = 1                 ,
      Abort    = 2                 ,
      Postpone = 3                 }
      CallBackResult               ;

    typedef enum FlowSituation     {
      Stagnated = 0                ,
      Started   = 1                ,
      Stalled   = 2                ,
      Completed = 3                ,
      Ruptured  = 4                }
    FlowSituation                  ;

    typedef enum CallbackFlags     {
      InputUnderflow  = 0x00000001 ,
      InputOverflow   = 0x00000002 ,
      OutputUnderflow = 0x00000004 ,
      OutputOverflow  = 0x00000008 ,
      PrimingOutput   = 0x00000010 }
      CallbackFlags                ;

    typedef enum ConduitDirection {
      NoDirection     = 0         ,
      InputDirection  = 1         ,
      OutputDirection = 2         }
      ConduitDirection            ;

    typedef enum FinishCondition {
      Correct      = 0           ,
      Abortion     = 1           ,
      Interruption = 2           ,
      Accident     = 3           }
      FinishCondition            ;

    unsigned long     StatusFlags          ; // to be obsoleted
    CaTime            CurrentTime          ; // to be obsoleted

    void            * InputBuffer          ;
    int               InputBytesPerSample  ;
    unsigned long     InputFrameCount      ;
    unsigned long     MaxInputSize         ;
    unsigned long     InputStatusFlags     ;
    CaTime            InputCurrentTime     ;
    CaTime            InputBufferAdcTime   ;
    FlowSituation     InputSituation       ;
    CacInputFunction  inputFunction        ;

    void            * OutputBuffer         ;
    int               OutputBytesPerSample ;
    unsigned long     OutputFrameCount     ;
    unsigned long     MaxOutputSize        ;
    unsigned long     OutputStatusFlags    ;
    CaTime            OutputCurrentTime    ;
    FlowSituation     OutputSituation      ;
    CaTime            OutputBufferDacTime  ;
    CacOutputFunction outputFunction       ;

    explicit     Conduit          (void) ;
    virtual     ~Conduit          (void) ;

    virtual int  obtain           (void) = 0 ;
    virtual int  put              (void) = 0 ;
    virtual void finish           (ConduitDirection direction = NoDirection,
                                   FinishCondition  condition = Correct) = 0 ;

    virtual void LockConduit      (void) ;
    virtual void UnlockConduit    (void) ;

  protected:

    virtual int  ObtainByFunction (void) ;
    virtual int  PutByFunction    (void) ;

};