PMH4514
asked on
Unhandled Exception in AVIFileOpen()
I'm having a problem opening an AVI file.
Using VC++ 6.0
In my header file:
protected
PAVIFILE* m_pAviFile;
in my class constructor:
CAviFile::CAviFile()
{
AVIFileInit();
m_pAviFile = NULL;
..//
and then later I try to open the file:
HRESULT hr = AVIFileOpen(m_pAviFile, m_sMoviePath, OF_WRITE | OF_CREATE, NULL);
That line crashes "Unhandled exception in MYAPP.exe [AVIFIL32.dll]: 0XC0000005: Access Violation"
The file is however being created, I can browse to the folder in windows and see it, so it's not a path problem. So what's going wrong here?
thanks
-Paul
Using VC++ 6.0
In my header file:
protected
PAVIFILE* m_pAviFile;
in my class constructor:
CAviFile::CAviFile()
{
AVIFileInit();
m_pAviFile = NULL;
..//
and then later I try to open the file:
HRESULT hr = AVIFileOpen(m_pAviFile, m_sMoviePath, OF_WRITE | OF_CREATE, NULL);
That line crashes "Unhandled exception in MYAPP.exe [AVIFIL32.dll]: 0XC0000005: Access Violation"
The file is however being created, I can browse to the folder in windows and see it, so it's not a path problem. So what's going wrong here?
thanks
-Paul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>or does "P" in "PAVIFILE" infer it's already a pointer type?
Yes, these are MS' naming conventions.
>>now I'm getting the same error on this line:
>>HRESULT hr = AVIFileCreateStream(m_pAvi File, &m_psWrite, &strhdr);
Hm, that actually looks good. Have you tried to
ASSERT(m_pAviFile);
HRESULT hr = AVIFileCreateStream(m_pAvi File, &m_psWrite, &strhdr);
?
Yes, these are MS' naming conventions.
>>now I'm getting the same error on this line:
>>HRESULT hr = AVIFileCreateStream(m_pAvi
Hm, that actually looks good. Have you tried to
ASSERT(m_pAviFile);
HRESULT hr = AVIFileCreateStream(m_pAvi
?
ASKER
actually, I think the CreateStream is crashing because my AVIFileOpen is still not working properly. I don't crash with the access violation, but the pointer remains NULL, and the result equals a long negative number..
(the fact that my code got to my AVIFileCreateStream() call in that state means I need better error trapping, but that's offtopic)
(the fact that my code got to my AVIFileCreateStream() call in that state means I need better error trapping, but that's offtopic)
ASKER
looks like we were typing at the same time.. I guess the problem is still that AVIFileOpen() isn't properly returning the file handle (though again, the file is being created, I see it in windows explorer)
Are you sure you are filling in the header correctly? The sample at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_reading_from_one_stream_and_writing_to_another.asp ("Reading from One Stream and Writing to Another") illustrates how to use these APIs, and they're doing it exactly the same way.
ASKER
Oh duh, once again I forgot to call CoInitialize()..
it's all set now, thanks!
-Paul
it's all set now, thanks!
-Paul
ASKER
but.... wouldn't passing m_pAviFile (no ampersand) into AVIFileOpen, m_pAviFile having being defined as type PAVIFILE* be the same thing? or does "P" in "PAVIFILE" infer it's already a pointer type? (ie. I'm creating a pointer to a pointer by doing what I was doing??)
anyway - I made that change, and AVIFileOpen is no longer crashing. but now I'm getting the same error on this line:
HRESULT hr = AVIFileCreateStream(m_pAvi
where m_psWrite is defined in the header:
PAVISTREAM m_psWrite
and strhdr is defined locally within my method:
AVISTREAMINFO strhdr;
memset(&strhdr, 0, sizeof(strhdr));
strhdr.fccType = streamtypeVIDEO; // stream type
// etc..