root/branches/streaming-rework/tests/streaming/test-isohandling.cpp

Revision 419, 5.5 kB (checked in by pieterpalmers, 16 years ago)

namespace simplification

Line 
1 /***************************************************************************
2   Copyright (C) 2005 by Pieter Palmers   *
3                                                                         *
4   This program is free software; you can redistribute it and/or modify  *
5   it under the terms of the GNU General Public License as published by  *
6   the Free Software Foundation; either version 2 of the License, or     *
7   (at your option) any later version.                                   *
8                                                                         *
9   This program is distributed in the hope that it will be useful,       *
10   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12   GNU General Public License for more details.                          *
13                                                                         *
14   You should have received a copy of the GNU General Public License     *
15   along with this program; if not, write to the                         *
16   Free Software Foundation, Inc.,                                       *
17   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18  ***************************************************************************/
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 #include <signal.h>
29 #include "src/debugmodule/debugmodule.h"
30
31 #include <netinet/in.h>
32
33 #include "src/libstreaming/IsoHandler.h"
34 #include "src/libstreaming/IsoStream.h"
35 #include "src/libstreaming/StreamProcessorManager.h"
36 #include "src/libstreaming/AmdtpStreamProcessor.h"
37 #include "src/libstreaming/IsoHandlerManager.h"
38 #include "src/libutil/PosixThread.h"
39 #include "src/libstreaming/AmdtpPort.h"
40
41 using namespace Streaming;
42
43
44 int run;
45
46 static void sighandler (int sig)
47 {
48         run = 0;
49 }
50
51 int main(int argc, char *argv[])
52 {
53
54         int retval=0;
55         int i=0;
56         run=1;
57
58         signal (SIGINT, sighandler);
59         signal (SIGPIPE, sighandler);
60
61         printf("Freebob streaming test application\n");
62         printf(" ISO handler tests\n");
63
64         // also create a processor manager to manage the actual stream
65         // processors   
66         StreamProcessorManager *procMan = new StreamProcessorManager(512,3);
67         if(!procMan) {
68                 printf("Could not create StreamProcessorManager\n");
69                 return -1;
70         }
71         procMan->setVerboseLevel(DEBUG_LEVEL_VERBOSE);
72
73         // now we can allocate the stream processors themselves
74
75 //      StreamProcessor *spt = new AmdtpTransmitStreamProcessor(3,2,44100,10);
76 //      if(!spt) {
77 //              printf("Could not create transmit AmdtpTransmitStreamProcessor\n");
78 //              return -1;
79 //      }
80 //      spt->setVerboseLevel(DEBUG_LEVEL_VERBOSE);
81
82         AmdtpReceiveStreamProcessor *spr = new AmdtpReceiveStreamProcessor(2,44100,7);
83 //      ReceiveStreamProcessor *spr = new ReceiveStreamProcessor(0,2,44100);
84         if(!spr) {
85                 printf("Could not create receive AmdtpStreamProcessor\n");
86                 return -1;
87         }
88         spr->setVerboseLevel(DEBUG_LEVEL_VERBOSE);
89         spr->setChannel(0);
90
91         AmdtpReceiveStreamProcessor *spr2 = new AmdtpReceiveStreamProcessor(2,44100,11);
92 //      ReceiveStreamProcessor *spr = new ReceiveStreamProcessor(0,2,44100);
93         if(!spr2) {
94                 printf("Could not create receive AmdtpStreamProcessor\n");
95                 return -1;
96         }
97         spr2->setVerboseLevel(DEBUG_LEVEL_VERBOSE);
98         spr2->setChannel(1);
99
100 //      printf("----------------------\n");
101 //      if (procMan->registerProcessor(spt)) {
102 //              printf("Could not register transmit stream processor with the Processor manager\n");
103 //              return -1;
104 //      }
105 //      printf("----------------------\n");
106
107         // also register it with the processor manager, so that it is aware of
108         // buffer sizes etc...
109         if (procMan->registerProcessor(spr)) {
110                 printf("Could not register receive stream processor with the Processor manager\n");
111                 return -1;
112         }
113         printf("----------------------\n");
114
115         if (procMan->registerProcessor(spr2)) {
116                 printf("Could not register receive stream processor with the Processor manager\n");
117                 return -1;
118         }
119         printf("----------------------\n");
120
121         AmdtpAudioPort *p1=new AmdtpAudioPort(
122                            std::string("Test port 1"),
123                            AmdtpAudioPort::E_Capture,
124                            1,
125                            0,
126                            AmdtpPortInfo::E_MBLA,
127                            0
128                 );
129         if (!p1) {
130                 printf("Could not create port 1\n");
131                 return -1;
132         }
133
134         p1->setBufferSize(512);
135
136         printf("----------------------\n");
137
138         if (spr2->addPort(p1)) {
139                 printf("Could not register port with receive stream processor\n");
140                 return -1;
141         }
142        
143         Util::PosixThread *thread=new Util::PosixThread(procMan);
144
145
146         procMan->prepare();
147
148         // start the runner
149         thread->Start();
150         printf("----------------------\n");
151
152         if(procMan->start()) {
153                 printf("Could not start handlers\n");
154                 return -1;
155         }
156         printf("----------------------\n");
157
158         int periods=0;
159         int periods_print=0;
160         while(run) {
161                 periods++;
162                 if(periods>periods_print) {
163                         printf("\n");
164                         printf("============================================\n");
165                         procMan->dumpInfo();
166                         printf("--------------------------------------------\n");
167 /*                      hexDumpQuadlets((quadlet_t*)(p1->getBufferAddress()),10);
168                         printf("--------------------------------------------\n");*/
169                         hexDumpQuadlets((quadlet_t*)(p1->getBufferAddress()),10);
170                         printf("============================================\n");
171                         printf("\n");
172                         periods_print+=100;
173                 }
174                 procMan->waitForPeriod();
175                 procMan->transfer();
176                
177         }
178
179         thread->Stop();
180
181         procMan->stop();
182
183 //      procMan->unregisterProcessor(spt);
184         procMan->unregisterProcessor(spr);
185         procMan->unregisterProcessor(spr2);
186
187         delete thread;
188
189         delete procMan;
190
191 //      delete spt;
192         delete spr;
193         delete spr2;
194
195         printf("Bye...\n");
196
197
198   return EXIT_SUCCESS;
199 }
Note: See TracBrowser for help on using the browser.