comparison modules/bluespec/Pygar/common/AudioProcessorRRR.cpp @ 8:74716e9a81cc pygar svn.9

[svn r9] Pygar now has the proper directory structure to play nicely with awb. Also, the apm file for audio-core willcompile successfully.
author rlm
date Fri, 23 Apr 2010 02:32:05 -0400
parents
children
comparison
equal deleted inserted replaced
7:7393cd19371e 8:74716e9a81cc
1 #include <cstdio>
2 #include <cstdlib>
3 #include <iostream>
4 #include <iomanip>
5 #include <stdio.h>
6 #include <sys/stat.h>
7
8 #include "asim/rrr/service_ids.h"
9
10 #include "asim/provides/connected_application.h"
11
12
13
14 using namespace std;
15
16 // ===== service instantiation =====
17 AUDIOPROCESSORRRR_SERVER_CLASS AUDIOPROCESSORRRR_SERVER_CLASS::instance;
18
19 // constructor
20 AUDIOPROCESSORRRR_SERVER_CLASS::AUDIOPROCESSORRRR_SERVER_CLASS() :
21 serverStub(new AUDIOPROCESSORRRR_SERVER_STUB_CLASS(this))
22 {
23 // instantiate stub
24 printf("AUDIOPROCESSORRR init called\n");
25 outputFile = NULL;
26 }
27
28 // destructor
29 AUDIOPROCESSORRRR_SERVER_CLASS::~AUDIOPROCESSORRRR_SERVER_CLASS()
30 {
31 Cleanup();
32 }
33
34 // init
35 void
36 AUDIOPROCESSORRRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
37 {
38 parent = p;
39 }
40
41 // uninit
42 void
43 AUDIOPROCESSORRRR_SERVER_CLASS::Uninit()
44 {
45 Cleanup();
46 }
47
48 // cleanup
49 void
50 AUDIOPROCESSORRRR_SERVER_CLASS::Cleanup()
51 {
52 delete serverStub;
53 }
54
55
56 //
57 // RRR service methods
58 //
59
60 void
61 AUDIOPROCESSORRRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
62 {
63
64 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
65 switch(control) {
66 case EndOfFile:
67 if(outputFile != NULL) {
68 fflush(outputFile);
69 fclose(outputFile);
70 outputFile = NULL;
71 } else {
72 outputFile = fopen("out_hw.pcm","w");
73 assert(outputFile);
74 fflush(outputFile);
75 fclose(outputFile);
76 }
77
78 CONNECTED_APPLICATION_CLASS::EndSimulation();
79 break;
80
81 case Data:
82 if(outputFile == NULL) {
83 outputFile = fopen("out_hw.pcm","w");
84 assert(outputFile);
85 }
86
87 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
88 fwrite(&data, 2,1 , outputFile);
89 break;
90 }
91
92 }
93