mmioGetInfo.pchNext runtime error "Access violation writing location 0x0000000"

This is a discussion on mmioGetInfo.pchNext runtime error "Access violation writing location 0x0000000" within the C++ Programming forums, part of the General Programming Boards category; hi i create one file : Code: WAVEFORMATEX formatinfo; formatinfo.cbSize = 0; formatinfo.wFormatTag = WAVE_FORMAT_PCM; formatinfo.nChannels = 1; // 1 ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    1

    mmioGetInfo.pchNext runtime error "Access violation writing location 0x0000000"

    hi i create one file :

    Code:
    WAVEFORMATEX formatinfo;
    
    formatinfo.cbSize = 0;
    
    formatinfo.wFormatTag = WAVE_FORMAT_PCM;
    
    formatinfo.nChannels = 1;
    
    // 1 for mono 2 and 2 for stereo
    
    formatinfo.wBitsPerSample = 16;
    
    // can be 8 or 16
    
    formatinfo.nSamplesPerSec = 8000;
    
    // u can set nSamplesPerSec as 16000, 24000.
    
    formatinfo.nBlockAlign = formatinfo.nChannels * (formatinfo.wBitsPerSample / 8);
    
    formatinfo.nAvgBytesPerSec = formatinfo.nSamplesPerSec * formatinfo.nBlockAlign;
    
    
    
    memset (&m_mmioinfoOut, 0,sizeof (MMIOINFO));
    
    
    
    hFile = mmioOpen(L"NEWFILE.WAV", &m_mmioinfoOut, MMIO_CREATE | MMIO_READWRITE);
    
    
    if (hFile != NULL)
    MessageBox(g_hWnd, L"Success",L"DirectSound Demo", MB_OK);
    else
    MessageBox(g_hWnd, L"failed",L"DirectSound Demo", MB_OK);
    
    int fmtSize = 28;
    
    chunk.fccType = mmioFOURCC('W','A','V','E');
    
    chunk.cksize = 28;
    
    ::mmioCreateChunk(hFile, &chunk, MMIO_CREATERIFF);
    
    chunk2.ckid = mmioFOURCC('f','m','t',' ');
    
    chunk2.cksize =sizeof(WAVEFORMATEX);
    
    ::mmioCreateChunk(hFile, &chunk2, 0);
    
    ::mmioWrite(hFile, (const char*)&formatinfo,sizeof(formatinfo));
    
    ::mmioAscend(hFile, &chunk2, 0);
    
    mmckinfoData.ckid = mmioFOURCC('d','a','t','a');
    
    mmckinfoData.cksize = formatinfo.nAvgBytesPerSec;
    
    ::mmioCreateChunk(hFile, &mmckinfoData, 0);
    
    mmioGetInfo( hFile, &m_mmioinfoOut, 0 );
    but when i use :

    *((BYTE*)m_mmioinfoOut.pchNext) = *((BYTE*)pbSrcData+cT);

    i have one runtime error :

    First-chance exception at 0x0042f165 in CreateDevice.exe: 0xC0000005: Access violation writing location 0x00000000

    i see in debug that after mmioGetInfo( hFile, &m_mmioinfoOut, 0 ); m_mmioinfoOut.pchNext is 0x000000 <bad ptr>

    why?

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    EDIT: I guess you mean that you put
    Code:
    *((BYTE*)m_mmioinfoOut.pchNext) = *((BYTE*)pbSrcData+cT);
    after the end of the code you posted?

    In that case maybe mmioGetInfo() make m_mmioinfoOut.pchNext = NULL? Post mmioGetInfo()
    Last edited by C_ntua; 09-22-2009 at 03:37 AM.

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Ok. I find the function here

    Shouldn't be set to NULL except maybe if mmioGenInfo generates an error. Check its return value, it returns zero when it succeeds

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems installing Mingw5.1.4
    By BlackOps in forum C Programming
    Replies: 2
    Last Post: 07-26-2009, 03:28 AM
  2. Access violation writing location 0x00000000
    By bennyandthejets in forum Windows Programming
    Replies: 9
    Last Post: 04-14-2004, 03:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21