This project has moved and is read-only. For the latest updates, please go here.

NoDriver calling acmFormatSuggest

Apr 1, 2013 at 10:08 PM
I can't seem to get NAudio to read an MP3 file. It works fine on my local machine, but fails with "NoDriver calling acmFormatSuggest" in production. The line it fails on in creating the NAudio.Wave.Mp3FileReader.

I've created a small app that replicates the error (below) on a Win 2008 R2, 64bit machines. I've verified that the code is running in 32bit (same as IIS - which is what needs to work).
using System;

namespace NAudioTest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                using (var rdr = new NAudio.Wave.Mp3FileReader("Test.mp3"))
                {
                    Console.WriteLine("Duration: {0}", rdr.TotalTime);
                }
            }
            finally
            {
                Console.ReadKey();
            }
        }
    }
}
We also have LAME.exe running on this machine and it works just fine, so the machine should have the appropriate codecs. I started the audio service just in case that would help, but it didn't.

Any ideas?
Apr 1, 2013 at 10:54 PM
I was able to find a work-around, but I wouldn't mind figuring out why this is a problem in case I need to do more than just get duration with NAudio in the future.

Here's the work-around (adapted from http://stackoverflow.com/a/13269914/320)...
public static TimeSpan GetMediaDuration(string srcPath)
{
    var duration = 0.0;
    using (var fs = System.IO.File.OpenRead(srcPath))
    {
        var frame = Mp3Frame.LoadFromStream(fs);
        while (frame != null)
        {
            duration += (double)frame.SampleCount / (double)frame.SampleRate;
            frame = Mp3Frame.LoadFromStream(fs);
        }
    }
    return TimeSpan.FromSeconds(duration);
}