summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server
diff options
context:
space:
mode:
authornaga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-05 23:40:22 +0000
committernaga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-05 23:40:22 +0000
commit1a10fbd58029efc3d6942136419f9eaa646f2bfb (patch)
tree2713beb581e3ce1fa62ed34b985449f4a62a2219 /TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server
parent9a649ceef61322a1d12fcea231e8941352549232 (diff)
downloadATCD-1a10fbd58029efc3d6942136419f9eaa646f2bfb.tar.gz
changed the exit's to returns since we have changed fork to threads.
Diffstat (limited to 'TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server')
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/as.cpp88
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/proto.h4
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp166
3 files changed, 176 insertions, 82 deletions
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/as.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/as.cpp
index f94080fc976..734e0e905b9 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/as.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/as.cpp
@@ -64,15 +64,16 @@ static int fileSize;
static unsigned char cmd;
static live_source = 0;
-static void CmdRead(char *buf, int psize)
+static int CmdRead(char *buf, int psize)
{
int res = wait_read_bytes(serviceSocket, buf, psize);
- if (res == 0) exit(0);
+ if (res == 0) return (1);
if (res == -1) {
fprintf(stderr, "AS error on read cmdSocket, size %d", psize);
perror("");
- exit(1);
+ return (-1);
}
+ return 0;
}
static void CmdWrite(char *buf, int size)
@@ -84,12 +85,15 @@ static void CmdWrite(char *buf, int size)
}
}
-static void INITaudio(void)
+static int INITaudio(void)
{
+ int result;
int failureType; /* 0 - can't open file, 1 - can't open live source */
INITaudioPara para;
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
para.version = ntohl(para.version);
@@ -100,7 +104,9 @@ static void INITaudio(void)
para.para.bytesPerSample = ntohl(para.para.bytesPerSample);
#endif
if (para.nameLength>0)
- CmdRead(audioFile, para.nameLength);
+ result = CmdRead(audioFile, para.nameLength);
+ if (result != 0)
+ return result;
if (Mpeg_Global::session_num > Mpeg_Global::session_limit || para.version != VERSION) {
char errmsg[128];
cmd = CmdFAIL;
@@ -115,7 +121,7 @@ static void INITaudio(void)
para.version / 100, para.version % 100);
}
write_string(serviceSocket, errmsg);
- exit(0);
+ return(1);
}
memcpy(&audioPara, &para.para, sizeof(audioPara));
/*
@@ -133,7 +139,7 @@ static void INITaudio(void)
CmdWrite((char *)&cmd, 1);
sprintf(errmsg, "%s without suffix .au", audioFile);
write_string(serviceSocket, errmsg);
- exit(0);
+ return(1);
}
}
/*
@@ -186,7 +192,7 @@ static void INITaudio(void)
CmdWrite((char *)&cmd, 1);
CmdWrite((char *)&reply, sizeof(reply));
}
- return;
+ return 0;
failure:
{
@@ -198,7 +204,7 @@ static void INITaudio(void)
write_string(serviceSocket,
failureType == 0 ? "Failed to open audio file for read." :
"Failed to connect to live audio source.");
- exit(0);
+ return(1);
}
}
@@ -234,7 +240,7 @@ static int send_packet(int firstSample, int samples)
if (errno == EINTR)
continue; /* interrupted */
perror("AS error on read audio file");
- exit(1);
+ return(-1);
}
if (len < audioPara.bytesPerSample) {
return 0;
@@ -336,7 +342,7 @@ static void ResendPacket(int firstsample, int samples)
static AudioFeedBackPara * fbpara = NULL;
-static void PLAYaudio(void)
+static int PLAYaudio(void)
{
int hasdata = 1;
int addSamples;
@@ -345,12 +351,15 @@ static void PLAYaudio(void)
int upp; /* micro-seconds per packet */
int delta_sps = 0; /* compensation for sps from feedback msgs */
int nfds = (serviceSocket > audioSocket ? serviceSocket : audioSocket) + 1;
+ int result;
/*
fprintf(stderr, "PLAY . . .\n");
*/
{
PLAYaudioPara para;
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
para.nextSample = ntohl(para.nextSample);
@@ -430,17 +439,21 @@ static void PLAYaudio(void)
if (errno == EINTR)
continue;
perror("AS error on select reading or writing");
- exit(1);
+ return(-1);
}
if (FD_ISSET(serviceSocket, &read_mask)){ /* STOP, SPEED, or CLOSE*/
unsigned char tmp;
- CmdRead((char *)&tmp, 1);
+ result = CmdRead((char *)&tmp, 1);
+ if (result != 0)
+ return result;
switch (tmp)
{
case CmdSPEED:
{
SPEEDaudioPara para;
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
para.samplesPerSecond = ntohl(para.samplesPerSecond);
@@ -467,26 +480,28 @@ static void PLAYaudio(void)
/*
fprintf(stderr, "AS: CmdSTOP. . .\n");
*/
- CmdRead((char *)&val, sizeof(int));
+ result = CmdRead((char *)&val, sizeof(int));
+ if (result != 0)
+ return result;
/*
CmdWrite(AUDIO_STOP_PATTERN, strlen(AUDIO_STOP_PATTERN));
*/
if (live_source) {
StopPlayLiveAudio();
}
- return; /* return from PLAYaudio() */
+ return 0; /* return from PLAYaudio() */
}
case CmdCLOSE:
if (live_source) {
StopPlayLiveAudio();
}
- exit(0); /* The whole AS session terminates */
+ return(1); /* The whole AS session terminates */
default:
if (live_source) {
StopPlayLiveAudio();
}
fprintf(stderr, "AS error: cmd=%d while expects STOP/SPEED/CLOSE.\n", tmp);
- exit(1);
+ return(-1);
}
}
@@ -495,10 +510,10 @@ static void PLAYaudio(void)
for (;;) {
if (conn_tag >= 0) {
len = wait_read_bytes(audioSocket, (char *)fbpara, sizeof(*fbpara));
- if (len == 0) exit(0); /* connection broken */
+ if (len == 0) return(1); /* connection broken */
else if (len < 0) { /* unexpected error */
perror("AS read1 FB");
- exit(1);
+ return(-1);
}
}
else { /* discard mode packet stream, read the whole packet */
@@ -531,10 +546,10 @@ static void PLAYaudio(void)
len = wait_read_bytes(audioSocket,
((char *)fbpara) + sizeof(*fbpara),
bytes);
- if (len == 0) exit(0); /* connection broken */
+ if (len == 0) return(1); /* connection broken */
else if (len < 0) { /* unexpected error */
perror("AS read2 FB");
- exit(1);
+ return(-1);
}
len += sizeof(*fbpara);
}
@@ -624,8 +639,10 @@ static void on_exit_routine(void)
ComCloseConn(audioSocket);
}
-void AudioServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
+int AudioServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
{
+ int result;
+
serviceSocket = ctr_fd;
audioSocket = data_fd;
conn_tag = max_pkt_size;
@@ -637,12 +654,17 @@ void AudioServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
atexit(on_exit_routine);
- INITaudio();
+ result = INITaudio();
+
+ if (result != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) AudioServer: "),
+ result);
fbpara = (AudioFeedBackPara *)malloc(FBBUF_SIZE);
if (fbpara == NULL) {
perror("AS failed to allocate mem for fbpara");
- exit(1);
+ return (-1);
}
databuf_size = max_pkt_size - sizeof(*pktbuf);
@@ -651,7 +673,7 @@ void AudioServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
pktbuf = (AudioPacket *)malloc(sizeof(*pktbuf) + databuf_size);
if (pktbuf == NULL) {
perror("AS failed to allocate mem for pktbuf");
- exit(1);
+ return(-1);
}
for (;;)
@@ -659,17 +681,21 @@ void AudioServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
/*
fprintf(stderr, "AS: waiting for a new command...\n");
*/
- CmdRead((char *)&cmd, 1);
+ result = CmdRead((char *)&cmd, 1);
+ if (result != 0)
+ return result;
switch (cmd)
{
case CmdPLAY:
- PLAYaudio();
+ result = PLAYaudio();
+ if (result != 0)
+ return result;
break;
case CmdCLOSE:
/*
fprintf(stderr, "a session closed.\n");
*/
- exit(0);
+ return(0);
break;
default:
fprintf(stderr, "audio channel command %d not recoganizeable\n", cmd);
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/proto.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/proto.h
index 741cee12922..12aab8421c5 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/proto.h
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/proto.h
@@ -57,7 +57,7 @@ int ReadLiveVideoPicture(int * frame, char * buf, int size); /* ret # bytes */
int LiveVideoProcess(int argc, char ** argv);
/* as.c */
-void AudioServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size);
+int AudioServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size);
/* vs.c */
-void VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size);
+int VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size);
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp
index 0fd8f68dbb1..647f7581dcc 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp
@@ -153,12 +153,12 @@ static struct FrameTable
if (fseek(fp, (position), 0) == -1) \
{ \
perror("VS error on fseek VideoFile"); \
- exit(1); \
+ return (-1); \
} \
while (fread((buf), (size), 1, fp) == 0) \
{ if (errno == EINTR) { errno = 0; continue;}\
- perror("VS error on fread VideoFile"); \
- exit(1); \
+ perror("VS error on fread VideoFile"); \
+ return (-1); \
} \
}
@@ -194,15 +194,16 @@ static void FileRead(long position, char * pbuf, int psize)
}
*/
-static void CmdRead(char *buf, int psize)
+static int CmdRead(char *buf, int psize)
{
int res = wait_read_bytes(serviceSocket, buf, psize);
- if (res == 0) exit(0);
+ if (res == 0) return(1);
if (res == -1) {
fprintf(stderr, "VS error on read cmdSocket, size %d", psize);
perror("");
- exit(1);
+ return(-1);
}
+ return 0;
}
static void CmdWrite(char *buf, int size)
@@ -523,14 +524,15 @@ static int SendPacket(int shtag, int gop, int frame, int timeToUse)
}
-static void SendReferences(int group, int frame)
+static int SendReferences(int group, int frame)
{
unsigned char orgcmd;
int i, base;
int pregroup;
+ int result;
- if (group < 0 || group >= numG) return;
- if (frame <= 0 || frame >= gopTable[group].totalFrames) return;
+ if (group < 0 || group >= numG) return 0;
+ if (frame <= 0 || frame >= gopTable[group].totalFrames) return 0;
orgcmd = cmd;
cmd = CmdREF;
@@ -555,7 +557,9 @@ static void SendReferences(int group, int frame)
/*
SFprintf(stderr, "REF group%d, frame%d\n", pregroup, i);
*/
- SendPacket(i == 0, pregroup, i, 0);
+ result = SendPacket(i == 0, pregroup, i, 0);
+ if (result != 0)
+ return result;
}
}
}
@@ -1181,21 +1185,28 @@ static int init_MPEG1_video_file(void)
return 0;
}
-static void INITvideo(void)
+static int INITvideo(void)
{
INITvideoPara para;
int failureType = 0;
+ int result;
/*
fprintf(stderr, "VS about to read Para.\n");
*/
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
para.version = ntohl(para.version);
para.nameLength = ntohl(para.nameLength);
#endif
if (para.nameLength>0)
- CmdRead(videoFile, para.nameLength);
+ {
+ result = CmdRead(videoFile, para.nameLength);
+ if (result != 0)
+ return result;
+ }
if (Mpeg_Global::session_num > Mpeg_Global::session_limit || para.version != VERSION) {
char errmsg[128];
cmd = CmdFAIL;
@@ -1313,7 +1324,7 @@ static void INITvideo(void)
if (live_source) StopPlayLiveVideo();
}
- return;
+ return 0;
}
failure:
@@ -1340,12 +1351,12 @@ static void INITvideo(void)
#define CheckGroupRange(pnextGroup) \
{ if ((pnextGroup) < 0 || (pnextGroup) >= numG) \
{ fprintf(stderr, "VS: %d.nextGroup(%d) out of range (%d).\n", cmd, (pnextGroup), numG); \
- return; } }
+ return 0; } }
#define CheckFrameRange(pnextFrame) \
{ if ((pnextFrame) < 0 || (pnextFrame) >= numF) \
{ fprintf(stderr, "VS: %d.nextFrame(%d) out of range (%d).\n", cmd, (pnextFrame), numF); \
- return; } }
+ return 0; } }
static int FrameToGroup(int * frame)
{
@@ -1357,15 +1368,18 @@ static int FrameToGroup(int * frame)
return i;
}
-static void POSITIONvideo()
+static int POSITIONvideo()
{
+ int result;
POSITIONpara para;
/*
fprintf(stderr, "POSITION . . .\n");
*/
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
- if (live_source) return;
+ if (live_source) return 0;
#ifdef NeedByteOrderConversion
para.nextGroup = ntohl(para.nextGroup);
@@ -1374,16 +1388,20 @@ static void POSITIONvideo()
CheckGroupRange(para.nextGroup);
cmdsn = para.sn;
- SendPacket(numS>1 || para.nextGroup == 0, para.nextGroup, 0, 0);
+ result = SendPacket(numS>1 || para.nextGroup == 0, para.nextGroup, 0, 0);
+ return result;
}
-static void STEPvideo()
+static int STEPvideo()
{
int group;
STEPpara para;
int tag = 0;
+ int result;
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
para.nextFrame = ntohl(para.nextFrame);
@@ -1403,7 +1421,9 @@ static void STEPvideo()
CheckFrameRange(para.nextFrame);
group = FrameToGroup(&para.nextFrame);
if (precmd != CmdSTEP && !tag ) {
- SendReferences(group, para.nextFrame);
+ result = SendReferences(group, para.nextFrame);
+ if (result < 0 )
+ return result;
}
}
if (live_source) StartPlayLiveVideo();
@@ -1419,6 +1439,7 @@ static void STEPvideo()
}
if (live_source) StopPlayLiveVideo();
+ return 0;
}
static int timerHeader, timerGroup, timerFrame;
@@ -1637,14 +1658,17 @@ static void GetFeedBack()
*/
}
-static void FastVideoPlay(void)
+static int FastVideoPlay(void)
{
+ int result;
FFpara para;
int preGroup = -1;
int preHeader = -1;
int nfds = (serviceSocket > videoSocket ? serviceSocket : videoSocket) + 1;
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
para.nextGroup = ntohl(para.nextGroup);
@@ -1653,7 +1677,7 @@ static void FastVideoPlay(void)
para.VStimeAdvance = ntohl(para.VStimeAdvance);
#endif
- if (live_source) return;
+ if (live_source) return 0;
VStimeAdvance = para.VStimeAdvance;
/*
@@ -1698,7 +1722,9 @@ static void FastVideoPlay(void)
}
if (FD_ISSET(serviceSocket, &read_mask)) /* stop */
{
- CmdRead((char *)&cmd, 1);
+ result = CmdRead((char *)&cmd, 1);
+ if (result != 0)
+ return result;
if (cmd == CmdCLOSE) {
exit(0);
}
@@ -1707,7 +1733,9 @@ static void FastVideoPlay(void)
normalExit = 0;
exit(1);
}
- CmdRead((char *)&cmdsn, sizeof(int));
+ result = CmdRead((char *)&cmdsn, sizeof(int));
+ if (result != 0 )
+ return result;
#ifdef NeedByteOrderConversion
cmdsn = ntohl(cmdsn);
#endif
@@ -1719,6 +1747,7 @@ static void FastVideoPlay(void)
GetFeedBack();
}
}
+ return 0;
}
static void FFvideo()
@@ -1780,7 +1809,7 @@ static void ComputeFirstSendPattern(float limit)
free(pat);
}
-static void PLAYliveVideo(PLAYpara * para)
+static int PLAYliveVideo(PLAYpara * para)
{
int doscale;
int count;
@@ -1790,6 +1819,7 @@ static void PLAYliveVideo(PLAYpara * para)
struct fd_set read_mask;
struct timeval tval = {0, 0};
double ratio;
+ int result;
currentUPF = (int)(1000000.0 / fps); /* ignore para.usecPerFrame */
if (frameRateLimit < fps) {
@@ -1836,7 +1866,9 @@ static void PLAYliveVideo(PLAYpara * para)
if (FD_ISSET(serviceSocket, &read_mask)) /* stop */
{
unsigned char tmp;
- CmdRead((char *)&tmp, 1);
+ result = CmdRead((char *)&tmp, 1);
+ if (result != 0)
+ return result;
if (tmp == CmdCLOSE) {
StopPlayLiveVideo();
exit(0);
@@ -1846,7 +1878,9 @@ static void PLAYliveVideo(PLAYpara * para)
/*
fprintf(stderr, "VS: CmdSTOP. . .\n");
*/
- CmdRead((char *)&cmdsn, sizeof(int));
+ result = CmdRead((char *)&cmdsn, sizeof(int));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
cmdsn = ntohl(cmdsn);
#endif
@@ -1859,7 +1893,9 @@ static void PLAYliveVideo(PLAYpara * para)
/*
fprintf(stderr, "VS: CmdSPEED. . .\n");
*/
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
/* ignore this thing for live video */
}
else
@@ -1879,7 +1915,7 @@ static void PLAYliveVideo(PLAYpara * para)
/*
SFprintf(stderr, "VS warning: a FB packet discarded.\n");
*/
- return;
+ return 0;
}
#ifdef NeedByteOrderConversion
para.frameRateLimit1000 = ntohl(para.frameRateLimit1000);
@@ -1898,18 +1934,22 @@ static void PLAYliveVideo(PLAYpara * para)
else doscale = 0;
}
}
+ return 0;
}
-static void PLAYvideo()
+static int PLAYvideo()
{
PLAYpara para;
int preGroup = -1;
int preHeader = -1;
int preFrame = -1;
+ int result;
fprintf(stderr, "PLAY . . .\n");
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
para.nextFrame = ntohl(para.nextFrame);
@@ -1933,7 +1973,7 @@ static void PLAYvideo()
if (live_source || video_format != VIDEO_MPEG1) {
if (live_source) PLAYliveVideo(&para);
- return;
+ return 0;
}
@@ -1950,7 +1990,9 @@ static void PLAYvideo()
timerGroup = FrameToGroup(&timerFrame);
timerHeader = gopTable[timerGroup].systemHeader;
memcpy(sendPattern, para.sendPattern, PATTERN_SIZE);
- SendReferences(timerGroup, timerFrame);
+ result = SendReferences(timerGroup, timerFrame);
+ if (result < 0)
+ return result;
StartTimer();
fprintf (stderr, "VS Going into the for loop\n");
@@ -2060,7 +2102,10 @@ static void PLAYvideo()
if (FD_ISSET(serviceSocket, &read_mask)) /* stop, speed change, loop swap */
{
unsigned char tmp;
- CmdRead((char *)&tmp, 1);
+ result = CmdRead((char *)&tmp, 1);
+ if (result != 0)
+ return result;
+
if (tmp == CmdCLOSE) {
exit(0);
}
@@ -2069,7 +2114,9 @@ static void PLAYvideo()
/*
fprintf(stderr, "VS: CmdSTOP. . .\n");
*/
- CmdRead((char *)&cmdsn, sizeof(int));
+ result = CmdRead((char *)&cmdsn, sizeof(int));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
cmdsn = ntohl(cmdsn);
#endif
@@ -2082,7 +2129,9 @@ static void PLAYvideo()
/*
fprintf(stderr, "VS: CmdSPEED. . .\n");
*/
- CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&para, sizeof(para));
+ if (result != 0)
+ return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
para.usecPerFrame = ntohl(para.usecPerFrame);
@@ -2109,6 +2158,7 @@ static void PLAYvideo()
GetFeedBack();
}
}
+ return 0;
}
#include <ctype.h>
@@ -2177,8 +2227,10 @@ static void on_exit_routine(void)
ComCloseConn(videoSocket);
}
-void VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
+int VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
{
+ int result;
+
serviceSocket = ctr_fd;
videoSocket = data_fd;
conn_tag = max_pkt_size;
@@ -2198,7 +2250,10 @@ void VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
lastRef[0] = lastRef[1] = -1;
lastRefPtr = 0;
- INITvideo();
+ result = INITvideo();
+
+ if (result != 0)
+ return result;
if (rttag) {
if (SetRTpriority("VS", 0) == -1) rttag = 0;
@@ -2210,18 +2265,28 @@ void VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
fprintf(stderr, "VS: waiting for a new command...\n");
precmd = cmd;
- CmdRead((char *)&cmd, 1);
-
+ result = CmdRead((char *)&cmd, 1);
+ if (result != 0)
+ {
+ cerr << result;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) VideoServer "),
+ result);
+ }
fprintf(stderr, "VS got cmd %d\n", cmd);
switch (cmd)
{
case CmdPOSITION:
case CmdPOSITIONrelease:
- POSITIONvideo();
+ result = POSITIONvideo();
+ if (result != 0)
+ return result;
break;
case CmdSTEP:
- STEPvideo();
+ result = STEPvideo();
+ if (result != 0)
+ return result;
break;
case CmdFF:
FFvideo();
@@ -2230,14 +2295,17 @@ void VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
FBvideo();
break;
case CmdPLAY:
- PLAYvideo();
+ result = PLAYvideo();
+ if (result != 0)
+ return result;
break;
case CmdCLOSE:
/*
fprintf(stderr, "a session closed.\n");
normalExit =1;
*/
- exit(0);
+ // exit(0);
+ return 0;
break;
case CmdSTATstream:
STATstream();
@@ -2249,7 +2317,7 @@ void VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
fprintf(stderr,
"VS error: video channel command %d not known.\n", cmd);
normalExit = 0;
- exit(1);
+ return -1;
break;
}
}