acmFormatSuggest() function question.

I'm making a routine to convert a compressed WAV file into PCM WAV.

I've got the complete WAVEFORMATEX including extra data after cbsize loaded and I'm calling acmFormatSuggest to have it suggest a valid PCM format to which the compressed format can be decompressed.

However, acmFormatSuggest is returning MMSYSERR_NODRIVER. If I call it again w/o re-loading my program it returns success. However, the first call always fails w/MMSYSERR_NODRIVER.

Here's my parms to acmFormatSuggest:
ptr to compressed wave file's WAVEFORMATEX,
ptr to WAVEFORMATEX (all zero's except for wFormatTag which = WAVE_FORMAT_PCM),

How come it's failing on my first try?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are you sure ptr to compressed wave file's WAVEFORMATEX is not changed on your second try?
RLMAuthor Commented:
Yes, I'm GlobalAllocating a memblock on each try with GPTR flag, then copying the WAVEFORMATEX in from the file including all extra data after cbsize. If it fails, I'm freeing this memblock. btw- it happens regardless of the file's compression format. It does this no matter what type of compression.

RLMAuthor Commented:
Note: acmGetVersion returns 0x4000000
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

RLMAuthor Commented:
Adjusted points to 500
Write a small program to test it. And make it as clean as possible to see what happens.
I checked it on my computer. It works fine. So, two possibilites:

1. There is a bug in your program;
2. Your system has got some problem. Try other computers.

You can check out the Win32 Multimedia Sample "ACMapp: Wave Files". Look into the AcmAppChooserFormatSuggest() in the aachoose.c. You may set a breakpoint there. Also, the menu View/System Information... displays the WinMM and ACM versions.

Good luck.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RLMAuthor Commented:
Can you send me your mini program so I can run it and see if it's my computer ( Only if it's not too much trouble :)

Either way, I give you 'A' but not until you reply since I wanna make sure you see my comment.

The program is here. Create a Win32 Console Application project and add the acmtest.cpp to it. Also, add msacm32.lib to the Link option. It works fine on my computer. You may add some code to display the destination format or simply use the debugger to watch it.

FYI, the ACMApp tells me the following:
WinMM Version: 49152.04
ACM Version: 4.00 (retail)

// acmtest.cpp

#include <stdio.h>
#include <windows.h>
#include <mmreg.h>
#include <msacm.h>

void main()
    BYTE pbyMSADPCM[] =
        0x02, 0x00,                 // Format Tag: WAVE_FORMAT_ADPCM
        0x01, 0x00,                 // Channels: 1
        0x11, 0x2B, 0x00, 0x00,     // Samples Per Second: 11,025
        0x22, 0x16, 0x00, 0x00,     // Avg Bytes Per Second: 5,666
        0x00, 0x01,                 // Block Alignment: 256
        0x04, 0x00,                 // Bits Per Sample: 4
        0x20, 0x00,                 // Extra Format Information: 32 bytes
                                    // Offset Data Bytes
        0xF4, 0x01, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00,
        0x00, 0x02, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
        0xC0, 0x00, 0x40, 0x00, 0xF0, 0x00, 0x00, 0x00,
        0xCC, 0x01, 0x30, 0xFF, 0x88, 0x01, 0x18, 0xFF

    MMRESULT mmr = ::acmFormatSuggest(NULL, (LPWAVEFORMATEX)pbyMSADPCM,
                                      &wfxDst, sizeof(wfxDst),
    ::printf("acmFormatSuggest returned mmr = %u\n", mmr);

RLMAuthor Commented:
Guess what, it returns "cmFormatSuggest returned mmr = 6" which is the error code for MMSYSERR_NODRIVER.

ACMApp tells me the following:
WinMM Version: 49152.04
ACM Version: 4.00 (retail)

Ours both seem to match! My OS version is Win95, 4.00.950 with IE4 installed. Should that matter? Since the acmtest worked as it should on your machine but returns NODRIVER on mine, it indicates that the bug isn't in my code but in my ACM. Yet our ACM versions are the same.

Currently, to get around the bug, I'm just making two sequential calls to acmFormatSuggest and the second call always works. It seems the first call my program makes after it is loaded always returns MMSYSERR_NODRIVER.

Perhaps I have a buggy ACM codec installed which is causing the problem. However, Media Player doesn't die on me and ACMApp works fine. However, I haven't checked source code to ACMApp to see if it's making two calls to acmFormatSuggest but I'm sure it must use that function.

My win95 isn't OSR2 and I've never installed service pack for exactly this reason. Since dealing with OS bugs is easier when you can see them on your machine. Tree View Control has a bug or two in it on my machine as well.

My OS version is also Win95, 4.00.950 with IE4 installed. It is interesting. Can you trace the ACMApp to see why it works fine? It seems to call acmFormatSuggest only once.
I just realized that ACMApp uses dynamical linking to the MSACM32.DLL (acmthunk.c, acmthunk.h). Does this affect?
RLMAuthor Commented:
Hmm that could be it. Since I'm running osr1 with no service pack maybe service pack includes new msacm32.dll cause this is definitely a bug in os. btw- acmapp doesn't completely work on my system. It crashes when I select snd convert or batch convert. I'm sure service pack and/or osr2 would fix this prob on my pc but I like to develop for lowest common denominator and have my app work for people who are to lazy to service pack themselves.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.