本文整理汇总了C#中AudioClientShareMode类的典型用法代码示例。如果您正苦于以下问题:C# AudioClientShareMode类的具体用法?C# AudioClientShareMode怎么用?C# AudioClientShareMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AudioClientShareMode类属于命名空间,在下文中一共展示了AudioClientShareMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WasapiOut
/// <summary>
/// Creates a new WASAPI Output
/// </summary>
/// <param name="device">Device to use</param>
/// <param name="shareMode"></param>
/// <param name="useEventSync">true if sync is done with event. false use sleep.</param>
/// <param name="latency"></param>
public WasapiOut(MMDevice device, AudioClientShareMode shareMode, bool useEventSync, int latency)
{
audioClient = device.AudioClient;
this.shareMode = shareMode;
isUsingEventSync = useEventSync;
latencyMilliseconds = latency;
}
开发者ID:teetow,项目名称:teevegas,代码行数:14,代码来源:WasapiOut.cs
示例2: WasapiOutRT
/// <summary>
/// Creates a new WASAPI Output
/// </summary>
/// <param name="device">Device to use</param>
/// <param name="shareMode"></param>
/// <param name="latency"></param>
public WasapiOutRT(string device, AudioClientShareMode shareMode, int latency)
{
this.device = device;
this.shareMode = shareMode;
this.latencyMilliseconds = latency;
this.syncContext = SynchronizationContext.Current;
}
开发者ID:KarimLUCCIN,项目名称:NAudioCustom,代码行数:13,代码来源:WasapiOutRT.cs
示例3: WasapiOut
/// <summary>
/// Creates a new WASAPI Output
/// </summary>
/// <param name="device">Device to use</param>
/// <param name="shareMode"></param>
/// <param name="useEventSync">true if sync is done with event. false use sleep.</param>
/// <param name="latency"></param>
public WasapiOut(MMDevice device, AudioClientShareMode shareMode, bool useEventSync, int latency)
{
this.audioClient = device.AudioClient;
this.shareMode = shareMode;
this.isUsingEventSync = useEventSync;
this.latencyMilliseconds = latency;
this.syncContext = SynchronizationContext.Current;
}
开发者ID:NoOnes2,项目名称:scharfrichter,代码行数:15,代码来源:WasapiOut.cs
示例4: WasapiOutRT
/// <summary>
/// Creates a new WASAPI Output
/// </summary>
/// <param name="device">Device to use</param>
/// <param name="shareMode"></param>
/// <param name="latency"></param>
public WasapiOutRT(string device, AudioClientShareMode shareMode, int latency)
{
this.device = device;
this.shareMode = shareMode;
this.latencyMilliseconds = latency;
this.syncContext = SynchronizationContext.Current;
playThreadEvent = new AutoResetEvent(false);
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:14,代码来源:WasapiOutRT.cs
示例5: WasapiOut
/// <summary>
/// Creates a new WASAPI Output
/// </summary>
/// <param name="device">Device to use</param>
/// <param name="shareMode"></param>
/// <param name="useEventSync">true if sync is done with event. false use sleep.</param>
/// <param name="latency">Desired latency in milliseconds</param>
public WasapiOut(MMDevice device, AudioClientShareMode shareMode, bool useEventSync, int latency)
{
audioClient = device.AudioClient;
mmDevice = device;
this.shareMode = shareMode;
isUsingEventSync = useEventSync;
latencyMilliseconds = latency;
syncContext = SynchronizationContext.Current;
outputFormat = audioClient.MixFormat; // allow the user to query the default format for shared mode streams
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:17,代码来源:WasapiOut.cs
示例6: WasapiOutGuiThread
/// <summary>
/// Creates a new WASAPI Output device
/// </summary>
/// <param name="device">Device to use</param>
/// <param name="shareMode">Share mode to use</param>
/// <param name="latency">Latency in milliseconds</param>
public WasapiOutGuiThread(MMDevice device, AudioClientShareMode shareMode, int latency)
{
audioClient = device.AudioClient;
outputFormat = audioClient.MixFormat;
this.shareMode = shareMode;
latencyMilliseconds = latency;
timer = new Timer();
timer.Tick += TimerOnTick;
timer.Interval = latency/2;
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:16,代码来源:WasapiOutGuiThread.cs
示例7: Initialize
/// <summary>
/// Initialize the Audio Client
/// </summary>
/// <param name="shareMode">Share Mode</param>
/// <param name="streamFlags">Stream Flags</param>
/// <param name="bufferDuration">Buffer Duration</param>
/// <param name="periodicity">Periodicity</param>
/// <param name="waveFormat">Wave Format</param>
/// <param name="audioSessionGuid">Audio Session GUID (can be null)</param>
public void Initialize(AudioClientShareMode shareMode,
AudioClientStreamFlags streamFlags,
long bufferDuration,
long periodicity,
WaveFormat waveFormat,
Guid audioSessionGuid)
{
audioClientInterface.Initialize(shareMode, streamFlags, bufferDuration, periodicity, waveFormat, ref audioSessionGuid);
// may have changed the mix format so reset it
mixFormat = null;
}
开发者ID:androidhacker,项目名称:DotNetProjs,代码行数:20,代码来源:AudioClient.cs
示例8: Initialize
/// <summary>
/// Initializes the Audio Client
/// </summary>
/// <param name="shareMode">Share Mode</param>
/// <param name="streamFlags">Stream Flags</param>
/// <param name="bufferDuration">Buffer Duration</param>
/// <param name="periodicity">Periodicity</param>
/// <param name="waveFormat">Wave Format</param>
/// <param name="audioSessionGuid">Audio Session GUID (can be null)</param>
public void Initialize(AudioClientShareMode shareMode,
AudioClientStreamFlags streamFlags,
long bufferDuration,
long periodicity,
WaveFormat waveFormat,
Guid audioSessionGuid)
{
this.shareMode = shareMode;
int hresult = audioClientInterface.Initialize(shareMode, streamFlags, bufferDuration, periodicity, waveFormat, ref audioSessionGuid);
Marshal.ThrowExceptionForHR(hresult);
// may have changed the mix format so reset it
mixFormat = null;
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:22,代码来源:AudioClient.cs
示例9: WasapiOut
/// <summary>
/// Creates a new WASAPI Output
/// </summary>
/// <param name="device">Device to use</param>
/// <param name="shareMode"></param>
/// <param name="useEventSync">true if sync is done with event. false use sleep.</param>
/// <param name="latency"></param>
public WasapiOut(MMDevice device, AudioClientShareMode shareMode, bool useEventSync, int latency, AudioPCMConfig pcm)
{
this.audioClient = device.AudioClient;
this.shareMode = shareMode;
this.isUsingEventSync = useEventSync;
this.latencyMilliseconds = latency;
this.pcm = pcm;
this.outputFormat = new NAudio.Wave.WaveFormatExtensible(pcm.SampleRate, pcm.BitsPerSample, pcm.ChannelCount);
NAudio.Wave.WaveFormatExtensible closestSampleRateFormat;
if (!audioClient.IsFormatSupported(shareMode, outputFormat, out closestSampleRateFormat))
throw new NotSupportedException("PCM format mismatch");
Init();
bufferFrameCount = audioClient.BufferSize;
readBuffers = new AudioBuffer[2];
readBuffers[0] = new AudioBuffer(pcm, bufferFrameCount);
readBuffers[1] = new AudioBuffer(pcm, bufferFrameCount);
//if (this.shareMode == AudioClientShareMode.Exclusive)
// this.latencyMilliseconds = (int)(this.audioClient.DefaultDevicePeriod / 10000);
}
开发者ID:androidhacker,项目名称:DotNetProjs,代码行数:26,代码来源:WasapiOut.cs
示例10: InitializeClient
private AudioClient InitializeClient(AudioClientShareMode shareMode)
{
AudioClient audioClient = GetAudioClient();
WaveFormat waveFormat = audioClient.MixFormat;
long refTimesPerSecond = 10000000;
audioClient.Initialize(shareMode,
AudioClientStreamFlags.None,
refTimesPerSecond,
0,
waveFormat,
Guid.Empty);
return audioClient;
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:13,代码来源:AudioClientTests.cs
示例11: IsFormatSupported
public bool IsFormatSupported(AudioClientShareMode shareMode, WAVEFORMATEXTENSIBLE format, ref WAVEFORMATEXTENSIBLE closestMatch)
{
int hr = _RealClient.IsFormatSupported(shareMode, format, out closestMatch);
bool ret = false;
if (hr == 0) ret = true;
else if (hr == 1) ret = false;
else Marshal.ThrowExceptionForHR(hr);
return ret;
}
开发者ID:davinx,项目名称:PitchPitch,代码行数:10,代码来源:AudioClient.cs
示例12: WasapiCapture
/// <summary>
/// Initializes a new instance of the <see cref="WasapiCapture"/> class.
/// </summary>
/// <param name="eventSync">True, to use eventsynchronization instead of a simple loop and sleep behavior. Don't use this in combination with exclusive mode.</param>
/// <param name="shareMode">Specifies how to open the audio device. Note that if exclusive mode is used, the device can only be used once on the whole system. Don't use exclusive mode in combination with eventSync.</param>
/// <param name="latency">Latency of the capture specified in milliseconds.</param>
/// <param name="captureThreadPriority">ThreadPriority of the capturethread which runs in background and provides the audiocapture itself.</param>
/// <param name="defaultFormat">The default WaveFormat to use for the capture. If this parameter is set to null, the best available format will be chosen automatically.</param>
/// <param name="synchronizationContext">The <see cref="SynchronizationContext"/> to use to fire events on.</param>
/// <exception cref="PlatformNotSupportedException">The current platform does not support Wasapi. For more details see: <see cref="IsSupportedOnCurrentPlatform"/>.</exception>
/// <exception cref="ArgumentException">The <paramref name="eventSync"/> parameter is set to true while the <paramref name="shareMode"/> is set to <see cref="AudioClientShareMode.Exclusive"/>.</exception>
public WasapiCapture(bool eventSync, AudioClientShareMode shareMode, int latency, WaveFormat defaultFormat,
ThreadPriority captureThreadPriority, SynchronizationContext synchronizationContext)
{
if (!IsSupportedOnCurrentPlatform)
throw new PlatformNotSupportedException("Wasapi is only supported on Windows Vista and above.");
if (eventSync && shareMode == AudioClientShareMode.Exclusive)
throw new ArgumentException("Don't use eventSync in combination with exclusive mode.");
_eventSync = eventSync;
_shareMode = shareMode;
_waveFormat = defaultFormat;
_latency = latency;
_captureThreadPriority = captureThreadPriority;
_synchronizationContext = synchronizationContext;
_recordingState = RecordingState.Stopped;
}
开发者ID:EQ4,项目名称:cscore,代码行数:29,代码来源:WasapiCapture.cs
示例13: IsFormatSupported
/// <summary>
/// Checks whether the audio endpoint device supports a particular stream format.
/// </summary>
public bool IsFormatSupported(AudioClientShareMode shareMode, WaveFormat waveFormat, out WaveFormatExtensible closestMatch)
{
int result = IsFormatSupportedNative(shareMode, waveFormat, out closestMatch);
switch (result)
{
case 0x0:
return true;
case 0x1:
case unchecked((int)0x88890008):
return false;
default:
CoreAudioAPIException.Try(result, c, "IsFormatSupported");
return false;
}
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:20,代码来源:AudioClient.cs
示例14: Initialize
public void Initialize(
AudioClientShareMode shareMode,
AudioClientStreamFlags streamFlags,
long bufferDuration, long periodicity,
WAVEFORMATEXTENSIBLE format, Guid audioSessionGuid)
{
int hr = _RealClient.Initialize(shareMode, streamFlags, bufferDuration, periodicity, format, ref audioSessionGuid);
Marshal.ThrowExceptionForHR(hr);
if ((streamFlags & AudioClientStreamFlags.EventCallback) != 0)
{
_audioSampleReady = new AutoResetEvent(false);
IntPtr eventHandle = CreateEventEx(IntPtr.Zero, "audioSampleReady", CreateEventFlags.None, AccessRight.Synchronize | AccessRight.EventModifyState);
_audioSampleReady.SafeWaitHandle = new Microsoft.Win32.SafeHandles.SafeWaitHandle(eventHandle, true);
hr = _RealClient.SetEventHandle(eventHandle);
Marshal.ThrowExceptionForHR(hr);
_audioSampleReadyRegistered = ThreadPool.RegisterWaitForSingleObject(
_audioSampleReady, new WaitOrTimerCallback(sampleReady), null, -1, false);
}
_isInitialized = true;
}
开发者ID:davinx,项目名称:PitchPitch,代码行数:23,代码来源:AudioClient.cs
示例15: WasapiOut
/// <summary>
/// Initializes an new instance of <see cref="WasapiOut" /> class.
/// EventSyncContext = SynchronizationContext.Current.
/// PlaybackThreadPriority = AboveNormal.
/// </summary>
/// <param name="eventSync">True, to use eventsynchronization instead of a simple loop and sleep behavior.</param>
/// <param name="shareMode">
/// Specifies how to open the audio device. Note that if exclusive mode is used, only one single
/// playback for the specified device is possible at once.
/// </param>
/// <param name="latency">Latency of the playback specified in milliseconds.</param>
public WasapiOut(bool eventSync, AudioClientShareMode shareMode, int latency)
: this(eventSync, shareMode, latency, ThreadPriority.AboveNormal)
{
}
开发者ID:opcon,项目名称:cscore,代码行数:15,代码来源:WasapiOut.cs
示例16: IsFormatSupported
/// <summary>
/// Determines if the specified output format is supported in shared mode
/// </summary>
/// <param name="shareMode">Share Mode</param>
/// <param name="desiredFormat">Desired Format</param>
/// <param name="closestMatchFormat">Output The closest match format.</param>
/// <returns>
/// <c>true</c> if [is format supported] [the specified share mode]; otherwise, <c>false</c>.
/// </returns>
public bool IsFormatSupported(AudioClientShareMode shareMode, WaveFormat desiredFormat, out WaveFormatExtensible closestMatchFormat)
{
int hresult = audioClientInterface.IsFormatSupported(shareMode, desiredFormat, out closestMatchFormat);
// S_OK is 0, S_FALSE = 1
if (hresult == 0)
{
// directly supported
return true;
}
if (hresult == 1)
{
return false;
}
else if (hresult == (int)AudioClientErrors.UnsupportedFormat)
{
return false;
}
else
{
Marshal.ThrowExceptionForHR(hresult);
}
// shouldn't get here
throw new NotSupportedException("Unknown hresult " + hresult.ToString());
}
开发者ID:androidhacker,项目名称:DotNetProjs,代码行数:33,代码来源:AudioClient.cs
示例17: IsFormatSupported
/// <summary>
/// Determines if the specified output format is supported in shared mode
/// </summary>
/// <param name="shareMode">Share Mode</param>
/// <param name="desiredFormat">Desired Format</param>
/// <param name="closestMatchFormat">Output The closest match format.</param>
/// <returns>True if the format is supported</returns>
public bool IsFormatSupported(AudioClientShareMode shareMode, WaveFormat desiredFormat, out WaveFormatExtensible closestMatchFormat)
{
IntPtr pointerToPtr = GetPointerToPointer(); // IntPtr.Zero; // Marshal.AllocHGlobal(Marshal.SizeOf<WaveFormatExtensible>());
closestMatchFormat = null;
var pDesiredFormat = desiredFormat.AsInterop();
int hresult = audioClientInterface.IsFormatSupported(shareMode, ref pDesiredFormat, pointerToPtr);
var closestMatchPtr = MarshalHelpers.PtrToStructure<IntPtr>(pointerToPtr);
if (closestMatchPtr != IntPtr.Zero)
{
closestMatchFormat = MarshalHelpers.PtrToStructure<WaveFormatExtensibleInterop>(closestMatchPtr);
Marshal.FreeCoTaskMem(closestMatchPtr);
}
Marshal.FreeHGlobal(pointerToPtr);
// S_OK is 0, S_FALSE = 1
if (hresult == 0)
{
// directly supported
return true;
}
if (hresult == 1)
{
return false;
}
if (hresult == (int)AudioClientErrors.UnsupportedFormat)
{
// Succeeded but the specified format is not supported in exclusive mode.
return shareMode != AudioClientShareMode.Exclusive;
}
Marshal.ThrowExceptionForHR(hresult);
// shouldn't get here
throw new NotSupportedException("Unknown hresult " + hresult);
}
开发者ID:KarimLUCCIN,项目名称:NAudio,代码行数:42,代码来源:AudioClient.cs
示例18: InitializeNative
/// <summary>
/// The Initialize method initializes the audio stream.
/// </summary>
public unsafe int InitializeNative(AudioClientShareMode shareMode, AudioClientStreamFlags streamFlags, long hnsBufferDuration, long hnsPeriodicity,
WaveFormat waveFormat, Guid audioSessionGuid)
{
var hWaveFormat = GCHandle.Alloc(waveFormat, GCHandleType.Pinned);
int result = -1;
result = InteropCalls.CallI(_basePtr, shareMode, streamFlags, hnsBufferDuration, hnsPeriodicity, hWaveFormat.AddrOfPinnedObject().ToPointer(), audioSessionGuid, ((void**)(*(void**)_basePtr))[3]);
hWaveFormat.Free();
return result;
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:12,代码来源:AudioClient.cs
示例19: CallI
internal static unsafe int CallI(void* _basePtr, AudioClientShareMode shareMode,
AudioClientStreamFlags streamFlags, long hnsBufferDuration, long hnsPeriodicity, void* p1,
Guid audioSessionGuid, void* p2)
{
throw new NotImplementedException();
}
开发者ID:hoangduit,项目名称:cscore,代码行数:6,代码来源:InteropCalls.cs
示例20: IsFormatSupportedNative
/// <summary>
/// The IsFormatSupportedInternal method indicates whether the audio endpoint device
/// supports a particular stream format.
/// </summary>
/// <returns>For exclusive mode, IsFormatSupportedInternal returns S_OK if the audio
/// endpoint device supports the caller-specified format, or it returns
/// AUDCLNT_E_UNSUPPORTED_FORMAT if the device does not support the format. The
/// ppClosestMatch parameter can be NULL. If it is not NULL, the method writes NULL to
/// *ppClosestMatch. For shared mode, if the audio engine supports the caller-specified
/// format, IsFormatSupportedInternal sets *ppClosestMatch to NULL and returns S_OK. If the
/// audio engine does not support the caller-specified format but does support a similar
/// format, the method retrieves the similar format through the ppClosestMatch parameter and
/// returns S_FALSE. If the audio engine does not support the caller-specified format or any
/// similar format, the method sets *ppClosestMatch to NULL and returns
/// AUDCLNT_E_UNSUPPORTED_FORMAT.</returns>
public unsafe int IsFormatSupportedNative(AudioClientShareMode shareMode, WaveFormat waveFormat, out WaveFormatExtensible closestMatch)
{
closestMatch = null;
var hClosestMatch = GCHandle.Alloc(closestMatch, GCHandleType.Pinned);
var hWaveFormat = GCHandle.Alloc(waveFormat, GCHandleType.Pinned);
IntPtr pclosestmatch = hClosestMatch.AddrOfPinnedObject();
var result = InteropCalls.CallI(_basePtr, shareMode, hWaveFormat.AddrOfPinnedObject().ToPointer(),
&pclosestmatch, ((void**)(*(void**)_basePtr))[7]);
hWaveFormat.Free();
hClosestMatch.Free();
return result;
}
开发者ID:CheViana,项目名称:AudioLab,代码行数:31,代码来源:AudioClient.cs
注:本文中的AudioClientShareMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论