Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
23 changes: 23 additions & 0 deletions audio/Soundwire/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The Microsoft Public License (MS-PL)
Copyright (c) 2015 Microsoft

This license governs use of the accompanying software. If you use the software, you
accept this license. If you do not accept the license, do not use the software.

1. Definitions
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the
same meaning here as under U.S. copyright law.
A "contribution" is the original software, or any additions or changes to the software.
A "contributor" is any person that distributes its contribution under this license.
"Licensed patents" are a contributor's patent claims that read directly on its contribution.

2. Grant of Rights
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.

3. Conditions and Limitations
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
2 changes: 2 additions & 0 deletions audio/Soundwire/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Soundwire
Microsoft Soundwire Samples and Guides
337 changes: 337 additions & 0 deletions audio/Soundwire/Samples/SdcaVad/Apo/inc/CommonMacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
//**@@@*@@@****************************************************
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//**@@@*@@@****************************************************

//
// FileName: CommonMacros.h
//
// Abstract: Useful macros
//
// ----------------------------------------------------------------------------


#pragma once
#include <windef.h>
#include <windows.h>


//-------------------------------------------------------------------------
// Description:
//
// If the condition evaluates to TRUE, jump to the given label.
//
// Parameters:
//
// condition - [in] code that fits in if statement
// label - [in] label to jump if condition is met
//
#define IF_TRUE_JUMP(condition, label) \
if (condition) \
{ \
goto label; \
}

//-------------------------------------------------------------------------
// Description:
//
// If the condition evaluates to FALSE, jump to the given label.
//
// Parameters:
//
// condition - [in] code that fits in if statement
// label - [in] label to jump if condition is met
//
#define IF_FALSE_JUMP(condition, label) \
if (!condition) \
{ \
goto label; \
}

//-------------------------------------------------------------------------
// Description:
//
// If the hresult passed FAILED, jump to the given label.
//
// Parameters:
//
// _hresult - [in] Value to check
// label - [in] label to jump if condition is met
//
#define IF_FAILED_JUMP(_hresult, label) \
if (FAILED(_hresult)) \
{ \
goto label; \
}

//-------------------------------------------------------------------------
// Description:
//
// If the hresult passed SUCCEEDED, jump to the given label.
//
// Parameters:
//
// _hresult - [in] Value to check
// label - [in] label to jump if condition is met
//
#define IF_SUCCEEDED_JUMP(_hresult, label) \
if (SUCCEEDED(_hresult)) \
{ \
goto label; \
}

//-------------------------------------------------------------------------
// Description:
//
// If the condition evaluates to TRUE, perform the given statement
// then jump to the given label.
//
// Parameters:
//
// condition - [in] Code that fits in if statement
// action - [in] action to perform in body of if statement
// label - [in] label to jump if condition is met
//
#define IF_TRUE_ACTION_JUMP(condition, action, label) \
if (condition) \
{ \
action; \
goto label; \
}

//-------------------------------------------------------------------------
// Description:
//
// If the hresult FAILED, perform the given statement then jump to
// the given label.
//
// Parameters:
//
// _hresult - [in] Value to check
// action - [in] action to perform in body of if statement
// label - [in] label to jump if condition is met
//
#define IF_FAILED_ACTION_JUMP(_hresult, action, label) \
if (FAILED(_hresult)) \
{ \
action; \
goto label; \
}

//-------------------------------------------------------------------------
// Description:
//
// Closes a handle and assigns NULL.
//
// Parameters:
//
// h - [in] handle to close
//
#define SAFE_CLOSE_HANDLE(h) \
if (NULL != h) \
{ \
CloseHandle(h); \
h = NULL; \
}

//-------------------------------------------------------------------------
// Description:
//
// Addref an interface pointer
//
// Parameters:
//
// p - [in] object to addref
//
#define SAFE_ADDREF(p) \
if (NULL != p) \
{ \
(p)->AddRef();; \
}

//-------------------------------------------------------------------------
// Description:
//
// Releases an interface pointer and assigns NULL.
//
// Parameters:
//
// p - [in] object to release
//
#define SAFE_RELEASE(p) \
if (NULL != p) \
{ \
(p)->Release(); \
(p) = NULL; \
}

//-------------------------------------------------------------------------
// Description:
//
// Deletes a pointer and assigns NULL. Do not check for NULL because
// the default delete operator checks for it.
//
// Parameters:
//
// p - [in] object to delete
//
#define SAFE_DELETE(p) \
delete p; \
p = NULL;

//-------------------------------------------------------------------------
// Description:
//
// Deletes an array pointer and assigns NULL. Do not check for NULL because
// the default delete operator checks for it.
//
// Parameters:
//
// p - [in] Array to delete
//
#define SAFE_DELETE_ARRAY(p) \
delete [] p; \
p = NULL;

//-------------------------------------------------------------------------
// Description:
//
// Frees a block of memory allocated by CoTaskMemAlloc and assigns NULL to
// the pointer
//
// Parameters:
//
// p - [in] Pointer to memory to free
//
#define SAFE_COTASKMEMFREE(p) \
if (NULL != p) \
{ \
CoTaskMemFree(p); \
(p) = NULL; \
}

//-------------------------------------------------------------------------
// Description:
//
// Frees a DLL loaded with LoadLibrary and assigns NULL to the handle
//
// Parameters:
//
// h - [in] Handle to DLL to free
//
#define SAFE_FREELIBRARY(h) \
if (NULL != h) \
{ \
FreeLibrary(h); \
(h) = NULL; \
}

//-------------------------------------------------------------------------
// Description:
//
// Used to validate a read pointer
//
// Parameters:
//
// p - [in] read pointer.
// s - [in] size of memory in bytes pointed to by p.
//
#define IS_VALID_READ_POINTER(p, s) ((NULL != p) || (0 == s))

//-------------------------------------------------------------------------
// Description:
//
// Used to validate a write pointer
//
// Parameters:
//
// p - [in] write pointer.
// s - [in] size of memory in bytes pointed to by p.
//
#define IS_VALID_WRITE_POINTER(p, s) ((NULL != p) || (0 == s))

//-------------------------------------------------------------------------
// Description:
//
// Used to validate a read pointer of a particular type
//
// Parameters:
//
// p - [in] typed read pointer
//
#define IS_VALID_TYPED_READ_POINTER(p) IS_VALID_READ_POINTER((p), sizeof *(p))

//-------------------------------------------------------------------------
// Description:
//
// Used to validate a write pointer of a particular type
//
// Parameters:
//
// p - [in] typed write pointer
//
#define IS_VALID_TYPED_WRITE_POINTER(p) IS_VALID_WRITE_POINTER((p), sizeof *(p))

// ---------------------------------------------------------------------------
// Macros that wrap windows messages. Similar to those in windowsX.h and
// commctrl.h
//
#if !defined Static_SetIcon
#define Static_SetIcon(hwnd, hi) \
(BOOL)SNDMSG((hwnd), STM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)(hi))
#endif

#define TrackBar_SetTickFrequency(hwnd, f) \
(BOOL)SNDMSG((hwnd), TBM_SETTICFREQ, (WPARAM)(f), 0)

#define TrackBar_SetBuddy(hwnd, f, hbud) \
(HWND)SNDMSG((hwnd), TBM_SETBUDDY, (WPARAM)(f), (LPARAM)hbud)

#define TrackBar_GetPos(hwnd) \
(int)SNDMSG((hwnd), TBM_GETPOS, 0, 0)

#define TrackBar_SetPos(hwnd, pos) \
SNDMSG((hwnd), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)pos)

#define TrackBar_SetRange(hwnd, min, max) \
SNDMSG((hwnd), TBM_SETRANGE , (WPARAM)TRUE, (LPARAM) MAKELONG(min, max))

#define TrackBar_SetThumbLength(hwnd, l) \
SNDMSG((hwnd), TBM_SETTHUMBLENGTH, (WPARAM)l, 0);

#define TrackBar_SetPageSize(hwnd, n) \
SNDMSG((hwnd), TBM_SETPAGESIZE, 0, (LPARAM)n)

#define Window_GetFont(hwnd) \
(HFONT)SNDMSG((hwnd), WM_GETFONT, 0, 0)

#define Window_SetFont(hwnd, font) \
SNDMSG((hwnd), WM_SETFONT, (WPARAM)font, FALSE)


// ----------------------------------------------------------------------
// A struct for holding a rect in easier terms than a RECT struct
//
struct SRECT
{
int x, y, w, h;
SRECT()
{
x = y = w = h = 0;
}
SRECT(int X, int Y, int W, int H)
{
x = X; y = Y; w = W; h = H;
}
SRECT(RECT* prc)
{
x = prc->left;
y = prc->top;
w = prc->right - prc->left;
h = prc->bottom - prc->top;
}
};

#define HNS_PER_SECOND (10ull * 1000ull * 1000ull)
Loading
Loading