Solved

acmFormatSuggest() function question.

Posted on 1998-02-18
12
980 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
Comment Utility
Are you sure ptr to compressed wave file's WAVEFORMATEX is not changed on your second try?
0
 

Author Comment

by:RLM
Comment Utility
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
Comment Utility
Note: acmGetVersion returns 0x4000000
0
 

Author Comment

by:RLM
Comment Utility
Adjusted points to 500
0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:RLM
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I just realized that ACMApp uses dynamical linking to the MSACM32.DLL (acmthunk.c, acmthunk.h). Does this affect?
0
 

Author Comment

by:RLM
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now