root/trunk/libffado/tests/streaming/test-isohandling.cpp

Revision 742, 5.5 kB (checked in by ppalmers, 13 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

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