0

If I create an AsioOut and use the MultiplexingWaveProvider it works fine (plays / disposes etc..) only if I call AsioOut.Stop() before MultiplexingWaveProvider has run out of data.

If I wait until the MultiplexingWaveProvider has run out of data (and AsioOut has triggered a PlaybackStopped event) I can't Dispose of AsioOut it just hangs and never returns (no error). Note: there is no Dispose() on the MultiplexingWaveProvider, but I've tried calling dispose on the all WaveFileReaders that are used for the MultiplexingWaveProvider.

4

2 回答 2

2

我有几个人在尝试自动停止时报告了 ASIO 驱动程序的问题。如果在缓冲区交换回调中调用 stop ,可能有些驱动程序不喜欢它。

理想情况下AsioOut应该更新以提供禁用自动停止的选项。您可以通过创建一个永无止境的方法来模拟这一点,ISampleProviderRead方法在到达源末尾后返回静音。然后您可以轮询以查看何时到达输入的结尾,然后Stop以及Dispose何时完成

于 2015-07-09T15:28:40.930 回答
0

这是我对马克的回答的暗示。我不得不使用 IWaveProvidor,因为我使用的 MultiplexingWaveProvider 不支持 ISampleProvidor。(我也可以实现 MultiplexingWaveProvider 来获得与我认为相同的结果)。请注意,过去没有在数据处理程序内部调用停止的任务。

  public class AsioWavProvidor :IWaveProvider
        {
            private bool EndSignaled = false;
            public Action EndofAudioData;
            public Mp3FileReader Mp3Reader;
            public AsioWavProvidor(string mp3File)
            {
                Mp3Reader = new Mp3FileReader(mp3File);
            }
            public TimeSpan CurrentTime { get { return Mp3Reader.CurrentTime; } }


 public int Read(byte[] buffer, int offset, int count)
            {
                var retCount = Mp3Reader.Read(buffer, offset, count);
                if (retCount == 0)
                {
                   if (EndofAudioData != null && !EndSignaled)
                    {

                        EndSignaled = true;
                        System.Threading.Tasks.Task.Run(() =>
                        {
                            try
                            {
                                EndofAudioData();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex);
                            }
                        });

                    }
                    return count;
                }
                return retCount;
            }
于 2015-07-11T13:32:56.310 回答