Uint8 work[STM_WORK_SIZE(STMGRP_OPEN_MAX, STM_OPEN_MAX)]; /* Work area */ Sint32 a_id, b_id, c_id; /* File identifier */ StmGrpHn abc_grp; /* Stream group handle */ StmHn a_stm, b_stm, c_stm; /* Stream handle */ StmKey key; /* Stream key */ Uint8 a_buf[A_BUFSIZE * STM_UNIT_FORM1]; /* Transfer area A */ Uint8 b_buf[B_BUFSIZE * STM_UNIT_FORM2]; /* Transfer area B */ Uint8 c_buf[C_BUFSIZE * STM_UNIT_FORM1]; /* Transfer area C */GFS_Init(・・・); /* Initialize the file system */ STM_Init(STMGRP_OPEN_MAX, STM_OPEN_MAX, work); /* Initialize the stream system */ a_id = GFS_NameToId(・・・); /* Get file identifier */ ・ ・ ・ abc_grp = STM_OpenGrp(); /* Open stream group */ /* Stream key settings */ STM_KEY_CN(&key) = STM_KEY_NONE; /* Channel number */ STM_KEY_CIMSK(&key) = STM_KEY_CIVAL(&key) = STM_KEY_NONE; /* Coding information */ /* Open stream by file identifier */ STM_KEY_SMMSK(&key) = STM_KEY_SMVAL(&key) = STM_SM_VIDEO; /* Video stream */ a_stm = STM_OpenFid(abc_grp, a_id, &key, STM_LOOP_NOREAD); /* Stream A */ STM_KEY_SMMSK(&key) = STM_KEY_SMVAL(&key) = STM_SM_AUDIO; /* Audio stream */ b_stm = STM_OpenFid(abc_grp, b_id, &key, STM_LOOP_NOREAD); /* Stream B */ STM_KEY_SMMSK(&key) = STM_KEY_SMVAL(&key) = STM_SM_DATA; /* Data stream */ c_stm = STM_OpenFid(abc_grp, c_id, &key, STM_LOOP_NOREAD); /* Stream C */
/* Transfer area settings */ STM_SetTrBuf(a_stm, a_buf, A_BUFSIZE, STM_UNIT_FORM1); STM_SetTrBuf(b_stm, b_buf, B_BUFSIZE, STM_UNIT_FORM2); STM_SetTrBuf(c_stm, c_buf, C_BUFSIZE, STM_UNIT_FORM1);
/* Stream access */ STM_SetExecGrp(abc_grp); /* Set execution group */ while (1) { if (STM_ExecServer() == STM_EXEC_COMPLETED) { break; /* Stream access ends */ } user(); /* User processing */ } STM_CloseGrp(abc_grp); /* Close stream group */
Figure 5.1 Transfer processing in sector units
Figure 5.2 Transfer processing when not in sector units
Uint8 read_buf[READBUF_SIZE];
Sint32 decodeFunc(void *obj, StmHn stm, Sint32 nsct)
{
Sint32 i;
Sint32 read_len; /* Number of longwords transferred by subFunc */
Sint32 nlongword; /* Number of longwords to be transferred */
Uint32 *src; /* Source address */
Sint32 dadr; /* Address/variation per longword transfer */
Uint32 *buffer; /* Transfer area */
/* Conversion from number of sectors to number of words (call before starting transfer) */
nlongword = STM_SctToWord(stm, nsct) / 2;
src = STM_StartTrans(stm, &dadr); /* Start transfer */
buffer = (Uint8 *)obj; /* The third argument of STM_SetTrFunc is passed to obj */
for (i = 0; i< nlongword; i += read_len) {
/* Function that returns the number of expanded bytes */
buffer += subFunc(src, dadr, buffer, &read_len);
src += read_len * dadr;
}
return (nsct); /* Return the number of transferred sectors */
}
Figure 5.3 Operation when using transfer function
・
・ /* Read ahead the stream */
STM_SetExecGrp(NULL); /* Pause the drive */
GFS_NwFread(………);
while (1) {
if (GFS_NwExecOne(gfs) == GFS_SVR_COMPLETED) /* Read file */
break;
STM_ExecTrans(stm); /* Transfer stream data */
}
STM_SetExecGrp(grp); /* Resume reading stream */
★ PROGRAMMER'S GUIDE ★ Stream system library