---
title: "NDK学习 mp3解码器等相关"
author: "sfshine"
date: "2012-11-17T11:19:43Z"
tags: []
categories: ["移动开发"]
slug: "ndk-mp3"
draft: false
lastmod: "2012-11-17T11:19:43Z"
id: 1728344
url: "https://sfshine.iteye.com/blog/1728344"
---

C写文件

 

**\[cpp]** [view plain](http://blog.csdn.net/sfshine/article/details/8192284 "view plain")[copy](http://blog.csdn.net/sfshine/article/details/8192284 "copy")[print](http://blog.csdn.net/sfshine/article/details/8192284 "print")[?](http://blog.csdn.net/sfshine/article/details/8192284 "?")

01. #include&lt;stdio.h&gt;
02. main(){
03. // java
04. // File file = new File("1.txt")
05. // 打开一个文件的c语言的函数
06. // sharedpreference  db content.openoutput()
07. // 获取到文件的指针
08. FILE* fp = fopen("1.txt","wt");
09. char* str ="haha wirte file";
10. // fwrite方法接受4个参数
11. // 第一个参数 写什么内容
12. // 第二个参数 是一次 数据写多长
13. // 第三个参数 是写多少次
14. // 第四个参数 写到哪个文件里面
15. int len = fwrite(str,sizeof(char),15,fp);
16. printf("len =%d\\n",len);
17. //释放文件句柄
18. fclose(fp);
19. system("pause");
20. }

c读文件

 

 

**\[cpp]** [view plain](http://blog.csdn.net/sfshine/article/details/8192284 "view plain")[copy](http://blog.csdn.net/sfshine/article/details/8192284 "copy")[print](http://blog.csdn.net/sfshine/article/details/8192284 "print")[?](http://blog.csdn.net/sfshine/article/details/8192284 "?")

01. #include&lt;stdio.h&gt;
02. main(){
03. FILE* fp = fopen("1.txt","rt");
04. char arr\[20]={};
05. //第一个参数 是读出来内容放在哪里
06. // 第二个 参数 一次读的数据的长度
07. // 第三个参数 读多少次
08. // 第四个参数 从哪个文件里面读
09. int read = fread(arr,sizeof(char),15,fp);
10. printf("arr = %s\\n",arr);
11. printf("读了%d个char类型\\n",read);
12. fclose(fp);//必须加入 否则会造成一直在占用这个文件
13. system("pause");
14. }

编写编码器应用的流程

 

1.明确需求

2.研究技术实现 如果没有做过 需要进行一定时间的调研,如果还不能ok 只能想办法绕过这个知识点实现需求

3.实施:

    -1 研究c源码解码器的工作过程,找到核心代码 找到入口等

    -2将核心代码放入jni然后编译 注意头文件的引入

    -3测试

注意android需要在

LOCAL\_SRC\_FILES 描述中把所有的c文件都知名 可以做个 程序获取

 

这次老师代码有个不好的地方是没有吧解码器的代码进行封装 如果封装成一个方法 然后输入文件输出文件就可以了

另外

含有进度的进度条有两种 一种是真正计算出来的进度去 一种是估算出来的 会在99%哪里卡住.