• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*---------------------------------------------------------------------------*
2 *  fpi_tgt.inl  *
3 *                                                                           *
4 *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5 *                                                                           *
6 *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7 *  you may not use this file except in compliance with the License.         *
8 *                                                                           *
9 *  You may obtain a copy of the License at                                  *
10 *      http://www.apache.org/licenses/LICENSE-2.0                           *
11 *                                                                           *
12 *  Unless required by applicable law or agreed to in writing, software      *
13 *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 *  See the License for the specific language governing permissions and      *
16 *  limitations under the License.                                           *
17 *                                                                           *
18 *---------------------------------------------------------------------------*/
19
20#ifndef _fpi_tgt_inl_
21#define _fpi_tgt_inl_
22
23#include "fpi_tgt.h"
24#include "PortExport.h"
25
26static PINLINE int isFrameBufferActive(fepFramePkt* frmPkt);
27static PINLINE void setFrameBufferDead(fepFramePkt* frmPkt);
28static PINLINE int getFrameGap(fepFramePkt* frmPkt);
29static PINLINE int getBlockGap(fepFramePkt* frmPkt);
30
31
32static PINLINE int isFrameBufferActive(fepFramePkt* frmPkt)
33{
34  ASSERT(frmPkt);
35  if (frmPkt->isCollecting == FB_ACTIVE)
36    return (True);
37  else
38    return (False);
39}
40
41static PINLINE void setFrameBufferDead(fepFramePkt* frmPkt)
42{
43  ASSERT(frmPkt);
44  frmPkt->isCollecting = FB_DEAD;
45  return;
46}
47
48/************************************************************************
49 * Returns number of unread frames in buffer (Those not seen by REC)    *
50 ************************************************************************
51 *
52 *                 "FRAMES_IN_BUF"
53 *   <------------------------------------------>
54 *
55 *                            "pushp"
56 *                               |
57 *                               v
58 *  +--------------------------------------------+
59 *  |          |x|              |x|              |  <= Frame Buffer for
60 *  +--------------------------------------------+      Channel 'n'
61 *              |
62 *              v
63 *            "pullp"
64 *
65 *              <--------------->
66 *                 'frameGap()'
67 *
68 *               Scenario A:    If: FRAME_IN_BUFFER == 1000
69 *                                  pullp == frame 70
70 *                                  pushp == frame 900   Gap == 830
71 *
72 *               Scenario B:    If: FRAME_IN_BUFFER == 1000
73 *                                  pullp == frame 720
74 *                                  pushp == frame 600   Gap == 880
75 *
76 * HOW FAR CAN WE MOVE ? (for 'moveFramePtr()' function)
77 * ===================
78 *
79 * In Scenario A
80 *
81 *      Forward  = +830
82 *      Backward = -168
83 *
84 *      We can only move forward "830" frames from our
85 *          current 'pullp' position, as frame 899 is the newest
86 *          COMPLETE frame.
87 *      We can only move backwards safely
88 *          to frame number 902 (as 'pushp' may have changed during our
89 *          deliberation), i.e. "(830 - FRAMES_IN_BUF + FRAME_BACK_GUARD)"
90 *
91 * In Scenario B
92 *
93 *      Forward  = +880
94 *      Backward = -118
95 *
96 *      We can only move forward "880" frames from our
97 *      current 'pullp' position.  We can only move backwards safely
98 *      to frame number 602 (as 'pushp' may have changed during our
99 *      deliberation), i.e. "(880 - FRAMES_IN_BUF + FRAME_BACK_GUARD)"
100 *
101 ************************************************************************
102 *
103 * NOTES
104 *
105 * If 'masterREC', 'pullp' is manipulated, otherwise one of the
106 * multiple recognition pointers, 'auxPullp[]' is used.
107 *
108 ************************************************************************
109 *
110 * Arguments: "n"      Channel Number of Selected Frame
111 *
112 * Retunrs:   int      +ve (or ZERO) = Gap Between FEP and REC frame pointers
113 *                     -ve           = Error
114 *
115 ************************************************************************/
116
117static PINLINE int getFrameGap(fepFramePkt* frmPkt)
118{
119  ASSERT(frmPkt);
120  return (POINTER_GAP(frmPkt, frmPkt->pushp, frmPkt->pullp));
121}
122
123/************************************************************************
124 ************************************************************************/
125
126static PINLINE int getBlockGap(fepFramePkt* frmPkt)
127{
128  ASSERT(frmPkt);
129  return (POINTER_GAP(frmPkt, frmPkt->pullp, frmPkt->pushBlkp));
130}
131
132#endif
133