"Fossies" - the Fresh Open Source Software Archive

Member "quicktime4linux-2.3/thirdparty/faac-1.24/plugins/aac_acm/aac_acm.cpp" (31 May 2008, 4881 Bytes) of package /linux/privat/old/quicktime4linux-2.3-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // aac_acm.cpp : Defines the entry point for the DLL application.
    2 //
    3 
    4 #include "stdafx.h"
    5 #include "codec.h"
    6 #include <list>
    7 
    8 struct messagetype
    9 {
   10     const char* c;
   11     int i;
   12 };
   13 
   14 const messagetype g_types[] =
   15 {
   16     "DRV_LOAD", DRV_LOAD,
   17     "DRV_FREE", DRV_FREE,
   18     "DRV_OPEN", DRV_OPEN,
   19     "DRV_CLOSE", DRV_CLOSE,
   20     "DRV_DISABLE", DRV_DISABLE,
   21     "DRV_ENABLE", DRV_ENABLE,
   22     "DRV_INSTALL", DRV_INSTALL,
   23     "DRV_REMOVE", DRV_REMOVE,
   24     "DRV_CONFIGURE", DRV_CONFIGURE,
   25     "DRV_QUERYCONFIGURE", DRV_QUERYCONFIGURE,
   26     "ACMDM_DRIVER_DETAILS", ACMDM_DRIVER_DETAILS,
   27     "ACMDM_DRIVER_ABOUT", ACMDM_DRIVER_ABOUT,
   28     "ACMDM_FORMATTAG_DETAILS", ACMDM_FORMATTAG_DETAILS,
   29     "ACMDM_FORMAT_DETAILS", ACMDM_FORMAT_DETAILS,
   30     "ACMDM_FORMAT_SUGGEST", ACMDM_FORMAT_SUGGEST,
   31     "ACMDM_STREAM_OPEN", ACMDM_STREAM_OPEN,
   32     "ACMDM_STREAM_CLOSE", ACMDM_STREAM_CLOSE,
   33     "ACMDM_STREAM_SIZE", ACMDM_STREAM_SIZE,
   34     "ACMDM_STREAM_CONVERT", ACMDM_STREAM_CONVERT,
   35     "ACMDM_STREAM_RESET", ACMDM_STREAM_RESET,
   36     "ACMDM_STREAM_PREPARE", ACMDM_STREAM_PREPARE,
   37     "ACMDM_STREAM_UNPREPARE", ACMDM_STREAM_UNPREPARE,
   38     "ACMDM_STREAM_UPDATE", ACMDM_STREAM_UPDATE,
   39 };
   40 
   41 #include <stdio.h>
   42 
   43 static void Message(const char* fmt, ...)
   44 {
   45 #ifndef NDEBUG
   46     FILE* f=fopen("c:\\msg.log", "ab");
   47     va_list va;
   48     va_start(va, fmt);
   49     vfprintf(f, fmt, va);
   50     va_end(va);
   51     fclose(f);
   52 #endif
   53 }
   54 
   55 //codec c1;
   56 //codec c2;
   57 //int iCodecs=0;
   58 
   59 bool g_bAttached=false;
   60 std::list<codec*> g_codec_objects;
   61 
   62 BOOL APIENTRY DllMain( HANDLE hModule, 
   63                       DWORD  ul_reason_for_call, 
   64                       LPVOID lpReserved
   65                       )
   66 {
   67     Message("DllMain(%d)\n");
   68     if(ul_reason_for_call==DLL_PROCESS_ATTACH)
   69         g_bAttached=true;
   70     if(ul_reason_for_call==DLL_PROCESS_DETACH)
   71     {
   72         for(std::list<codec*>::iterator it=g_codec_objects.begin();
   73         it!=g_codec_objects.end();
   74         it++)
   75             delete *it;
   76         g_bAttached=false;
   77     }
   78     return TRUE;
   79 }
   80 
   81 
   82 extern "C" LONG WINAPI DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2) 
   83 {
   84     codec *cdx = (codec *)(UINT)dwDriverID;
   85     ICOPEN *icinfo = (ICOPEN *)lParam2;
   86     
   87     if(g_bAttached==false) 
   88         // it really happens!
   89         // and since our heap may be already destroyed, we don't dare to do anything
   90         return E_FAIL;
   91     
   92     for(int i=0; i<sizeof(g_types)/sizeof(g_types[0]); i++)
   93     {
   94         if(uiMessage==g_types[i].i)
   95         {
   96             Message("%x %s %x %x\n", dwDriverID, g_types[i].c, lParam1, lParam2);
   97             goto cont;
   98         }
   99     }
  100     Message("%x %x %x %x\n", dwDriverID, uiMessage, lParam1, lParam2);
  101 cont:
  102     switch (uiMessage) 
  103     {
  104     /****************************************
  105     
  106       standard driver messages
  107       
  108     ****************************************/
  109         
  110     case DRV_LOAD:
  111         return (LRESULT)1L;
  112         
  113     case DRV_FREE:
  114         return (LRESULT)1L;
  115         
  116     case DRV_OPEN:
  117         if (icinfo && icinfo->fccType != ICTYPE_AUDIO) return NULL;
  118         //  if(!iCodecs)
  119         //      cdx=&c1;
  120         //  else
  121         //      cdx=&c2;
  122         //  iCodecs++;
  123         cdx = new codec;
  124         g_codec_objects.push_back(cdx);
  125         if (icinfo) icinfo->dwError = cdx ? ICERR_OK : ICERR_MEMORY;
  126         Message(" ==> %x\n", cdx);
  127         return (LRESULT)(DWORD)(UINT) cdx;
  128         
  129     case DRV_CLOSE:
  130         g_codec_objects.remove(cdx);
  131         delete cdx;
  132         return (LRESULT)1L;
  133         
  134     case DRV_DISABLE:
  135     case DRV_ENABLE:
  136         return (LRESULT)1L;
  137         
  138     case DRV_INSTALL:
  139     case DRV_REMOVE:
  140         return (LRESULT)DRV_OK;
  141         
  142     case DRV_QUERYCONFIGURE:    
  143         return (LRESULT)0L; // does support drive configure with the about box
  144         
  145     case DRV_CONFIGURE:
  146         //  return cdx->about(lParam1,lParam2);
  147         MessageBox(0, "Configure", "qqq", MB_OK);
  148         return DRVCNF_OK;
  149         
  150     case ACMDM_DRIVER_DETAILS:
  151         return cdx->details((ACMDRIVERDETAILSW*)lParam1);
  152         
  153     case ACMDM_DRIVER_ABOUT:
  154         return cdx->about((DWORD)lParam1);
  155         
  156     case ACMDM_FORMATTAG_DETAILS:
  157         return cdx->formattag_details((ACMFORMATTAGDETAILSW*)lParam1, (DWORD)lParam2);
  158         
  159     case ACMDM_FORMAT_DETAILS:
  160         return cdx->format_details((ACMFORMATDETAILSW*)lParam1, (DWORD)lParam2);
  161         
  162     case ACMDM_FORMAT_SUGGEST:
  163         return cdx->format_suggest((ACMDRVFORMATSUGGEST*)lParam1);
  164         
  165     case ACMDM_STREAM_OPEN:
  166         return cdx->open((ACMDRVSTREAMINSTANCE*)lParam1);
  167         
  168     case ACMDM_STREAM_PREPARE:
  169         return cdx->prepare((ACMDRVSTREAMINSTANCE*)lParam1, (ACMDRVSTREAMHEADER*) lParam2);
  170         
  171     case ACMDM_STREAM_RESET:
  172         return cdx->reset((ACMDRVSTREAMINSTANCE*)lParam1);
  173         
  174     case ACMDM_STREAM_SIZE:
  175         return cdx->size((ACMDRVSTREAMINSTANCE*)lParam1, (ACMDRVSTREAMSIZE*)lParam2);
  176         
  177     case ACMDM_STREAM_UNPREPARE:
  178         return cdx->unprepare((ACMDRVSTREAMINSTANCE*)lParam1, (ACMDRVSTREAMHEADER*) lParam2);
  179         
  180     case ACMDM_STREAM_CONVERT:
  181         return cdx->convert((ACMDRVSTREAMINSTANCE*)lParam1, (ACMDRVSTREAMHEADER*) lParam2);
  182         
  183     case ACMDM_STREAM_CLOSE:
  184         return cdx->close((ACMDRVSTREAMINSTANCE*)lParam1);
  185         
  186     }
  187     
  188     if (uiMessage < DRV_USER)
  189         return DefDriverProc(dwDriverID, hDriver, uiMessage, lParam1, lParam2);
  190     else
  191         return MMSYSERR_NOTSUPPORTED;
  192 }