ホーム › Media.MediaFoundation › MFBeginRegisterWorkQueueWithMMCSS
MFBeginRegisterWorkQueueWithMMCSS
関数作業キューをMMCSSタスクへ非同期で関連付け開始する。
シグネチャ
// MFPlat.dll
#include <windows.h>
HRESULT MFBeginRegisterWorkQueueWithMMCSS(
DWORD dwWorkQueueId,
LPCWSTR wszClass,
DWORD dwTaskId,
IMFAsyncCallback* pDoneCallback,
IUnknown* pDoneState
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dwWorkQueueId | DWORD | in | ワークキューの識別子。プライベートワークキューの場合、識別子は MFAllocateWorkQueue 関数によって返されます。プラットフォームワークキューについては、Work Queue Identifiers を参照してください。 |
| wszClass | LPCWSTR | in | MMCSS タスクの名前。詳細については、Multimedia Class Scheduler Service を参照してください。 |
| dwTaskId | DWORD | in | 一意のタスク識別子。新しいタスク識別子を取得するには、この値をゼロに設定します。 |
| pDoneCallback | IMFAsyncCallback* | in | コールバックオブジェクトの IMFAsyncCallback インターフェイスへのポインター。呼び出し元がこのインターフェイスを実装する必要があります。 |
| pDoneState | IUnknown* | in | 呼び出し元によって定義された状態オブジェクトの IUnknown インターフェイスへのポインター。このパラメーターは NULL でもかまいません。このオブジェクトを使用して状態情報を保持できます。コールバックが呼び出されると、オブジェクトが呼び出し元に返されます。 |
戻り値の型: HRESULT
公式ドキュメント
ワークキューを Multimedia Class Scheduler Service (MMCSS) タスクに関連付けます。(MFBeginRegisterWorkQueueWithMMCSS)
戻り値
この関数は HRESULT を返します。指定可能な値には、次の表に示すものが含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| 関数が成功しました。 |
解説(Remarks)
この関数は非同期です。操作が完了すると、コールバックオブジェクトの IMFAsyncCallback::Invoke メソッドが呼び出されます。その時点で、アプリケーションは MFEndRegisterWorkQueueWithMMCSS を呼び出して非同期要求を完了する必要があります。
MMCSS タスクからワークキューの登録を解除するには、MFBeginUnregisterWorkQueueWithMMCSS を呼び出します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MFPlat.dll
#include <windows.h>
HRESULT MFBeginRegisterWorkQueueWithMMCSS(
DWORD dwWorkQueueId,
LPCWSTR wszClass,
DWORD dwTaskId,
IMFAsyncCallback* pDoneCallback,
IUnknown* pDoneState
);[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFBeginRegisterWorkQueueWithMMCSS(
uint dwWorkQueueId, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string wszClass, // LPCWSTR
uint dwTaskId, // DWORD
IntPtr pDoneCallback, // IMFAsyncCallback*
IntPtr pDoneState // IUnknown*
);<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFBeginRegisterWorkQueueWithMMCSS(
dwWorkQueueId As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> wszClass As String, ' LPCWSTR
dwTaskId As UInteger, ' DWORD
pDoneCallback As IntPtr, ' IMFAsyncCallback*
pDoneState As IntPtr ' IUnknown*
) As Integer
End Function' dwWorkQueueId : DWORD
' wszClass : LPCWSTR
' dwTaskId : DWORD
' pDoneCallback : IMFAsyncCallback*
' pDoneState : IUnknown*
Declare PtrSafe Function MFBeginRegisterWorkQueueWithMMCSS Lib "mfplat" ( _
ByVal dwWorkQueueId As Long, _
ByVal wszClass As LongPtr, _
ByVal dwTaskId As Long, _
ByVal pDoneCallback As LongPtr, _
ByVal pDoneState As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MFBeginRegisterWorkQueueWithMMCSS = ctypes.windll.mfplat.MFBeginRegisterWorkQueueWithMMCSS
MFBeginRegisterWorkQueueWithMMCSS.restype = ctypes.c_int
MFBeginRegisterWorkQueueWithMMCSS.argtypes = [
wintypes.DWORD, # dwWorkQueueId : DWORD
wintypes.LPCWSTR, # wszClass : LPCWSTR
wintypes.DWORD, # dwTaskId : DWORD
ctypes.c_void_p, # pDoneCallback : IMFAsyncCallback*
ctypes.c_void_p, # pDoneState : IUnknown*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MFPlat.dll')
MFBeginRegisterWorkQueueWithMMCSS = Fiddle::Function.new(
lib['MFBeginRegisterWorkQueueWithMMCSS'],
[
-Fiddle::TYPE_INT, # dwWorkQueueId : DWORD
Fiddle::TYPE_VOIDP, # wszClass : LPCWSTR
-Fiddle::TYPE_INT, # dwTaskId : DWORD
Fiddle::TYPE_VOIDP, # pDoneCallback : IMFAsyncCallback*
Fiddle::TYPE_VOIDP, # pDoneState : IUnknown*
],
Fiddle::TYPE_INT)#[link(name = "mfplat")]
extern "system" {
fn MFBeginRegisterWorkQueueWithMMCSS(
dwWorkQueueId: u32, // DWORD
wszClass: *const u16, // LPCWSTR
dwTaskId: u32, // DWORD
pDoneCallback: *mut core::ffi::c_void, // IMFAsyncCallback*
pDoneState: *mut core::ffi::c_void // IUnknown*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MFPlat.dll")]
public static extern int MFBeginRegisterWorkQueueWithMMCSS(uint dwWorkQueueId, [MarshalAs(UnmanagedType.LPWStr)] string wszClass, uint dwTaskId, IntPtr pDoneCallback, IntPtr pDoneState);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MFPlat_MFBeginRegisterWorkQueueWithMMCSS' -Namespace Win32 -PassThru
# $api::MFBeginRegisterWorkQueueWithMMCSS(dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState)#uselib "MFPlat.dll"
#func global MFBeginRegisterWorkQueueWithMMCSS "MFBeginRegisterWorkQueueWithMMCSS" sptr, sptr, sptr, sptr, sptr
; MFBeginRegisterWorkQueueWithMMCSS dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState ; 戻り値は stat
; dwWorkQueueId : DWORD -> "sptr"
; wszClass : LPCWSTR -> "sptr"
; dwTaskId : DWORD -> "sptr"
; pDoneCallback : IMFAsyncCallback* -> "sptr"
; pDoneState : IUnknown* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MFPlat.dll"
#cfunc global MFBeginRegisterWorkQueueWithMMCSS "MFBeginRegisterWorkQueueWithMMCSS" int, wstr, int, sptr, sptr
; res = MFBeginRegisterWorkQueueWithMMCSS(dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState)
; dwWorkQueueId : DWORD -> "int"
; wszClass : LPCWSTR -> "wstr"
; dwTaskId : DWORD -> "int"
; pDoneCallback : IMFAsyncCallback* -> "sptr"
; pDoneState : IUnknown* -> "sptr"; HRESULT MFBeginRegisterWorkQueueWithMMCSS(DWORD dwWorkQueueId, LPCWSTR wszClass, DWORD dwTaskId, IMFAsyncCallback* pDoneCallback, IUnknown* pDoneState)
#uselib "MFPlat.dll"
#cfunc global MFBeginRegisterWorkQueueWithMMCSS "MFBeginRegisterWorkQueueWithMMCSS" int, wstr, int, intptr, intptr
; res = MFBeginRegisterWorkQueueWithMMCSS(dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState)
; dwWorkQueueId : DWORD -> "int"
; wszClass : LPCWSTR -> "wstr"
; dwTaskId : DWORD -> "int"
; pDoneCallback : IMFAsyncCallback* -> "intptr"
; pDoneState : IUnknown* -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mfplat = windows.NewLazySystemDLL("MFPlat.dll")
procMFBeginRegisterWorkQueueWithMMCSS = mfplat.NewProc("MFBeginRegisterWorkQueueWithMMCSS")
)
// dwWorkQueueId (DWORD), wszClass (LPCWSTR), dwTaskId (DWORD), pDoneCallback (IMFAsyncCallback*), pDoneState (IUnknown*)
r1, _, err := procMFBeginRegisterWorkQueueWithMMCSS.Call(
uintptr(dwWorkQueueId),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wszClass))),
uintptr(dwTaskId),
uintptr(pDoneCallback),
uintptr(pDoneState),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MFBeginRegisterWorkQueueWithMMCSS(
dwWorkQueueId: DWORD; // DWORD
wszClass: PWideChar; // LPCWSTR
dwTaskId: DWORD; // DWORD
pDoneCallback: Pointer; // IMFAsyncCallback*
pDoneState: Pointer // IUnknown*
): Integer; stdcall;
external 'MFPlat.dll' name 'MFBeginRegisterWorkQueueWithMMCSS';result := DllCall("MFPlat\MFBeginRegisterWorkQueueWithMMCSS"
, "UInt", dwWorkQueueId ; DWORD
, "WStr", wszClass ; LPCWSTR
, "UInt", dwTaskId ; DWORD
, "Ptr", pDoneCallback ; IMFAsyncCallback*
, "Ptr", pDoneState ; IUnknown*
, "Int") ; return: HRESULT●MFBeginRegisterWorkQueueWithMMCSS(dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState) = DLL("MFPlat.dll", "int MFBeginRegisterWorkQueueWithMMCSS(dword, char*, dword, void*, void*)")
# 呼び出し: MFBeginRegisterWorkQueueWithMMCSS(dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState)
# dwWorkQueueId : DWORD -> "dword"
# wszClass : LPCWSTR -> "char*"
# dwTaskId : DWORD -> "dword"
# pDoneCallback : IMFAsyncCallback* -> "void*"
# pDoneState : IUnknown* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mfplat" fn MFBeginRegisterWorkQueueWithMMCSS(
dwWorkQueueId: u32, // DWORD
wszClass: [*c]const u16, // LPCWSTR
dwTaskId: u32, // DWORD
pDoneCallback: ?*anyopaque, // IMFAsyncCallback*
pDoneState: ?*anyopaque // IUnknown*
) callconv(std.os.windows.WINAPI) i32;proc MFBeginRegisterWorkQueueWithMMCSS(
dwWorkQueueId: uint32, # DWORD
wszClass: WideCString, # LPCWSTR
dwTaskId: uint32, # DWORD
pDoneCallback: pointer, # IMFAsyncCallback*
pDoneState: pointer # IUnknown*
): int32 {.importc: "MFBeginRegisterWorkQueueWithMMCSS", stdcall, dynlib: "MFPlat.dll".}pragma(lib, "mfplat");
extern(Windows)
int MFBeginRegisterWorkQueueWithMMCSS(
uint dwWorkQueueId, // DWORD
const(wchar)* wszClass, // LPCWSTR
uint dwTaskId, // DWORD
void* pDoneCallback, // IMFAsyncCallback*
void* pDoneState // IUnknown*
);ccall((:MFBeginRegisterWorkQueueWithMMCSS, "MFPlat.dll"), stdcall, Int32,
(UInt32, Cwstring, UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState)
# dwWorkQueueId : DWORD -> UInt32
# wszClass : LPCWSTR -> Cwstring
# dwTaskId : DWORD -> UInt32
# pDoneCallback : IMFAsyncCallback* -> Ptr{Cvoid}
# pDoneState : IUnknown* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MFBeginRegisterWorkQueueWithMMCSS(
uint32_t dwWorkQueueId,
const uint16_t* wszClass,
uint32_t dwTaskId,
void* pDoneCallback,
void* pDoneState);
]]
local mfplat = ffi.load("mfplat")
-- mfplat.MFBeginRegisterWorkQueueWithMMCSS(dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState)
-- dwWorkQueueId : DWORD
-- wszClass : LPCWSTR
-- dwTaskId : DWORD
-- pDoneCallback : IMFAsyncCallback*
-- pDoneState : IUnknown*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MFPlat.dll');
const MFBeginRegisterWorkQueueWithMMCSS = lib.func('__stdcall', 'MFBeginRegisterWorkQueueWithMMCSS', 'int32_t', ['uint32_t', 'str16', 'uint32_t', 'void *', 'void *']);
// MFBeginRegisterWorkQueueWithMMCSS(dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState)
// dwWorkQueueId : DWORD -> 'uint32_t'
// wszClass : LPCWSTR -> 'str16'
// dwTaskId : DWORD -> 'uint32_t'
// pDoneCallback : IMFAsyncCallback* -> 'void *'
// pDoneState : IUnknown* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MFPlat.dll", {
MFBeginRegisterWorkQueueWithMMCSS: { parameters: ["u32", "buffer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.MFBeginRegisterWorkQueueWithMMCSS(dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState)
// dwWorkQueueId : DWORD -> "u32"
// wszClass : LPCWSTR -> "buffer"
// dwTaskId : DWORD -> "u32"
// pDoneCallback : IMFAsyncCallback* -> "pointer"
// pDoneState : IUnknown* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MFBeginRegisterWorkQueueWithMMCSS(
uint32_t dwWorkQueueId,
const uint16_t* wszClass,
uint32_t dwTaskId,
void* pDoneCallback,
void* pDoneState);
C, "MFPlat.dll");
// $ffi->MFBeginRegisterWorkQueueWithMMCSS(dwWorkQueueId, wszClass, dwTaskId, pDoneCallback, pDoneState);
// dwWorkQueueId : DWORD
// wszClass : LPCWSTR
// dwTaskId : DWORD
// pDoneCallback : IMFAsyncCallback*
// pDoneState : IUnknown*
// 構造体/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 Mfplat extends StdCallLibrary {
Mfplat INSTANCE = Native.load("mfplat", Mfplat.class);
int MFBeginRegisterWorkQueueWithMMCSS(
int dwWorkQueueId, // DWORD
WString wszClass, // LPCWSTR
int dwTaskId, // DWORD
Pointer pDoneCallback, // IMFAsyncCallback*
Pointer pDoneState // IUnknown*
);
}@[Link("mfplat")]
lib LibMFPlat
fun MFBeginRegisterWorkQueueWithMMCSS = MFBeginRegisterWorkQueueWithMMCSS(
dwWorkQueueId : UInt32, # DWORD
wszClass : UInt16*, # LPCWSTR
dwTaskId : UInt32, # DWORD
pDoneCallback : Void*, # IMFAsyncCallback*
pDoneState : Void* # IUnknown*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MFBeginRegisterWorkQueueWithMMCSSNative = Int32 Function(Uint32, Pointer<Utf16>, Uint32, Pointer<Void>, Pointer<Void>);
typedef MFBeginRegisterWorkQueueWithMMCSSDart = int Function(int, Pointer<Utf16>, int, Pointer<Void>, Pointer<Void>);
final MFBeginRegisterWorkQueueWithMMCSS = DynamicLibrary.open('MFPlat.dll')
.lookupFunction<MFBeginRegisterWorkQueueWithMMCSSNative, MFBeginRegisterWorkQueueWithMMCSSDart>('MFBeginRegisterWorkQueueWithMMCSS');
// dwWorkQueueId : DWORD -> Uint32
// wszClass : LPCWSTR -> Pointer<Utf16>
// dwTaskId : DWORD -> Uint32
// pDoneCallback : IMFAsyncCallback* -> Pointer<Void>
// pDoneState : IUnknown* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MFBeginRegisterWorkQueueWithMMCSS(
dwWorkQueueId: DWORD; // DWORD
wszClass: PWideChar; // LPCWSTR
dwTaskId: DWORD; // DWORD
pDoneCallback: Pointer; // IMFAsyncCallback*
pDoneState: Pointer // IUnknown*
): Integer; stdcall;
external 'MFPlat.dll' name 'MFBeginRegisterWorkQueueWithMMCSS';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MFBeginRegisterWorkQueueWithMMCSS"
c_MFBeginRegisterWorkQueueWithMMCSS :: Word32 -> CWString -> Word32 -> Ptr () -> Ptr () -> IO Int32
-- dwWorkQueueId : DWORD -> Word32
-- wszClass : LPCWSTR -> CWString
-- dwTaskId : DWORD -> Word32
-- pDoneCallback : IMFAsyncCallback* -> Ptr ()
-- pDoneState : IUnknown* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mfbeginregisterworkqueuewithmmcss =
foreign "MFBeginRegisterWorkQueueWithMMCSS"
(uint32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* dwWorkQueueId : DWORD -> uint32_t *)
(* wszClass : LPCWSTR -> (ptr uint16_t) *)
(* dwTaskId : DWORD -> uint32_t *)
(* pDoneCallback : IMFAsyncCallback* -> (ptr void) *)
(* pDoneState : IUnknown* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mfplat (t "MFPlat.dll"))
(cffi:use-foreign-library mfplat)
(cffi:defcfun ("MFBeginRegisterWorkQueueWithMMCSS" mfbegin-register-work-queue-with-mmcss :convention :stdcall) :int32
(dw-work-queue-id :uint32) ; DWORD
(wsz-class (:string :encoding :utf-16le)) ; LPCWSTR
(dw-task-id :uint32) ; DWORD
(p-done-callback :pointer) ; IMFAsyncCallback*
(p-done-state :pointer)) ; IUnknown*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MFBeginRegisterWorkQueueWithMMCSS = Win32::API::More->new('MFPlat',
'int MFBeginRegisterWorkQueueWithMMCSS(DWORD dwWorkQueueId, LPCWSTR wszClass, DWORD dwTaskId, LPVOID pDoneCallback, LPVOID pDoneState)');
# my $ret = $MFBeginRegisterWorkQueueWithMMCSS->Call($dwWorkQueueId, $wszClass, $dwTaskId, $pDoneCallback, $pDoneState);
# dwWorkQueueId : DWORD -> DWORD
# wszClass : LPCWSTR -> LPCWSTR
# dwTaskId : DWORD -> DWORD
# pDoneCallback : IMFAsyncCallback* -> LPVOID
# pDoneState : IUnknown* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f MFBeginRegisterWorkQueueWithMMCSSEx — 優先度付きで作業キューをMMCSSへ非同期登録開始する。