diff AudioProcessorRRR.cpp @ 16:7e1510b47336 pygar svn.17

[svn r17] added rest of items for core
author punk
date Tue, 27 Apr 2010 22:54:50 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/AudioProcessorRRR.cpp	Tue Apr 27 22:54:50 2010 -0400
     1.3 @@ -0,0 +1,93 @@
     1.4 +#include <cstdio>
     1.5 +#include <cstdlib>
     1.6 +#include <iostream>
     1.7 +#include <iomanip>
     1.8 +#include <stdio.h>
     1.9 +#include <sys/stat.h>
    1.10 +
    1.11 +#include "asim/rrr/service_ids.h"
    1.12 +
    1.13 +#include "asim/provides/connected_application.h"
    1.14 +
    1.15 +
    1.16 +
    1.17 +using namespace std;
    1.18 +
    1.19 +// ===== service instantiation =====
    1.20 +AUDIOPROCESSORRRR_SERVER_CLASS AUDIOPROCESSORRRR_SERVER_CLASS::instance;
    1.21 +
    1.22 +// constructor
    1.23 +AUDIOPROCESSORRRR_SERVER_CLASS::AUDIOPROCESSORRRR_SERVER_CLASS() :
    1.24 +    serverStub(new AUDIOPROCESSORRRR_SERVER_STUB_CLASS(this))
    1.25 +{
    1.26 +    // instantiate stub
    1.27 +    printf("AUDIOPROCESSORRR init called\n");
    1.28 +    outputFile = NULL;
    1.29 +}
    1.30 +
    1.31 +// destructor
    1.32 +AUDIOPROCESSORRRR_SERVER_CLASS::~AUDIOPROCESSORRRR_SERVER_CLASS()
    1.33 +{
    1.34 +    Cleanup();
    1.35 +}
    1.36 +
    1.37 +// init
    1.38 +void
    1.39 +AUDIOPROCESSORRRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
    1.40 +{
    1.41 +    parent = p;
    1.42 +}
    1.43 +
    1.44 +// uninit
    1.45 +void
    1.46 +AUDIOPROCESSORRRR_SERVER_CLASS::Uninit()
    1.47 +{
    1.48 +    Cleanup();
    1.49 +}
    1.50 +
    1.51 +// cleanup
    1.52 +void
    1.53 +AUDIOPROCESSORRRR_SERVER_CLASS::Cleanup()
    1.54 +{
    1.55 +    delete serverStub;
    1.56 +}
    1.57 +
    1.58 +
    1.59 +//
    1.60 +// RRR service methods
    1.61 +//
    1.62 +
    1.63 +void
    1.64 +AUDIOPROCESSORRRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
    1.65 +{
    1.66 +
    1.67 +  AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
    1.68 +  switch(control) {
    1.69 +    case EndOfFile:
    1.70 +      if(outputFile != NULL) {
    1.71 +        fflush(outputFile);
    1.72 +        fclose(outputFile);
    1.73 +        outputFile = NULL;
    1.74 +      } else {
    1.75 +        outputFile = fopen("out_hw.pcm","w");
    1.76 +        assert(outputFile);
    1.77 +        fflush(outputFile);
    1.78 +        fclose(outputFile);
    1.79 +      }
    1.80 +
    1.81 +      CONNECTED_APPLICATION_CLASS::EndSimulation(); 
    1.82 +    break;
    1.83 +
    1.84 +    case Data:
    1.85 +      if(outputFile == NULL) {
    1.86 +        outputFile = fopen("out_hw.pcm","w");
    1.87 +        assert(outputFile);
    1.88 +      }
    1.89 +
    1.90 +      CONNECTED_APPLICATION_CLASS::UpdateSemaphore();  
    1.91 +      fwrite(&data, 2,1 , outputFile);
    1.92 +    break;
    1.93 +  }
    1.94 + 
    1.95 +}
    1.96 +