This commit is contained in:
chudov
2010-03-30 02:41:43 +00:00
parent 771df3be5a
commit 881951cb02
74 changed files with 6489 additions and 1709 deletions

View File

@@ -0,0 +1,54 @@
/*
LICENSE
-------
Copyright (C) 2007 Ray Molenkamp
This source code is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this source code or the software it produces.
Permission is granted to anyone to use this source code for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace NAudio.CoreAudioApi.Interfaces
{
internal struct AudioVolumeNotificationDataStruct
{
public Guid guidEventContext;
public bool bMuted;
public float fMasterVolume;
public uint nChannels;
public float ChannelVolume;
//Code Should Compile at warning level4 without any warnings,
//However this struct will give us Warning CS0649: Field [Fieldname]
//is never assigned to, and will always have its default value
//You can disable CS0649 in the project options but that will disable
//the warning for the whole project, it's a nice warning and we do want
//it in other places so we make a nice dummy function to keep the compiler
//happy.
private void FixCS0649()
{
guidEventContext = Guid.Empty;
bMuted = false;
fMasterVolume = 0;
nChannels = 0;
ChannelVolume = 0;
}
}
}

View File

@@ -0,0 +1,49 @@
/*
LICENSE
-------
Copyright (C) 2007 Ray Molenkamp
This source code is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this source code or the software it produces.
Permission is granted to anyone to use this source code for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
*/
// Adapted for NAudio
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
internal struct Blob
{
public int Length;
public IntPtr Data;
//Code Should Compile at warning level4 without any warnings,
//However this struct will give us Warning CS0649: Field [Fieldname]
//is never assigned to, and will always have its default value
//You can disable CS0649 in the project options but that will disable
//the warning for the whole project, it's a nice warning and we do want
//it in other places so we make a nice dummy function to keep the compiler
//happy.
private void FixCS0649()
{
Length = 0;
Data = IntPtr.Zero;
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace NAudio.CoreAudioApi.Interfaces
{
/// <summary>
/// is defined in WTypes.h
/// </summary>
[Flags]
enum ClsCtx
{
INPROC_SERVER = 0x1,
INPROC_HANDLER = 0x2,
LOCAL_SERVER = 0x4,
INPROC_SERVER16 = 0x8,
REMOTE_SERVER = 0x10,
INPROC_HANDLER16 = 0x20,
//RESERVED1 = 0x40,
//RESERVED2 = 0x80,
//RESERVED3 = 0x100,
//RESERVED4 = 0x200,
NO_CODE_DOWNLOAD = 0x400,
//RESERVED5 = 0x800,
NO_CUSTOM_MARSHAL = 0x1000,
ENABLE_CODE_DOWNLOAD = 0x2000,
NO_FAILURE_LOG = 0x4000,
DISABLE_AAA = 0x8000,
ENABLE_AAA = 0x10000,
FROM_DEFAULT_CONTEXT = 0x20000,
ACTIVATE_32_BIT_SERVER = 0x40000,
ACTIVATE_64_BIT_SERVER = 0x80000,
ENABLE_CLOAKING = 0x100000,
PS_DLL = unchecked ( (int) 0x80000000 ),
INPROC = INPROC_SERVER | INPROC_HANDLER,
SERVER = INPROC_SERVER | LOCAL_SERVER | REMOTE_SERVER,
ALL = SERVER | INPROC_HANDLER
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace NAudio.CoreAudioApi.Interfaces
{
enum AudioClientErrors
{
/// <summary>
/// AUDCLNT_E_NOT_INITIALIZED
/// </summary>
NotInitialized = unchecked((int)0x88890001),
/// <summary>
/// AUDCLNT_E_UNSUPPORTED_FORMAT
/// </summary>
UnsupportedFormat = unchecked((int)0x88890008),
/// <summary>
/// AUDCLNT_E_DEVICE_IN_USE
/// </summary>
DeviceInUse = unchecked((int)0x8889000A),
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
[Guid("C8ADBD64-E71E-48a0-A4DE-185C395CD317"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IAudioCaptureClient
{
/*HRESULT GetBuffer(
BYTE** ppData,
UINT32* pNumFramesToRead,
DWORD* pdwFlags,
UINT64* pu64DevicePosition,
UINT64* pu64QPCPosition
);*/
int GetBuffer(
out IntPtr dataBuffer,
out int numFramesToRead,
out AudioClientBufferFlags bufferFlags,
out long devicePosition,
out long qpcPosition);
int ReleaseBuffer(int numFramesRead);
int GetNextPacketSize(out int numFramesInNextPacket);
}
}

View File

@@ -0,0 +1,53 @@
using System;
using System.Runtime.InteropServices;
using NAudio.Wave;
namespace NAudio.CoreAudioApi.Interfaces
{
/// <summary>
/// n.b. WORK IN PROGRESS - this code will probably do nothing but crash at the moment
/// Defined in AudioClient.h
/// </summary>
[Guid("1CB9AD4C-DBFA-4c32-B178-C2F568A703B2"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAudioClient
{
void Initialize(AudioClientShareMode shareMode,
AudioClientStreamFlags StreamFlags,
long hnsBufferDuration, // REFERENCE_TIME
long hnsPeriodicity, // REFERENCE_TIME
[In] WaveFormat pFormat,
[In] ref Guid AudioSessionGuid);
/// <summary>
/// The GetBufferSize method retrieves the size (maximum capacity) of the endpoint buffer.
/// </summary>
void GetBufferSize(out uint bufferSize);
[return: MarshalAs(UnmanagedType.I8)]
long GetStreamLatency();
void GetCurrentPadding(out int currentPadding);
[PreserveSig]
int IsFormatSupported(
AudioClientShareMode shareMode,
[In] WaveFormat pFormat,
[Out, MarshalAs(UnmanagedType.LPStruct)] out WaveFormatExtensible closestMatchFormat);
void GetMixFormat(out IntPtr deviceFormatPointer);
// REFERENCE_TIME is 64 bit int
void GetDevicePeriod(out long defaultDevicePeriod, out long minimumDevicePeriod);
void Start();
void Stop();
void Reset();
void SetEventHandle(IntPtr eventHandle);
void GetService(ref Guid interfaceId, [MarshalAs(UnmanagedType.IUnknown)] out object interfacePointer);
}
}

View File

@@ -0,0 +1,52 @@
/*
LICENSE
-------
Copyright (C) 2007 Ray Molenkamp
This source code is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this source code or the software it produces.
Permission is granted to anyone to use this source code for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAudioEndpointVolume
{
int RegisterControlChangeNotify(IAudioEndpointVolumeCallback pNotify);
int UnregisterControlChangeNotify(IAudioEndpointVolumeCallback pNotify);
int GetChannelCount(out int pnChannelCount);
int SetMasterVolumeLevel(float fLevelDB, Guid pguidEventContext);
int SetMasterVolumeLevelScalar(float fLevel, Guid pguidEventContext);
int GetMasterVolumeLevel(out float pfLevelDB);
int GetMasterVolumeLevelScalar(out float pfLevel);
int SetChannelVolumeLevel(uint nChannel, float fLevelDB, Guid pguidEventContext);
int SetChannelVolumeLevelScalar(uint nChannel, float fLevel, Guid pguidEventContext);
int GetChannelVolumeLevel(uint nChannel, out float pfLevelDB);
int GetChannelVolumeLevelScalar(uint nChannel, out float pfLevel);
int SetMute([MarshalAs(UnmanagedType.Bool)] Boolean bMute, Guid pguidEventContext);
int GetMute(out bool pbMute);
int GetVolumeStepInfo(out uint pnStep, out uint pnStepCount);
int VolumeStepUp(Guid pguidEventContext);
int VolumeStepDown(Guid pguidEventContext);
int QueryHardwareSupport(out uint pdwHardwareSupportMask);
int GetVolumeRange(out float pflVolumeMindB, out float pflVolumeMaxdB, out float pflVolumeIncrementdB);
}
}

View File

@@ -0,0 +1,37 @@
/*
LICENSE
-------
Copyright (C) 2007 Ray Molenkamp
This source code is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this source code or the software it produces.
Permission is granted to anyone to use this source code for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
[Guid("657804FA-D6AD-4496-8A60-352752AF4F89"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAudioEndpointVolumeCallback
{
//int OnNotify(IntPtr NotifyData);
void OnNotify(ref AudioVolumeNotificationDataStruct pNotifyData);
};
}

View File

@@ -0,0 +1,38 @@
/*
LICENSE
-------
Copyright (C) 2007 Ray Molenkamp
This source code is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this source code or the software it produces.
Permission is granted to anyone to use this source code for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
[Guid("C02216F6-8C67-4B5B-9D00-D008E73E0064"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAudioMeterInformation
{
int GetPeakValue(out float pfPeak);
int GetMeteringChannelCount(out int pnChannelCount);
int GetChannelsPeakValues(int u32ChannelCount, [In] IntPtr afPeakValues);
int QueryHardwareSupport(out int pdwHardwareSupportMask);
};
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
[Guid("F294ACFC-3146-4483-A7BF-ADDCA7C260E2"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IAudioRenderClient
{
IntPtr GetBuffer(int numFramesRequested);
void ReleaseBuffer(int numFramesWritten, AudioClientBufferFlags bufferFlags);
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
[Guid("D666063F-1587-4E43-81F1-B948E807363F"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IMMDevice
{
// activationParams is a propvariant
int Activate(ref Guid id, ClsCtx clsCtx, IntPtr activationParams,
[MarshalAs(UnmanagedType.IUnknown)] out object interfacePointer);
int OpenPropertyStore(StorageAccessMode stgmAccess, out IPropertyStore properties);
int GetId(out string id);
int GetState(out DeviceState state);
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
[Guid("0BD7A1BE-7A1A-44DB-8397-CC5392387B5E"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IMMDeviceCollection
{
int GetCount(out int numDevices);
int Item(int deviceNumber, out IMMDevice device);
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
[Guid("A95664D2-9614-4F35-A746-DE8DB63617E6"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IMMDeviceEnumerator
{
int EnumAudioEndpoints(DataFlow dataFlow, DeviceState stateMask,
out IMMDeviceCollection devices);
int GetDefaultAudioEndpoint(DataFlow dataFlow, Role role, out IMMDevice endpoint);
int GetDevice(string id, out IMMDevice deviceName);
int RegisterEndpointNotificationCallback(IMMNotificationClient client);
int UnregisterEndpointNotificationCallback(IMMNotificationClient client);
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
/// <summary>
/// defined in MMDeviceAPI.h
/// </summary>
[Guid("1BE09788-6894-4089-8586-9A2A6C265AC5"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IMMEndpoint
{
int GetDataFlow(out DataFlow dataFlow);
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
[Guid("7991EEC9-7E89-4D85-8390-6C703CEC60C0"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IMMNotificationClient
{
int OnDeviceStateChanged(string deviceId, int newState);
int OnDeviceAdded(string pwstrDeviceId);
int OnDeviceRemoved(string deviceId);
int OnDefaultDeviceChanged(DataFlow flow, Role role, string defaultDeviceId);
int OnPropertyValueChanged(string pwstrDeviceId, PropertyKey key);
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
/// <summary>
/// is defined in propsys.h
/// </summary>
[Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IPropertyStore
{
int GetCount(out int propCount);
int GetAt(int property, out PropertyKey key);
int GetValue(ref PropertyKey key, out PropVariant value);
int SetValue(ref PropertyKey key, ref PropVariant value);
int Commit();
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
/// <summary>
/// implements IMMDeviceEnumerator
/// </summary>
[ComImport, Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")]
class MMDeviceEnumeratorComObject
{
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace NAudio.CoreAudioApi.Interfaces
{
/// <summary>
/// MMDevice STGM enumeration
/// </summary>
enum StorageAccessMode
{
Read,
Write,
ReadWrite
}
}