Author |
|
Cwilson Intermediate
Joined: August 10 2012 Location: United Kingdom Posts: 25
|
Posted: April 10 2013 at 10:18am | IP Logged
|
|
|
I'm using a class based on the TEST_TX_IVR chunk of the
console test example to stream wave data over a phone
line.
I start this class on a new thread, and tell it to stream
various wave files over the phone line and then let the
application know when it's done.
This was fine until I started using the following code to
stop the wave file transmission before the end of the
wave file.
public void StopWav()
{
_continuePlaying = false;
TxIvrChannel.StopIvrTransmit();
TxIvrChannel.CloseTxIvrChannel();
WaveFileObj.CloseWaveFile();
// Let the call handler know that we're done.
if (StreamingCompleted != null)
StreamingCompleted();
}
My problem is that when I call CloseWaveFile(), I
sometimes get a AccessViolationException thrown, or a
FileAccessException.
Any ideas on what I'm doing wrong?
|
Back to Top |
|
|
support Administrator
Joined: January 26 2005 Location: United States Posts: 1666
|
Posted: April 10 2013 at 12:18pm | IP Logged
|
|
|
Without seeing your call stack, specific exception error information or other debugging related info, I am not sure why you are seeing a problem.
Questions:
1) Do you open and then close the wave file on the same thread?
2) Is the wave file possibly being closed more than once?
3) IMPORTANT: Is it possible that the wave file object is being collected by the managed code garbage collector while you are trying to also close the wave file?
One thing I do see is this: It is good to wait for the tx ivr channel to complete before closing it. Here’s your modified code:
Code:
public void StopWav()
{
_continuePlaying = false;
TxIvrChannel.StopIvrTransmit();
// wait for Tx ivr to complete before closing the channel.
TxIvrChannel.WaitForIvrTransmitComplete()
TxIvrChannel.CloseTxIvrChannel();
WaveFileObj.CloseWaveFile();
// Let the call handler know that we're done.
if (StreamingCompleted != null)
StreamingCompleted();
}
|
|
|
Other possible things to do:
1) Post your specific exception information to this thread.
2) Post your call stack at the time the exception gets caught.
I will see if I can quickly spot a problem but keep in mind that we cannot help debug user code or applications without paid support. With paid support, there is no limit to how I am able to assist you.
RJ
|
Back to Top |
|
|
Cwilson Intermediate
Joined: August 10 2012 Location: United Kingdom Posts: 25
|
Posted: April 18 2013 at 5:24am | IP Logged
|
|
|
support wrote:
Questions:
1) Do you open and then close the wave file on the same
thread?
2) Is the wave file possibly being closed more than once?
3) IMPORTANT: Is it possible that the
wave file object is being collected by the managed code
garbage collector while you are trying to also close the
wave file?
|
|
|
1) No. This turned out to be the problem. Closing the
file from the same thread that spawned it fixed the
problem.
This turned out to be one of those dumb problems that you
immediately fix as soon as you go asking for technical
support.
|
Back to Top |
|
|
support Administrator
Joined: January 26 2005 Location: United States Posts: 1666
|
Posted: April 18 2013 at 10:15am | IP Logged
|
|
|
Very glad you identified the issue. Nicely done.
RJ
|
Back to Top |
|
|