// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
// File: Wave.c
//
// Desc: DirectShow sample code - Wave library routines.
//------------------------------------------------------------------------------
/*==========================================================================
*
* This file is used for loading/saving waves, and reading and
* writing waves in smaller blocks.
* Uses WaveOpenFile, WaveReadFile and WaveCloseReadFile for
* single block access to reading wave files.
* Uses WaveCreateFile, WaveWriteFile, WaveCloseWriteFile for
* single block access for writing wave files.
* Uses WaveLoadFile to load a whole wave file into memory.
* Uses WaveSaveFile to save a whole wave file into memory.
*
***************************************************************************/
#pragma warning(disable:4100) // Disable C4100: unreferenced formal parameter
#pragma warning(disable:4213) // Disable C4213: cast on lvalue
#pragma warning(disable:4115) // Disable C4115: (from VC6.0 header rpsasync.h)
#include <windows.h>
#include <mmsystem.h>
#include "wave.h"
#include "debug.h"
#include "windowsx.h"
#pragma warning(default:4115) // Reset to default behavior for C4115
/* ROUTINES */
/* -------------------------------------------------------*/
/* This function will open a wave input file and prepare it for reading,
* so the data can be easily
* read with WaveReadFile. Returns 0 if successful, the error code if not.
* pszFileName - Input filename to load.
* phmmioIn - Pointer to handle which will be used
* for further mmio routines.
* ppwfxInfo - Ptr to ptr to WaveFormatEx structure
* with all info about the file.
*
*/
int WaveOpenFile(
TCHAR*pszFileName, // (IN)
HMMIO *phmmioIn, // (OUT)
WAVEFORMATEX **ppwfxInfo, // (OUT)
MMCKINFO *pckInRIFF // (OUT)
)
{
HMMIO hmmioIn;
MMCKINFO ckIn; // chunk info. for general use.
PCMWAVEFORMAT pcmWaveFormat; // Temp PCM structure to load in.
WORD cbExtraAlloc; // Extra bytes for waveformatex
int nError; // Return value.
// Initialization
*ppwfxInfo = NULL;
nError = 0;
hmmioIn = NULL;
if ((hmmioIn = mmioOpen(pszFileName, NULL, MMIO_ALLOCBUF | MMIO_READ)) == NULL)
{
nError = ER_CANNOTOPEN;
goto ERROR_READING_WAVE;
}
if ((nError = (int)mmioDescend(hmmioIn, pckInRIFF, NULL, 0)) != 0)
{
goto ERROR_READING_WAVE;
}
if ((pckInRIFF->ckid != FOURCC_RIFF) || (pckInRIFF->fccType != mmioFOURCC('W', 'A', 'V', 'E')))
{
nError = ER_NOTWAVEFILE;
goto ERROR_READING_WAVE;
}
/* Search the input file for for the 'fmt ' chunk. */
ckIn.ckid = mmioFOURCC('f', 'm', 't', ' ');
if ((nError = (int)mmioDescend(hmmioIn, &ckIn, pckInRIFF, MMIO_FINDCHUNK)) != 0)
{
goto ERROR_READING_WAVE;
}
/* Expect the 'fmt' chunk to be at least as large as <PCMWAVEFORMAT>;
* if there are extra parameters at the end, we'll ignore them */
if (ckIn.cksize < (long) sizeof(PCMWAVEFORMAT))
{
nError = ER_NOTWAVEFILE;
goto ERROR_READING_WAVE;
}
/* Read the 'fmt ' chunk into <pcmWaveFormat>.*/
if (mmioRead(hmmioIn, (HPSTR) &pcmWaveFormat, (long) sizeof(pcmWaveFormat)) != (long) sizeof(pcmWaveFormat))
{
nError = ER_CANNOTREAD;
goto ERROR_READING_WAVE;
}
// Allocate the waveformatex, but if its not pcm
// format, read the next word, and thats how many extra
// bytes to allocate.
if (pcmWaveFormat.wf.wFormatTag == WAVE_FORMAT_PCM)
cbExtraAlloc = 0;
else
{
// Read in length of extra bytes.
if (mmioRead(hmmioIn, (HPSTR) &cbExtraAlloc,
(long) sizeof(cbExtraAlloc)) != (long) sizeof(cbExtraAlloc))
{
nError = ER_CANNOTREAD;
goto ERROR_READING_WAVE;
}
}
// Now allocate that waveformatex structure.
if ((*ppwfxInfo = GlobalAlloc(GMEM_FIXED, sizeof(WAVEFORMATEX)+cbExtraAlloc)) == NULL)
{
nError = ER_MEM;
goto ERROR_READING_WAVE;
}
// Copy the bytes from the pcm structure to the waveformatex structure
memcpy(*ppwfxInfo, &pcmWaveFormat, sizeof(pcmWaveFormat));
(*ppwfxInfo)->cbSize = cbExtraAlloc;
// Read those extra bytes into the structure, if cbExtraAlloc != 0.
if (cbExtraAlloc != 0)
{
if (mmioRead(hmmioIn, (HPSTR) (((BYTE*)&((*ppwfxInfo)->cbSize))+sizeof(cbExtraAlloc)),
(long) (cbExtraAlloc)) != (long) (cbExtraAlloc))
{
nError = ER_NOTWAVEFILE;
goto ERROR_READING_WAVE;
}
}
/* Ascend the input file out of the 'fmt ' chunk. */
if ((nError = mmioAscend(hmmioIn, &ckIn, 0)) != 0)
{
goto ERROR_READING_WAVE;
}
goto TEMPCLEANUP;
ERROR_READING_WAVE:
if (*ppwfxInfo != NULL)
{
GlobalFree(*ppwfxInfo);
*ppwfxInfo = NULL;
}
if (hmmioIn != NULL)
{
mmioClose(hmmioIn, 0);
hmmioIn = NULL;
}
TEMPCLEANUP:
*phmmioIn = hmmioIn;
return(nError);
}
/* This routine has to be called before WaveReadFile as it searchs for the
chunk to descend into for reading, that is, the 'data' chunk. For
simplicity, this used to be in the open routine, but was taken out and
moved to a separate routine so there was more control on the chunks that
are before the data chunk, such as 'fact', etc... */
int WaveStartDataRead(
HMMIO *phmmioIn,
MMCKINFO *pckIn,
MMCKINFO *pckInRIFF
)
{
int nError=0;
// Perform a seek...
if ((nError = mmioSeek(*phmmioIn,
pckInRIFF->dwDataOffset + sizeof(FOURCC), SEEK_SET)) == -1)
{
// ASSERT(FALSE);
}
nError = 0;
// Search the input file for for the 'data' chunk.
pckIn->ckid = mmioFOURCC('d', 'a', 't', 'a');
nError = mmioDescend(*phmmioIn, pckIn, pckInRIFF, MMIO_FINDCHUNK);
return(nError);
}
/* This will read wave data from the wave file. Makre sure we're descended into
the data chunk, else this will fail bigtime!
hmmioIn - Handle to mmio.
cbRead - # of bytes to read.
pbDest - Destination buffer to put bytes.
cbActualRead- # of bytes actually read.
*/
int WaveReadFile(
HMMIO hmmioIn, // IN
UINT cbRead, // IN
BYTE *pbDest, // IN
MMCKINFO *pckIn, // IN.
UINT *cbActualRead // OUT.
)
{
MMIOINFO mmioinfoIn; // current status of <hmmioIn>
int nError=0;
UINT cT, cbDataIn;
if ((nError = mmioGetInfo(hmmioIn, &mmioinfoIn, 0)) != 0)
{
goto ERROR_CANNOT_READ;
}
cbDataIn = cbRead;
if (cbDataIn > pckIn->cksize)
cbDataIn = pckIn->cksize;
pckIn->cksize -= cbDataIn;
for (cT = 0; cT < cbDataIn; cT++
没有合适的资源?快使用搜索试试~ 我知道了~
directshow9
共463个文件
h:149个
cpp:112个
obj:62个
需积分: 50 47 下载量 127 浏览量
2018-06-20
16:05:34
上传
评论
收藏 11.98MB RAR 举报
温馨提示
directshow9 开发头文件和库
资源推荐
资源详情
资源评论
收起资源包目录
directshow9 (463个子文件)
toolbar2.bmp 68KB
toolbar1.bmp 68KB
WideWatermark.bmp 60KB
vmr.bmp 48KB
ticker.bmp 4KB
toolbar.bmp 2KB
volume.bmp 2KB
slider.bmp 2KB
TOOLBAR.BMP 2KB
toolbar.bmp 1KB
wave.c 26KB
amfilter.cpp 155KB
amcap.cpp 148KB
renbase.cpp 97KB
winutil.cpp 94KB
dvdcore.cpp 90KB
winctrl.cpp 67KB
dvapp.cpp 64KB
CDVGraph.cpp 56KB
app.cpp 55KB
dsutil.cpp 55KB
ctlutil.cpp 54KB
wxdebug.cpp 48KB
scope.cpp 44KB
SampleCGB.cpp 44KB
synth.cpp 43KB
dialogs.cpp 41KB
windowless.cpp 35KB
inftee.cpp 35KB
transip.cpp 34KB
dxutil.cpp 34KB
dvdsample.cpp 32KB
PsiParser.cpp 31KB
transfrm.cpp 28KB
ticker.cpp 26KB
watermark.cpp 26KB
gargle.cpp 25KB
wxlist.cpp 25KB
progprop.cpp 24KB
outputq.cpp 24KB
namedguid.cpp 23KB
videoctl.cpp 23KB
metronom.cpp 23KB
ezrgb24.cpp 22KB
dump.cpp 22KB
vcdplyer.cpp 21KB
maindialog.cpp 21KB
wxutil.cpp 20KB
bitmap.cpp 20KB
sampvid.cpp 19KB
crossbar.cpp 18KB
dllsetup.cpp 18KB
fball.cpp 18KB
maindialog.cpp 18KB
dynsrc.cpp 18KB
vtrans.cpp 17KB
asyncio.cpp 17KB
slider.cpp 17KB
dmodemo.cpp 17KB
videotxt.cpp 17KB
MainWindow.cpp 16KB
playcap.cpp 16KB
bitmap.cpp 16KB
DShowPlayer.cpp 15KB
synthprp.cpp 15KB
MyCompositor9.cpp 14KB
commands.cpp 13KB
refclock.cpp 13KB
maindialog.cpp 13KB
vmr9allocator.cpp 13KB
PushSourceBitmap.cpp 13KB
strmctl.cpp 13KB
vmr9compositor.cpp 13KB
source.cpp 12KB
PushSourceBitmapSet.cpp 12KB
toolbar.cpp 12KB
PushSourceDesktop.cpp 12KB
wavdest.cpp 12KB
mtype.cpp 12KB
pullpin.cpp 11KB
arithutil.cpp 10KB
Allocator.cpp 10KB
cprop.cpp 10KB
gargprop.cpp 10KB
cutscene.cpp 10KB
PlaneScene.cpp 10KB
appstream.cpp 10KB
video.cpp 10KB
asyncrdr.cpp 10KB
dllentry.cpp 10KB
amvideo.cpp 9KB
status.cpp 9KB
persist.cpp 9KB
listbox.cpp 9KB
stringutil.cpp 8KB
perflog.cpp 8KB
schedule.cpp 8KB
combase.cpp 8KB
ball.cpp 7KB
combobox.cpp 7KB
共 463 条
- 1
- 2
- 3
- 4
- 5
资源评论
coder-HRQ
- 粉丝: 28
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Vue和TypeScript的房地产管理系统前端设计源码
- 基于微信小程序的通用订票系统设计源码
- 基于ThinkPHP的轻量级PHP开发框架设计源码
- 基于CSS的响应式鲜花网站全屏效果设计源码
- 基于JavaScript的访客预约系统设计源码
- 基于Vue和ECharts的工作租房数据可视化系统设计源码
- 1040g0cg310ravpiu6ibg5pg00tsipsln3ju2d0g 2
- 基于Python的SAR图像去噪CNN-NLM设计源码
- redhat6升级到redhat7,过程redhat6.x-> redhat6.10->rehat7.9 主版本最高版本
- 基于Django的流程引擎设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功