1,381
edits
Changes
From IGEP - ISEE Wiki
→Example
== Example ==
Below is a simple DMAI example showing audio decode using an AAC decoder and the Codec Engine (no error checking). Input is an elementary stream file and output is the sound device driver:
<code lang='"c'">{</code>{ #include <<xdc/std.h>> #include <<ti/sdo/ce/Engine.h>> #include <<ti/sdo/ce/CERuntime.h>> #include <<ti/sdo/dmai/Dmai.h>> #include <<ti/sdo/dmai/Buffer.h>> #include <<ti/sdo/dmai/Sound.h>> #include <<ti/sdo/dmai/Loader.h>> #include <<ti/sdo/dmai/ce/Adec.h>>
Adec_Handle hAd;
Loader_Handle hLoader;
Buffer_Handle hOutBuf, hInBuf;
Engine_Handle hEngine;
Sound_Handle hSound;
AUDDEC_Params params = Adec_Params_DEFAULT;
AUDDEC_DynamicParams dynParams = Adec_DynamicParams_DEFAULT;
Loader_Attrs lAttrs = Loader_Attrs_DEFAULT;
Buffer_Attrs bAttrs = Buffer_Attrs_DEFAULT;
Sound_Attrs sAttrs = Sound_Attrs_STEREO_DEFAULT;
CERuntime_init();
Dmai_init();
hSound = Sound_create(&sAttrs);
hEngine = Engine_open("myengine", NULL, NULL);
hAd = Adec_create(hEngine, "aacdec", &params, &dynParams); hOutBuf = Buffer_create(Adec_getOutBufSize(hAd), &bAttrs);
lAttrs.readSize = Adec_getInBufSize(hAd);
lAttrs.readBufSize = lAttrs.readSize * 2;
hLoader = Loader_create("myfile.aac", &lAttrs); Loader_prime(hLoader, &hInBuf);
while (1) {
Adec_process(hAd, hInBuf, hOutBuf);
Loader_getFrame(hLoader, hInBuf);
if (Buffer_getUserPtr(hInBuf) == NULL) break;
}
Loader_delete(hLoader);
Buffer_delete(hOutBuf);
Engine_close(hEngine);
Sound_delete(hSound);
}
==Versions==