locked
Windows Media Encoder not releasing Source file after processing - VB2010 RRS feed

  • Question

  • I have a VB2010 application in Windows 7 that I've converted from an old VB5.0 program running under XP. The program records audio from the Microphone (using XNA - converted from using DirectSound) and I save the recording(s) as *.wav files in a Temporary directory.

    The user has the option of recording many *.wav files serially and they all end up in the Temporary directory as Track001.wav, Track002.wav, etc.

    When the user clicks on the Form's button indicating that they have finished recording, then the program calls a procedure that passes each *.wav file to WME to be converted into *.wma files (the procedure also gives WME Title, Artist, etc. information for each file).

    All of this is working fine. My problem is that before I begin to record again, I Zap all of the *.wav files in the Temporary directory using the Kill(<directoryname>) command. This works when I originally run the program (if any files were left from the previous execution of the program), but if I'm already using it, and I've processed the *.wav(s) into *.wma(s), the Kill command removes all of the files except for the final file listed in the folder. Then I get a "UnauthorizedAccessException was undhandled" error. It then says Access to the path "<directoryname>/Track003.wav" is denied.

    I know that WME is the cause, because when I skip the WME processing, the files are removed from the Directory using the Kill command each time successfully.

    I'm using:
    myEnc.EnableAutoArchive = True
    myEnc.PrepareToEncode(True)
    myEnc.AutoStop = True
    myEnc.RemoteAdmin = True

    Then I issue the:
    myEnc.Start

    After detecting that it has finished, I have:
    myEnc.Flush
    IWMFile = Nothing
    ediEncoderInfo = Nothing
    encAttr = Nothing
    myEnc = Nothing

    Any ideas would be greatly appreciated.

    Thank you for your time in advance,

    Paul Goldstein


    Paul D. Goldstein Forceware Systems, Inc.

    Wednesday, January 16, 2013 3:32 PM

Answers

  • You could try forcing a garbage collection after setting myEnc = Nothing, with

    GC.Collect()

    Also, how are you detecting that the encoding has finished?  Are you using the OnStateChange event, and checking that enumState = WMENC_ENCODER_STOPPED ?
    • Edited by John_78f Thursday, January 17, 2013 2:55 PM
    • Marked as answer by Paul D Goldstein Thursday, January 17, 2013 3:30 PM
    Thursday, January 17, 2013 2:50 PM

All replies

  • You could try forcing a garbage collection after setting myEnc = Nothing, with

    GC.Collect()

    Also, how are you detecting that the encoding has finished?  Are you using the OnStateChange event, and checking that enumState = WMENC_ENCODER_STOPPED ?
    • Edited by John_78f Thursday, January 17, 2013 2:55 PM
    • Marked as answer by Paul D Goldstein Thursday, January 17, 2013 3:30 PM
    Thursday, January 17, 2013 2:50 PM
  • Hi John,

    Yes, I had the Do Until encoder.Status (WMENC_ENCODER_STOPPED) and it had exited that loop.

    What I didn't have before I exited the Procedure was a: Encoder.Stop command (not sure why I needed this). I didn't have this in the VB5.0 XP version of the program. But adding that, fixed the bug.

    Thanks.

    Paul


    Paul D. Goldstein Forceware Systems, Inc.

    Thursday, January 17, 2013 3:30 PM