Solved

acmFormatSuggest() function question.

Posted on 1998-02-18
12
1,007 Views
Last Modified: 2013-12-03
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:
NULL,
ptr to compressed wave file's WAVEFORMATEX,
ptr to WAVEFORMATEX (all zero's except for wFormatTag which = WAVE_FORMAT_PCM),
size of WAVEFORMATEX,
ACM_FORMATSUGGESTF_WFORMATTAG

How come it's failing on my first try?
0
Comment
Question by:RLM
  • 6
  • 6
12 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1411373
Are you sure ptr to compressed wave file's WAVEFORMATEX is not changed on your second try?
0
 

Author Comment

by:RLM
ID: 1411374
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.

0
 

Author Comment

by:RLM
ID: 1411375
Note: acmGetVersion returns 0x4000000
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:RLM
ID: 1411376
Adjusted points to 500
0
 
LVL 23

Expert Comment

by:chensu
ID: 1411377
Write a small program to test it. And make it as clean as possible to see what happens.
0
 
LVL 23

Accepted Solution

by:
chensu earned 500 total points
ID: 1411378
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.
0
 

Author Comment

by:RLM
ID: 1411379
Can you send me your mini program so I can run it and see if it's my computer (rob@gosupersonic.com). 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.


0
 
LVL 23

Expert Comment

by:chensu
ID: 1411380
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
    };
    WAVEFORMATEX wfxDst = { WAVE_FORMAT_PCM };

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

0
 

Author Comment

by:RLM
ID: 1411381
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.

0
 
LVL 23

Expert Comment

by:chensu
ID: 1411382
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.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1411383
I just realized that ACMApp uses dynamical linking to the MSACM32.DLL (acmthunk.c, acmthunk.h). Does this affect?
0
 

Author Comment

by:RLM
ID: 1411384
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.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question