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

Revision 445, 5.6 kB (checked in by pieterpalmers, 17 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

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