ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

format.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:     ReactOS Sound System "MME Buddy" Library
00003  * LICENSE:     GPL - See COPYING in the top level directory
00004  * FILE:        lib/drivers/sound/mmebuddy/wave/format.c
00005  *
00006  * PURPOSE:     Queries and sets wave device format (sample rate, etc.)
00007  *
00008  * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
00009 */
00010 
00011 #include "precomp.h"
00012 
00013 MMRESULT
00014 QueryWaveDeviceFormatSupport(
00015     IN  PSOUND_DEVICE SoundDevice,
00016     IN  LPWAVEFORMATEX Format,
00017     IN  DWORD FormatSize)
00018 {
00019     MMRESULT Result;
00020     MMDEVICE_TYPE DeviceType;
00021     PMMFUNCTION_TABLE FunctionTable;
00022 
00023     SND_TRACE(L"Querying wave format support\n");
00024 
00025     VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
00026     VALIDATE_MMSYS_PARAMETER( Format );
00027     VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
00028 
00029     Result = GetSoundDeviceType(SoundDevice, &DeviceType);
00030     SND_ASSERT( Result == MMSYSERR_NOERROR );
00031 
00032     /* Ensure we have a wave device (TODO: check if this applies to wavein as well) */
00033     VALIDATE_MMSYS_PARAMETER( IS_WAVE_DEVICE_TYPE(DeviceType) );
00034 
00035     /* Obtain the function table */
00036     Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
00037     SND_ASSERT( Result == MMSYSERR_NOERROR );
00038 
00039     if ( ! MMSUCCESS(Result) )
00040         return TranslateInternalMmResult(Result);
00041 
00042     if ( ! FunctionTable->QueryWaveFormatSupport )
00043         return MMSYSERR_NOTSUPPORTED;
00044 
00045     return FunctionTable->QueryWaveFormatSupport(SoundDevice, Format, FormatSize);
00046 }
00047 
00048 MMRESULT
00049 SetWaveDeviceFormat(
00050     IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
00051     IN  DWORD DeviceId,
00052     IN  LPWAVEFORMATEX Format,
00053     IN  DWORD FormatSize)
00054 {
00055     MMRESULT Result;
00056     MMDEVICE_TYPE DeviceType;
00057     PMMFUNCTION_TABLE FunctionTable;
00058     PSOUND_DEVICE SoundDevice;
00059 
00060     SND_TRACE(L"Setting wave format\n");
00061 
00062     VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
00063 
00064     Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
00065     if ( ! MMSUCCESS(Result) )
00066         return TranslateInternalMmResult(Result);
00067 
00068     Result = GetSoundDeviceType(SoundDevice, &DeviceType);
00069     SND_ASSERT( Result == MMSYSERR_NOERROR );
00070     if (DeviceType == WAVE_IN_DEVICE_TYPE || DeviceType == WAVE_OUT_DEVICE_TYPE)
00071     {
00072         VALIDATE_MMSYS_PARAMETER( Format );
00073         VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
00074     }
00075 
00076     /* Ensure we have a wave device (TODO: check if this applies to wavein as well) */
00077     VALIDATE_MMSYS_PARAMETER( IS_WAVE_DEVICE_TYPE(DeviceType) || IS_MIDI_DEVICE_TYPE(DeviceType) || IS_MIXER_DEVICE_TYPE(DeviceType));
00078 
00079     /* Obtain the function table */
00080     Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
00081     SND_ASSERT( Result == MMSYSERR_NOERROR );
00082 
00083     if ( ! MMSUCCESS(Result) )
00084         return TranslateInternalMmResult(Result);
00085 
00086     if ( ! FunctionTable->SetWaveFormat )
00087         return MMSYSERR_NOTSUPPORTED;
00088 
00089     return FunctionTable->SetWaveFormat(SoundDeviceInstance, DeviceId, Format, FormatSize);
00090 }

Generated on Sat May 26 2012 04:16:53 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.