rename some files

This commit is contained in:
dumganhar 2011-10-14 18:33:14 +08:00
parent eaad344762
commit 7d9ff2af6f
4 changed files with 63 additions and 197 deletions

View File

@ -1,14 +1,5 @@
/* #include "CCAudioOut.h"
* MyAudioOutListener.cpp
*
* Created on: 2011-1-21
* Author: Administrator
*/
#include "MyAudioOutListener.h"
#include <stdio.h> #include <stdio.h>
#include "WavHead.h"
using namespace Osp::Base; using namespace Osp::Base;
using namespace Osp::Base::Collection; using namespace Osp::Base::Collection;
@ -16,6 +7,63 @@ using namespace Osp::Media;
#define MAX_BUFFER_SIZE 2520 // 840 byte #define MAX_BUFFER_SIZE 2520 // 840 byte
typedef struct wave_tag
{
char ChunkID[5];
unsigned long int ChunkSize;
char Format[5];
char SubChunk1ID[5];
unsigned long int SubChunk1Size;
unsigned short int AudioFormat;
unsigned short int NumChannels;
unsigned long int SampleRate;
unsigned long int ByteRate;
unsigned short int BlockAlign;
unsigned short int BitsPerSample;
char SubChunk2ID[5];
unsigned long int SubChunk2Size;
}WAVE;
static bool GetWaveHeadInfo(FILE*stream, WAVE& outWavHead)
{
char szTmp[100] = {0};
int i = 0;
fread(outWavHead.ChunkID, 4, 1, stream);
outWavHead.ChunkID[4] = (char)0;
fread(&(outWavHead.ChunkSize),4, 1, stream);
fread(outWavHead.Format, 4, 1, stream);
outWavHead.Format[4] = (char)0;
fread(outWavHead.SubChunk1ID, 4, 1, stream);
outWavHead.SubChunk1ID[4] = (char)0;
fread(&(outWavHead.SubChunk1Size), 4, 1, stream);
fread(&(outWavHead.AudioFormat), 2, 1, stream);
fread(&(outWavHead.NumChannels), 2, 1, stream);
fread(&(outWavHead.SampleRate), 4, 1, stream);
fread(&(outWavHead.ByteRate), 4, 1, stream);
fread(&(outWavHead.BlockAlign), 2, 1, stream);
fread(&(outWavHead.BitsPerSample), 2, 1, stream);
fseek(stream, 0, SEEK_SET);
fread(szTmp, 64, 1, stream);
for (i = 0; i <= 60; i++)
{
if (szTmp[i] == 'd' && szTmp[i+1] == 'a' && szTmp[i+2] == 't' && szTmp[i+3] == 'a')
{
break;
}
}
fseek(stream, i, SEEK_SET);
fread(outWavHead.SubChunk2ID, 4, 1, stream);
outWavHead.SubChunk2ID[4] = (char)0;
fread(&(outWavHead.SubChunk2Size), 4, 1, stream);
return true;
}
MyAudioOutEventListener::MyAudioOutEventListener() MyAudioOutEventListener::MyAudioOutEventListener()
{ {
__totalWriteBufferNum = 0; __totalWriteBufferNum = 0;

View File

@ -1,18 +1,9 @@
/* #ifndef __CCAUDIOOUT_H__
* MyAudioOutListener.h #define __CCAUDIOOUT_H__
*
* Created on: 2011-1-21
* Author: Administrator
*/
#ifndef MYAUDIOOUTLISTENER_H_
#define MYAUDIOOUTLISTENER_H_
#include <FBase.h> #include <FBase.h>
#include <FMedia.h> #include <FMedia.h>
class MyAudioOutEventListener : class MyAudioOutEventListener :
public Osp::Media::IAudioOutEventListener public Osp::Media::IAudioOutEventListener
{ {
@ -24,9 +15,9 @@ public:
result Construct(const char* pszFilePath); result Construct(const char* pszFilePath);
void play(); void Play();
void stop(); void Stop();
void setVolume(int volume); void SetVolume(int volume);
/** /**
* Notifies when the device has written a buffer completely. * Notifies when the device has written a buffer completely.
* *

View File

@ -1,81 +0,0 @@
/*
* WaveHead.cpp
*
* Created on: 2011-1-21
* Author: Administrator
*/
#include "WavHead.h"
#include <stdio.h>
#include <FBaseSys.h>
bool GetWaveHeadInfo(FILE*stream, WAVE& outWavHead)
{
char szTmp[100] = {0};
int i = 0;
// FILE *stream;
// if((stream = fopen(fileName,"rb"))==NULL)
// {
// AppLog("ERROR:can't open the file!");
//
// return false;
// }
/*
* wav文件的各个field
*/
fread(outWavHead.ChunkID, 4, 1, stream);
outWavHead.ChunkID[4] = (char)0;
fread(&(outWavHead.ChunkSize),4, 1, stream);
fread(outWavHead.Format, 4, 1, stream);
outWavHead.Format[4] = (char)0;
fread(outWavHead.SubChunk1ID, 4, 1, stream);
outWavHead.SubChunk1ID[4] = (char)0;
fread(&(outWavHead.SubChunk1Size), 4, 1, stream);
fread(&(outWavHead.AudioFormat), 2, 1, stream);
fread(&(outWavHead.NumChannels), 2, 1, stream);
fread(&(outWavHead.SampleRate), 4, 1, stream);
fread(&(outWavHead.ByteRate), 4, 1, stream);
fread(&(outWavHead.BlockAlign), 2, 1, stream);
fread(&(outWavHead.BitsPerSample), 2, 1, stream);
fseek(stream, 0, SEEK_SET);
fread(szTmp, 64, 1, stream);
for (i = 0; i <= 60; i++)
{
if (szTmp[i] == 'd' && szTmp[i+1] == 'a' && szTmp[i+2] == 't' && szTmp[i+3] == 'a')
{
break;
}
}
fseek(stream, i, SEEK_SET);
fread(outWavHead.SubChunk2ID, 4, 1, stream);
outWavHead.SubChunk2ID[4] = (char)0;
fread(&(outWavHead.SubChunk2Size), 4, 1, stream);
return true;
}

View File

@ -1,92 +0,0 @@
/*
* WavHead.h
*
* Created on: 2011-1-21
* Author: Administrator
*/
#ifndef WAVHEAD_H_
#define WAVHEAD_H_
#include <stdio.h>
/* WAVE文件头 */
typedef struct wave_tag
{
char ChunkID[5]; // "RIFF"标志
unsigned long int ChunkSize; // 文件长度(WAVE文件的大小, 不含前8个字节)
char Format[5]; // "WAVE"标志
char SubChunk1ID[5];// "fmt "标志
unsigned long int SubChunk1Size; /*
* ()
* 16 for PCM. This is the size of the rest of the
* Subchunk which follows this number.
*/
unsigned short int AudioFormat; /*
* (10H为PCM格式的声音数据)
* PCM=1 (i.e. Linear quantization)
* Values other than 1 indicate some form of compression.
*/
unsigned short int NumChannels; // 通道数(单声道为1, 双声道为2)
//unsigned short int SampleRate; // 采样率(每秒样本数), 表示每个通道的播放速度
unsigned long int SampleRate; // 采样率(每秒样本数), 表示每个通道的播放速度
unsigned long int ByteRate; /*
* , :**/8
*
*/
unsigned short int BlockAlign; /*
* (), :*/8
* , 便
*/
unsigned short int BitsPerSample; /*
* , . ,
* ,
*/
char SubChunk2ID[5]; // 数据标记"data"
unsigned long int SubChunk2Size; // 语音数据的长度
} WAVE;
/*
* pBuffer内部申请空间
*/
bool GetWaveHeadInfo(FILE*stream, WAVE& outWavHead);
#endif /* WAVHEAD_H_ */