Solved

mixerGetLineControls failure

Posted on 2000-05-15
6
1,077 Views
Last Modified: 2013-11-20
I'm trying to open a mixer to monitor audio levels but am getting a MIXERR_INVALCONTROL failure on mixerGetLineControls(). Here is the code I'm using:

    MMRESULT rc;              // Return code.
    MIXERCONTROL mxc;         // Holds the mixer control data.
    MIXERLINE mxl;            // Holds the mixer line data.
    MIXERLINECONTROLS mxlc;   // Obtains the mixer control.
      MIXERCAPS mxrcaps;
      HMIXER hMixer = NULL;

      int nNumDevs = ::mixerGetNumDevs();

      ::ZeroMemory(&m_mxrcaps, sizeof(MIXERCAPS));

      if(!nNumDevs)
      {
            GetMMError(rc);
            return;
      }

      rc = ::mixerOpen(&m_hMixer, 0, 0, NULL, MIXER_OBJECTF_MIXER );
      if(rc != MMSYSERR_NOERROR )
      {
            GetMMError(rc);
            return;
      }

      if(m_hMixer == NULL)
      {
            GetMMError(rc);
            return;
      }

    // Initialize MIXERLINE structure.
    ZeroMemory(&mxl,sizeof(mxl));
    mxl.cbStruct = sizeof(mxl);

    mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;

    rc = mixerGetLineInfo((HMIXEROBJ)m_hMixer, &mxl,
                           MIXER_GETLINEINFOF_COMPONENTTYPE);
      if(rc != MMSYSERR_NOERROR )
      {
            GetMMError(rc);
      }

    // Get the control.
    ZeroMemory(&mxlc, sizeof(mxlc));
    mxlc.cbStruct = sizeof(mxlc);
    mxlc.dwLineID = mxl.dwLineID;
    mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_PEAKMETER;
    mxlc.cControls = 1;
    mxlc.cbmxctrl = sizeof(mxc);
    mxlc.pamxctrl = &mxc;
    ZeroMemory(&mxc, sizeof(mxc));
    mxc.cbStruct = sizeof(mxc);
    rc = mixerGetLineControls((HMIXEROBJ)m_hMixer,&mxlc,
                               MIXER_GETLINECONTROLSF_ONEBYTYPE);
    if (MMSYSERR_NOERROR != rc)
      {
            GetMMError(rc);
    }

    MIXERCONTROLDETAILS mxcd;             // Gets the control values.
    MIXERCONTROLDETAILS_SIGNED volStruct; // Gets the control values.

    // Initialize the MIXERCONTROLDETAILS structure
    ZeroMemory(&mxcd, sizeof(mxcd));
    mxcd.cbStruct = sizeof(mxcd);
    mxcd.cbDetails = sizeof(volStruct);
    mxcd.dwControlID = mxc.dwControlID;
    mxcd.paDetails = &volStruct;
    mxcd.cChannels = 1;

    rc = mixerGetControlDetails((HMIXEROBJ)m_hMixer, &mxcd,
                                 MIXER_GETCONTROLDETAILSF_VALUE);
    if (MMSYSERR_NOERROR != rc)
      {
            GetMMError(rc);
      }

      ... use MIXERCONTROLDETAILS structure


Any ideas?
0
Comment
Question by:Grailman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 2811231
The MIXERLINE_COMPONENTTYPE_DST_WAVEIN audio line might not support the MIXERCONTROL_CONTROLTYPE_PEAKMETER control. Check out the Windows Volume Control utility and the following Win32 sample to see if the control is there.

MixApp: Sample Mixer Application
http://msdn.microsoft.com/library/devprods/vs6/visualc/vcsample/vcsmpmixapp.htm

Also, check out my article at CodeGuru.

Audio Mixer Functions Demo
http://www.codeguru.com/multimedia/ADMixer.shtml
0
 
LVL 1

Author Comment

by:Grailman
ID: 2813169
I tried your Audio Mixer Functions Demo and it worked fine but only for playing wav files. How do you use it to get the cd play or the microphone input?
0
 
LVL 1

Author Comment

by:Grailman
ID: 2813191
I tried using MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC and MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE for mxl.dwComponentType but still could not get any response...?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:chensu
ID: 2814120
The controls you are trying to get are unlikely to be supported by the audio driver. Check out the Windows Volume Control utility and the following Win32 sample to see if the controls are there.
0
 
LVL 1

Author Comment

by:Grailman
ID: 2838796
The win32 sample & volume controls show the mixer so it should be there. I don't have time to dig into it for now but it looks like I should be able t find it.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2839068
Good luck.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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