ホーム › Media.Audio › CreateRenderAudioStateMonitorForCategoryAndDeviceRole
CreateRenderAudioStateMonitorForCategoryAndDeviceRole
関数カテゴリとデバイスロール指定でレンダリング状態監視を生成する。
シグネチャ
// Windows.Media.MediaControl.dll
#include <windows.h>
HRESULT CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
AUDIO_STREAM_CATEGORY category,
ERole role,
IAudioStateMonitor** audioStateMonitor
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| category | AUDIO_STREAM_CATEGORY | in | 監視対象とするオーディオストリームのカテゴリ(AUDIO_STREAM_CATEGORY列挙値)。 |
| role | ERole | in | 監視対象とするデバイスの役割(ERole列挙値。eConsole、eMultimedia、eCommunications)。 |
| audioStateMonitor | IAudioStateMonitor** | out | 作成したレンダリング用オーディオ状態モニタIAudioStateMonitorを受け取るポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// Windows.Media.MediaControl.dll
#include <windows.h>
HRESULT CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
AUDIO_STREAM_CATEGORY category,
ERole role,
IAudioStateMonitor** audioStateMonitor
);[DllImport("Windows.Media.MediaControl.dll", ExactSpelling = true)]
static extern int CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
int category, // AUDIO_STREAM_CATEGORY
int role, // ERole
IntPtr audioStateMonitor // IAudioStateMonitor** out
);<DllImport("Windows.Media.MediaControl.dll", ExactSpelling:=True)>
Public Shared Function CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
category As Integer, ' AUDIO_STREAM_CATEGORY
role As Integer, ' ERole
audioStateMonitor As IntPtr ' IAudioStateMonitor** out
) As Integer
End Function' category : AUDIO_STREAM_CATEGORY
' role : ERole
' audioStateMonitor : IAudioStateMonitor** out
Declare PtrSafe Function CreateRenderAudioStateMonitorForCategoryAndDeviceRole Lib "windows.media.mediacontrol" ( _
ByVal category As Long, _
ByVal role As Long, _
ByVal audioStateMonitor As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateRenderAudioStateMonitorForCategoryAndDeviceRole = ctypes.windll.LoadLibrary("Windows.Media.MediaControl.dll").CreateRenderAudioStateMonitorForCategoryAndDeviceRole
CreateRenderAudioStateMonitorForCategoryAndDeviceRole.restype = ctypes.c_int
CreateRenderAudioStateMonitorForCategoryAndDeviceRole.argtypes = [
ctypes.c_int, # category : AUDIO_STREAM_CATEGORY
ctypes.c_int, # role : ERole
ctypes.c_void_p, # audioStateMonitor : IAudioStateMonitor** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('Windows.Media.MediaControl.dll')
CreateRenderAudioStateMonitorForCategoryAndDeviceRole = Fiddle::Function.new(
lib['CreateRenderAudioStateMonitorForCategoryAndDeviceRole'],
[
Fiddle::TYPE_INT, # category : AUDIO_STREAM_CATEGORY
Fiddle::TYPE_INT, # role : ERole
Fiddle::TYPE_VOIDP, # audioStateMonitor : IAudioStateMonitor** out
],
Fiddle::TYPE_INT)#[link(name = "windows.media.mediacontrol")]
extern "system" {
fn CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
category: i32, // AUDIO_STREAM_CATEGORY
role: i32, // ERole
audioStateMonitor: *mut *mut core::ffi::c_void // IAudioStateMonitor** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("Windows.Media.MediaControl.dll")]
public static extern int CreateRenderAudioStateMonitorForCategoryAndDeviceRole(int category, int role, IntPtr audioStateMonitor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Windows.Media.MediaControl_CreateRenderAudioStateMonitorForCategoryAndDeviceRole' -Namespace Win32 -PassThru
# $api::CreateRenderAudioStateMonitorForCategoryAndDeviceRole(category, role, audioStateMonitor)#uselib "Windows.Media.MediaControl.dll"
#func global CreateRenderAudioStateMonitorForCategoryAndDeviceRole "CreateRenderAudioStateMonitorForCategoryAndDeviceRole" sptr, sptr, sptr
; CreateRenderAudioStateMonitorForCategoryAndDeviceRole category, role, audioStateMonitor ; 戻り値は stat
; category : AUDIO_STREAM_CATEGORY -> "sptr"
; role : ERole -> "sptr"
; audioStateMonitor : IAudioStateMonitor** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "Windows.Media.MediaControl.dll"
#cfunc global CreateRenderAudioStateMonitorForCategoryAndDeviceRole "CreateRenderAudioStateMonitorForCategoryAndDeviceRole" int, int, sptr
; res = CreateRenderAudioStateMonitorForCategoryAndDeviceRole(category, role, audioStateMonitor)
; category : AUDIO_STREAM_CATEGORY -> "int"
; role : ERole -> "int"
; audioStateMonitor : IAudioStateMonitor** out -> "sptr"; HRESULT CreateRenderAudioStateMonitorForCategoryAndDeviceRole(AUDIO_STREAM_CATEGORY category, ERole role, IAudioStateMonitor** audioStateMonitor)
#uselib "Windows.Media.MediaControl.dll"
#cfunc global CreateRenderAudioStateMonitorForCategoryAndDeviceRole "CreateRenderAudioStateMonitorForCategoryAndDeviceRole" int, int, intptr
; res = CreateRenderAudioStateMonitorForCategoryAndDeviceRole(category, role, audioStateMonitor)
; category : AUDIO_STREAM_CATEGORY -> "int"
; role : ERole -> "int"
; audioStateMonitor : IAudioStateMonitor** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
windows_media_mediacontrol = windows.NewLazySystemDLL("Windows.Media.MediaControl.dll")
procCreateRenderAudioStateMonitorForCategoryAndDeviceRole = windows_media_mediacontrol.NewProc("CreateRenderAudioStateMonitorForCategoryAndDeviceRole")
)
// category (AUDIO_STREAM_CATEGORY), role (ERole), audioStateMonitor (IAudioStateMonitor** out)
r1, _, err := procCreateRenderAudioStateMonitorForCategoryAndDeviceRole.Call(
uintptr(category),
uintptr(role),
uintptr(audioStateMonitor),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
category: Integer; // AUDIO_STREAM_CATEGORY
role: Integer; // ERole
audioStateMonitor: Pointer // IAudioStateMonitor** out
): Integer; stdcall;
external 'Windows.Media.MediaControl.dll' name 'CreateRenderAudioStateMonitorForCategoryAndDeviceRole';result := DllCall("Windows.Media.MediaControl\CreateRenderAudioStateMonitorForCategoryAndDeviceRole"
, "Int", category ; AUDIO_STREAM_CATEGORY
, "Int", role ; ERole
, "Ptr", audioStateMonitor ; IAudioStateMonitor** out
, "Int") ; return: HRESULT●CreateRenderAudioStateMonitorForCategoryAndDeviceRole(category, role, audioStateMonitor) = DLL("Windows.Media.MediaControl.dll", "int CreateRenderAudioStateMonitorForCategoryAndDeviceRole(int, int, void*)")
# 呼び出し: CreateRenderAudioStateMonitorForCategoryAndDeviceRole(category, role, audioStateMonitor)
# category : AUDIO_STREAM_CATEGORY -> "int"
# role : ERole -> "int"
# audioStateMonitor : IAudioStateMonitor** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "windows.media.mediacontrol" fn CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
category: i32, // AUDIO_STREAM_CATEGORY
role: i32, // ERole
audioStateMonitor: ?*anyopaque // IAudioStateMonitor** out
) callconv(std.os.windows.WINAPI) i32;proc CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
category: int32, # AUDIO_STREAM_CATEGORY
role: int32, # ERole
audioStateMonitor: pointer # IAudioStateMonitor** out
): int32 {.importc: "CreateRenderAudioStateMonitorForCategoryAndDeviceRole", stdcall, dynlib: "Windows.Media.MediaControl.dll".}pragma(lib, "windows.media.mediacontrol");
extern(Windows)
int CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
int category, // AUDIO_STREAM_CATEGORY
int role, // ERole
void* audioStateMonitor // IAudioStateMonitor** out
);ccall((:CreateRenderAudioStateMonitorForCategoryAndDeviceRole, "Windows.Media.MediaControl.dll"), stdcall, Int32,
(Int32, Int32, Ptr{Cvoid}),
category, role, audioStateMonitor)
# category : AUDIO_STREAM_CATEGORY -> Int32
# role : ERole -> Int32
# audioStateMonitor : IAudioStateMonitor** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
int32_t category,
int32_t role,
void* audioStateMonitor);
]]
local windows.media.mediacontrol = ffi.load("windows.media.mediacontrol")
-- windows.media.mediacontrol.CreateRenderAudioStateMonitorForCategoryAndDeviceRole(category, role, audioStateMonitor)
-- category : AUDIO_STREAM_CATEGORY
-- role : ERole
-- audioStateMonitor : IAudioStateMonitor** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('Windows.Media.MediaControl.dll');
const CreateRenderAudioStateMonitorForCategoryAndDeviceRole = lib.func('__stdcall', 'CreateRenderAudioStateMonitorForCategoryAndDeviceRole', 'int32_t', ['int32_t', 'int32_t', 'void *']);
// CreateRenderAudioStateMonitorForCategoryAndDeviceRole(category, role, audioStateMonitor)
// category : AUDIO_STREAM_CATEGORY -> 'int32_t'
// role : ERole -> 'int32_t'
// audioStateMonitor : IAudioStateMonitor** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("Windows.Media.MediaControl.dll", {
CreateRenderAudioStateMonitorForCategoryAndDeviceRole: { parameters: ["i32", "i32", "pointer"], result: "i32" },
});
// lib.symbols.CreateRenderAudioStateMonitorForCategoryAndDeviceRole(category, role, audioStateMonitor)
// category : AUDIO_STREAM_CATEGORY -> "i32"
// role : ERole -> "i32"
// audioStateMonitor : IAudioStateMonitor** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
int32_t category,
int32_t role,
void* audioStateMonitor);
C, "Windows.Media.MediaControl.dll");
// $ffi->CreateRenderAudioStateMonitorForCategoryAndDeviceRole(category, role, audioStateMonitor);
// category : AUDIO_STREAM_CATEGORY
// role : ERole
// audioStateMonitor : IAudioStateMonitor** out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Windows.media.mediacontrol extends StdCallLibrary {
Windows.media.mediacontrol INSTANCE = Native.load("windows.media.mediacontrol", Windows.media.mediacontrol.class);
int CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
int category, // AUDIO_STREAM_CATEGORY
int role, // ERole
Pointer audioStateMonitor // IAudioStateMonitor** out
);
}@[Link("windows.media.mediacontrol")]
lib LibWindows.Media.MediaControl
fun CreateRenderAudioStateMonitorForCategoryAndDeviceRole = CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
category : Int32, # AUDIO_STREAM_CATEGORY
role : Int32, # ERole
audioStateMonitor : Void* # IAudioStateMonitor** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CreateRenderAudioStateMonitorForCategoryAndDeviceRoleNative = Int32 Function(Int32, Int32, Pointer<Void>);
typedef CreateRenderAudioStateMonitorForCategoryAndDeviceRoleDart = int Function(int, int, Pointer<Void>);
final CreateRenderAudioStateMonitorForCategoryAndDeviceRole = DynamicLibrary.open('Windows.Media.MediaControl.dll')
.lookupFunction<CreateRenderAudioStateMonitorForCategoryAndDeviceRoleNative, CreateRenderAudioStateMonitorForCategoryAndDeviceRoleDart>('CreateRenderAudioStateMonitorForCategoryAndDeviceRole');
// category : AUDIO_STREAM_CATEGORY -> Int32
// role : ERole -> Int32
// audioStateMonitor : IAudioStateMonitor** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CreateRenderAudioStateMonitorForCategoryAndDeviceRole(
category: Integer; // AUDIO_STREAM_CATEGORY
role: Integer; // ERole
audioStateMonitor: Pointer // IAudioStateMonitor** out
): Integer; stdcall;
external 'Windows.Media.MediaControl.dll' name 'CreateRenderAudioStateMonitorForCategoryAndDeviceRole';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CreateRenderAudioStateMonitorForCategoryAndDeviceRole"
c_CreateRenderAudioStateMonitorForCategoryAndDeviceRole :: Int32 -> Int32 -> Ptr () -> IO Int32
-- category : AUDIO_STREAM_CATEGORY -> Int32
-- role : ERole -> Int32
-- audioStateMonitor : IAudioStateMonitor** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let createrenderaudiostatemonitorforcategoryanddevicerole =
foreign "CreateRenderAudioStateMonitorForCategoryAndDeviceRole"
(int32_t @-> int32_t @-> (ptr void) @-> returning int32_t)
(* category : AUDIO_STREAM_CATEGORY -> int32_t *)
(* role : ERole -> int32_t *)
(* audioStateMonitor : IAudioStateMonitor** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library windows.media.mediacontrol (t "Windows.Media.MediaControl.dll"))
(cffi:use-foreign-library windows.media.mediacontrol)
(cffi:defcfun ("CreateRenderAudioStateMonitorForCategoryAndDeviceRole" create-render-audio-state-monitor-for-category-and-device-role :convention :stdcall) :int32
(category :int32) ; AUDIO_STREAM_CATEGORY
(role :int32) ; ERole
(audio-state-monitor :pointer)) ; IAudioStateMonitor** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CreateRenderAudioStateMonitorForCategoryAndDeviceRole = Win32::API::More->new('Windows.Media.MediaControl',
'int CreateRenderAudioStateMonitorForCategoryAndDeviceRole(int category, int role, LPVOID audioStateMonitor)');
# my $ret = $CreateRenderAudioStateMonitorForCategoryAndDeviceRole->Call($category, $role, $audioStateMonitor);
# category : AUDIO_STREAM_CATEGORY -> int
# role : ERole -> int
# audioStateMonitor : IAudioStateMonitor** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。