view modules/bluespec/Pygar/common/AudioProcessorRRR.cpp @ 38:05598d745f99 pygar svn.39

[svn r39] fixed audiocorepipe
author punk
date Tue, 04 May 2010 19:27:38 -0400
parents 74716e9a81cc
children
line wrap: on
line source
1 #include <cstdio>
2 #include <cstdlib>
3 #include <iostream>
4 #include <iomanip>
5 #include <stdio.h>
6 #include <sys/stat.h>
8 #include "asim/rrr/service_ids.h"
10 #include "asim/provides/connected_application.h"
14 using namespace std;
16 // ===== service instantiation =====
17 AUDIOPROCESSORRRR_SERVER_CLASS AUDIOPROCESSORRRR_SERVER_CLASS::instance;
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 }
28 // destructor
29 AUDIOPROCESSORRRR_SERVER_CLASS::~AUDIOPROCESSORRRR_SERVER_CLASS()
30 {
31 Cleanup();
32 }
34 // init
35 void
36 AUDIOPROCESSORRRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
37 {
38 parent = p;
39 }
41 // uninit
42 void
43 AUDIOPROCESSORRRR_SERVER_CLASS::Uninit()
44 {
45 Cleanup();
46 }
48 // cleanup
49 void
50 AUDIOPROCESSORRRR_SERVER_CLASS::Cleanup()
51 {
52 delete serverStub;
53 }
56 //
57 // RRR service methods
58 //
60 void
61 AUDIOPROCESSORRRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
62 {
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 }
78 CONNECTED_APPLICATION_CLASS::EndSimulation();
79 break;
81 case Data:
82 if(outputFile == NULL) {
83 outputFile = fopen("out_hw.pcm","w");
84 assert(outputFile);
85 }
87 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
88 fwrite(&data, 2,1 , outputFile);
89 break;
90 }
92 }