diff --git a/lib/native/windows-64/jnwincoreaudio.dll b/lib/native/windows-64/jnwincoreaudio.dll new file mode 100644 index 0000000000000000000000000000000000000000..b3a5415e24b162ad206d27cffd7dc7a53bd1f19d Binary files /dev/null and b/lib/native/windows-64/jnwincoreaudio.dll differ diff --git a/src/native/build.xml b/src/native/build.xml index b257e950c5386fce0496efa18eb719aceced74f8..71c8045093ff7b58dbd3a9474c21ab1106bbd2a5 100644 --- a/src/native/build.xml +++ b/src/native/build.xml @@ -668,10 +668,36 @@ </cc> </target> - <!-- compile jncoreaudio library for Mac OS X (32-bit/64-bit) --> - <target name="coreaudio" description="Build jncoreaudio shared library for Mac OS X" if="is.running.macos" + <!-- compile jnwincoreaudio library for Windows Vista, 7 and 8 (32-bit/64-bit) + --> + <target + name="win-coreaudio" + description="Build jnwincoreaudio shared library for Windows Vista, 7 and 8" + if="is.running.windows" + depends="init-native"> + <cc outtype="shared" name="g++" + outfile="${native_install_dir}/jnwincoreaudio" objdir="${obj}"> + + <compilerarg value="-Wall" /> + <compilerarg value="-O2" /> + <compilerarg value="-I${system.JAVA_HOME}/include" /> + <compilerarg value="-I${system.JAVA_HOME}/include/win32" /> + + <linkerarg value="-ojnwincoreaudio.dll" /> + <libset libs="ole32" /> + + <fileset dir="${src}/native/windows/coreaudio/lib" includes="*.c" /> + <fileset dir="${src}/native/windows/coreaudio/jni" includes="*.c" /> + </cc> + + <delete dir="${obj}" failonerror="false" /> + <delete file="${native_install_dir}/history.xml" failonerror="false" /> + </target> + + <!-- compile jnmaccoreaudio library for Mac OS X (32-bit/64-bit) --> + <target name="mac-coreaudio" description="Build jnmaccoreaudio shared library for Mac OS X" if="is.running.macos" depends="init-native"> - <cc outtype="shared" name="gcc" outfile="${native_install_dir}/jncoreaudio" objdir="${obj}"> + <cc outtype="shared" name="gcc" outfile="${native_install_dir}/jnmaccoreaudio" objdir="${obj}"> <compilerarg value="-Wall" /> <compilerarg value="-O2" /> <compilerarg value="-arch" /> @@ -682,7 +708,7 @@ /> <linkerarg value="-o" location="end" /> - <linkerarg value="libjncoreaudio.jnilib" location="end" /> + <linkerarg value="libjnmaccoreaudio.jnilib" location="end" /> <linkerarg value="-arch" /> <linkerarg value="x86_64" /> <linkerarg value="-arch" /> @@ -799,7 +825,8 @@ <echo message="'ant directshow (Windows only)' to compile jdirectshow shared library" /> <echo message="'ant aegeturleventhandler (Mac OS X only)' to compile AEGetURLEventHandler shared library" /> <echo message="'ant sparkle (Mac OS X only)' to compile sparkle shared library" /> - <echo message="'ant coreaudio (Mac OS X only)' to compile jcoreaudio shared library" /> + <echo message="'ant win-coreaudio (Windows Vista, 7 and 8 only)' to compile jnwincoreaudio shared library" /> + <echo message="'ant mac-coreaudio (Mac OS X only)' to compile jnmaccoreaudio shared library" /> <echo message="'ant quicktime (Mac OS X only)' to compile jquicktime shared library" /> <echo message="" /> <echo message="Options:" /> diff --git a/src/native/macosx/coreaudio/jni/org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice.c b/src/native/macosx/coreaudio/jni/org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice.c index d66c9aa4e2a39571d32c2dfaf358e691cb97c348..460bb397c4ed664d18f06d0c48a76d4fffa2a474 100644 --- a/src/native/macosx/coreaudio/jni/org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice.c +++ b/src/native/macosx/coreaudio/jni/org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice.c @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -#include "org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice.h" +#include "org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice.h" #include "../lib/device.h" @@ -22,7 +22,7 @@ static jbyteArray getStrBytes(JNIEnv *env, const char *str); // Implementation JNIEXPORT jbyteArray JNICALL -Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_getDeviceNameBytes +Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_getDeviceNameBytes (JNIEnv *env, jclass clazz, jstring deviceUID) { const char * deviceUIDPtr = (*env)->GetStringUTFChars(env, deviceUID, 0); @@ -36,7 +36,7 @@ Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_getDeviceNameBytes } JNIEXPORT jint JNICALL -Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_setInputDeviceVolume +Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_setInputDeviceVolume (JNIEnv *env, jclass clazz, jstring deviceUID, jfloat volume) { const char * deviceUIDPtr = (*env)->GetStringUTFChars(env, deviceUID, 0); @@ -48,7 +48,7 @@ Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_setInputDeviceVolume } JNIEXPORT jint JNICALL -Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_setOutputDeviceVolume +Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_setOutputDeviceVolume (JNIEnv *env, jclass clazz, jstring deviceUID, jfloat volume) { const char * deviceUIDPtr = (*env)->GetStringUTFChars(env, deviceUID, 0); @@ -60,7 +60,7 @@ Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_setOutputDeviceVolume } JNIEXPORT jfloat JNICALL -Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_getInputDeviceVolume +Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_getInputDeviceVolume (JNIEnv *env, jclass clazz, jstring deviceUID) { const char * deviceUIDPtr = (*env)->GetStringUTFChars(env, deviceUID, 0); @@ -72,7 +72,7 @@ Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_getInputDeviceVolume } JNIEXPORT jfloat JNICALL -Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_getOutputDeviceVolume +Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_getOutputDeviceVolume (JNIEnv *env, jclass clazz, jstring deviceUID) { const char * deviceUIDPtr = (*env)->GetStringUTFChars(env, deviceUID, 0); diff --git a/src/native/macosx/coreaudio/jni/org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice.h b/src/native/macosx/coreaudio/jni/org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice.h index 5e7e83bba31f51f9a941537892dd996df578e701..06ff03ca89db95c7b81dc2ea5a1dcf75a9ec07be 100644 --- a/src/native/macosx/coreaudio/jni/org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice.h +++ b/src/native/macosx/coreaudio/jni/org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice.h @@ -7,51 +7,51 @@ /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> -/* Header for class org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice */ +/* Header for class org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice */ -#ifndef _Included_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice -#define _Included_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice +#ifndef _Included_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice +#define _Included_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice #ifdef __cplusplus extern "C" { #endif /* - * Class: org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice + * Class: org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice * Method: getDeviceNameBytes * Signature: (Ljava/lang/String;)[B */ -JNIEXPORT jbyteArray JNICALL Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_getDeviceNameBytes +JNIEXPORT jbyteArray JNICALL Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_getDeviceNameBytes (JNIEnv *, jclass, jstring); /* - * Class: org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice + * Class: org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice * Method: setInputDeviceVolume * Signature: (Ljava/lang/String;F)I */ -JNIEXPORT jint JNICALL Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_setInputDeviceVolume +JNIEXPORT jint JNICALL Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_setInputDeviceVolume (JNIEnv *, jclass, jstring, jfloat); /* - * Class: org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice + * Class: org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice * Method: setOutputDeviceVolume * Signature: (Ljava/lang/String;F)I */ -JNIEXPORT jint JNICALL Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_setOutputDeviceVolume +JNIEXPORT jint JNICALL Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_setOutputDeviceVolume (JNIEnv *, jclass, jstring, jfloat); /* - * Class: org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice + * Class: org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice * Method: getInputDeviceVolume * Signature: (Ljava/lang/String;)F */ -JNIEXPORT jfloat JNICALL Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_getInputDeviceVolume +JNIEXPORT jfloat JNICALL Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_getInputDeviceVolume (JNIEnv *, jclass, jstring); /* - * Class: org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice + * Class: org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice * Method: getOutputDeviceVolume * Signature: (Ljava/lang/String;)F */ -JNIEXPORT jfloat JNICALL Java_org_jitsi_impl_neomedia_coreaudio_CoreAudioDevice_getOutputDeviceVolume +JNIEXPORT jfloat JNICALL Java_org_jitsi_impl_neomedia_maccoreaudio_CoreAudioDevice_getOutputDeviceVolume (JNIEnv *, jclass, jstring); #ifdef __cplusplus diff --git a/src/native/macosx/coreaudio/lib/device.c b/src/native/macosx/coreaudio/lib/device.c index a6bfe3482ca87c58be31ba00a26c95ec555f4cea..a7e1df9f4b117db2a9d1bcc2ee5ef3baea9112a8 100644 --- a/src/native/macosx/coreaudio/lib/device.c +++ b/src/native/macosx/coreaudio/lib/device.c @@ -293,7 +293,7 @@ OSStatus setDeviceVolume( /** * Gets the input volume for a given device. * - * @param device The device to get volume from. + * @param deviceUID The device UID to get volume from. * * @return The device volume as a scalar value between 0.0 and 1.0. Returns -1.0 * if an error occurs. @@ -309,7 +309,7 @@ Float32 getInputDeviceVolume( /** * Gets the output volume for a given device. * - * @param device The device to get volume from. + * @param deviceUID The device UID to get volume from. * * @return The device volume as a scalar value between 0.0 and 1.0. Returns -1.0 * if an error occurs. @@ -327,7 +327,7 @@ Float32 getOutputDeviceVolume( * (private) function and must only be called by getInputDeviceVolume or * getOutputDeviceVolume. * - * @param device The device to get volume from. + * @param deviceUID The device UID to get volume from. * @param inputOutputScope The scope to tell if this is an output or an input * device. * @@ -410,7 +410,7 @@ Float32 getDeviceVolume( /** * Sets the channels for stereo of a given device. * - * @param device The device to get the channels from. + * @param deviceUID The device UID to get the channels from. * @param channels The channels to be filled in with the correct values. This * must be a 2 item length array. * diff --git a/src/native/windows/coreaudio/jni/org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice.c b/src/native/windows/coreaudio/jni/org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice.c new file mode 100644 index 0000000000000000000000000000000000000000..a0824d3e64dd8da7dce0e2f242edf39f5601594b --- /dev/null +++ b/src/native/windows/coreaudio/jni/org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice.c @@ -0,0 +1,125 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +#include "org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice.h" + +#include "../lib/device.h" + +/** + * JNI code for CoreAudioDevice. + * + * @author Vicnent Lucas + */ + +// Private functions + +static jbyteArray getStrBytes(JNIEnv *env, const char *str); + +// Implementation + +JNIEXPORT jint JNICALL +Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_initDevices + (JNIEnv *env, jclass clazz) +{ + return initDevices(); +} + +JNIEXPORT void JNICALL +Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_freeDevices + (JNIEnv *env, jclass clazz) +{ + freeDevices(); +} + +JNIEXPORT jbyteArray JNICALL +Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_getDeviceNameBytes + (JNIEnv *env, jclass clazz, jstring deviceUID) +{ + const char * deviceUIDPtr = env->GetStringUTFChars(deviceUID, 0); + char * deviceName = getDeviceName(deviceUIDPtr); + jbyteArray deviceNameBytes = getStrBytes(env, deviceName); + // Free + free(deviceName); + env->ReleaseStringUTFChars(deviceUID, deviceUIDPtr); + + return deviceNameBytes; +} + +JNIEXPORT jint JNICALL +Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_setInputDeviceVolume + (JNIEnv *env, jclass clazz, jstring deviceUID, jfloat volume) +{ + const char * deviceUIDPtr = env->GetStringUTFChars(deviceUID, 0); + jint err = setInputDeviceVolume(deviceUIDPtr, volume); + // Free + env->ReleaseStringUTFChars(deviceUID, deviceUIDPtr); + + return err; +} + +JNIEXPORT jint JNICALL +Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_setOutputDeviceVolume + (JNIEnv *env, jclass clazz, jstring deviceUID, jfloat volume) +{ + const char * deviceUIDPtr = env->GetStringUTFChars(deviceUID, 0); + jint err = setOutputDeviceVolume(deviceUIDPtr, volume); + // Free + env->ReleaseStringUTFChars(deviceUID, deviceUIDPtr); + + return err; +} + +JNIEXPORT jfloat JNICALL +Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_getInputDeviceVolume + (JNIEnv *env, jclass clazz, jstring deviceUID) +{ + const char * deviceUIDPtr = env->GetStringUTFChars(deviceUID, 0); + jfloat volume = getInputDeviceVolume(deviceUIDPtr); + // Free + env->ReleaseStringUTFChars(deviceUID, deviceUIDPtr); + + return volume; +} + +JNIEXPORT jfloat JNICALL +Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_getOutputDeviceVolume + (JNIEnv *env, jclass clazz, jstring deviceUID) +{ + const char * deviceUIDPtr = env->GetStringUTFChars(deviceUID, 0); + jfloat volume = getOutputDeviceVolume(deviceUIDPtr); + // Free + env->ReleaseStringUTFChars(deviceUID, deviceUIDPtr); + + return volume; +} + +/** + * Gets a new <tt>jbyteArray</tt> instance which is initialized with the bytes + * of a specific C string i.e. <tt>const char *</tt>. + * + * @param env + * @param str the bytes/C string to initialize the new <tt>jbyteArray</tt> + * instance with + * @return a new <tt>jbyteArray</tt> instance which is initialized with the + * bytes of the specified <tt>str</tt> + */ +static jbyteArray getStrBytes(JNIEnv *env, const char *str) +{ + jbyteArray bytes; + + if (str) + { + size_t length = strlen(str); + + bytes = env->NewByteArray(length); + if (bytes && length) + env->SetByteArrayRegion(bytes, 0, length, (jbyte *) str); + } + else + bytes = NULL; + return bytes; +} diff --git a/src/native/windows/coreaudio/jni/org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice.h b/src/native/windows/coreaudio/jni/org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice.h new file mode 100644 index 0000000000000000000000000000000000000000..fafe376c04a4059f4e6528c7a637d7327101dd43 --- /dev/null +++ b/src/native/windows/coreaudio/jni/org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice.h @@ -0,0 +1,69 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice */ + +#ifndef _Included_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice +#define _Included_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice + * Method: initDevices + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_initDevices + (JNIEnv *, jclass); + +/* + * Class: org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice + * Method: freeDevices + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_freeDevices + (JNIEnv *, jclass); + +/* + * Class: org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice + * Method: getDeviceNameBytes + * Signature: (Ljava/lang/String;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_getDeviceNameBytes + (JNIEnv *, jclass, jstring); + +/* + * Class: org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice + * Method: setInputDeviceVolume + * Signature: (Ljava/lang/String;F)I + */ +JNIEXPORT jint JNICALL Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_setInputDeviceVolume + (JNIEnv *, jclass, jstring, jfloat); + +/* + * Class: org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice + * Method: setOutputDeviceVolume + * Signature: (Ljava/lang/String;F)I + */ +JNIEXPORT jint JNICALL Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_setOutputDeviceVolume + (JNIEnv *, jclass, jstring, jfloat); + +/* + * Class: org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice + * Method: getInputDeviceVolume + * Signature: (Ljava/lang/String;)F + */ +JNIEXPORT jfloat JNICALL Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_getInputDeviceVolume + (JNIEnv *, jclass, jstring); + +/* + * Class: org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice + * Method: getOutputDeviceVolume + * Signature: (Ljava/lang/String;)F + */ +JNIEXPORT jfloat JNICALL Java_org_jitsi_impl_neomedia_wincoreaudio_CoreAudioDevice_getOutputDeviceVolume + (JNIEnv *, jclass, jstring); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/native/windows/coreaudio/lib/device.c b/src/native/windows/coreaudio/lib/device.c new file mode 100644 index 0000000000000000000000000000000000000000..b6bac3f7618fad0bc81227d895b90afdc4e4122e --- /dev/null +++ b/src/native/windows/coreaudio/lib/device.c @@ -0,0 +1,444 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +#include "device.h" + +#include <initguid.h> +#include <stdio.h> +#include <tchar.h> + +#include <windows.h> +#include <propkeydef.h> // Must be defined after windows.h + +#include <commctrl.h> // Must be defined after mmdeviceapi.h +#include "include/endpointvolume.h" // Must be defined after mmdeviceapi.h + +/** + * Functions to list, access and modifies audio devices via coreaudio. + * + * @author Vincent Lucas + */ + +/** + * Private definition of functions, + */ +IAudioEndpointVolume * getEndpointVolume( + const char * deviceUID); + +void freeEndpointVolume( + IAudioEndpointVolume * endpointVolume); + +int setDeviceVolume( + const char * deviceUID, + float volume); + +float getDeviceVolume( + const char * deviceUID); + +DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); // DEVPROP_TYPE_STRING + +const IID IID_IAudioEndpointVolume = +{0x5CDF2C82, 0x841E, 0x4546, {0x97, 0x22, 0x0C, 0xF7, 0x40, 0x78, 0x22, 0x9A}}; + +/** + * Initializes the COM component. This function must be called first in order to + * able each following function to work correctly. Once finished, the caller of + * this function must call the "freeDevices" function. + * + * @return 0 if everything is OK. -1 if an error has occured. + */ +int initDevices(void) +{ + fprintf(stderr, + "initDevices (coreaudio/device.c): \n"); + fflush(stderr); + if(CoInitializeEx(NULL, COINIT_MULTITHREADED) != S_OK) + { + fprintf(stderr, + "initDevices (coreaudio/device.c): \ + \n\tCoInitialize\n"); + fflush(stderr); + return -1; + } + return 0; +} + +/** + * Frees the resources used by the COM component. This function must be called + * last. + */ +void freeDevices(void) +{ + fprintf(stderr, + "freeDevices (coreaudio/device.c): \n"); + fflush(stderr); + CoUninitialize(); +} + +/** + * Returns the audio device corresponding to the UID given in parameter. Or + * NULL if the device is nonexistant or if anything as failed. The device must + * be freed by the caller of this function. + * + * @param deviceUID The device UID. + * + * @return The audio device corresponding to the UID given in parameter. Or + * NULL if the device is nonexistant or if anything as failed. + */ +IMMDevice * getDevice( + const char * deviceUID) +{ + // Gets the enumerator of the system devices. + int err; + IMMDeviceEnumerator * enumerator = NULL; + const CLSID clsid = __uuidof(MMDeviceEnumerator); + const IID iid = __uuidof(IMMDeviceEnumerator); + + if((err = CoCreateInstance( + clsid, + NULL, + CLSCTX_ALL, + iid, + (void**) &enumerator)) + != S_OK) + { + fprintf(stderr, + "getDevice (coreaudio/device.c): \ + \n\tCoCreateInstance\n"); + fflush(stderr); + if(err == REGDB_E_CLASSNOTREG) + { + fprintf(stderr, + "getDevice (coreaudio/device.c): \ + \n\tCoCreateInstance: REGDB_E_CLASSNOTREG\n"); + fflush(stderr); + } + else if(err == CLASS_E_NOAGGREGATION) + { + fprintf(stderr, + "getDevice (coreaudio/device.c): \ + \n\tCoCreateInstance: CLASS_E_NOAGGREGATION\n"); + fflush(stderr); + } + else if(err == E_NOINTERFACE) + { + fprintf(stderr, + "getDevice (coreaudio/device.c): \ + \n\tCoCreateInstance: E_NOINTERFACE\n"); + fflush(stderr); + } + else if(err == E_POINTER) + { + fprintf(stderr, + "getDevice (coreaudio/device.c): \ + \n\tCoCreateInstance: E_POINTER\n"); + fflush(stderr); + } + return NULL; + } + + // Gets the requested device selected by its UID. + IMMDevice *device = NULL; + size_t deviceUIDLength = strlen(deviceUID); + wchar_t wCharDeviceUID[deviceUIDLength + 1]; + if(mbstowcs(wCharDeviceUID, deviceUID, deviceUIDLength + 1) + != deviceUIDLength) + { + fprintf(stderr, + "getDevice (coreaudio/device.c): \ + \n\tmbstowcs\n"); + fflush(stderr); + return NULL; + } + if(enumerator->GetDevice(wCharDeviceUID, &device) != S_OK) + { + fprintf(stderr, + "getDevice (coreaudio/device.c): \ + \n\tIMMDeviceEnumerator.GetDevice\n"); + fflush(stderr); + return NULL; + } + + return device; +} + +/** + * Frees an audio device returned by the function getDevice. + * + * @param device The audio device + */ +void freeDevice( + IMMDevice * device) +{ + device->Release(); +} + +/** + * Returns the audio device volume endpoint corresponding to the UID given in + * parameter. Or NULL if the endpoint is nonexistant or if anything as failed. + * The endpoint must be freed by the caller of this function. + * + * @param deviceUID The device UID. + * + * @return the audio device volume endpoint corresponding to the UID given in + * parameter. Or NULL if the endpoint is nonexistant or if anything as failed. + */ +IAudioEndpointVolume * getEndpointVolume( + const char * deviceUID) +{ + // Gets the device corresponding to its UID. + IMMDevice * device = getDevice(deviceUID); + if(device == NULL) + { + fprintf(stderr, + "getEndpointVolume (coreaudio/device.c): \ + \n\tgetDevice\n"); + fflush(stderr); + return NULL; + } + + // retrives the volume endpoint. + IAudioEndpointVolume *endpointVolume = NULL; + if(device->Activate( + IID_IAudioEndpointVolume, + CLSCTX_ALL, + NULL, + (void**) &endpointVolume) != S_OK) + { + fprintf(stderr, + "getEndpointVolume (coreaudio/device.c): \ + \n\tIMMDevice.Activate\n"); + fflush(stderr); + return NULL; + } + + // Frees the device. + freeDevice(device); + + return endpointVolume; +} + +/** + * Frees an audio device volume endpoint returned by the function + * getEndpointVolume. + * + * @param endpointVolume The audio device volume endpoint. + */ +void freeEndpointVolume( + IAudioEndpointVolume * endpointVolume) +{ + endpointVolume->Release(); +} + +/** + * Returns the device name for the given device. Or NULL, if not available. The + * returned string must be freed by the caller. + * + * @param device The device to get the name from. + * + * @return The device name for the given device. Or NULL, if not available. The + * returned string must be freed by the caller. + */ +char* getDeviceName( + const char * deviceUID) +{ + size_t deviceNameLength; + char * deviceName = NULL; + PROPVARIANT propertyDeviceName; + PropVariantInit(&propertyDeviceName); + IPropertyStore * properties = NULL; + + // Gets the audio device. + IMMDevice * device = getDevice(deviceUID); + if(device == NULL) + { + fprintf(stderr, + "getDeviceName (coreaudio/device.c): \ + \n\tgetDevice\n"); + fflush(stderr); + return NULL; + } + + // Read the properties from the audio device. + if(device->OpenPropertyStore(STGM_READ, &properties) != S_OK) + { + fprintf(stderr, + "getDeviceName (coreaudio/device.c): \ + \n\tIMMDevice.OpenPropertyStore\n"); + fflush(stderr); + return NULL; + } + if(properties->GetValue(PKEY_Device_FriendlyName, &propertyDeviceName) + != S_OK) + { + fprintf(stderr, + "getDeviceName (coreaudio/device.c): \ + \n\tIPropertyStore.GetValue\n"); + fflush(stderr); + return NULL; + } + deviceNameLength = wcslen(propertyDeviceName.pwszVal); + if((deviceName = (char *) malloc((deviceNameLength + 1) * sizeof(char))) + == NULL) + { + fprintf(stderr, + "getDeviceName (coreaudio/device.c): \ + \n\tmalloc\n"); + fflush(stderr); + return NULL; + } + if(wcstombs(deviceName, propertyDeviceName.pwszVal, deviceNameLength + 1) + != deviceNameLength) + { + fprintf(stderr, + "getDeviceName (coreaudio/device.c): \ + \n\twcstombs\n"); + fflush(stderr); + return NULL; + } + + // Frees. + freeDevice(device); + PropVariantClear(&propertyDeviceName); + + return deviceName; +} + +/** + * Sets the input volume for a given device. + * + * @param deviceUID The device UID which volume must be changed. + * @param volume The new volume of the device. This is a scalar value between + * 0.0 and 1.0 + * + * @return 0 if everything works well. -1 if an error has occured. + */ +int setInputDeviceVolume( + const char * deviceUID, + float volume) +{ + return setDeviceVolume(deviceUID, volume); +} + +/** + * Sets the output volume for a given device. + * + * @param deviceUID The device UID which volume must be changed. + * @param volume The new volume of the device. This is a scalar value between + * 0.0 and 1.0 + * + * @return 0 if everything works well. -1 if an error has occured. + */ +int setOutputDeviceVolume( + const char * deviceUID, + float volume) +{ + return setDeviceVolume(deviceUID, volume); +} + +/** + * Sets the input or output volume for a given device. This is an internal + * (private) function and must only be called by setInputDeviceVolume or + * setOutputDeviceVolume. + * + * @param deviceUID The device UID which volume must be changed. + * @param volume The new volume of the device. This is a scalar value between + * 0.0 and 1.0 + * @param inputOutputScope The scope to tell if this is an output or an input + * device. + * + * @return 0 if everything works well. -1 if an error has occured. + */ +int setDeviceVolume( + const char * deviceUID, + float volume) +{ + IAudioEndpointVolume *endpointVolume = getEndpointVolume(deviceUID); + if(endpointVolume == NULL) + { + fprintf(stderr, + "setDeviceVolume (coreaudio/device.c): \ + \n\tgetEndpointVolume\n"); + fflush(stderr); + return -1; + } + if(endpointVolume->SetMasterVolumeLevelScalar(volume, NULL) != S_OK) + { + fprintf(stderr, + "setDeviceVolume (coreaudio/device.c): \ + \n\tSetMasterVolumeLevelScalar\n"); + fflush(stderr); + return -1; + } + freeEndpointVolume(endpointVolume); + + return 0; +} + +/** + * Gets the input volume for a given device. + * + * @param deviceUID The device UID to get volume from. + * + * @return The device volume as a scalar value between 0.0 and 1.0. Returns -1.0 + * if an error occurs. + */ +float getInputDeviceVolume( + const char * deviceUID) +{ + return getDeviceVolume(deviceUID); +} + +/** + * Gets the output volume for a given device. + * + * @param deviceUID The device UID to get volume from. + * + * @return The device volume as a scalar value between 0.0 and 1.0. Returns -1.0 + * if an error occurs. + */ +float getOutputDeviceVolume( + const char * deviceUID) +{ + return getDeviceVolume(deviceUID); +} + +/** + * Gets the input or output volume for a given device. This is an internal + * (private) function and must only be called by getInputDeviceVolume or + * getOutputDeviceVolume. + * + * @param deviceUID The device UID to get volume from. + * + * @return The device volume as a scalar value between 0.0 and 1.0. Returns -1.0 + * if an error occurs. + */ +float getDeviceVolume( + const char * deviceUID) +{ + float volume; + + IAudioEndpointVolume *endpointVolume = getEndpointVolume(deviceUID); + if(endpointVolume == NULL) + { + fprintf(stderr, + "getDeviceVolume (coreaudio/device.c): \ + \n\tgetEndpointVolume\n"); + fflush(stderr); + return -1; + } + if(endpointVolume->GetMasterVolumeLevelScalar(&volume) != S_OK) + { + fprintf(stderr, + "getDeviceVolume (coreaudio/device.c): \ + \n\tGetMasterVolumeLevelScalar\n"); + fflush(stderr); + return -1; + } + freeEndpointVolume(endpointVolume); + + return volume; +} diff --git a/src/native/windows/coreaudio/lib/device.h b/src/native/windows/coreaudio/lib/device.h new file mode 100644 index 0000000000000000000000000000000000000000..abc05f2eaa17e97304d094af81a41cab9c689787 --- /dev/null +++ b/src/native/windows/coreaudio/lib/device.h @@ -0,0 +1,44 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +#ifndef device_h +#define device_h + +#include <mmdeviceapi.h> + +/** + * Functions to list, access and modifies audio devices via coreaudio. + * Look at correspondig ".c" file for documentation. + * + * @author Vincent Lucas + */ +int initDevices(void); + +void freeDevices(void); + +IMMDevice * getDevice( + const char * deviceUID); + +void freeDevice( + IMMDevice * device); + +char* getDeviceName( + const char * deviceUID); + +int setInputDeviceVolume( + const char * deviceUID, + float volume); + +int setOutputDeviceVolume( + const char * deviceUID, + float volume); + +float getInputDeviceVolume( + const char * deviceUID); + +float getOutputDeviceVolume( + const char * deviceUID); +#endif diff --git a/src/native/windows/coreaudio/lib/include/endpointvolume.h b/src/native/windows/coreaudio/lib/include/endpointvolume.h new file mode 100644 index 0000000000000000000000000000000000000000..b423b5a484210e6d1e79c0a0e45a3d12a10e45af --- /dev/null +++ b/src/native/windows/coreaudio/lib/include/endpointvolume.h @@ -0,0 +1,908 @@ + /* File created by MIDL compiler version 8.00.0595 */ +/* @@MIDL_FILE_HEADING( ) */ + +//#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the <rpcndr.h> version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 500 +#endif + +/* verify that the <rpcsal.h> version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCSAL_H_VERSION__ +#define __REQUIRED_RPCSAL_H_VERSION__ 100 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of <rpcndr.h> +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __endpointvolume_h__ +#define __endpointvolume_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __IAudioEndpointVolumeCallback_FWD_DEFINED__ +#define __IAudioEndpointVolumeCallback_FWD_DEFINED__ +typedef interface IAudioEndpointVolumeCallback IAudioEndpointVolumeCallback; + +#endif /* __IAudioEndpointVolumeCallback_FWD_DEFINED__ */ + + +#ifndef __IAudioEndpointVolume_FWD_DEFINED__ +#define __IAudioEndpointVolume_FWD_DEFINED__ +typedef interface IAudioEndpointVolume IAudioEndpointVolume; + +#endif /* __IAudioEndpointVolume_FWD_DEFINED__ */ + + +#ifndef __IAudioEndpointVolumeEx_FWD_DEFINED__ +#define __IAudioEndpointVolumeEx_FWD_DEFINED__ +typedef interface IAudioEndpointVolumeEx IAudioEndpointVolumeEx; + +#endif /* __IAudioEndpointVolumeEx_FWD_DEFINED__ */ + + +#ifndef __IAudioMeterInformation_FWD_DEFINED__ +#define __IAudioMeterInformation_FWD_DEFINED__ +typedef interface IAudioMeterInformation IAudioMeterInformation; + +#endif /* __IAudioMeterInformation_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "unknwn.h" +#include "devicetopology.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +/* interface __MIDL_itf_endpointvolume_0000_0000 */ +/* [local] */ + +#include "winapifamily.h" +//#pragma region Application Family +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +typedef struct AUDIO_VOLUME_NOTIFICATION_DATA + { + GUID guidEventContext; + BOOL bMuted; + float fMasterVolume; + UINT nChannels; + float afChannelVolumes[ 1 ]; + } AUDIO_VOLUME_NOTIFICATION_DATA; + +typedef struct AUDIO_VOLUME_NOTIFICATION_DATA *PAUDIO_VOLUME_NOTIFICATION_DATA; + +#define ENDPOINT_HARDWARE_SUPPORT_VOLUME 0x00000001 +#define ENDPOINT_HARDWARE_SUPPORT_MUTE 0x00000002 +#define ENDPOINT_HARDWARE_SUPPORT_METER 0x00000004 + + +extern RPC_IF_HANDLE __MIDL_itf_endpointvolume_0000_0000_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_endpointvolume_0000_0000_v0_0_s_ifspec; + +#ifndef __IAudioEndpointVolumeCallback_INTERFACE_DEFINED__ +#define __IAudioEndpointVolumeCallback_INTERFACE_DEFINED__ + +/* interface IAudioEndpointVolumeCallback */ +/* [unique][helpstring][nonextensible][uuid][local][object] */ + + +EXTERN_C const IID IID_IAudioEndpointVolumeCallback; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("657804FA-D6AD-4496-8A60-352752AF4F89") + IAudioEndpointVolumeCallback : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE OnNotify( + PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) = 0; + + }; + + +#else /* C style interface */ + + typedef struct IAudioEndpointVolumeCallbackVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IAudioEndpointVolumeCallback * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IAudioEndpointVolumeCallback * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IAudioEndpointVolumeCallback * This); + + HRESULT ( STDMETHODCALLTYPE *OnNotify )( + IAudioEndpointVolumeCallback * This, + PAUDIO_VOLUME_NOTIFICATION_DATA pNotify); + + END_INTERFACE + } IAudioEndpointVolumeCallbackVtbl; + + interface IAudioEndpointVolumeCallback + { + CONST_VTBL struct IAudioEndpointVolumeCallbackVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IAudioEndpointVolumeCallback_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IAudioEndpointVolumeCallback_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IAudioEndpointVolumeCallback_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IAudioEndpointVolumeCallback_OnNotify(This,pNotify) \ + ( (This)->lpVtbl -> OnNotify(This,pNotify) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IAudioEndpointVolumeCallback_INTERFACE_DEFINED__ */ + + +#ifndef __IAudioEndpointVolume_INTERFACE_DEFINED__ +#define __IAudioEndpointVolume_INTERFACE_DEFINED__ + +/* interface IAudioEndpointVolume */ +/* [unique][helpstring][nonextensible][uuid][local][object] */ + + +EXTERN_C const IID IID_IAudioEndpointVolume; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("5CDF2C82-841E-4546-9722-0CF74078229A") + IAudioEndpointVolume : public IUnknown + { + public: + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE RegisterControlChangeNotify( + /* [annotation][in] */ + _In_ IAudioEndpointVolumeCallback *pNotify) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE UnregisterControlChangeNotify( + /* [annotation][in] */ + _In_ IAudioEndpointVolumeCallback *pNotify) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetChannelCount( + /* [annotation][out] */ + _Out_ UINT *pnChannelCount) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetMasterVolumeLevel( + /* [annotation][in] */ + _In_ float fLevelDB, + /* [unique][in] */ LPCGUID pguidEventContext) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetMasterVolumeLevelScalar( + /* [annotation][in] */ + _In_ float fLevel, + /* [unique][in] */ LPCGUID pguidEventContext) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetMasterVolumeLevel( + /* [annotation][out] */ + _Out_ float *pfLevelDB) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetMasterVolumeLevelScalar( + /* [annotation][out] */ + _Out_ float *pfLevel) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetChannelVolumeLevel( + /* [annotation][in] */ + _In_ UINT nChannel, + float fLevelDB, + /* [unique][in] */ LPCGUID pguidEventContext) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetChannelVolumeLevelScalar( + /* [annotation][in] */ + _In_ UINT nChannel, + float fLevel, + /* [unique][in] */ LPCGUID pguidEventContext) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetChannelVolumeLevel( + /* [annotation][in] */ + _In_ UINT nChannel, + /* [annotation][out] */ + _Out_ float *pfLevelDB) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetChannelVolumeLevelScalar( + /* [annotation][in] */ + _In_ UINT nChannel, + /* [annotation][out] */ + _Out_ float *pfLevel) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetMute( + /* [annotation][in] */ + _In_ BOOL bMute, + /* [unique][in] */ LPCGUID pguidEventContext) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetMute( + /* [annotation][out] */ + _Out_ BOOL *pbMute) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetVolumeStepInfo( + /* [annotation][out] */ + _Out_ UINT *pnStep, + /* [annotation][out] */ + _Out_ UINT *pnStepCount) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE VolumeStepUp( + /* [unique][in] */ LPCGUID pguidEventContext) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE VolumeStepDown( + /* [unique][in] */ LPCGUID pguidEventContext) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryHardwareSupport( + /* [annotation][out] */ + _Out_ DWORD *pdwHardwareSupportMask) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetVolumeRange( + /* [annotation][out] */ + _Out_ float *pflVolumeMindB, + /* [annotation][out] */ + _Out_ float *pflVolumeMaxdB, + /* [annotation][out] */ + _Out_ float *pflVolumeIncrementdB) = 0; + + }; + + +#else /* C style interface */ + + typedef struct IAudioEndpointVolumeVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IAudioEndpointVolume * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IAudioEndpointVolume * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IAudioEndpointVolume * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *RegisterControlChangeNotify )( + IAudioEndpointVolume * This, + /* [annotation][in] */ + _In_ IAudioEndpointVolumeCallback *pNotify); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *UnregisterControlChangeNotify )( + IAudioEndpointVolume * This, + /* [annotation][in] */ + _In_ IAudioEndpointVolumeCallback *pNotify); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetChannelCount )( + IAudioEndpointVolume * This, + /* [annotation][out] */ + _Out_ UINT *pnChannelCount); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetMasterVolumeLevel )( + IAudioEndpointVolume * This, + /* [annotation][in] */ + _In_ float fLevelDB, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetMasterVolumeLevelScalar )( + IAudioEndpointVolume * This, + /* [annotation][in] */ + _In_ float fLevel, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetMasterVolumeLevel )( + IAudioEndpointVolume * This, + /* [annotation][out] */ + _Out_ float *pfLevelDB); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetMasterVolumeLevelScalar )( + IAudioEndpointVolume * This, + /* [annotation][out] */ + _Out_ float *pfLevel); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetChannelVolumeLevel )( + IAudioEndpointVolume * This, + /* [annotation][in] */ + _In_ UINT nChannel, + float fLevelDB, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetChannelVolumeLevelScalar )( + IAudioEndpointVolume * This, + /* [annotation][in] */ + _In_ UINT nChannel, + float fLevel, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetChannelVolumeLevel )( + IAudioEndpointVolume * This, + /* [annotation][in] */ + _In_ UINT nChannel, + /* [annotation][out] */ + _Out_ float *pfLevelDB); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetChannelVolumeLevelScalar )( + IAudioEndpointVolume * This, + /* [annotation][in] */ + _In_ UINT nChannel, + /* [annotation][out] */ + _Out_ float *pfLevel); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetMute )( + IAudioEndpointVolume * This, + /* [annotation][in] */ + _In_ BOOL bMute, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetMute )( + IAudioEndpointVolume * This, + /* [annotation][out] */ + _Out_ BOOL *pbMute); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetVolumeStepInfo )( + IAudioEndpointVolume * This, + /* [annotation][out] */ + _Out_ UINT *pnStep, + /* [annotation][out] */ + _Out_ UINT *pnStepCount); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *VolumeStepUp )( + IAudioEndpointVolume * This, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *VolumeStepDown )( + IAudioEndpointVolume * This, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *QueryHardwareSupport )( + IAudioEndpointVolume * This, + /* [annotation][out] */ + _Out_ DWORD *pdwHardwareSupportMask); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetVolumeRange )( + IAudioEndpointVolume * This, + /* [annotation][out] */ + _Out_ float *pflVolumeMindB, + /* [annotation][out] */ + _Out_ float *pflVolumeMaxdB, + /* [annotation][out] */ + _Out_ float *pflVolumeIncrementdB); + + END_INTERFACE + } IAudioEndpointVolumeVtbl; + + interface IAudioEndpointVolume + { + CONST_VTBL struct IAudioEndpointVolumeVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IAudioEndpointVolume_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IAudioEndpointVolume_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IAudioEndpointVolume_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IAudioEndpointVolume_RegisterControlChangeNotify(This,pNotify) \ + ( (This)->lpVtbl -> RegisterControlChangeNotify(This,pNotify) ) + +#define IAudioEndpointVolume_UnregisterControlChangeNotify(This,pNotify) \ + ( (This)->lpVtbl -> UnregisterControlChangeNotify(This,pNotify) ) + +#define IAudioEndpointVolume_GetChannelCount(This,pnChannelCount) \ + ( (This)->lpVtbl -> GetChannelCount(This,pnChannelCount) ) + +#define IAudioEndpointVolume_SetMasterVolumeLevel(This,fLevelDB,pguidEventContext) \ + ( (This)->lpVtbl -> SetMasterVolumeLevel(This,fLevelDB,pguidEventContext) ) + +#define IAudioEndpointVolume_SetMasterVolumeLevelScalar(This,fLevel,pguidEventContext) \ + ( (This)->lpVtbl -> SetMasterVolumeLevelScalar(This,fLevel,pguidEventContext) ) + +#define IAudioEndpointVolume_GetMasterVolumeLevel(This,pfLevelDB) \ + ( (This)->lpVtbl -> GetMasterVolumeLevel(This,pfLevelDB) ) + +#define IAudioEndpointVolume_GetMasterVolumeLevelScalar(This,pfLevel) \ + ( (This)->lpVtbl -> GetMasterVolumeLevelScalar(This,pfLevel) ) + +#define IAudioEndpointVolume_SetChannelVolumeLevel(This,nChannel,fLevelDB,pguidEventContext) \ + ( (This)->lpVtbl -> SetChannelVolumeLevel(This,nChannel,fLevelDB,pguidEventContext) ) + +#define IAudioEndpointVolume_SetChannelVolumeLevelScalar(This,nChannel,fLevel,pguidEventContext) \ + ( (This)->lpVtbl -> SetChannelVolumeLevelScalar(This,nChannel,fLevel,pguidEventContext) ) + +#define IAudioEndpointVolume_GetChannelVolumeLevel(This,nChannel,pfLevelDB) \ + ( (This)->lpVtbl -> GetChannelVolumeLevel(This,nChannel,pfLevelDB) ) + +#define IAudioEndpointVolume_GetChannelVolumeLevelScalar(This,nChannel,pfLevel) \ + ( (This)->lpVtbl -> GetChannelVolumeLevelScalar(This,nChannel,pfLevel) ) + +#define IAudioEndpointVolume_SetMute(This,bMute,pguidEventContext) \ + ( (This)->lpVtbl -> SetMute(This,bMute,pguidEventContext) ) + +#define IAudioEndpointVolume_GetMute(This,pbMute) \ + ( (This)->lpVtbl -> GetMute(This,pbMute) ) + +#define IAudioEndpointVolume_GetVolumeStepInfo(This,pnStep,pnStepCount) \ + ( (This)->lpVtbl -> GetVolumeStepInfo(This,pnStep,pnStepCount) ) + +#define IAudioEndpointVolume_VolumeStepUp(This,pguidEventContext) \ + ( (This)->lpVtbl -> VolumeStepUp(This,pguidEventContext) ) + +#define IAudioEndpointVolume_VolumeStepDown(This,pguidEventContext) \ + ( (This)->lpVtbl -> VolumeStepDown(This,pguidEventContext) ) + +#define IAudioEndpointVolume_QueryHardwareSupport(This,pdwHardwareSupportMask) \ + ( (This)->lpVtbl -> QueryHardwareSupport(This,pdwHardwareSupportMask) ) + +#define IAudioEndpointVolume_GetVolumeRange(This,pflVolumeMindB,pflVolumeMaxdB,pflVolumeIncrementdB) \ + ( (This)->lpVtbl -> GetVolumeRange(This,pflVolumeMindB,pflVolumeMaxdB,pflVolumeIncrementdB) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IAudioEndpointVolume_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_endpointvolume_0000_0002 */ +/* [local] */ + +#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */ +//#pragma endregion +//#pragma region Desktop Family +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + + +extern RPC_IF_HANDLE __MIDL_itf_endpointvolume_0000_0002_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_endpointvolume_0000_0002_v0_0_s_ifspec; + +#ifndef __IAudioEndpointVolumeEx_INTERFACE_DEFINED__ +#define __IAudioEndpointVolumeEx_INTERFACE_DEFINED__ + +/* interface IAudioEndpointVolumeEx */ +/* [unique][helpstring][nonextensible][uuid][local][object] */ + + +EXTERN_C const IID IID_IAudioEndpointVolumeEx; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("66E11784-F695-4F28-A505-A7080081A78F") + IAudioEndpointVolumeEx : public IAudioEndpointVolume + { + public: + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetVolumeRangeChannel( + /* [in] */ UINT iChannel, + /* [annotation][out] */ + _Out_ float *pflVolumeMindB, + /* [annotation][out] */ + _Out_ float *pflVolumeMaxdB, + /* [annotation][out] */ + _Out_ float *pflVolumeIncrementdB) = 0; + + }; + + +#else /* C style interface */ + + typedef struct IAudioEndpointVolumeExVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IAudioEndpointVolumeEx * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IAudioEndpointVolumeEx * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IAudioEndpointVolumeEx * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *RegisterControlChangeNotify )( + IAudioEndpointVolumeEx * This, + /* [annotation][in] */ + _In_ IAudioEndpointVolumeCallback *pNotify); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *UnregisterControlChangeNotify )( + IAudioEndpointVolumeEx * This, + /* [annotation][in] */ + _In_ IAudioEndpointVolumeCallback *pNotify); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetChannelCount )( + IAudioEndpointVolumeEx * This, + /* [annotation][out] */ + _Out_ UINT *pnChannelCount); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetMasterVolumeLevel )( + IAudioEndpointVolumeEx * This, + /* [annotation][in] */ + _In_ float fLevelDB, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetMasterVolumeLevelScalar )( + IAudioEndpointVolumeEx * This, + /* [annotation][in] */ + _In_ float fLevel, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetMasterVolumeLevel )( + IAudioEndpointVolumeEx * This, + /* [annotation][out] */ + _Out_ float *pfLevelDB); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetMasterVolumeLevelScalar )( + IAudioEndpointVolumeEx * This, + /* [annotation][out] */ + _Out_ float *pfLevel); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetChannelVolumeLevel )( + IAudioEndpointVolumeEx * This, + /* [annotation][in] */ + _In_ UINT nChannel, + float fLevelDB, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetChannelVolumeLevelScalar )( + IAudioEndpointVolumeEx * This, + /* [annotation][in] */ + _In_ UINT nChannel, + float fLevel, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetChannelVolumeLevel )( + IAudioEndpointVolumeEx * This, + /* [annotation][in] */ + _In_ UINT nChannel, + /* [annotation][out] */ + _Out_ float *pfLevelDB); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetChannelVolumeLevelScalar )( + IAudioEndpointVolumeEx * This, + /* [annotation][in] */ + _In_ UINT nChannel, + /* [annotation][out] */ + _Out_ float *pfLevel); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *SetMute )( + IAudioEndpointVolumeEx * This, + /* [annotation][in] */ + _In_ BOOL bMute, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetMute )( + IAudioEndpointVolumeEx * This, + /* [annotation][out] */ + _Out_ BOOL *pbMute); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetVolumeStepInfo )( + IAudioEndpointVolumeEx * This, + /* [annotation][out] */ + _Out_ UINT *pnStep, + /* [annotation][out] */ + _Out_ UINT *pnStepCount); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *VolumeStepUp )( + IAudioEndpointVolumeEx * This, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *VolumeStepDown )( + IAudioEndpointVolumeEx * This, + /* [unique][in] */ LPCGUID pguidEventContext); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *QueryHardwareSupport )( + IAudioEndpointVolumeEx * This, + /* [annotation][out] */ + _Out_ DWORD *pdwHardwareSupportMask); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetVolumeRange )( + IAudioEndpointVolumeEx * This, + /* [annotation][out] */ + _Out_ float *pflVolumeMindB, + /* [annotation][out] */ + _Out_ float *pflVolumeMaxdB, + /* [annotation][out] */ + _Out_ float *pflVolumeIncrementdB); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetVolumeRangeChannel )( + IAudioEndpointVolumeEx * This, + /* [in] */ UINT iChannel, + /* [annotation][out] */ + _Out_ float *pflVolumeMindB, + /* [annotation][out] */ + _Out_ float *pflVolumeMaxdB, + /* [annotation][out] */ + _Out_ float *pflVolumeIncrementdB); + + END_INTERFACE + } IAudioEndpointVolumeExVtbl; + + interface IAudioEndpointVolumeEx + { + CONST_VTBL struct IAudioEndpointVolumeExVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IAudioEndpointVolumeEx_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IAudioEndpointVolumeEx_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IAudioEndpointVolumeEx_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IAudioEndpointVolumeEx_RegisterControlChangeNotify(This,pNotify) \ + ( (This)->lpVtbl -> RegisterControlChangeNotify(This,pNotify) ) + +#define IAudioEndpointVolumeEx_UnregisterControlChangeNotify(This,pNotify) \ + ( (This)->lpVtbl -> UnregisterControlChangeNotify(This,pNotify) ) + +#define IAudioEndpointVolumeEx_GetChannelCount(This,pnChannelCount) \ + ( (This)->lpVtbl -> GetChannelCount(This,pnChannelCount) ) + +#define IAudioEndpointVolumeEx_SetMasterVolumeLevel(This,fLevelDB,pguidEventContext) \ + ( (This)->lpVtbl -> SetMasterVolumeLevel(This,fLevelDB,pguidEventContext) ) + +#define IAudioEndpointVolumeEx_SetMasterVolumeLevelScalar(This,fLevel,pguidEventContext) \ + ( (This)->lpVtbl -> SetMasterVolumeLevelScalar(This,fLevel,pguidEventContext) ) + +#define IAudioEndpointVolumeEx_GetMasterVolumeLevel(This,pfLevelDB) \ + ( (This)->lpVtbl -> GetMasterVolumeLevel(This,pfLevelDB) ) + +#define IAudioEndpointVolumeEx_GetMasterVolumeLevelScalar(This,pfLevel) \ + ( (This)->lpVtbl -> GetMasterVolumeLevelScalar(This,pfLevel) ) + +#define IAudioEndpointVolumeEx_SetChannelVolumeLevel(This,nChannel,fLevelDB,pguidEventContext) \ + ( (This)->lpVtbl -> SetChannelVolumeLevel(This,nChannel,fLevelDB,pguidEventContext) ) + +#define IAudioEndpointVolumeEx_SetChannelVolumeLevelScalar(This,nChannel,fLevel,pguidEventContext) \ + ( (This)->lpVtbl -> SetChannelVolumeLevelScalar(This,nChannel,fLevel,pguidEventContext) ) + +#define IAudioEndpointVolumeEx_GetChannelVolumeLevel(This,nChannel,pfLevelDB) \ + ( (This)->lpVtbl -> GetChannelVolumeLevel(This,nChannel,pfLevelDB) ) + +#define IAudioEndpointVolumeEx_GetChannelVolumeLevelScalar(This,nChannel,pfLevel) \ + ( (This)->lpVtbl -> GetChannelVolumeLevelScalar(This,nChannel,pfLevel) ) + +#define IAudioEndpointVolumeEx_SetMute(This,bMute,pguidEventContext) \ + ( (This)->lpVtbl -> SetMute(This,bMute,pguidEventContext) ) + +#define IAudioEndpointVolumeEx_GetMute(This,pbMute) \ + ( (This)->lpVtbl -> GetMute(This,pbMute) ) + +#define IAudioEndpointVolumeEx_GetVolumeStepInfo(This,pnStep,pnStepCount) \ + ( (This)->lpVtbl -> GetVolumeStepInfo(This,pnStep,pnStepCount) ) + +#define IAudioEndpointVolumeEx_VolumeStepUp(This,pguidEventContext) \ + ( (This)->lpVtbl -> VolumeStepUp(This,pguidEventContext) ) + +#define IAudioEndpointVolumeEx_VolumeStepDown(This,pguidEventContext) \ + ( (This)->lpVtbl -> VolumeStepDown(This,pguidEventContext) ) + +#define IAudioEndpointVolumeEx_QueryHardwareSupport(This,pdwHardwareSupportMask) \ + ( (This)->lpVtbl -> QueryHardwareSupport(This,pdwHardwareSupportMask) ) + +#define IAudioEndpointVolumeEx_GetVolumeRange(This,pflVolumeMindB,pflVolumeMaxdB,pflVolumeIncrementdB) \ + ( (This)->lpVtbl -> GetVolumeRange(This,pflVolumeMindB,pflVolumeMaxdB,pflVolumeIncrementdB) ) + + +#define IAudioEndpointVolumeEx_GetVolumeRangeChannel(This,iChannel,pflVolumeMindB,pflVolumeMaxdB,pflVolumeIncrementdB) \ + ( (This)->lpVtbl -> GetVolumeRangeChannel(This,iChannel,pflVolumeMindB,pflVolumeMaxdB,pflVolumeIncrementdB) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IAudioEndpointVolumeEx_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_endpointvolume_0000_0003 */ +/* [local] */ + +#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */ +//#pragma endregion +//#pragma region Application Family +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) + + +extern RPC_IF_HANDLE __MIDL_itf_endpointvolume_0000_0003_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_endpointvolume_0000_0003_v0_0_s_ifspec; + +#ifndef __IAudioMeterInformation_INTERFACE_DEFINED__ +#define __IAudioMeterInformation_INTERFACE_DEFINED__ + +/* interface IAudioMeterInformation */ +/* [unique][helpstring][nonextensible][uuid][local][object] */ + + +EXTERN_C const IID IID_IAudioMeterInformation; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("C02216F6-8C67-4B5B-9D00-D008E73E0064") + IAudioMeterInformation : public IUnknown + { + public: + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetPeakValue( + /* [out] */ float *pfPeak) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetMeteringChannelCount( + /* [annotation][out] */ + _Out_ UINT *pnChannelCount) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetChannelsPeakValues( + /* [in] */ UINT32 u32ChannelCount, + /* [size_is][out] */ float *afPeakValues) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE QueryHardwareSupport( + /* [annotation][out] */ + _Out_ DWORD *pdwHardwareSupportMask) = 0; + + }; + + +#else /* C style interface */ + + typedef struct IAudioMeterInformationVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IAudioMeterInformation * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IAudioMeterInformation * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IAudioMeterInformation * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetPeakValue )( + IAudioMeterInformation * This, + /* [out] */ float *pfPeak); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetMeteringChannelCount )( + IAudioMeterInformation * This, + /* [annotation][out] */ + _Out_ UINT *pnChannelCount); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *GetChannelsPeakValues )( + IAudioMeterInformation * This, + /* [in] */ UINT32 u32ChannelCount, + /* [size_is][out] */ float *afPeakValues); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE *QueryHardwareSupport )( + IAudioMeterInformation * This, + /* [annotation][out] */ + _Out_ DWORD *pdwHardwareSupportMask); + + END_INTERFACE + } IAudioMeterInformationVtbl; + + interface IAudioMeterInformation + { + CONST_VTBL struct IAudioMeterInformationVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IAudioMeterInformation_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IAudioMeterInformation_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IAudioMeterInformation_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IAudioMeterInformation_GetPeakValue(This,pfPeak) \ + ( (This)->lpVtbl -> GetPeakValue(This,pfPeak) ) + +#define IAudioMeterInformation_GetMeteringChannelCount(This,pnChannelCount) \ + ( (This)->lpVtbl -> GetMeteringChannelCount(This,pnChannelCount) ) + +#define IAudioMeterInformation_GetChannelsPeakValues(This,u32ChannelCount,afPeakValues) \ + ( (This)->lpVtbl -> GetChannelsPeakValues(This,u32ChannelCount,afPeakValues) ) + +#define IAudioMeterInformation_QueryHardwareSupport(This,pdwHardwareSupportMask) \ + ( (This)->lpVtbl -> QueryHardwareSupport(This,pdwHardwareSupportMask) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IAudioMeterInformation_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_endpointvolume_0000_0004 */ +/* [local] */ + +#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */ +//#pragma endregion + + +extern RPC_IF_HANDLE __MIDL_itf_endpointvolume_0000_0004_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_endpointvolume_0000_0004_v0_0_s_ifspec; + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/native/windows/coreaudio/lib/include/winapifamily.h b/src/native/windows/coreaudio/lib/include/winapifamily.h new file mode 100644 index 0000000000000000000000000000000000000000..bb1f3c181ec8a57fc3ffddd749c2cc0693db951d --- /dev/null +++ b/src/native/windows/coreaudio/lib/include/winapifamily.h @@ -0,0 +1,88 @@ +/* + +Copyright (c) Microsoft Corporation. All rights reserved. + +Module Name: + + winapifamily.h + +Abstract: + + Master include file for API family partitioning. + +*/ + +#ifndef _INC_WINAPIFAMILY +#define _INC_WINAPIFAMILY + +#if defined(_MSC_VER) && !defined(MOFCOMP_PASS) +#pragma once +#endif // defined(_MSC_VER) && !defined(MOFCOMP_PASS) + +/* + * Windows APIs can be placed in a partition represented by one of the below bits. The + * WINAPI_FAMILY value determines which partitions are available to the client code. + */ + +#define WINAPI_PARTITION_DESKTOP 0x00000001 +#define WINAPI_PARTITION_APP 0x00000002 + +/* + * A family may be defined as the union of multiple families. WINAPI_FAMILY should be set + * to one of these values. + */ +#define WINAPI_FAMILY_APP WINAPI_PARTITION_APP +#define WINAPI_FAMILY_DESKTOP_APP (WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_APP) + +/* + * A constant that specifies which code is available to the program's target runtime platform. + * By default we use the 'desktop app' family which places no restrictions on the API surface. + * To restrict the API surface to just the App API surface, define WINAPI_FAMILY to WINAPI_FAMILY_APP. + */ +#ifndef WINAPI_FAMILY +#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP +#endif + +/* Macro to determine if a partition is enabled */ +#define WINAPI_FAMILY_PARTITION(Partition) ((WINAPI_FAMILY & Partition) == Partition) + +/* Macro to determine if only one partition is enabled from a set */ +#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition) + +/* + * Macro examples: + * The following examples are typical macro usage for enabling/restricting access to header code based + * on the target runtime platform. The examples assume a correct setting of the WINAPI_FAMILY macro. + * + * App programs: + * Explicitly set WINAPI_FAMILY to WINAPI_PARTITION_APP (cannot access DESKTOP partition) + * Desktop programs: + * Leave WINAPI_FAMILY set to the default above (currently WINAPI_FAMILY_DESKTOP_APP) + * + * Note: Other families and partitions may be added in the future. + * + * + * The WINAPI_FAMILY_PARTITION macro: + * Code-block is available to programs that have access to specified partition. + * + * Example: Available to App and Desktop programs + * #if WINAPI_FAMILY_PARTITION( WINAPI_PARTITION_APP ) + * + * Example: Available to Desktop programs + * #if WINAPI_FAMILY_PARTITION( WINAPI_PARTITION_DESKTOP ) + * + * + * The WINAPI_FAMILY_ONE_PARTITION macro: + * Code-block is available to programs that have access to specified parition, but not others in the partition set. + * + * Example: Available only to App programs + * #if WINAPI_FAMILY_ONE_PARTITION( WINAPI_FAMILY, WINAPI_PARTITION_APP ) + * + * Example: Available only to Desktop programs + * #if WINAPI_FAMILY_ONE_PARTITION( WINAPI_FAMILY, WINAPI_PARTITION_DESKTOP ) + * + * Example: Available to App, but not Desktop programs + * #if WINAPI_FAMILY_ONE_PARTITION( WINAPI_FAMILY_DESKTOP_APP, WINAPI_PARTITION_APP ) + */ + +#endif /* !_INC_WINAPIFAMILY */ diff --git a/src/org/jitsi/impl/neomedia/coreaudio/CoreAudioVolumeControl.java b/src/org/jitsi/impl/neomedia/AbstractHardwareVolumeControl.java similarity index 77% rename from src/org/jitsi/impl/neomedia/coreaudio/CoreAudioVolumeControl.java rename to src/org/jitsi/impl/neomedia/AbstractHardwareVolumeControl.java index b0b4f136858de19dbc866ced32e25314dd3cee07..8e3216bde18b3cc200a1353d69d48e7ff9f68530 100644 --- a/src/org/jitsi/impl/neomedia/coreaudio/CoreAudioVolumeControl.java +++ b/src/org/jitsi/impl/neomedia/AbstractHardwareVolumeControl.java @@ -4,27 +4,26 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package org.jitsi.impl.neomedia.coreaudio; +package org.jitsi.impl.neomedia; -import org.jitsi.impl.neomedia.*; import org.jitsi.impl.neomedia.device.*; import org.jitsi.util.*; /** - * Implementation of VolumeControl which uses MacOSX sound architecture - * CoreAudio to change input/output hardware volume. + * Abstract implementation of VolumeControl which uses system sound architecture + * to change input/output hardware volume. * * @author Vincent Lucas */ -public class CoreAudioVolumeControl +public abstract class AbstractHardwareVolumeControl extends AbstractVolumeControl { /** - * The <tt>Logger</tt> used by the <tt>CoreAudioVolumeControl</tt> class and - * its instances for logging output. + * The <tt>Logger</tt> used by the <tt>AbstractHarwareVolumeControl</tt> + * class and its instances for logging output. */ private static final Logger logger - = Logger.getLogger(CoreAudioVolumeControl.class); + = Logger.getLogger(AbstractHardwareVolumeControl.class); /** * The media service implementation. @@ -46,7 +45,7 @@ public class CoreAudioVolumeControl * property which specifies the value of the volume level of the new * instance */ - public CoreAudioVolumeControl( + public AbstractHardwareVolumeControl( MediaServiceImpl mediaServiceImpl, String volumeLevelConfigurationPropertyName) { @@ -102,11 +101,21 @@ protected void updateHardwareVolume() } // Changes the input volume of the capture device. - if(CoreAudioDevice.setInputDeviceVolume( + if(this.setInputDeviceVolume( deviceUID, hardwareVolumeLevel) != 0) { - logger.debug("Could not change CoreAudio input device level"); + logger.debug("Could not change hardware input device level"); } } + + /** + * Changes the device volume via the system API. + * + * @param deviceUID The device ID. + * @param volume The volume requested. + * + * @return 0 if everything works fine. + */ + protected abstract int setInputDeviceVolume(String deviceUID, float volume); } diff --git a/src/org/jitsi/impl/neomedia/MediaServiceImpl.java b/src/org/jitsi/impl/neomedia/MediaServiceImpl.java index 2055b523419f75574c5cc70d6191f33f63a1f796..68581caab1f7acb2cd09916ee2e5c47b3e0f2284 100644 --- a/src/org/jitsi/impl/neomedia/MediaServiceImpl.java +++ b/src/org/jitsi/impl/neomedia/MediaServiceImpl.java @@ -21,7 +21,6 @@ import org.jitsi.impl.neomedia.codec.*; import org.jitsi.impl.neomedia.codec.video.*; -import org.jitsi.impl.neomedia.coreaudio.*; import org.jitsi.impl.neomedia.device.*; import org.jitsi.impl.neomedia.format.*; import org.jitsi.impl.neomedia.transform.sdes.*; @@ -752,10 +751,21 @@ public VolumeControl getInputVolumeControl() if(OSUtils.IS_MAC) { inputVolumeControl - = new CoreAudioVolumeControl( + = new + org.jitsi.impl.neomedia.maccoreaudio.CoreAudioVolumeControl( this, VolumeControl.CAPTURE_VOLUME_LEVEL_PROPERTY_NAME); } + /*else if(OSUtils.IS_WINDOWS_VISTA + || OSUtils.IS_WINDOWS_7 + || OSUtils.IS_WINDOWS_8) + { + inputVolumeControl + = new + org.jitsi.impl.neomedia.wincoreaudio.CoreAudioVolumeControl( + this, + VolumeControl.CAPTURE_VOLUME_LEVEL_PROPERTY_NAME); + }*/ else { inputVolumeControl diff --git a/src/org/jitsi/impl/neomedia/coreaudio/CoreAudioDevice.java b/src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioDevice.java similarity index 88% rename from src/org/jitsi/impl/neomedia/coreaudio/CoreAudioDevice.java rename to src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioDevice.java index 0ed93340fe3c6c1d12b6deb6c98d57706683f759..21d7481a8a3e0794e95318d2657ac81dd68d4252 100644 --- a/src/org/jitsi/impl/neomedia/coreaudio/CoreAudioDevice.java +++ b/src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioDevice.java @@ -4,12 +4,12 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package org.jitsi.impl.neomedia.coreaudio; +package org.jitsi.impl.neomedia.maccoreaudio; import org.jitsi.util.*; /** - * JNI link to the CoreAudio library. + * JNI link to the MacOSX CoreAudio library. * * @author Vincent Lucqs */ @@ -17,7 +17,7 @@ public class CoreAudioDevice { static { - System.loadLibrary("jncoreaudio"); + System.loadLibrary("jnmaccoreaudio"); } // public static native AudioDeviceID getDevice( diff --git a/src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioVolumeControl.java b/src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioVolumeControl.java new file mode 100644 index 0000000000000000000000000000000000000000..2df72ad7fdec94cd7dafb3bea5b34853bed1b30a --- /dev/null +++ b/src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioVolumeControl.java @@ -0,0 +1,64 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jitsi.impl.neomedia.maccoreaudio; + +import org.jitsi.impl.neomedia.*; +import org.jitsi.impl.neomedia.device.*; +import org.jitsi.util.*; + +/** + * Implementation of VolumeControl which uses MacOSX sound architecture + * CoreAudio to change input/output hardware volume. + * + * @author Vincent Lucas + */ +public class CoreAudioVolumeControl + extends AbstractHardwareVolumeControl +{ + /** + * The <tt>Logger</tt> used by the <tt>CoreAudioVolumeControl</tt> class and + * its instances for logging output. + */ + private static final Logger logger + = Logger.getLogger(CoreAudioVolumeControl.class); + + /** + * Creates volume control instance and initializes initial level value + * if stored in the configuration service. + * + * @param mediaServiceImpl The media service implementation. + * @param volumeLevelConfigurationPropertyName the name of the configuration + * property which specifies the value of the volume level of the new + * instance + */ + public CoreAudioVolumeControl( + MediaServiceImpl mediaServiceImpl, + String volumeLevelConfigurationPropertyName) + { + super(mediaServiceImpl, volumeLevelConfigurationPropertyName); + } + + /** + * Changes the device volume via the system API. + * + * @param deviceUID The device ID. + * @param volume The volume requested. + * + * @return 0 if everything works fine. + */ + protected int setInputDeviceVolume(String deviceUID, float volume) + { + // Changes the input volume of the capture device. + if(CoreAudioDevice.setInputDeviceVolume(deviceUID, volume) != 0) + { + logger.debug( + "Could not change MacOsX CoreAudio input device level"); + return -1; + } + return 0; + } +} diff --git a/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioDevice.java b/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioDevice.java new file mode 100644 index 0000000000000000000000000000000000000000..3477f5ec93b453f1438be7d5cac50b6de5451b2e --- /dev/null +++ b/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioDevice.java @@ -0,0 +1,55 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jitsi.impl.neomedia.wincoreaudio; + +import org.jitsi.util.*; + +/** + * JNI link to the Windows CoreAudio library. + * + * @author Vincent Lucqs + */ +public class CoreAudioDevice +{ + static + { + System.loadLibrary("jnwincoreaudio"); + } + +// public static native AudioDeviceID getDevice( +// String deviceUID); + + public static String getDeviceName( + String deviceUID) + { + byte[] deviceNameBytes = getDeviceNameBytes(deviceUID); + String deviceName = StringUtils.newString(deviceNameBytes); + + return deviceName; + } + + public static native int initDevices(); + + public static native void freeDevices(); + + public static native byte[] getDeviceNameBytes( + String deviceUID); + + public static native int setInputDeviceVolume( + String deviceUID, + float volume); + + public static native int setOutputDeviceVolume( + String deviceUID, + float volume); + + public static native float getInputDeviceVolume( + String deviceUID); + + public static native float getOutputDeviceVolume( + String deviceUID); +} diff --git a/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioVolumeControl.java b/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioVolumeControl.java new file mode 100644 index 0000000000000000000000000000000000000000..a14c77f43c7ed6e8ca024820762645917cbcc5ec --- /dev/null +++ b/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioVolumeControl.java @@ -0,0 +1,74 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jitsi.impl.neomedia.wincoreaudio; + +import org.jitsi.impl.neomedia.*; +import org.jitsi.impl.neomedia.device.*; +import org.jitsi.util.*; + +/** + * Implementation of VolumeControl which uses Windows sound architecture + * CoreAudio to change input/output hardware volume. + * + * @author Vincent Lucas + */ +public class CoreAudioVolumeControl + extends AbstractHardwareVolumeControl +{ + /** + * The <tt>Logger</tt> used by the <tt>CoreAudioVolumeControl</tt> class and + * its instances for logging output. + */ + private static final Logger logger + = Logger.getLogger(CoreAudioVolumeControl.class); + + /** + * Creates volume control instance and initializes initial level value + * if stored in the configuration service. + * + * @param mediaServiceImpl The media service implementation. + * @param volumeLevelConfigurationPropertyName the name of the configuration + * property which specifies the value of the volume level of the new + * instance + */ + public CoreAudioVolumeControl( + MediaServiceImpl mediaServiceImpl, + String volumeLevelConfigurationPropertyName) + { + super(mediaServiceImpl, volumeLevelConfigurationPropertyName); + } + + /** + * Changes the device volume via the system API. + * + * @param deviceUID The device ID. + * @param volume The volume requested. + * + * @return 0 if everything works fine. + */ + protected int setInputDeviceVolume(String deviceUID, float volume) + { + if(CoreAudioDevice.initDevices() == -1) + { + CoreAudioDevice.freeDevices(); + logger.debug( + "Could not initialize Windows CoreAudio input devices"); + return -1; + } + // Changes the input volume of the capture device. + if(CoreAudioDevice.setInputDeviceVolume(deviceUID, volume) != 0) + { + CoreAudioDevice.freeDevices(); + logger.debug( + "Could not change Windows CoreAudio input device level"); + return -1; + } + CoreAudioDevice.freeDevices(); + + return 0; + } +} diff --git a/src/org/jitsi/util/OSUtils.java b/src/org/jitsi/util/OSUtils.java index e42a5490f5ffb9746206fdde8a529f901e407c96..dc91f95d75fc08bc4a82291197bac80284920f43 100644 --- a/src/org/jitsi/util/OSUtils.java +++ b/src/org/jitsi/util/OSUtils.java @@ -57,6 +57,9 @@ public class OSUtils /** <tt>true</tt> if OS is Windows 7. */ public static final boolean IS_WINDOWS_7; + /** <tt>true</tt> if OS is Windows 8. */ + public static final boolean IS_WINDOWS_8; + /** <tt>true</tt> if OS is FreeBSD. */ public static final boolean IS_FREEBSD; @@ -73,6 +76,7 @@ public class OSUtils IS_WINDOWS = false; IS_WINDOWS_VISTA = false; IS_WINDOWS_7 = false; + IS_WINDOWS_8 = false; IS_FREEBSD = false; } else if (osName.startsWith("Linux")) @@ -93,6 +97,7 @@ else if (osName.startsWith("Linux")) IS_WINDOWS = false; IS_WINDOWS_VISTA = false; IS_WINDOWS_7 = false; + IS_WINDOWS_8 = false; IS_FREEBSD = false; } else if (osName.startsWith("Mac")) @@ -103,6 +108,7 @@ else if (osName.startsWith("Mac")) IS_WINDOWS = false; IS_WINDOWS_VISTA = false; IS_WINDOWS_7 = false; + IS_WINDOWS_8 = false; IS_FREEBSD = false; } else if (osName.startsWith("Windows")) @@ -113,6 +119,7 @@ else if (osName.startsWith("Windows")) IS_WINDOWS = true; IS_WINDOWS_VISTA = (osName.indexOf("Vista") != -1); IS_WINDOWS_7 = (osName.indexOf("7") != -1); + IS_WINDOWS_8 = (osName.indexOf("8") != -1); IS_FREEBSD = false; } else if (osName.startsWith("FreeBSD")) @@ -123,6 +130,7 @@ else if (osName.startsWith("FreeBSD")) IS_WINDOWS = false; IS_WINDOWS_VISTA = false; IS_WINDOWS_7 = false; + IS_WINDOWS_8 = false; IS_FREEBSD = true; } else @@ -133,6 +141,7 @@ else if (osName.startsWith("FreeBSD")) IS_WINDOWS = false; IS_WINDOWS_VISTA = false; IS_WINDOWS_7 = false; + IS_WINDOWS_8 = false; IS_FREEBSD = false; }