因为DSP中RAM主要是用来存储数据,但是当使用FFT算法,小波算法等时会遇见数据量太大,内部RAM空间根本不够,这个问题的解决方法有两种:1、如果数据时const类型,可以定义在flash里面;2、外扩SRAM。
外扩SRAM后,怎么使用呢?
1、在CMD文件中定义一段数据空间,如:Zone7Data :origin=0x25ffff,length=0x02000
Zone7DataFile :> Zone7Data ,PAGE=1
2、将较大的数组编译到CMD中定义的段中
#pragma DATA_SECTION(s,"Zone7DataFile ");
unsigned int s[1024];
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/soundcard.h> int main(int argc, char *argv[]) { int id,fd,i; char buf[4096]; int rate; /* 采样频率 44.1KHz*/ int format; /* 量化位数 16*/ int channels; /* 声道数 2*/ int setting; /* 高16位标明分片最大序号,低16位标明缓冲区的尺寸*/ if (argc != 2) { fprintf (stderr, "usage: %s <filename>!\n", argv[0]); exit ( -1 ) ; } if ( ( fd = open (argv[1],O_RDONLY))<0) { fprintf ( stderr, " Can't open sound file!\n"); exit (-1 ); } if ( ( id = open ( "/dev/dsp", O_WRONLY) ) < 0 ) { fprintf (stderr, " Can't open sound device!\n"); exit ( -1 ) ; } /* 此项在Virtual PC中可减少电流声 */ setting = 0x0002000F; ioctl(id, SNDCTL_DSP_SETFRAGMENT, &setting); rate = 441000; ioctl(id, SNDCTL_DSP_SPEED, &rate); format = AFMT_S16_LE; ioctl(id, SNDCTL_DSP_SETFMT, &format); channels = 2; ioctl(id, SNDCTL_DSP_CHANNELS, &channels); while((i = read(fd,buf, sizeof(buf)))>0) { write(id,buf,i); } close(fd); close(id); exit(0); }
具体报错如下:
FATAL EXCEPTION: main
android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4051c0e0 is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:558)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:433)
at android.app.Dialog.show(Dialog.java:265)
at net.reecam.CameraSearch$3.onClick(CameraSearch.java:103)
at android.view.View.performClick(View.java:2532)
at android.view.View$PerformClick.run(View.java:9308)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
问题原因:
看报错关键词提示: Unable to add window 、LocalActivityManager、is your activity running,再结合应用程序中用到了AcitivityGroup来管理子Activity这个环境,而报错的前提就是在子Activity上弹出ProgressDialog进度条会话框,提示如上报错提示。就是说不能在子Activity上添加此窗口,LocalActivityManager$LocalActivityRecord@4051c0e0
is not valid就是说当前Activity管理器中此4051c0e0代表的Acitivity是无效的,也就是网上资料所说找不到它依附的Acitivity。
解决办法:
将new DialogToast(this);
改为:
new DialogToast(getParent());
就OK了。
小结:
以后在弹出子窗口时要注意下这个问题。在此记录下,备忘。
参考网址:
http://blog.csdn.net/biangren/article/details/7514722