annotate modules/bluespec/Pygar/common/AudioProcessorRRR.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 74716e9a81cc
children
rev   line source
rlm@8 1 #include <cstdio>
rlm@8 2 #include <cstdlib>
rlm@8 3 #include <iostream>
rlm@8 4 #include <iomanip>
rlm@8 5 #include <stdio.h>
rlm@8 6 #include <sys/stat.h>
rlm@8 7
rlm@8 8 #include "asim/rrr/service_ids.h"
rlm@8 9
rlm@8 10 #include "asim/provides/connected_application.h"
rlm@8 11
rlm@8 12
rlm@8 13
rlm@8 14 using namespace std;
rlm@8 15
rlm@8 16 // ===== service instantiation =====
rlm@8 17 AUDIOPROCESSORRRR_SERVER_CLASS AUDIOPROCESSORRRR_SERVER_CLASS::instance;
rlm@8 18
rlm@8 19 // constructor
rlm@8 20 AUDIOPROCESSORRRR_SERVER_CLASS::AUDIOPROCESSORRRR_SERVER_CLASS() :
rlm@8 21 serverStub(new AUDIOPROCESSORRRR_SERVER_STUB_CLASS(this))
rlm@8 22 {
rlm@8 23 // instantiate stub
rlm@8 24 printf("AUDIOPROCESSORRR init called\n");
rlm@8 25 outputFile = NULL;
rlm@8 26 }
rlm@8 27
rlm@8 28 // destructor
rlm@8 29 AUDIOPROCESSORRRR_SERVER_CLASS::~AUDIOPROCESSORRRR_SERVER_CLASS()
rlm@8 30 {
rlm@8 31 Cleanup();
rlm@8 32 }
rlm@8 33
rlm@8 34 // init
rlm@8 35 void
rlm@8 36 AUDIOPROCESSORRRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
rlm@8 37 {
rlm@8 38 parent = p;
rlm@8 39 }
rlm@8 40
rlm@8 41 // uninit
rlm@8 42 void
rlm@8 43 AUDIOPROCESSORRRR_SERVER_CLASS::Uninit()
rlm@8 44 {
rlm@8 45 Cleanup();
rlm@8 46 }
rlm@8 47
rlm@8 48 // cleanup
rlm@8 49 void
rlm@8 50 AUDIOPROCESSORRRR_SERVER_CLASS::Cleanup()
rlm@8 51 {
rlm@8 52 delete serverStub;
rlm@8 53 }
rlm@8 54
rlm@8 55
rlm@8 56 //
rlm@8 57 // RRR service methods
rlm@8 58 //
rlm@8 59
rlm@8 60 void
rlm@8 61 AUDIOPROCESSORRRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
rlm@8 62 {
rlm@8 63
rlm@8 64 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
rlm@8 65 switch(control) {
rlm@8 66 case EndOfFile:
rlm@8 67 if(outputFile != NULL) {
rlm@8 68 fflush(outputFile);
rlm@8 69 fclose(outputFile);
rlm@8 70 outputFile = NULL;
rlm@8 71 } else {
rlm@8 72 outputFile = fopen("out_hw.pcm","w");
rlm@8 73 assert(outputFile);
rlm@8 74 fflush(outputFile);
rlm@8 75 fclose(outputFile);
rlm@8 76 }
rlm@8 77
rlm@8 78 CONNECTED_APPLICATION_CLASS::EndSimulation();
rlm@8 79 break;
rlm@8 80
rlm@8 81 case Data:
rlm@8 82 if(outputFile == NULL) {
rlm@8 83 outputFile = fopen("out_hw.pcm","w");
rlm@8 84 assert(outputFile);
rlm@8 85 }
rlm@8 86
rlm@8 87 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
rlm@8 88 fwrite(&data, 2,1 , outputFile);
rlm@8 89 break;
rlm@8 90 }
rlm@8 91
rlm@8 92 }
rlm@8 93