comparison modules/bluespec/Pygar/core/AudioCoreSystem.cpp @ 36:99519a031813 pygar svn.37

[svn r37] moved the server into audioCorePipeline
author punk
date Tue, 04 May 2010 18:54:54 -0400
parents 1a21b4cd85ee
children 0475235d1513
comparison
equal deleted inserted replaced
35:14f7a7ace3f5 36:99519a031813
62 void 62 void
63 CONNECTED_APPLICATION_CLASS::Main() 63 CONNECTED_APPLICATION_CLASS::Main()
64 { 64 {
65 //rlm: two files 65 //rlm: two files
66 FILE *inputFile; 66 FILE *inputFile;
67 FILE *inputFile1; 67 // FILE *inputFile1;
68 UINT16 sample; 68 UINT16 sample;
69 UINT16 sample1; 69 //UINT16 sample1;
70 70
71 //rlm: not sure if normal ints are ok here; using UINT16 because I know it works 71 //rlm: not sure if normal ints are ok here; using UINT16 because I know it works
72 UINT16 channel0 = 0; 72 UINT16 channel0 = 0;
73 UINT16 channel1 = 1; 73 //UINT16 channel1 = 1;
74 74
75 //init processor 75 //init processor
76 int sleepCount = 0; 76 int sleepCount = 0;
77 int result = 0; 77 int result = 0;
78 78
79 bool coreFin = false; 79 bool coreFin = false;
80
81
82 80
83 fflush(stdout); 81 fflush(stdout);
84 82
85 // Convert input wav to pcm 83 // Convert input wav to pcm
86 84
87 85
88 //rlm: for now we are going to going to just have 2 files with "common names" 86 //rlm: for now we are going to going to just have 2 files with "common names"
89 87
90 generate_pcm("input.wav","input.pcm"); 88 generate_pcm("input.wav","input.pcm");
91 generate_pcm("input1.wav", "input1.pcm"); 89 //generate_pcm("input1.wav", "input1.pcm");
92
93 90
94 91
95 //Send data to the machine here. 92 //Send data to the machine here.
96 //rlm: two files 93 //rlm: two files
97 inputFile = fopen("input.pcm","r"); 94 inputFile = fopen("input.pcm","r");
98 inputFile = fopen("input1.pcm", "r"); 95 // inputFile = fopen("input1.pcm", "r");
99 96
100 assert(inputFile1); 97 //assert(inputFile1);
101 assert(inputFile); 98 assert(inputFile);
102 99
103 int count = 0; 100 int count = 0;
104 101
105 printf("main:PROCESSOR about to enter loop %d\n", count); 102 printf("main:PROCESSOR about to enter loop %d\n", count);
106 103
107 //rlm: here we read both files. later refactor into a function. 104 //rlm: here we read both files. later refactor into a function.
108 // also, this will terminate when the FIRST file reaches its end. 105 // also, this will terminate when the FIRST file reaches its end.
109 while( (fread(&sample, 2, 1, inputFile)) && (fread(&sample1, 2 , 1, inputFile1))) { 106 while( (fread(&sample, 2, 1, inputFile)) )//&& (fread(&sample1, 2 , 1, inputFile1)))
107 {
110 if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1) 108 if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1)
111 { 109 {
112 sleepCount++; 110 sleepCount++;
113 if(sleepCount == 200) { 111 if(sleepCount == 200) {
114 printf("Failed to get response from hardware, bailing\n\n"); 112 printf("Failed to get response from hardware, bailing\n\n");
129 printf("main: %d\n", count); 127 printf("main: %d\n", count);
130 count++; 128 count++;
131 sem_wait(&throttle); 129 sem_wait(&throttle);
132 130
133 //rlm: two files. 131 //rlm: two files.
134 clientStub->SendUnprocessedStream(channel0 , Data,(UINT32)sample); 132 clientStub->SendUnprocessedStream( Data,(UINT32)sample);
135 clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1); 133 //clientStub->SendUnprocessedStream(channel0 , Data,(UINT32)sample);
134 //clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1);
136 135
137 } 136 }
138 137
139 printf("main: out of loop\n"); 138 printf("main: out of loop\n");
140 139
141 // Need to put lock here to prevent potential race condition 140 // Need to put lock here to prevent potential race condition
142 pthread_mutex_lock(&lock); 141 pthread_mutex_lock(&lock);
143 142
144 //rlm: have to send end-files to both voices. 143 //rlm: have to send end-files to both voices.
145 // all of these operations wil eventually be moved into functions. 144 // all of these operations wil eventually be moved into functions.
146 clientStub->SendUnprocessedStream(channel0, EndOfFile,0); 145 clientStub->SendUnprocessedStream(EndOfFile,0);
147 clientStub->SendUnprocessedStream(channel1, EndOfFile,0); 146 //clientStub->SendUnprocessedStream(channel0, EndOfFile,0);
147 // clientStub->SendUnprocessedStream(channel1, EndOfFile,0);
148 148
149 printf("main: wait for end of file\n"); 149 printf("main: wait for end of file\n");
150 150
151 pthread_cond_wait(&cond, &lock); 151 pthread_cond_wait(&cond, &lock);
152 pthread_mutex_unlock(&lock); 152 pthread_mutex_unlock(&lock);