void Px_CloseMixer(PxMixer *mixer) { PxInfo *info = (PxInfo *)mixer; if (info->hInputMixer) mixerClose((HMIXER)info->hInputMixer); if (info->hOutputMixer) mixerClose((HMIXER)info->hOutputMixer); }
///////////////////////////////////////////////// // Component: value from dwComponentType member of MIXERLINE, eg:// MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE // Kind : 0 Wave ouput tunnle, 1 Wave input tunle, 2... other. CMixer::CMixer(DWORD ComponentType, DestKind dkKind): m_dwControlID(-1), m_bOK(false), m_dwChannels(0) { HMIXER hMixer; HRESULT hr; hr = mixerOpen(&hMixer, 0, 0, 0, 0); if (FAILED(hr)) return; MIXERLINE mxl; MIXERCONTROL mc; MIXERLINECONTROLS mxlc; DWORD kind, count; if (dkKind == Play) kind = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; else kind = MIXERLINE_COMPONENTTYPE_DST_WAVEIN; mxl.cbStruct = sizeof(mxl); mxl.dwComponentType = kind; hr = mixerGetLineInfo((HMIXEROBJ)hMixer, &mxl, MIXER_GETLINEINFOF_COMPONENTTYPE); if (FAILED(hr)) { mixerClose(hMixer); return; } count = mxl.dwSource; for(UINT i = 0; i < count; i++) { mxl.dwSource = i; mixerGetLineInfo((HMIXEROBJ)hMixer, &mxl, MIXER_GETLINEINFOF_SOURCE); if (mxl.dwComponentType == ComponentType) { m_dwChannels = mxl.cChannels; mc.cbStruct = sizeof(mc); mxlc.cbStruct = sizeof(mxlc); mxlc.dwLineID = mxl.dwLineID; mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME; mxlc.cControls = 1; mxlc.cbmxctrl = sizeof(MIXERCONTROL); mxlc.pamxctrl = &mc; hr = mixerGetLineControls((HMIXEROBJ)hMixer, &mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE); m_dwControlID = mc.dwControlID; break; }; } mixerClose(hMixer); m_bOK = true; }
static int cleanup(px_mixer *Px) { PxInfo *info = (PxInfo *)Px->info; int i; if (info) { if (info->hInputMixer) { mixerClose((HMIXER) info->hInputMixer); } if (info->hOutputMixer) { mixerClose((HMIXER) info->hOutputMixer); } if (info->inName) { free(info->inName); } if (info->outName) { free(info->outName); } if (info->src) { for (i = 0; i < info->numInputs; i++) { if (info->src[i].name) { free(info->src[i].name); } } free(info->src); } if (info->dst) { for (i = 0; i < info->numOutputs; i++) { if (info->dst[i].name) { free(info->dst[i].name); } } free(info->dst); } free(info); Px->info = NULL; } return FALSE; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //agenttype_mixer_destroy //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int agenttype_mixer_destroy(agent *a) { if (a->agentdetails) { //Get the details agenttype_mixer_details *details = (agenttype_mixer_details *) a->agentdetails; //Close the window if (details->hwnd_reciever) window_helper_destroy(details->hwnd_reciever); details->hwnd_reciever = NULL; //Close the mixer mixerClose(details->mixer_handle); //Delete the details delete details; a->agentdetails = NULL; } //Destroy the window if necessary mixer_controlcount--; if (mixer_controlcount < 1 && mixer_recieverregistered) { window_helper_unregister(mixer_recieverclass); mixer_recieverregistered = false; } //No errors return 0; }
HMIXER CMicVolume::MixDevice(HMIXER current_mix, unsigned int mix_id) { HMIXER h_mixer; MIXERCAPS mixer_caps; if(mixerGetDevCaps(mix_id, &mixer_caps, sizeof(mixer_caps)) != MMSYSERR_NOERROR) return NULL; if(mixerOpen(&h_mixer, mix_id, DWORD(NULL), 0L, CALLBACK_WINDOW) != MMSYSERR_NOERROR) return NULL; if(current_mix != NULL){ if(mixerClose(current_mix) != MMSYSERR_NOERROR) { #ifdef _DEBUG MessageBox(NULL,"Mixer 장치가 사용중입니다.", "Mixer 열기실패", MB_ICONSTOP); #endif current_mix = NULL; } } //char szbuf[128]; //wsprintf(szbuf,"Mixer 장치명: %s", mixer_caps.szPname); //SetWindowText(g_hWnd, szbuf); //윈도우 타이틀바에 장치명 알림 return h_mixer; }
//################################################## //agenttype_mixer_menu_devices //################################################## void agenttype_mixer_menu_devices(Menu *menu, control *c, char *action, char *agentname, int format) { //Variables MIXERCAPS mixer_capabilities; HMIXER mixer_handle; //Count the devices UINT count_devices = mixerGetNumDevs(); if (count_devices < 1) { make_menuitem_nop(menu, "No audio devices present."); return; } //For every device... for (UINT device = 0; device < count_devices; device++) { //Open the mixer if (MMSYSERR_NOERROR == mixerOpen( &mixer_handle, device, 0, 0, 0) && MMSYSERR_NOERROR == mixerGetDevCaps(device, &mixer_capabilities, sizeof(MIXERCAPS))) { //Create a submenu for destination lines Menu *submenu; submenu = make_menu(mixer_capabilities.szPname, c); agenttype_mixer_menu_destlines(submenu, c, action, agentname, format, device, mixer_handle, mixer_capabilities); make_submenu_item(menu, mixer_capabilities.szPname, submenu); //Close the mixer mixerClose(mixer_handle); } } return; }
void VolumeControl::deinit() { //deinitialize audio mixer interface #if defined (__APPLE__) #warning TODO: Not implemented for MacOS yet!!! #elif defined(__linux__) if (mixerHandle != nullptr) { snd_mixer_detach(mixerHandle, mixerCard); snd_mixer_free(mixerHandle); snd_mixer_close(mixerHandle); mixerHandle = nullptr; mixerElem = nullptr; } #elif defined(WIN32) || defined(_WIN32) if (mixerHandle != nullptr) { mixerClose(mixerHandle); mixerHandle = nullptr; } else if (endpointVolume != nullptr) { endpointVolume->Release(); endpointVolume = nullptr; CoUninitialize(); } #endif }
BOOL CMyVolumeCtrl::vSetMute(long dev,long vol)//设置设备静音 { // dev =0,1,2 分别表示主音量,波形,MIDI ,LINE IN // vol=0,1 分别表示取消静音,设置静音 // retrun false 表示取消或设置静音操作不成功 // retrun true 表示取消或设置静音操作成功 long device; BOOL rc = FALSE; MIXERCONTROL volCtrl; HMIXER hmixer; switch (dev) { case 1: device=MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; break; case 2: device=MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; break; case 3: device=MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; default: device=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; } if(mixerOpen(&hmixer, 0, 0, 0, 0)) return 0; if(vGetVolumeControl(hmixer,device,MIXERCONTROL_CONTROLTYPE_MUTE,&volCtrl)) if(vSetMuteValue(hmixer,&volCtrl,(BOOL)vol)) rc=TRUE; mixerClose(hmixer); return rc; }
BOOL CMyVolumeCtrl::vGetMute(long dev)//检查设备是否静音 { //dev =0,1,2 分别表示主音量,波形,MIDI ,LINE IN // retrun false 表示没有静音 // retrun true 表示静音 long device; BOOL rc = FALSE; MIXERCONTROL volCtrl; HMIXER hmixer; switch (dev) { case 1: device=MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; break; case 2: device=MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; break; case 3: device=MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; default: device=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; } if(mixerOpen(&hmixer, 0, 0, 0, 0)) return 0; if(vGetVolumeControl(hmixer,device,MIXERCONTROL_CONTROLTYPE_MUTE,&volCtrl)) rc = vGetMuteValue(hmixer,&volCtrl); mixerClose(hmixer); return rc; }
BOOL CMyVolumeCtrl::vSetVolume(long dev,long vol)//设置设备的音量 { // dev =0,1,2 分别表示主音量,波形,MIDI ,LINE IN // vol=0-MAX_VOL 表示音量的大小 , 设置与返回音量的值用的是百分比,即音量从0 - MAX_VOL,而不是设备的绝对值 // retrun false 表示设置音量的大小的操作不成功 // retrun true 表示设置音量的大小的操作成功 long device; BOOL rc = FALSE; MIXERCONTROL volCtrl; HMIXER hmixer; switch (dev) { case 1: device=MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; break; case 2: device=MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; break; case 3: device=MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; default: device=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; } if(mixerOpen(&hmixer, 0, 0, 0, 0)) return 0; if(vGetVolumeControl(hmixer,device,MIXERCONTROL_CONTROLTYPE_VOLUME,&volCtrl)) { vol=vol*volCtrl.Bounds.lMaximum/MAX_VOL; if(vSetVolumeValue(hmixer,&volCtrl,vol)) rc=true; } mixerClose(hmixer); return rc; }
unsigned int CMyVolumeCtrl::vGetVolume(int dev)//得到设备的音量dev=0主音量,1WAVE ,2MIDI ,3 LINE IN { long device; unsigned int rt=0; MIXERCONTROL volCtrl; HMIXER hmixer; switch (dev) { case 1: device=MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; break; case 2: device=MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; break; case 3: // device=MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; // cd 音量 // device=MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE; break; //麦克风音量 // device=MIXERLINE_COMPONENTTYPE_SRC_LINE; break; //PC 扬声器音量 device=MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; default: device=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; } if(mixerOpen(&hmixer, 0, 0, 0, 0)) return 0; if(!vGetVolumeControl(hmixer,device,MIXERCONTROL_CONTROLTYPE_VOLUME,&volCtrl)) return 0; rt=vGetVolumeValue(hmixer,&volCtrl)*MAX_VOL/volCtrl.Bounds.lMaximum; mixerClose(hmixer); return rt; }
static void test_mixerClose(HMIXER mix) { MMRESULT rc; rc = mixerClose(mix); ok(rc == MMSYSERR_NOERROR || rc == MMSYSERR_INVALHANDLE, "mixerClose: MMSYSERR_NOERROR or MMSYSERR_INVALHANDLE expected, got %s\n", mmsys_error(rc)); }
BOOL SndMixerSelect(PSND_MIXER Mixer, UINT MixerId) { if (MixerId >= Mixer->MixersCount) { return FALSE; } SndMixerClose(Mixer); if (mixerOpen(&Mixer->hmx, MixerId, (DWORD_PTR)Mixer->hWndNotification, 0, CALLBACK_WINDOW | MIXER_OBJECTF_MIXER) == MMSYSERR_NOERROR || mixerOpen(&Mixer->hmx, MixerId, (DWORD_PTR)Mixer->hWndNotification, 0, CALLBACK_WINDOW) == MMSYSERR_NOERROR || mixerOpen(&Mixer->hmx, MixerId, 0, 0, 0) == MMSYSERR_NOERROR) { if (mixerGetDevCaps(MixerId, &Mixer->Caps, sizeof(Mixer->Caps)) == MMSYSERR_NOERROR) { BOOL Ret = FALSE; Mixer->MixerId = MixerId; ClearMixerCache(Mixer); Ret = SndMixerQueryDestinations(Mixer); if (!Ret) { ClearMixerCache(Mixer); } return Ret; } else { mixerClose(Mixer->hmx); } } Mixer->hmx = NULL; Mixer->MixerId = NO_MIXER_SELECTED; return FALSE; }
VOID SndMixerClose(PSND_MIXER Mixer) { if (Mixer->hmx != NULL) { mixerClose(Mixer->hmx); Mixer->hmx = NULL; Mixer->MixerId = NO_MIXER_SELECTED; } }
void CVolumeOutMaster::Done() { if ( mixerClose( (HMIXER)m_dwMixerHandle ) != MMSYSERR_NOERROR ) { ssi_wrn (".MasterOutputVolume: WARNING: Could not close Mixer.\n" ); } ::DestroyWindow( m_hWnd ); m_bInitialized = false; m_bOK = false; }
void CVolumeCtrl::Clear() { if (mixerClose((HMIXER)m_dwMixerHandle ) != MMSYSERR_NOERROR) { TRACE("CVolumeCtrl WARNING: Could not close Mixer.\r\n"); } ::DestroyWindow( m_hWnd ); m_bInitialized = FALSE; m_bOK = FALSE; }
BOOL SndMixerEnumProducts(PSND_MIXER Mixer, PFNSNDMIXENUMPRODUCTS EnumProc, PVOID Context) { MIXERCAPS Caps; HMIXER hMixer; UINT i; BOOL Ret = TRUE; for (i = 0; i < Mixer->MixersCount; i++) { if (mixerOpen(&hMixer, i, 0, 0, 0) == MMSYSERR_NOERROR) { if (mixerGetDevCaps(i, &Caps, sizeof(Caps)) == MMSYSERR_NOERROR) { if (!EnumProc(Mixer, i, Caps.szPname, Context)) { mixerClose(hMixer); Ret = FALSE; break; } } else { DPRINT("Failed to get device capabilities for mixer id %d!\n", i); } mixerClose(hMixer); } } return Ret; }
void AgentType_Mixer_XP::Destroy () { if (m_hwnd_reciever) { window_helper_destroy(m_hwnd_reciever); m_hwnd_reciever = 0; } //Close the mixer mixerClose(m_mixer_handle); }
/* If the PROP_DEVICE_NAME is set, find the mixer related to device; * otherwise we get the default input mixer. */ static gboolean gst_directsound_src_mixer_find (GstDirectSoundSrc * dsoundsrc, MIXERCAPS * mixer_caps) { MMRESULT mmres; guint i, num_mixers; num_mixers = mixerGetNumDevs (); for (i = 0; i < num_mixers; i++) { mmres = mixerOpen (&dsoundsrc->mixer, i, 0L, 0L, MIXER_OBJECTF_MIXER | MIXER_OBJECTF_WAVEIN); if (mmres != MMSYSERR_NOERROR) continue; mmres = mixerGetDevCaps (GPOINTER_TO_UINT (dsoundsrc->mixer), mixer_caps, sizeof (MIXERCAPS)); if (mmres != MMSYSERR_NOERROR) { mixerClose (dsoundsrc->mixer); continue; } /* Get default mixer */ if (dsoundsrc->device_name == NULL) { GST_DEBUG ("Got default input mixer: %s", mixer_caps->szPname); return TRUE; } if (g_strstr_len (dsoundsrc->device_name, -1, mixer_caps->szPname) != NULL) { GST_DEBUG ("Got requested input mixer: %s", mixer_caps->szPname); return TRUE; } /* Wrong mixer */ mixerClose (dsoundsrc->mixer); } GST_DEBUG ("Can't find input mixer"); return FALSE; }
BOOL CMixOut::CloseMixer() { if (m_hMixer) { m_mmr = mixerClose((HMIXER)m_hMixer); if (m_mmr != MMSYSERR_NOERROR ) { return false; } } return TRUE; }
void PortAudioInput::CloseMixer(void) { m_dwCntlID = 0; if ( m_isOpen ) { for (int i = 0; i < m_mixerNums; i++ ) { if ( m_barrOpened[i] ) { mixerClose(m_mixer[i]); m_barrOpened[i] = false; } } m_isOpen = false; } }
BOOL mixer_deinit(void) { if (s_hMixer != NULL) mixerClose(s_hMixer); if (s_lines.mixers != NULL) free(s_lines.mixers); if (s_mutes.mixers != NULL) free(s_lines.mixers); return (TRUE); }
//设置设备静音 bool SoundControl::SetMute(long dev, bool vol) { // dev =0,1,2 分别表示主音量,波形,MIDI ,LINE IN // vol=false,true 分别表示取消静音,设置静音 // retrun false 表示取消或设置静音操作不成功 // retrun true 表示取消或设置静音操作成功 long device; bool rc = false; MIXERCONTROL volCtrl; HMIXER hmixer; switch (dev) { case 1: device = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; break; case 2: device = MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; break; case 3: device = MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; case 4: device = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE; break; default: device = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; break; } if (mixerOpen(&hmixer, 0, 0, 0, 0)) { return 0; } if (SoundControl::GetVolumeControl(hmixer, device, MIXERCONTROL_CONTROLTYPE_MUTE, &volCtrl)) { if (SoundControl::SetMuteValue(hmixer, &volCtrl, vol)) { rc = true; } //vol = vol * volCtrl.Bounds.lMaximum / 100; //if (SoundControl::SetVolumeValue(hmixer, &volCtrl, vol)) //{ // rc = true; //} } mixerClose(hmixer); return rc; }
static void shutdownMixer(void) { if(!initMixerOk) return; // Can't uninitialize if not inited. // Restore the original mixer volumes, if possible. mixer4i(MIX_MIDI, MIX_SET, MIX_VOLUME, origVol); if(origCDVol != MIX_ERROR) mixer4i(MIX_CDAUDIO, MIX_SET, MIX_VOLUME, origCDVol); mixerClose(mixer); mixer = NULL; initMixerOk = false; }
//设置音量值 bool WINAPI SetVolume(LONG vol) { bool Result=false; //用于判断函数是否执行成功 MIXERCONTROL volCtrl; HMIXER hmixer; if(mixerOpen(&hmixer, 0, 0, 0, 0)) return 0; if(GetVolumeControl(hmixer,MIXERLINE_COMPONENTTYPE_DST_SPEAKERS,MIXERCONTROL_CONTROLTYPE_VOLUME,&volCtrl)) { int ChangeValue=volCtrl.Bounds.lMaximum/INTERVAL; int TotalValue=ChangeValue*vol; if(SetVolumeValue(hmixer,&volCtrl,TotalValue)) Result=true; } mixerClose(hmixer); return Result; }
//设置设备的音量 bool SoundControl::SetVolume(long dev, long vol) { // dev =0,1,2 分别表示主音量,波形,MIDI ,LINE IN // vol=0-100 表示音量的大小 , 设置与返回音量的值用的是百分比,即音量从0 - 100,而不是设备的绝对值 // retrun false 表示设置音量的大小的操作不成功 // retrun true 表示设置音量的大小的操作成功 long device; bool rc = false; MIXERCONTROL volCtrl; HMIXER hmixer; switch (dev) { case 1: device = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; break; case 2: device = MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; break; case 3: device = MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; case 4: device = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE; break; default: device = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; break; } if (mixerOpen(&hmixer, 0, 0, 0, 0)) { return 0; } if (SoundControl::GetVolumeControl(hmixer, device, MIXERCONTROL_CONTROLTYPE_VOLUME, &volCtrl)) { vol = vol * volCtrl.Bounds.lMaximum / 100; if (SoundControl::SetVolumeValue(hmixer, &volCtrl, vol)) { rc = true; } } mixerClose(hmixer); return rc; }
void Win32RedBookDevice::closeVolume() { setLastError(""); if(!mVolumeInitialized) return; if(mUsingMixer) { mMixerVolumeValue.dwValue = mOriginalVolume; mixerSetControlDetails(mVolumeDeviceId, &mMixerVolumeDetails, MIXER_SETCONTROLDETAILSF_VALUE); mixerClose((HMIXER)mVolumeDeviceId); } else auxSetVolume(mAuxVolumeDeviceId, mOriginalVolume); mVolumeInitialized = false; }
//-------------------------------------------------------------------------------------- // Class: SoundResources // Method: (public)_uninitialize // Description: //-------------------------------------------------------------------------------------- int SoundResources::_uninitialize (void) { _bmutex.Wait (); m_InRecord = false; mixerClose(m_MixerHandle); // Close mixer waveInReset(m_WaveInHandle); // Reset the wave input device if(_rawBuffer != NULL){ delete[] _rawBuffer; // Delete the shared buffer _rawBuffer = NULL; } _bmutex.Post (); return YARP_OK; }
//得到音量,得到设备的音量dev=0主音量,1WAVE, 2MIDI , 3 LINE IN unsigned SoundControl::GetVolume(int dev) { long device; unsigned rt = 0; MIXERCONTROL volCtrl; HMIXER hmixer; switch (dev) { case 1: device = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; break; case 2: device = MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; break; case 3: // device=MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; // cd 音量 // device=MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE; break; //麦克风音量 // device=MIXERLINE_COMPONENTTYPE_SRC_LINE; break; //PC 扬声器音量 device = MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; case 4: device = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE; break; default: device = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; break; } if (mixerOpen(&hmixer, 0, 0, 0, 0)) { return 0; } if (!SoundControl::GetVolumeControl(hmixer, device, MIXERCONTROL_CONTROLTYPE_VOLUME, &volCtrl)) { return 0; } rt = SoundControl::GetVolumeValue(hmixer, &volCtrl) * 100 / volCtrl.Bounds.lMaximum; mixerClose(hmixer); return rt; }
//检查设备是否静音 bool SoundControl::GetMute(long dev) { //dev =0,1,2 分别表示主音量,波形,MIDI ,LINE IN // retrun false 表示没有静音 // retrun true 表示静音 long device; bool rc = false; MIXERCONTROL volCtrl; HMIXER hmixer; switch (dev) { case 1: device = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT; break; case 2: device = MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER; break; case 3: device = MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC; break; case 4: device = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE; break; default: device = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; break; } if (mixerOpen(&hmixer, 0, 0, 0, 0)) { return 0; } if (SoundControl::GetVolumeControl(hmixer, device, MIXERCONTROL_CONTROLTYPE_MUTE, &volCtrl)) { rc = GetMuteValue(hmixer, &volCtrl); } mixerClose(hmixer); return rc; }