0

我已经设法从源代码编译 android 并安装在我的手机上。我可能应该从一开始就说我不是 C++ 开发人员,但我希望我能够弄清楚如何将变量中保存的数据输出到文件中。

经过一番谷歌搜索后,我想出了以下代码:

#include <iostream>
#include <fstream>
using namespace std;

ofstream myfile;
myfile.open ("/data/wav.raw");
myfile < mMixBuffer;
myfile.close();

frameworks/base/services/audioflinger/AudioFlinger.cpp: In member function 'virtual bool android::AudioFlinger::MixerThread::threadLoop()':
frameworks/base/services/audioflinger/AudioFlinger.cpp:1769: error: 'ofstream' was not declared in this scope
frameworks/base/services/audioflinger/AudioFlinger.cpp:1769: error: expected ';' before 'myfile'
frameworks/base/services/audioflinger/AudioFlinger.cpp:1770: error: 'myfile' was not declared in this scope

在这不起作用之后,我尝试了再次给出编译错误:

int fd;
fd = ::open("/data/wav.raw",O_WRONLY | O_APPEND);
::write(fd,mMixBuffer,minBufferSize);
::close(fd);

frameworks/base/services/audioflinger/AudioFlinger.cpp: In member function 'virtual bool android::AudioFlinger::MixerThread::threadLoop()':
frameworks/base/services/audioflinger/AudioFlinger.cpp:1770: error: '::open' has not been declared
frameworks/base/services/audioflinger/AudioFlinger.cpp:1770: error: 'O_WRONLY' was not declared in this scope
frameworks/base/services/audioflinger/AudioFlinger.cpp:1770: error: 'O_APPEND' was not declared in this scope

如果从上面不清楚,我正在尝试将变量的内容附加mMixBufferminBufferSize文件/data/wav.raw中。有谁知道我怎么能做到这一点?

4

1 回答 1

1

/data/ 目录不能修改。您将不会拥有相同的权限。试试 /mnt/sdcard(或)/data/data/。

于 2012-12-18T10:00:58.853 回答