Mercurial > pygar
view 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 |
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 // constructor20 AUDIOPROCESSORRRR_SERVER_CLASS::AUDIOPROCESSORRRR_SERVER_CLASS() :21 serverStub(new AUDIOPROCESSORRRR_SERVER_STUB_CLASS(this))22 {23 // instantiate stub24 printf("AUDIOPROCESSORRR init called\n");25 outputFile = NULL;26 }28 // destructor29 AUDIOPROCESSORRRR_SERVER_CLASS::~AUDIOPROCESSORRRR_SERVER_CLASS()30 {31 Cleanup();32 }34 // init35 void36 AUDIOPROCESSORRRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)37 {38 parent = p;39 }41 // uninit42 void43 AUDIOPROCESSORRRR_SERVER_CLASS::Uninit()44 {45 Cleanup();46 }48 // cleanup49 void50 AUDIOPROCESSORRRR_SERVER_CLASS::Cleanup()51 {52 delete serverStub;53 }56 //57 // RRR service methods58 //60 void61 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 }