读取IWaveSource时如何实现OnEndOfStream

时间:2018-10-15 14:46:07

标签: cscore

去年1月,菲洛伊(Filoe)将OnEndOfStream添加到FluentExtensions.cs中,以检测波源或采样源中流的结束。我想使用该选项。

以前,可以在SingleBlockNotificationStream中拦截“ read == 0”,而在Win7中,此方法工作正常。现在,我要更改为Win10,即使在W7上编译的程序中也无法使用。 read==0在读取流时发生多次。

我的来源是:

        //the SingleBlockNotificationStream is used to intercept the played samples
        var notificationSource = new SingleBlockNotificationStream(source);
        notificationSource.SingleBlockStreamFinished += (s, a) => EndOfStream = true;

我在其中将SingleBlockStreamFinished添加到类SingleBlockNotificationStream中。

Filoe的解决方案如下:

    /// <summary>
    ///     Registers an <paramref name="action"/> to be executed on end of stream of the <paramref name="sampleSource"/>.
    /// </summary>
    /// <param name="sampleSource">The <see cref="ISampleSource"/> to be tracked.</param>
    /// <param name="action">The callback action with the <paramref name="sampleSource"/> as parameter.</param>
    /// <returns>A wrapper around the <paramref name="sampleSource"/>.</returns>
    public static ISampleSource OnEndOfStream(this ISampleSource sampleSource, Action<ISampleSource> action)
    {
        return new EofTrackingSampleSource(sampleSource, action);
    }

没有使用它的示例,所以我被困住了,而不是花几个小时来猜测需要什么:谁可以给我写那2或3条语句,将我的变量EndOfStream设置为true在流的结尾吗?也许我使用了Callbacks,但我从来没有自己写过

0 个答案:

没有答案