//----------------------------------------------------------------------------- // Name: CWaveFile::Close() // Desc: Closes the wave file //----------------------------------------------------------------------------- HRESULT CWaveFile::Close() { if( m_dwFlags == WAVEFILE_READ ) { mmioClose( m_hmmio, 0 ); m_hmmio = NULL; SAFE_DELETE_ARRAY( m_pResourceBuffer ); } else { m_mmioinfoOut.dwFlags |= MMIO_DIRTY; if( m_hmmio == NULL ) return CO_E_NOTINITIALIZED; if( 0 != mmioSetInfo( m_hmmio, &m_mmioinfoOut, 0 ) ) return DXTRACE_ERR( TEXT("mmioSetInfo"), E_FAIL ); // Ascend the output file out of the 'data' chunk -- this will cause // the chunk size of the 'data' chunk to be written. if( 0 != mmioAscend( m_hmmio, &m_ck, 0 ) ) return DXTRACE_ERR( TEXT("mmioAscend"), E_FAIL ); // Do this here instead... if( 0 != mmioAscend( m_hmmio, &m_ckRiff, 0 ) ) return DXTRACE_ERR( TEXT("mmioAscend"), E_FAIL ); mmioSeek( m_hmmio, 0, SEEK_SET ); if( 0 != (INT)mmioDescend( m_hmmio, &m_ckRiff, NULL, 0 ) ) return DXTRACE_ERR( TEXT("mmioDescend"), E_FAIL ); m_ck.ckid = mmioFOURCC('f', 'a', 'c', 't'); if( 0 == mmioDescend( m_hmmio, &m_ck, &m_ckRiff, MMIO_FINDCHUNK ) ) { DWORD dwSamples = 0; mmioWrite( m_hmmio, (HPSTR)&dwSamples, sizeof(DWORD) ); mmioAscend( m_hmmio, &m_ck, 0 ); } // Ascend the output file out of the 'RIFF' chunk -- this will cause // the chunk size of the 'RIFF' chunk to be written. if( 0 != mmioAscend( m_hmmio, &m_ckRiff, 0 ) ) return DXTRACE_ERR( TEXT("mmioAscend"), E_FAIL ); mmioClose( m_hmmio, 0 ); m_hmmio = NULL; } return S_OK; }
BOOL ReadWaveFile(LPTSTR lpszFileName, LPWAVEFORMATEX lpwf, LPBYTE *lplpData, LPDWORD lpdwDataSize) { HMMIO hmmio; MMCKINFO mmckRiff; MMCKINFO mmckFmt; MMCKINFO mmckData; LPBYTE lpData; hmmio = mmioOpen(lpszFileName, NULL, MMIO_READ); if (hmmio == NULL) { MessageBox(NULL, TEXT("ファイルのオープンに失敗しました。"), NULL, MB_ICONWARNING); return FALSE; } mmckRiff.fccType = mmioStringToFOURCC(TEXT("WAVE"), 0); if (mmioDescend(hmmio, &mmckRiff, NULL, MMIO_FINDRIFF) != MMSYSERR_NOERROR) { MessageBox(NULL, TEXT("WAVEファイルではありません。"), NULL, MB_ICONWARNING); mmioClose(hmmio, 0); return FALSE; } mmckFmt.ckid = mmioStringToFOURCC(TEXT("fmt "), 0); if (mmioDescend(hmmio, &mmckFmt, NULL, MMIO_FINDCHUNK) != MMSYSERR_NOERROR) { mmioClose(hmmio, 0); return FALSE; } mmioRead(hmmio, (HPSTR)lpwf, mmckFmt.cksize); mmioAscend(hmmio, &mmckFmt, 0); if (lpwf->wFormatTag != WAVE_FORMAT_PCM) { MessageBox(NULL, TEXT("PCMデータではありません。"), NULL, MB_ICONWARNING); mmioClose(hmmio, 0); return FALSE; } mmckData.ckid = mmioStringToFOURCC(TEXT("data"), 0); if (mmioDescend(hmmio, &mmckData, NULL, MMIO_FINDCHUNK) != MMSYSERR_NOERROR) { mmioClose(hmmio, 0); return FALSE; } lpData = (LPBYTE)HeapAlloc(GetProcessHeap(), 0, mmckData.cksize); mmioRead(hmmio, (HPSTR)lpData, mmckData.cksize); mmioAscend(hmmio, &mmckData, 0); mmioAscend(hmmio, &mmckRiff, 0); mmioClose(hmmio, 0); *lplpData = lpData; *lpdwDataSize = mmckData.cksize; return TRUE; }
//----------------------------------------------------------------------------- // Name: CWaveFile::Open() // Desc: Opens a wave file for reading //----------------------------------------------------------------------------- HRESULT CWaveFile::Open( LPSTR strFileName, WAVEFORMATEX* pwfx, DWORD dwFlags ) { HRESULT hr; m_dwFlags = dwFlags; m_bIsReadingFromMemory = FALSE; if( m_dwFlags == WAVEFILE_READ ) { if( strFileName == NULL ) return E_INVALIDARG; SAFE_DELETE_ARRAY( m_pwfx ); m_hmmio = mmioOpen( strFileName, NULL, MMIO_ALLOCBUF | MMIO_READ ); if( FAILED( hr = ReadMMIO() ) ) { // ReadMMIO will fail if its an not a wave file mmioClose( m_hmmio, 0 ); return WAVEFILE_ERROR( L"ReadMMIO", hr ); } if( FAILED( hr = ResetFile() ) ) return WAVEFILE_ERROR( L"ResetFile", hr ); // After the reset, the size of the wav file is m_ck.cksize so store it now m_dwSize = m_ck.cksize; } else { m_hmmio = mmioOpen( strFileName, NULL, MMIO_ALLOCBUF | MMIO_READWRITE | MMIO_CREATE ); if( NULL == m_hmmio ) return WAVEFILE_ERROR( L"mmioOpen", E_FAIL ); if( FAILED( hr = WriteMMIO( pwfx ) ) ) { mmioClose( m_hmmio, 0 ); return WAVEFILE_ERROR( L"WriteMMIO", hr ); } if( FAILED( hr = ResetFile() ) ) return WAVEFILE_ERROR( L"ResetFile", hr ); } return hr; }
/*------------------------------------------------------------------------------*/ void WaveClose( void ) { mmioAscend( hWaveRec, &WaveData, 0 ); mmioAscend( hWaveRec, &WaveRiff, 0 ); mmioClose( hWaveRec, 0 ); WaveOutFlag = 0; }
void CloseDevice() { MMRESULT mRes=0; if(m_hWaveIn) { UnPrepareBuffers(); mRes=waveInClose(m_hWaveIn); } if(m_hOPFile) { mRes=mmioAscend(m_hOPFile, &m_stckOut, 0); if(mRes!=MMSYSERR_NOERROR) { FAIL_M("bad"); } mRes=mmioAscend(m_hOPFile, &m_stckOutRIFF, 0); if(mRes!=MMSYSERR_NOERROR) { FAIL_M("bad"); } mmioClose(m_hOPFile,0); m_hOPFile=NULL; } m_hWaveIn=NULL; }
// Destructor void WaveFile::Close(void) { // Free memory if (m_pwfmt_original) { vm_free(m_pwfmt_original); m_pwfmt_original = NULL; } if (m_hStream_open) { ACM_stream_close((void*)m_hStream); m_hStream_open = 0; } // Close file if (m_snd_info.cfp) { //cfclose(cfp); if (m_wave_format == OGG_FORMAT_VORBIS) ov_clear(&m_snd_info.vorbis_file); mmioClose(m_snd_info.cfp, 0); m_snd_info.cfp = NULL; m_snd_info.true_offset = 0; m_snd_info.size = 0; } }
int bsave(char *nom,void *adr,long offset,long len) { void *buffer; long filesize; HMMIO fp; int r= -1; char nom2[200]; verifnom(nom,nom2); fp = mmioOpen(nom2,NULL,MMIO_READ); if (fp) { r=0; filesize = mmioSeek(fp, 0L, SEEK_END); mmioClose(fp,NULL); if (!r) { r= -1; buffer=memalloc(filesize); if (buffer) { if (!bload(nom,buffer,0L,filesize)) { bmove(adr,(char *)buffer+offset,len); r=bmake(nom,buffer,filesize); } memfree((void **)&buffer); } } } return(r); }
// Wave-Daten laden (Paramter 2-4: Grösse, Format, eigentliche Daten, werden durch interne Funktionen gefüllt) int LoadWave(const char *fileName, LPWAVEFORMATEX lpFormat, DWORD *lpLength, PBYTE *lpData) { HMMIO hmmio; // 1. Datei öffnen hmmio = mmioOpen((char*)((LPCTSTR)fileName), NULL, MMIO_READ); if(!hmmio) { MessageBox(NULL, "Error", "mmioOpen()", NULL); return 1; } // 2. Daten für WAVEFORMATEX Struktur aus Datei lesen if(LoadWaveFormat(hmmio, lpFormat)) { MessageBox(NULL, "Error", "LoadWaveFormat()", NULL); return 1; } // 3. Wave-Datenlänge und Wave Daten aus Datei lesen if(LoadWaveDataAndLength(hmmio, lpLength, lpData)) { MessageBox(NULL, "Error", "LoadWaveDataAndLength()", NULL); return 1; } // 4. Datei schliessen mmioClose(hmmio, 0); return 0; }
static void ANIMATE_Free(ANIMATE_INFO *infoPtr) { if (infoPtr->hMMio) { ANIMATE_DoStop(infoPtr); mmioClose(infoPtr->hMMio, 0); if (infoPtr->hRes) { FreeResource(infoPtr->hRes); infoPtr->hRes = 0; } Free (infoPtr->lpIndex); infoPtr->lpIndex = NULL; if (infoPtr->hic) { fnIC.fnICClose(infoPtr->hic); infoPtr->hic = 0; } Free (infoPtr->inbih); infoPtr->inbih = NULL; Free (infoPtr->outbih); infoPtr->outbih = NULL; Free (infoPtr->indata); infoPtr->indata = NULL; Free (infoPtr->outdata); infoPtr->outdata = NULL; if( infoPtr->hbmPrevFrame ) { DeleteObject(infoPtr->hbmPrevFrame); infoPtr->hbmPrevFrame = 0; } memset(&infoPtr->mah, 0, sizeof(infoPtr->mah)); memset(&infoPtr->ash, 0, sizeof(infoPtr->ash)); infoPtr->nFromFrame = infoPtr->nToFrame = infoPtr->nLoop = infoPtr->currFrame = 0; } infoPtr->transparentColor = ANIMATE_COLOR_NONE; }
LONG SoundFileFormat::identifyFile(PSZ fileName, HMMIO fileHandle) { HMMIO originalFileHandle = fileHandle; ULONG ulTempFlags = MMIO_READ | MMIO_DENYWRITE | MMIO_NOIDENTIFY; LONG returnCode; if (!fileName && !fileHandle) return (MMIO_ERROR); if (!fileHandle) if (!(fileHandle = mmioOpen((PSZ)fileName, NULL, ulTempFlags))) return (MMIO_ERROR); MovieAtom movieAtom; ULONG movieSize; returnCode = loadMovie(movieAtom, movieSize, fileHandle); if (!originalFileHandle) /* Don't close handle if provided to us */ mmioClose(fileHandle, 0); if (returnCode == MMIO_SUCCESS) /* This is a QuickTime file */ if (movieAtom.isSoundOnly()) return (MMIO_SUCCESS); else return (MMIO_ERROR); else return (returnCode); }
static ULONG WINAPI IUnknown_fnRelease(IUnknown *iface) { IAVIFileImpl *This = impl_from_IUnknown(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); if (!ref) { /* need to write headers to file */ if (This->fDirty) AVIFILE_SaveFile(This); HeapFree(GetProcessHeap(), 0, This->lpFormat); This->lpFormat = NULL; This->cbFormat = 0; HeapFree(GetProcessHeap(), 0, This->extra.lp); This->extra.lp = NULL; This->extra.cb = 0; HeapFree(GetProcessHeap(), 0, This->szFileName); This->szFileName = NULL; if (This->hmmio) { mmioClose(This->hmmio, 0); This->hmmio = NULL; } HeapFree(GetProcessHeap(), 0, This); } return ref; }
int main(int argc, char *argv[]) { MMIOINFO mmioinfo; HMMIO hmmio; MCI_OPEN_PARMS openParams; PSZ fileName = "test.ogg"; ULONG ulFlags; int rc; printf("start\n"); memset (&mmioinfo, 0, sizeof(MMIOINFO)); mmioinfo.fccIOProc = FOURCC_Vorbis; // mmioinfo.fccIOProc = mmioFOURCC('W','A','V','E'); ulFlags = MMIO_WRITE | MMIO_DENYNONE | MMIO_CREATE; mmioinfo.ulTranslate = MMIO_TRANSLATEHEADER | MMIO_TRANSLATEDATA; hmmio = mmioOpen(fileName, &mmioinfo, ulFlags); if (!hmmio) { printf("Can't open %s:%ld.\n",fileName,mmioinfo.ulErrorRet); return -1; } memset (&openParams, 0, sizeof(openParams)); openParams.pszDeviceType = "WaveAudio"; openParams.pszElementName = (PSZ)hmmio; rc = mciSendCommand (0, MCI_OPEN, MCI_WAIT | MCI_OPEN_MMIO,&openParams,0); if (LOUSHORT(rc) == MCIERR_SUCCESS) { USHORT usDeviceID = openParams.usDeviceID; MCI_RECORD_PARMS recParams; memset (&recParams, 0, sizeof(recParams)); rc = mciSendCommand (usDeviceID, MCI_RECORD,0 , &recParams, 0); if (LOUSHORT(rc)== MCIERR_SUCCESS) { sleep(2); rc = mciSendCommand (usDeviceID, MCI_STOP, MCI_WAIT, 0, 0); if (LOUSHORT(rc) == MCIERR_SUCCESS) { MCI_SAVE_PARMS saveParams; memset (&saveParams, 0, sizeof(saveParams)); rc = mciSendCommand (usDeviceID, MCI_SAVE, MCI_WAIT,&saveParams , 0); if (LOUSHORT(rc) != MCIERR_SUCCESS) { printf("save failed:%d.\n",rc); } } else { printf("stop failed:%d.\n",rc); } } else { printf("Can't record:%d.\n",rc); } /* endif */ rc = mciSendCommand (usDeviceID, MCI_CLOSE, MCI_WAIT, 0, 0); if (LOUSHORT(rc) != MCIERR_SUCCESS) { printf("Can't close audioDevice:%d.\n",rc); } /* endif */ } else { printf("Can't open audioDevice:%d.\n",rc); } return mmioClose(hmmio, 0); }
/** ストリームを閉じる * * @author SAM (T&GG, Org.)<*****@*****.**> * @date 2004/01/21 3:32:04 * Copyright (C) 2001,2002,2003,2004 SAM (T&GG, Org.). All rights reserved. */ HRslt WavFile::close() { if( !hmmio_ ) return CO_E_NOTINITIALIZED; if( flags_ & READ ) { mmioClose( hmmio_, 0 ); hmmio_ = NULL; } else { write_mmioinfo_.dwFlags |= MMIO_DIRTY; if( 0 != mmioSetInfo( hmmio_, &write_mmioinfo_, 0 ) ) return DXTRACE_ERR( TEXT("mmioSetInfo"), E_FAIL ); // Ascend the output file out of the 'data' chunk -- this will cause // the chunk size of the 'data' chunk to be written. if( 0 != mmioAscend( hmmio_, &ck_, 0 ) ) return DXTRACE_ERR( TEXT("mmioAscend"), E_FAIL ); // Do this here instead... if( 0 != mmioAscend( hmmio_, &ckriff_, 0 ) ) return DXTRACE_ERR( TEXT("mmioAscend"), E_FAIL ); mmioSeek( hmmio_, 0, SEEK_SET ); if( 0 != (int)mmioDescend( hmmio_, &ckriff_, NULL, 0 ) ) return DXTRACE_ERR( TEXT("mmioDescend"), E_FAIL ); ck_.ckid = mmioFOURCC('f','a','c','t'); if( 0 == mmioDescend( hmmio_, &ck_, &ckriff_, MMIO_FINDCHUNK ) ) { DWORD dwSamples = 0; mmioWrite( hmmio_, (HPSTR)&dwSamples, sizeof(dwSamples) ); mmioAscend( hmmio_, &ck_, 0 ); } // Ascend the output file out of the 'RIFF' chunk -- this will cause // the chunk size of the 'RIFF' chunk to be written. if( 0 != mmioAscend( hmmio_, &ckriff_, 0 ) ) return DXTRACE_ERR( TEXT("mmioAscend"), E_FAIL ); mmioClose( hmmio_, 0 ); hmmio_ = NULL; } SAFE_FREE( buffer_ ); SAFE_FREE( wfx_ ); return S_OK; }
void CMmioEmbeddedFile::Close() { ASSERT( m_hMmio != NULL ); ASSERT_VALID( this ); mmioClose( m_hMmio, MMIO_FHOPEN ); ctor(); }
void CMmio::Close () { ASSERT (m_hMmio != NULL); ASSERT_VALID (this); mmioClose (m_hMmio, 0); ctor (); }
void __fastcall CWaveFile::FileClose(void) { m_mode = 0; m_pause = 0; if( m_Handle != NULL ){ mmioClose(m_Handle, 0); m_Handle = 0; } }
void TinyWaveFile::Close() { if (hmmio != NULL) { mmioClose(hmmio, 0); hmmio = NULL; } dwSize = dwLSize = dwDataOffset = 0; }
void CreateSecondryBuffer(const LPDIRECTSOUND8* lpDS, LPDIRECTSOUNDBUFFER* secondryBuffer, wchar_t* path) { //WAVEファイルをロード HMMIO hSrc = mmioOpen(path, NULL, MMIO_ALLOCBUF | MMIO_READ | MMIO_COMPAT); if(!hSrc) return; //WAVEチャンクチェック MMCKINFO mSrcWaveFile; ZeroMemory(&mSrcWaveFile, sizeof(mSrcWaveFile)); mmioDescend(hSrc, &mSrcWaveFile, NULL, MMIO_FINDRIFF); //fmtチャンクチェック MMCKINFO mSrcWaveFmt; ZeroMemory(&mSrcWaveFmt, sizeof(mSrcWaveFmt)); mmioDescend(hSrc, &mSrcWaveFmt, &mSrcWaveFile, MMIO_FINDCHUNK); //ヘッダサイズの計算 int iSrcHeaderSize = max(mSrcWaveFmt.cksize, sizeof(WAVEFORMATEX)); //ヘッダメモリ確保 LPWAVEFORMATEX wf = (LPWAVEFORMATEX)malloc(iSrcHeaderSize); ZeroMemory(wf, iSrcHeaderSize); //WAVEフォーマットのロード mmioRead(hSrc, (char*)wf,mSrcWaveFmt.cksize); //fmtチャンクに戻る mmioAscend(hSrc, &mSrcWaveFmt, 0); //dataチャンクを探す MMCKINFO mSrcWaveData; mmioDescend(hSrc, &mSrcWaveData, &mSrcWaveFile, 0); while(mSrcWaveData.ckid != mmioStringToFOURCC(L"data", 0)) { mmioAscend(hSrc, &mSrcWaveData, 0); mmioDescend(hSrc, &mSrcWaveData, &mSrcWaveFile, 0); } //サウンドバッファの作成 DSBUFFERDESC dsdesc = { sizeof(DSBUFFERDESC), //DWORD dwSize サイズ DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STATIC | DSBCAPS_LOCDEFER, //DWORD dwFlags フラグ mSrcWaveData.cksize, //DWORD dwBufferBytes 0固定 0, //DWORD dwReserved 0固定 wf, //LPWAVEFORMATEX lpwfxFormat NULL固定 DS3DALG_DEFAULT //GUID guid3DAlgorithm GUID_NULL固定 }; (*lpDS)->CreateSoundBuffer(&dsdesc, secondryBuffer, NULL); //ロック開始 LPVOID pMem1, pMem2; DWORD dwSize1,dwSize2; (*secondryBuffer)->Lock(0, mSrcWaveData.cksize, &pMem1, &dwSize1, &pMem2, &dwSize2, 0); //データ書き込み mmioRead(hSrc, (char*)pMem1, dwSize1); mmioRead(hSrc, (char*)pMem2, dwSize2); //ロック解除 (*secondryBuffer)->Unlock(pMem1, dwSize1, pMem2, dwSize2); //ヘッダ用メモリを開放 free(wf); //WAVEを閉じる mmioClose(hSrc, 0); }
/** * Close WAV file */ static javacall_result close_wav_file(recorder_handle* hRecord) { if (hRecord && hRecord->hFile) { mmioAscend(hRecord->hFile, &_MMCKInfoChild, 0); mmioAscend(hRecord->hFile, &_MMCKInfoParent, 0); mmioClose(hRecord->hFile, 0); hRecord->hFile = NULL; } return JAVACALL_OK; }
void CWaveFile::StopRecord() { // Call mmioAscend function to mark the end of the chunk // And mmioAscend will corrects the chunk size if(m_hWaveFileRec) { mmioAscend(m_hWaveFileRec, &m_mmckinfoParent, 0); mmioAscend(m_hWaveFileRec, &m_mmckinfoSubChunk, 0); mmioClose(m_hWaveFileRec, 0); m_hWaveFileRec = NULL; } }
int bclose(int n) { HMMIO fp; int r=0; if (n) { fp=ftab[n-1]; mmioClose(fp,NULL); fused[n-1]=0; } return(r); }
static void clean_up(WAVFile* _wav) { WAVFile& wav = *_wav; if(wav.wav_file) { mmioAscend(wav.wav_file, &wav.dataChunk, 0); mmioAscend(wav.wav_file, &wav.waveChunk, 0); // mmioFlush(wav.wav_file, 0); mmioClose(wav.wav_file, 0); wav.wav_file = NULL; } }
~mmio_stream_raii() { data_info.dwFlags |= MMIO_DIRTY; CHECKED(mmioSetInfo( mmio, &data_info, 0 )); CHECKED(mmioAscend( mmio, &data_chunk, 0 )); CHECKED(mmioAscend( mmio, &WAVE_chunk, 0 )); CHECKED(mmioClose( mmio, 0 )); mmio = NULL; }
CPrefs::~CPrefs() { if (NULL != m_pMMDevice) { m_pMMDevice->Release(); } if (NULL != m_hFile) { mmioClose(m_hFile, 0); } if (NULL != m_pwfx) { CoTaskMemFree(m_pwfx); } }
/** ファイルからの読み込みモードでオープン * * @author SAM (T&GG, Org.)<*****@*****.**> * @date 2004/01/21 1:51:30 * Copyright (C) 2001,2002,2003,2004 SAM (T&GG, Org.). All rights reserved. */ HRslt WavFile::open(const _TCHAR *fname) { if(!fname) return E_INVALIDARG; if(isOpen()) close(); flags_ = READ; HRslt hr; _TCHAR fn[_MAX_PATH]; _tcsncpy(fn, fname, _MAX_PATH); hmmio_ = mmioOpen(fn, NULL, MMIO_ALLOCBUF | MMIO_READ | MMIO_COMPAT); if(!hmmio_) { // Loading it as a file failed, so try it as a resource HRSRC hResInfo = FindResource(NULL, fn, TEXT("WAVE")); if(!hResInfo) { hResInfo = FindResource(NULL, fn, TEXT("WAV")); if(!hResInfo) return DXTRACE_ERR(TEXT("FindResource"), ERROR_FILE_NOT_FOUND); } HGLOBAL hResData = LoadResource(NULL, hResInfo); if(!hResData) return DXTRACE_ERR(TEXT("LoadResource"), E_FAIL); DWORD dwSize = SizeofResource(NULL, hResInfo); if(dwSize == 0) return DXTRACE_ERR(TEXT("SizeofResource"), E_FAIL); void *pvRes = LockResource(hResData); if(!pvRes) return DXTRACE_ERR(TEXT("LockResource"), E_FAIL); buffer_ = malloc(dwSize); memcpy(buffer_, pvRes, dwSize); MMIOINFO mmioinfo; memset(&mmioinfo, 0, sizeof(mmioinfo)); mmioinfo.fccIOProc = FOURCC_MEM; mmioinfo.cchBuffer = dwSize; mmioinfo.pchBuffer = reinterpret_cast<char *>(buffer_); hmmio_ = mmioOpen(NULL, &mmioinfo, MMIO_ALLOCBUF | MMIO_READ | MMIO_COMPAT); } if(!( hr = readMMIO() )) { // ReadMMIO will fail if its an not a wave file mmioClose(hmmio_, 0); return DXTRACE_ERR(TEXT("readMMIO"), hr.i); } if(!( hr = rewind() )) return DXTRACE_ERR( TEXT("ResetFile"), hr.i ); // After the rewind, the size of the wav file is m_ck.cksize so store it now size_ = ck_.cksize; return S_OK; }
void __fastcall CWaveFile::ReadWrite(short *s, int size) { int csize = size * sizeof(short); if( m_Handle != NULL ){ if( m_mode == 2 ){ // 書きこみ if( !m_pause ){ if( mmioWrite(m_Handle, (const char*)s, csize) != csize ){ mmioClose(m_Handle, 0); m_Handle = 0; m_mode = 0; } else { m_pos += csize; } } } else { // 読み出し if( m_pause || m_dis ){ memset(s, 0, csize); } else { if( mmioRead(m_Handle, (char *)s, csize) == csize ){ m_pos += csize; } else if( m_autopause ){ // Rewind(); m_pause = 1; } else { mmioClose(m_Handle, 0); m_Handle = 0; m_mode = 0; } } } } }
void RecordStop() { // first some check, if recording is running iDoRecord=0; if(!hWaveFile) return; // now finish writing & close the wave file mmioAscend(hWaveFile,&mmckData,0); mmioAscend(hWaveFile,&mmckMain,0); mmioClose(hWaveFile,0); // init var hWaveFile=NULL; }
BOOL IsValidFile(PSZ pszFilename) { HMMIO hMMIO = NULL; MMIOINFO mmioInfo; memset((PVOID)&mmioInfo, 0, sizeof(MMIOINFO)); if((hMMIO = mmioOpen(pszFilename, &mmioInfo, MMIO_READ)) == NULL) return FALSE; mmioClose(hMMIO, 0); return TRUE; }
int bexist(char *nom) { HMMIO fp; char nom2[200]; verifnom(nom,nom2); fp = mmioOpen(nom2,NULL,MMIO_READ); if (fp) { mmioClose(fp,NULL); return(1); } else return(0); }
static void test_mmioOpen_fourcc(void) { char fname[] = "file+name.xyz+one.two"; LPMMIOPROC lpProc; HMMIO hmmio; MMIOINFO mmio; lpProc = mmioInstallIOProcA(FOURCC_DOS, mmio_test_IOProc, MMIO_INSTALLPROC); ok(lpProc == mmio_test_IOProc, "mmioInstallIOProcA error\n"); lpProc = mmioInstallIOProcA(FOURCC_XYZ, mmio_test_IOProc, MMIO_INSTALLPROC); ok(lpProc == mmio_test_IOProc, "mmioInstallIOProcA error\n"); memset(&mmio, 0, sizeof(mmio)); hmmio = mmioOpenA(fname, &mmio, MMIO_READ); mmioGetInfo(hmmio, &mmio, 0); ok(hmmio && mmio.fccIOProc == FOURCC_XYZ, "mmioOpenA error %u, got %4.4s\n", mmio.wErrorRet, (LPCSTR)&mmio.fccIOProc); ok(mmio.adwInfo[1] == 0, "mmioOpenA sent MMIOM_SEEK, got %d\n", mmio.adwInfo[1]); ok(mmio.lDiskOffset == 0, "mmioOpenA updated lDiskOffset, got %d\n", mmio.lDiskOffset); mmioClose(hmmio, 0); mmioInstallIOProcA(FOURCC_XYZ, NULL, MMIO_REMOVEPROC); memset(&mmio, 0, sizeof(mmio)); hmmio = mmioOpenA(fname, &mmio, MMIO_READ); mmioGetInfo(hmmio, &mmio, 0); ok(!hmmio && mmio.wErrorRet == MMIOERR_FILENOTFOUND, "mmioOpenA error %u, got %4.4s\n", mmio.wErrorRet, (LPCSTR)&mmio.fccIOProc); mmioClose(hmmio, 0); mmioInstallIOProcA(FOURCC_DOS, NULL, MMIO_REMOVEPROC); }