From 8d0e18f87b2068f62c60efb79b1034731dcd16c3 Mon Sep 17 00:00:00 2001
From: Etienne Dechamps
Date: Sun, 25 Nov 2018 13:54:22 +0000
Subject: [PATCH 001/157] Get rid of the garbage testcvs/ directory.
---
testcvs/changeme.txt | 21 ---------------------
testcvs/file1.txt | 9 ---------
testcvs/file2.txt | 9 ---------
3 files changed, 39 deletions(-)
delete mode 100644 testcvs/changeme.txt
delete mode 100644 testcvs/file1.txt
delete mode 100644 testcvs/file2.txt
diff --git a/testcvs/changeme.txt b/testcvs/changeme.txt
deleted file mode 100644
index 48904b7..0000000
--- a/testcvs/changeme.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-This is just a dopy little file used to test the source code repository.
-Feel free to trash this file.
-Minor change.
-Another tweak.
-philburk tweak
-stephane test
-Phil changed this again on 2/21/02. Yawn...
-Bjorn test3!
-Phil tried to change this on 5/13/08
-Now we are using SVN instead of CVS. PB 2/10/10
-Test from builder-pc
-
-make a change using SVN on Ubuntu
-tweak
-testing
-
-PLB changing it to see if SVN broken
-Testing from Ubuntu with SVN on Assembla.
-
-5/2/2016 - Now using Git!
-
diff --git a/testcvs/file1.txt b/testcvs/file1.txt
deleted file mode 100644
index a900ec6..0000000
--- a/testcvs/file1.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-This is used to test the SVN versioning system.
-
- $Revision$
- $Author$
- $Date$
- $Id$
-
-After propset svn:keywords
-
diff --git a/testcvs/file2.txt b/testcvs/file2.txt
deleted file mode 100644
index a900ec6..0000000
--- a/testcvs/file2.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-This is used to test the SVN versioning system.
-
- $Revision$
- $Author$
- $Date$
- $Id$
-
-After propset svn:keywords
-
From f269bf93e6ccbfef5b1221e2c3839d84dd008138 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Tue, 14 May 2019 07:36:24 +1000
Subject: [PATCH 002/157] follow up fix related to 933b05c331 (ticket #263
uninitialized dir variable): fix the three other places where dir parameter
wasn't set prior to entry to a snd_pcm_*_get_* function. There is some
ambiguity about (a) whether this is intentional (i.e. use the rounding dir
returned by previous *_get_* call, the PA source code does not indicate), and
(b) whether it is meaningful (i.e. whether *_get_* functions actually use the
value upon input -- the ALSA docs are not clear. regarding (a): I don't think
it's intentional, i think it was just oversight. In any case thr risk is low:
the underlying values of period_size, periods_max, periods_min, are all
integer and should not be rounded, get_rate_min/get_rate_max are used only
for debug reporting (I've set them to 0,0 for a minimal change from the
current code, but -1,1 makes more sense).
---
src/hostapi/alsa/pa_linux_alsa.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c
index 584cde8..e600821 100644
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -323,8 +323,10 @@ int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_buffer_size_max) (const snd_pcm_hw_para
snd_pcm_uframes_t pmax = 0;
unsigned int pcnt = 0;
+ dir = 0;
if(( ret = _PA_LOCAL_IMPL(snd_pcm_hw_params_get_period_size_max)(params, &pmax, &dir) ) < 0 )
return ret;
+ dir = 0;
if(( ret = _PA_LOCAL_IMPL(snd_pcm_hw_params_get_periods_max)(params, &pcnt, &dir) ) < 0 )
return ret;
@@ -2324,6 +2326,7 @@ static PaError PaAlsaStreamComponent_DetermineFramesPerBuffer( PaAlsaStreamCompo
/* It may be that the device only supports 2 periods for instance */
dir = 0;
ENSURE_( alsa_snd_pcm_hw_params_get_periods_min( hwParams, &minPeriods, &dir ), paUnanticipatedHostError );
+ dir = 0;
ENSURE_( alsa_snd_pcm_hw_params_get_periods_max( hwParams, &maxPeriods, &dir ), paUnanticipatedHostError );
assert( maxPeriods > 1 );
@@ -3209,6 +3212,7 @@ error:
unsigned int _min = 0, _max = 0;
int _dir = 0;
ENSURE_( alsa_snd_pcm_hw_params_get_rate_min( hwParams, &_min, &_dir ), paUnanticipatedHostError );
+ _dir = 0;
ENSURE_( alsa_snd_pcm_hw_params_get_rate_max( hwParams, &_max, &_dir ), paUnanticipatedHostError );
PA_DEBUG(( "%s: SR min = %u, max = %u, req = %u\n", __FUNCTION__, _min, _max, reqRate ));
}
From 799a6834a58592eadc5712cba73b35956dc51579 Mon Sep 17 00:00:00 2001
From: dmitrykos
Date: Thu, 26 Mar 2020 20:05:53 +0200
Subject: [PATCH 003/157] wasapi: Fixed OSVERSIONINFO initialization (patch
provided by Carlo Bramini).
---
src/hostapi/wasapi/pa_win_wasapi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index 1d8f200..f4b3186 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -1081,7 +1081,7 @@ static EWindowsVersion GetWindowsVersion()
// by GetVersion API)
if ((fnRtlGetVersion = (LPFN_RTLGETVERSION)GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion")) != NULL)
{
- OSVERSIONINFOW ver = { sizeof(OSVERSIONINFOW), 0, 0, 0, {0} };
+ OSVERSIONINFOW ver = { sizeof(OSVERSIONINFOW), 0, 0, 0, 0, {0} };
PRINT(("WASAPI: getting Windows version with RtlGetVersion()\n"));
From 7273b8de2755902aa1123fd15a9e53b3ca469159 Mon Sep 17 00:00:00 2001
From: Phil Burk
Date: Wed, 23 Sep 2020 20:36:04 -0700
Subject: [PATCH 004/157] Update and rename README.txt to README.md
Use markdown
---
README.txt => README.md | 60 +++++++++--------------------------------
1 file changed, 12 insertions(+), 48 deletions(-)
rename README.txt => README.md (54%)
diff --git a/README.txt b/README.md
similarity index 54%
rename from README.txt
rename to README.md
index 2113827..fde4556 100644
--- a/README.txt
+++ b/README.md
@@ -1,42 +1,4 @@
-README for PortAudio
-
-/*
- * PortAudio Portable Real-Time Audio Library
- * Latest Version at: http://www.portaudio.com
- *
- * Copyright (c) 1999-2008 Phil Burk and Ross Bencina
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * The text above constitutes the entire PortAudio license; however,
- * the PortAudio community also makes the following non-binding requests:
- *
- * Any person wishing to distribute modifications to the Software is
- * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
- * license above.
- */
-
+# PortAudio - portable audio I/O library
PortAudio is a portable audio I/O library designed for cross-platform
support of audio. It uses either a callback mechanism to request audio
@@ -45,12 +7,12 @@ native audio subsystem and the client. Audio can be processed in various
formats, including 32 bit floating point, and will be converted to the
native format internally.
-Documentation:
- Documentation is available in "/doc/html/index.html"
- Also see "src/common/portaudio.h" for API spec.
- Also see http://www.portaudio.com/docs/
- And see the "test/" directory for many examples of usage
- (we suggest "test/patest_saw.c" for an example)
+## Documentation:
+
+* Documentation is available in "/doc/html/index.html"
+* Also see "src/common/portaudio.h" for API spec.
+* Also see http://www.portaudio.com/docs/
+* And see the "test/" directory for many examples of usage. (we suggest "test/patest_saw.c" for an example)
For information on compiling programs with PortAudio, please see the
tutorial at:
@@ -60,8 +22,8 @@ tutorial at:
We have an active mailing list for user and developer discussions.
Please feel free to join. See http://www.portaudio.com for details.
+## Important Files and Folders:
-Important Files and Folders:
include/portaudio.h = header file for PortAudio API. Specifies API.
src/common/ = platform independant code, host independant
code for all implementations.
@@ -69,7 +31,8 @@ Important Files and Folders:
src/hostapi = implementations for different host apis
-Host API Implementations:
+### Host API Implementations:
+
src/hostapi/alsa = Advanced Linux Sound Architecture (ALSA)
src/hostapi/asihpi = AudioScience HPI
src/hostapi/asio = ASIO for Windows and Macintosh
@@ -82,7 +45,8 @@ Host API Implementations:
src/hostapi/wmme = Windows MultiMedia Extensions (MME)
-Test Programs:
+### Test Programs:
+
test/pa_fuzz.c = guitar fuzz box
test/pa_devs.c = print a list of available devices
test/pa_minlat.c = determine minimum latency for your machine
From ffa556a4750707518f55a906bf856e6d984a0ba9 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 24 Sep 2020 14:11:42 +1000
Subject: [PATCH 005/157] Fix doc and examples references in README.md
---
README.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index fde4556..919ab31 100644
--- a/README.md
+++ b/README.md
@@ -9,10 +9,10 @@ native format internally.
## Documentation:
-* Documentation is available in "/doc/html/index.html"
-* Also see "src/common/portaudio.h" for API spec.
-* Also see http://www.portaudio.com/docs/
-* And see the "test/" directory for many examples of usage. (we suggest "test/patest_saw.c" for an example)
+* Documentation is available at http://www.portaudio.com/docs/
+* Or at `/doc/html/index.html` after running Doxygen.
+* Also see `src/common/portaudio.h` for the API spec.
+* And see the `examples/` and `test/` directories for many examples of usage. (We suggest `examples/paex_saw.c` for an example.)
For information on compiling programs with PortAudio, please see the
tutorial at:
From e1443bae258f16c69b22b5054f275676f76a3873 Mon Sep 17 00:00:00 2001
From: Ingo Bauersachs
Date: Sun, 27 Sep 2020 00:02:53 +0200
Subject: [PATCH 006/157] Fix CMake build after renaming readme
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1024016..4fbb3a8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -441,7 +441,7 @@ IF(NOT PA_OUTPUT_OSX_FRAMEWORK AND NOT PA_DISABLE_INSTALL)
VERSION ${PA_VERSION}
COMPATIBILITY SameMajorVersion)
CONFIGURE_FILE(cmake_support/portaudio-2.0.pc.in ${CMAKE_CURRENT_BINARY_DIR}/portaudio-2.0.pc @ONLY)
- INSTALL(FILES README.txt DESTINATION share/doc/portaudio)
+ INSTALL(FILES README.md DESTINATION share/doc/portaudio)
INSTALL(FILES LICENSE.txt DESTINATION share/doc/portaudio)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/portaudio-2.0.pc DESTINATION lib/pkgconfig)
INSTALL(FILES ${PA_PUBLIC_INCLUDES} DESTINATION include)
From 9ebe293dc5e9b929852acdbdaa310caee1bdc3e6 Mon Sep 17 00:00:00 2001
From: Svein Seldal
Date: Sun, 27 Sep 2020 18:28:19 +0200
Subject: [PATCH 007/157] Implement fix for glitching WASAPI playback #303
---
src/hostapi/wasapi/pa_win_wasapi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index f4b3186..7354f8a 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -5764,6 +5764,7 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
// Calculate timeout for next polling attempt.
sleep_ms_in = GetFramesSleepTime(stream->in.framesPerHostCallback / WASAPI_PACKETS_PER_INPUT_BUFFER, stream->in.wavex.Format.nSamplesPerSec);
sleep_ms_out = GetFramesSleepTime(stream->out.framesPerBuffer, stream->out.wavex.Format.nSamplesPerSec);
+ sleep_ms_out /= 2; // wait only for half of the buffer
// WASAPI Input packets tend to expire very easily, let's limit sleep time to 2 milliseconds
// for all cases. Please propose better solution if any.
@@ -5776,6 +5777,7 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
{
//sleep_ms_in = GetFramesSleepTime((stream->bufferProcessor.framesPerUserBuffer ? stream->bufferProcessor.framesPerUserBuffer : stream->in.params.frames_per_buffer), stream->in.wavex.Format.nSamplesPerSec);
sleep_ms_out = GetFramesSleepTime((stream->bufferProcessor.framesPerUserBuffer ? stream->bufferProcessor.framesPerUserBuffer : stream->out.params.frames_per_buffer), stream->out.wavex.Format.nSamplesPerSec);
+ sleep_ms_out /= 2; // wait only for half of the buffer
}
// Choose smallest
@@ -5789,6 +5791,7 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
{
sleep_ms_in = GetFramesSleepTimeMicroseconds(stream->in.framesPerHostCallback / WASAPI_PACKETS_PER_INPUT_BUFFER, stream->in.wavex.Format.nSamplesPerSec);
sleep_ms_out = GetFramesSleepTimeMicroseconds((stream->bufferProcessor.framesPerUserBuffer ? stream->bufferProcessor.framesPerUserBuffer : stream->out.params.frames_per_buffer), stream->out.wavex.Format.nSamplesPerSec);
+ sleep_ms_out /= 2; // wait only for half of the buffer
// Choose smallest
if ((sleep_ms_in != 0) && (sleep_ms_out != 0))
From df4e0bf4052eddbe4a0e09ca751c18597df852f9 Mon Sep 17 00:00:00 2001
From: Phil Burk
Date: Thu, 24 Sep 2020 10:55:57 -0700
Subject: [PATCH 008/157] Create c-cpp.yml
Add continuous integration build test.
---
.github/workflows/c-cpp.yml | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 .github/workflows/c-cpp.yml
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
new file mode 100644
index 0000000..10ecb69
--- /dev/null
+++ b/.github/workflows/c-cpp.yml
@@ -0,0 +1,19 @@
+name: C/C++ CI
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: configure
+ run: ./configure
+ - name: make
+ run: make
From 2a1b7d4ad6546b1f6075226001d7d99c445fb935 Mon Sep 17 00:00:00 2001
From: Phil Burk
Date: Mon, 28 Sep 2020 07:40:34 -0700
Subject: [PATCH 009/157] Add bug report template
---
.github/ISSUE_TEMPLATE/bug_report.md | 34 ++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..7870a2e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,34 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+(Please use the mailing list for general discussion. This is only for actual bugs.)
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior. Include code if applicable.
+1.
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Actual behavior**
+What actually happened.
+Include a recording if helpful.
+Error messages or logs longer than a page should be attached as a .txt file.
+
+**Desktop (please complete the following information):**
+ - OS: [e.g. iOS]
+ - OS Version [e.g. 22]
+ - PortAudio: stable or current
+ - If Windows, which API:
+
+**Additional context**
+Add any other context about the problem here.
From 8119355f76247f95883ae0940b579877e82de17d Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 1 Oct 2020 10:38:48 +1000
Subject: [PATCH 010/157] Update bug_report.md with more details
---
.github/ISSUE_TEMPLATE/bug_report.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 7870a2e..794c5e9 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -7,7 +7,7 @@ assignees: ''
---
-(Please use the mailing list for general discussion. This is only for actual bugs.)
+(Please use the mailing list for support requests and general discussion. This is only for actual bugs.)
**Describe the bug**
A clear and concise description of what the bug is.
@@ -25,10 +25,10 @@ Include a recording if helpful.
Error messages or logs longer than a page should be attached as a .txt file.
**Desktop (please complete the following information):**
- - OS: [e.g. iOS]
+ - OS: [e.g. Mac OS]
- OS Version [e.g. 22]
- - PortAudio: stable or current
- - If Windows, which API:
+ - PortAudio version: stable, nightly snapshot (which?), current (please give date and/or Git hash):
+ - If Windows or Linux, which Host API (e.g. WASAPI):
**Additional context**
Add any other context about the problem here.
From 519364b9a59184a2b55def8141a692a439dbdb21 Mon Sep 17 00:00:00 2001
From: Tatsuya Matsumoto
Date: Sat, 3 Oct 2020 22:19:10 +0900
Subject: [PATCH 011/157] Fix a broken link (Tutorial Start) in README.md.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 919ab31..74cfe6f 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ native format internally.
For information on compiling programs with PortAudio, please see the
tutorial at:
- http://portaudio.com/trac/wiki/TutorialDir/TutorialStart
+ http://portaudio.com/docs/v19-doxydocs/tutorial_start.html
We have an active mailing list for user and developer discussions.
Please feel free to join. See http://www.portaudio.com for details.
From 697fcddce5e9f1307711489f5b47b15c139c5e12 Mon Sep 17 00:00:00 2001
From: dmitrykos
Date: Wed, 30 Sep 2020 12:55:28 +0300
Subject: [PATCH 012/157] wasapi: Improve stability of playback in Polling
Shared mode with a low host latency requsted (22 ms):
- Implement workaround for system timer coarse granularity causing underruns by using timeBeginPeriod/timeEndPeriod APIs inside the Event and Poll thread handlers.
- Update next sleep time of the Poll rendering loop dynamically depending on time taken for processing/rendering of audio data into the available host buffer to avoid underruns and fit processing time into periodic polling time slots.
- Add support for time slots logging in Poll mode if PA_WASAPI_LOG_TIME_SLOTS is defined. Fixed audible glitches by preloading the whole host buffer before stream is started.
- Fix audible glitches on stream start by preloading the whole host buffer before stream is started.
---
src/hostapi/wasapi/pa_win_wasapi.c | 601 +++++++++++++++--------------
1 file changed, 317 insertions(+), 284 deletions(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index 7354f8a..17846bd 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -61,6 +61,9 @@
// not change the Event mode to Polling and use the mode which user provided.
//#define PA_WASAPI_FORCE_POLL_IF_LARGE_BUFFER
+//! Poll mode time slots logging.
+//#define PA_WASAPI_LOG_TIME_SLOTS
+
// WinRT
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
#define PA_WINRT
@@ -741,6 +744,7 @@ typedef struct ThreadIdleScheduler
UINT32 m_resolution; //!< resolution in number of milliseconds
}
ThreadIdleScheduler;
+
//! Setup scheduler.
static void ThreadIdleScheduler_Setup(ThreadIdleScheduler *sched, UINT32 resolution, UINT32 microseconds)
{
@@ -754,11 +758,12 @@ static void ThreadIdleScheduler_Setup(ThreadIdleScheduler *sched, UINT32 resolut
sched->m_resolution = resolution;
sched->m_next_sleep = (resolution * 1000) / microseconds;
}
+
//! Iterate and check if can sleep.
-static UINT32 ThreadIdleScheduler_NextSleep(ThreadIdleScheduler *sched)
+static inline UINT32 ThreadIdleScheduler_NextSleep(ThreadIdleScheduler *sched)
{
// advance and check if thread can sleep
- if (++ sched->m_i == sched->m_next_sleep)
+ if (++sched->m_i == sched->m_next_sleep)
{
sched->m_i = 0;
return sched->m_resolution;
@@ -766,6 +771,81 @@ static UINT32 ThreadIdleScheduler_NextSleep(ThreadIdleScheduler *sched)
return 0;
}
+// ------------------------------------------------------------------------------------------
+typedef struct _SystemTimer
+{
+ UINT32 granularity;
+
+} SystemTimer;
+static LARGE_INTEGER g_SystemTimerFrequency;
+static BOOL g_SystemTimerUseQpc = FALSE;
+
+//! Set granularity of the system timer.
+static BOOL SystemTimer_SetGranularity(SystemTimer *timer, UINT32 granularity)
+{
+#ifndef PA_WINRT
+ TIMECAPS caps;
+
+ timer->granularity = granularity;
+
+ if (timeGetDevCaps(&caps, sizeof(caps)) == MMSYSERR_NOERROR)
+ {
+ if (timer->granularity < caps.wPeriodMin)
+ timer->granularity = caps.wPeriodMin;
+ }
+
+ if (timeBeginPeriod(timer->granularity) != TIMERR_NOERROR)
+ {
+ PRINT(("SetSystemTimer: timeBeginPeriod(1) failed!\n"));
+
+ timer->granularity = 0;
+ return FALSE;
+ }
+#endif
+
+ return TRUE;
+}
+
+//! Restore granularity of the system timer.
+static void SystemTimer_RestoreGranularity(SystemTimer *timer)
+{
+#ifndef PA_WINRT
+ if (timer->granularity != 0)
+ {
+ if (timeEndPeriod(timer->granularity) != TIMERR_NOERROR)
+ {
+ PRINT(("RestoreSystemTimer: timeEndPeriod(1) failed!\n"));
+ }
+ }
+#endif
+}
+
+//! Initialize high-resolution time getter.
+static void SystemTimer_InitializeTimeGetter()
+{
+ g_SystemTimerUseQpc = QueryPerformanceFrequency(&g_SystemTimerFrequency);
+}
+
+//! Get high-resolution time in milliseconds (using QPC by default).
+static inline LONGLONG SystemTimer_GetTime(SystemTimer *timer)
+{
+ // QPC: https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
+ if (g_SystemTimerUseQpc)
+ {
+ LARGE_INTEGER now;
+ QueryPerformanceCounter(&now);
+ return (now.QuadPart * 1000LL) / g_SystemTimerFrequency.QuadPart;
+ }
+ else
+ {
+ #ifdef PA_WINRT
+ return GetTickCount64();
+ #else
+ return timeGetTime();
+ #endif
+ }
+}
+
// ------------------------------------------------------------------------------------------
/*static double nano100ToMillis(REFERENCE_TIME ref)
{
@@ -2140,6 +2220,9 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
// Detect if platform workaround is required
paWasapi->useWOW64Workaround = UseWOW64Workaround();
+ // Initialize time getter
+ SystemTimer_InitializeTimeGetter();
+
PaUtil_InitializeStreamInterface( &paWasapi->callbackStreamInterface, CloseStream, StartStream,
StopStream, AbortStream, IsStreamStopped, IsStreamActive,
GetStreamTime, GetStreamCpuLoad,
@@ -5507,19 +5590,9 @@ void _StreamOnStop(PaWasapiStream *stream)
}
// ------------------------------------------------------------------------------------------
-PA_THREAD_FUNC ProcThreadEvent(void *param)
+static BOOL PrepareComPointers(PaWasapiStream *stream, BOOL *threadComInitialized)
{
- PaWasapiHostProcessor processor[S_COUNT];
HRESULT hr;
- DWORD dwResult;
- PaWasapiStream *stream = (PaWasapiStream *)param;
- PaWasapiHostProcessor defaultProcessor;
- BOOL set_event[S_COUNT] = { FALSE, FALSE };
- BOOL bWaitAllEvents = FALSE;
- BOOL bThreadComInitialized = FALSE;
-
- // Notify: state
- NotifyStateChanged(stream, paWasapiStreamStateThreadPrepare, ERROR_SUCCESS);
/*
If COM is already initialized CoInitialize will either return
@@ -5532,22 +5605,61 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
if (FAILED(hr) && (hr != RPC_E_CHANGED_MODE))
{
PRINT(("WASAPI: failed ProcThreadEvent CoInitialize"));
- return (UINT32)paUnanticipatedHostError;
+ return FALSE;
}
if (hr != RPC_E_CHANGED_MODE)
- bThreadComInitialized = TRUE;
+ *threadComInitialized = TRUE;
// Unmarshal stream pointers for safe COM operation
hr = UnmarshalStreamComPointers(stream);
- if (hr != S_OK) {
- PRINT(("Error unmarshaling stream COM pointers. HRESULT: %i\n", hr));
- goto thread_end;
+ if (hr != S_OK)
+ {
+ PRINT(("WASAPI: Error unmarshaling stream COM pointers. HRESULT: %i\n", hr));
+ CoUninitialize();
+ return FALSE;
}
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------------------------
+static void FinishComPointers(PaWasapiStream *stream, BOOL threadComInitialized)
+{
+ // Release unmarshaled COM pointers
+ ReleaseUnmarshaledComPointers(stream);
+
+ // Cleanup COM for this thread
+ if (threadComInitialized == TRUE)
+ CoUninitialize();
+}
+
+// ------------------------------------------------------------------------------------------
+PA_THREAD_FUNC ProcThreadEvent(void *param)
+{
+ PaWasapiHostProcessor processor[S_COUNT];
+ HRESULT hr;
+ DWORD dwResult;
+ PaWasapiStream *stream = (PaWasapiStream *)param;
+ PaWasapiHostProcessor defaultProcessor;
+ BOOL setEvent[S_COUNT] = { FALSE, FALSE };
+ BOOL waitAllEvents = FALSE;
+ BOOL threadComInitialized = FALSE;
+ SystemTimer timer;
+
+ // Notify: state
+ NotifyStateChanged(stream, paWasapiStreamStateThreadPrepare, ERROR_SUCCESS);
+
+ // Prepare COM pointers
+ if (!PrepareComPointers(stream, &threadComInitialized))
+ return (UINT32)paUnanticipatedHostError;
+
+ // Request fine (1 ms) granularity of the system timer functions for precise operation of waitable timers
+ SystemTimer_SetGranularity(&timer, 1);
+
// Waiting on all events in case of Full-Duplex/Exclusive mode.
if ((stream->in.clientProc != NULL) && (stream->out.clientProc != NULL))
{
- bWaitAllEvents = (stream->in.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) &&
+ waitAllEvents = (stream->in.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) &&
(stream->out.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE);
}
@@ -5564,12 +5676,12 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
if (stream->event[S_OUTPUT] == NULL)
{
stream->event[S_OUTPUT] = CreateEvent(NULL, FALSE, FALSE, NULL);
- set_event[S_OUTPUT] = TRUE;
+ setEvent[S_OUTPUT] = TRUE;
}
if (stream->event[S_INPUT] == NULL)
{
stream->event[S_INPUT] = CreateEvent(NULL, FALSE, FALSE, NULL);
- set_event[S_INPUT] = TRUE;
+ setEvent[S_INPUT] = TRUE;
}
if ((stream->event[S_OUTPUT] == NULL) || (stream->event[S_INPUT] == NULL))
{
@@ -5581,7 +5693,7 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
if (stream->in.clientProc)
{
// Create & set handle
- if (set_event[S_INPUT])
+ if (setEvent[S_INPUT])
{
if ((hr = IAudioClient_SetEventHandle(stream->in.clientProc, stream->event[S_INPUT])) != S_OK)
{
@@ -5602,7 +5714,7 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
if (stream->out.clientProc)
{
// Create & set handle
- if (set_event[S_OUTPUT])
+ if (setEvent[S_OUTPUT])
{
if ((hr = IAudioClient_SetEventHandle(stream->out.clientProc, stream->event[S_OUTPUT])) != S_OK)
{
@@ -5640,7 +5752,7 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
for (;;)
{
// 10 sec timeout (on timeout stream will auto-stop when processed by WAIT_TIMEOUT case)
- dwResult = WaitForMultipleObjects(S_COUNT, stream->event, bWaitAllEvents, 10*1000);
+ dwResult = WaitForMultipleObjects(S_COUNT, stream->event, waitAllEvents, 10*1000);
// Check for close event (after wait for buffers to avoid any calls to user
// callback when hCloseRequest was set)
@@ -5691,11 +5803,10 @@ thread_end:
_StreamOnStop(stream);
// Release unmarshaled COM pointers
- ReleaseUnmarshaledComPointers(stream);
+ FinishComPointers(stream, threadComInitialized);
- // Cleanup COM for this thread
- if (bThreadComInitialized == TRUE)
- CoUninitialize();
+ // Restore system timer granularity
+ SystemTimer_RestoreGranularity(&timer);
// Notify: not running
stream->running = FALSE;
@@ -5717,6 +5828,105 @@ thread_error:
goto thread_end;
}
+// ------------------------------------------------------------------------------------------
+static UINT32 GetSleepTime(PaWasapiStream *stream, UINT32 sleepTimeIn, UINT32 sleepTimeOut, UINT32 userFramesOut)
+{
+ UINT32 sleepTime;
+
+ // According to the issue [https://github.com/PortAudio/portaudio/issues/303] glitches may occur when user frames
+ // equal to 1/2 of the host buffer frames, therefore the emperical workaround for this problem is to lower
+ // the sleep time by 2
+ if (userFramesOut != 0)
+ {
+ UINT32 chunks = stream->out.framesPerHostCallback / userFramesOut;
+ if (chunks <= 2)
+ {
+ sleepTimeOut /= 2;
+ PRINT(("WASAPI: underrun workaround, sleep [%d] ms - 1/2 of the user buffer[%d] | host buffer[%d]\n", sleepTimeOut, userFramesOut, stream->out.framesPerHostCallback));
+ }
+ }
+
+ // Choose the smallest
+ if ((sleepTimeIn != 0) && (sleepTimeOut != 0))
+ sleepTime = min(sleepTimeIn, sleepTimeOut);
+ else
+ sleepTime = (sleepTimeIn ? sleepTimeIn : sleepTimeOut);
+
+ return sleepTime;
+}
+
+// ------------------------------------------------------------------------------------------
+static UINT32 ConfigureLoopSleepTimeAndScheduler(PaWasapiStream *stream, ThreadIdleScheduler *scheduler)
+{
+ UINT32 sleepTime, sleepTimeIn, sleepTimeOut;
+ UINT32 userFramesIn = stream->in.framesPerHostCallback / WASAPI_PACKETS_PER_INPUT_BUFFER;
+ UINT32 userFramesOut = stream->out.framesPerBuffer;
+
+ // Adjust polling time for non-paUtilFixedHostBufferSize, input stream is not adjustable as it is being
+ // polled according its packet length
+ if (stream->bufferMode != paUtilFixedHostBufferSize)
+ {
+ userFramesOut = (stream->bufferProcessor.framesPerUserBuffer ? stream->bufferProcessor.framesPerUserBuffer :
+ stream->out.params.frames_per_buffer);
+ }
+
+ // Calculate timeout for the next polling attempt
+ sleepTimeIn = GetFramesSleepTime(userFramesIn, stream->in.wavex.Format.nSamplesPerSec);
+ sleepTimeOut = GetFramesSleepTime(userFramesOut, stream->out.wavex.Format.nSamplesPerSec);
+
+ // WASAPI input packets tend to expire very easily, let's limit sleep time to 2 milliseconds
+ // for all cases. Please propose better solution if any
+ if (sleepTimeIn > 2)
+ sleepTimeIn = 2;
+
+ sleepTime = GetSleepTime(stream, sleepTimeIn, sleepTimeOut, userFramesOut);
+
+ // Make sure not 0, othervise use ThreadIdleScheduler to bounce between [0, 1] ms to avoid too busy loop
+ if (sleepTime == 0)
+ {
+ sleepTimeIn = GetFramesSleepTimeMicroseconds(userFramesIn, stream->in.wavex.Format.nSamplesPerSec);
+ sleepTimeOut = GetFramesSleepTimeMicroseconds(userFramesOut, stream->out.wavex.Format.nSamplesPerSec);
+
+ sleepTime = GetSleepTime(stream, sleepTimeIn, sleepTimeOut, userFramesOut);
+
+ // Setup thread sleep scheduler
+ ThreadIdleScheduler_Setup(scheduler, 1, sleepTime/* microseconds here */);
+ sleepTime = 0;
+ }
+
+ return sleepTime;
+}
+
+// ------------------------------------------------------------------------------------------
+static inline INT32 GetNextSleepTime(SystemTimer *timer, ThreadIdleScheduler *scheduler, LONGLONG startTime,
+ UINT32 sleepTime)
+{
+ INT32 nextSleepTime;
+
+ // Get next sleep time
+ if (sleepTime == 0)
+ nextSleepTime = ThreadIdleScheduler_NextSleep(scheduler);
+ else
+ nextSleepTime = sleepTime;
+
+ // Adjust next sleep time dynamically depending on how much time was spent in ProcessOutputBuffer/ProcessInputBuffer
+ // therefore periodicity will not jitter or be increased for the amount of time spent in processing;
+ // example when sleepTime is 10 ms where [] is polling time slot, {} processing time slot:
+ //
+ // [9],{2},[8],{1},[9],{1},[9],{3},[7],{2},[8],{3},[7],{2},[8],{2},[8],{3},[7],{2},[8],...
+ //
+ INT32 procTime = (INT32)(SystemTimer_GetTime(timer) - startTime);
+ nextSleepTime -= procTime;
+ if (nextSleepTime < 0)
+ nextSleepTime = 0;
+
+#ifdef PA_WASAPI_LOG_TIME_SLOTS
+ printf("{%d},", procTime);
+#endif
+
+ return nextSleepTime;
+}
+
// ------------------------------------------------------------------------------------------
PA_THREAD_FUNC ProcThreadPoll(void *param)
{
@@ -5726,83 +5936,27 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
PaWasapiHostProcessor defaultProcessor;
INT32 i;
ThreadIdleScheduler scheduler;
-
- // Calculate the actual duration of the allocated buffer.
- DWORD sleep_ms = 0;
- DWORD sleep_ms_in;
- DWORD sleep_ms_out;
-
- BOOL bThreadComInitialized = FALSE;
+ SystemTimer timer;
+ LONGLONG startTime;
+ UINT32 sleepTime;
+ INT32 nextSleepTime = 0; //! Do first loop without waiting as time could be spent when calling other APIs before ProcessXXXBuffer.
+ BOOL threadComInitialized = FALSE;
+#ifdef PA_WASAPI_LOG_TIME_SLOTS
+ LONGLONG startWaitTime;
+#endif
// Notify: state
NotifyStateChanged(stream, paWasapiStreamStateThreadPrepare, ERROR_SUCCESS);
- /*
- If COM is already initialized CoInitialize will either return
- FALSE, or RPC_E_CHANGED_MODE if it was initialized in a different
- threading mode. In either case we shouldn't consider it an error
- but we need to be careful to not call CoUninitialize() if
- RPC_E_CHANGED_MODE was returned.
- */
- hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
- if (FAILED(hr) && (hr != RPC_E_CHANGED_MODE))
- {
- PRINT(("WASAPI: failed ProcThreadPoll CoInitialize"));
+ // Prepare COM pointers
+ if (!PrepareComPointers(stream, &threadComInitialized))
return (UINT32)paUnanticipatedHostError;
- }
- if (hr != RPC_E_CHANGED_MODE)
- bThreadComInitialized = TRUE;
- // Unmarshal stream pointers for safe COM operation
- hr = UnmarshalStreamComPointers(stream);
- if (hr != S_OK)
- {
- PRINT(("Error unmarshaling stream COM pointers. HRESULT: %i\n", hr));
- return 0;
- }
+ // Request fine (1 ms) granularity of the system timer functions to guarantee correct logic around WaitForSingleObject
+ SystemTimer_SetGranularity(&timer, 1);
- // Calculate timeout for next polling attempt.
- sleep_ms_in = GetFramesSleepTime(stream->in.framesPerHostCallback / WASAPI_PACKETS_PER_INPUT_BUFFER, stream->in.wavex.Format.nSamplesPerSec);
- sleep_ms_out = GetFramesSleepTime(stream->out.framesPerBuffer, stream->out.wavex.Format.nSamplesPerSec);
- sleep_ms_out /= 2; // wait only for half of the buffer
-
- // WASAPI Input packets tend to expire very easily, let's limit sleep time to 2 milliseconds
- // for all cases. Please propose better solution if any.
- if (sleep_ms_in > 2)
- sleep_ms_in = 2;
-
- // Adjust polling time for non-paUtilFixedHostBufferSize. Input stream is not adjustable as it is being
- // polled according its packet length.
- if (stream->bufferMode != paUtilFixedHostBufferSize)
- {
- //sleep_ms_in = GetFramesSleepTime((stream->bufferProcessor.framesPerUserBuffer ? stream->bufferProcessor.framesPerUserBuffer : stream->in.params.frames_per_buffer), stream->in.wavex.Format.nSamplesPerSec);
- sleep_ms_out = GetFramesSleepTime((stream->bufferProcessor.framesPerUserBuffer ? stream->bufferProcessor.framesPerUserBuffer : stream->out.params.frames_per_buffer), stream->out.wavex.Format.nSamplesPerSec);
- sleep_ms_out /= 2; // wait only for half of the buffer
- }
-
- // Choose smallest
- if ((sleep_ms_in != 0) && (sleep_ms_out != 0))
- sleep_ms = min(sleep_ms_in, sleep_ms_out);
- else
- sleep_ms = (sleep_ms_in ? sleep_ms_in : sleep_ms_out);
-
- // Make sure not 0, othervise use ThreadIdleScheduler
- if (sleep_ms == 0)
- {
- sleep_ms_in = GetFramesSleepTimeMicroseconds(stream->in.framesPerHostCallback / WASAPI_PACKETS_PER_INPUT_BUFFER, stream->in.wavex.Format.nSamplesPerSec);
- sleep_ms_out = GetFramesSleepTimeMicroseconds((stream->bufferProcessor.framesPerUserBuffer ? stream->bufferProcessor.framesPerUserBuffer : stream->out.params.frames_per_buffer), stream->out.wavex.Format.nSamplesPerSec);
- sleep_ms_out /= 2; // wait only for half of the buffer
-
- // Choose smallest
- if ((sleep_ms_in != 0) && (sleep_ms_out != 0))
- sleep_ms = min(sleep_ms_in, sleep_ms_out);
- else
- sleep_ms = (sleep_ms_in ? sleep_ms_in : sleep_ms_out);
-
- // Setup thread sleep scheduler
- ThreadIdleScheduler_Setup(&scheduler, 1, sleep_ms/* microseconds here */);
- sleep_ms = 0;
- }
+ // Claculate sleep time of the processing loop (inside WaitForSingleObject)
+ sleepTime = ConfigureLoopSleepTimeAndScheduler(stream, &scheduler);
// Setup data processors
defaultProcessor.processor = WaspiHostProcessingLoop;
@@ -5832,17 +5986,20 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
{
UINT32 frames = 0;
if ((hr = _PollGetOutputFramesAvailable(stream, &frames)) == S_OK)
- {
+ {
if (stream->bufferMode == paUtilFixedHostBufferSize)
{
- if (frames >= stream->out.framesPerBuffer)
+ // It is important to preload whole host buffer to avoid underruns/glitches when stream is started,
+ // for more details see the discussion: https://github.com/PortAudio/portaudio/issues/303
+ while (frames >= stream->out.framesPerBuffer)
{
- frames = stream->out.framesPerBuffer;
-
- if ((hr = ProcessOutputBuffer(stream, processor, frames)) != S_OK)
+ if ((hr = ProcessOutputBuffer(stream, processor, stream->out.framesPerBuffer)) != S_OK)
{
LogHostError(hr); // not fatal, just log
+ break;
}
+
+ frames -= stream->out.framesPerBuffer;
}
}
else
@@ -5862,8 +6019,8 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
LogHostError(hr); // not fatal, just log
}
}
- }
- else
+ }
+ else
{
LogHostError(hr); // not fatal, just log
}
@@ -5886,16 +6043,20 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
// Notify: state
NotifyStateChanged(stream, paWasapiStreamStateThreadStart, ERROR_SUCCESS);
+#ifdef PA_WASAPI_LOG_TIME_SLOTS
+ startWaitTime = SystemTimer_GetTime(&timer);
+#endif
+
if (!PA_WASAPI__IS_FULLDUPLEX(stream))
{
- UINT32 next_sleep = sleep_ms;
-
// Processing Loop
- while (WaitForSingleObject(stream->hCloseRequest, next_sleep) == WAIT_TIMEOUT)
+ while (WaitForSingleObject(stream->hCloseRequest, nextSleepTime) == WAIT_TIMEOUT)
{
- // Get next sleep time
- if (sleep_ms == 0)
- next_sleep = ThreadIdleScheduler_NextSleep(&scheduler);
+ startTime = SystemTimer_GetTime(&timer);
+
+ #ifdef PA_WASAPI_LOG_TIME_SLOTS
+ printf("[%d|%d],", nextSleepTime, (INT32)(startTime - startWaitTime));
+ #endif
for (i = 0; i < S_COUNT; ++i)
{
@@ -5919,12 +6080,13 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
// Output stream
case S_OUTPUT: {
- UINT32 frames;
+ UINT32 framesAvail;
+
if (stream->renderClient == NULL)
break;
// Get available frames
- if ((hr = _PollGetOutputFramesAvailable(stream, &frames)) != S_OK)
+ if ((hr = _PollGetOutputFramesAvailable(stream, &framesAvail)) != S_OK)
{
LogHostError(hr);
goto thread_error;
@@ -5933,21 +6095,33 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
// Output data to the user callback
if (stream->bufferMode == paUtilFixedHostBufferSize)
{
- while (frames >= stream->out.framesPerBuffer)
+ UINT32 framesProc = stream->out.framesPerBuffer;
+
+ // If we got less frames avoid sleeping again as it might be the corner case and buffer
+ // has sufficient number of frames now, in case 'out.framesPerBuffer' is 1/2 of the host
+ // buffer sleeping again may cause underruns. Do short busy waiting (normally might take
+ // 1-2 iterations)
+ if (framesAvail < framesProc)
{
- if ((hr = ProcessOutputBuffer(stream, processor, stream->out.framesPerBuffer)) != S_OK)
+ nextSleepTime = 0;
+ continue;
+ }
+
+ while (framesAvail >= framesProc)
+ {
+ if ((hr = ProcessOutputBuffer(stream, processor, framesProc)) != S_OK)
{
LogHostError(hr);
goto thread_error;
}
- frames -= stream->out.framesPerBuffer;
+ framesAvail -= framesProc;
}
}
else
- if (frames != 0)
+ if (framesAvail != 0)
{
- if ((hr = ProcessOutputBuffer(stream, processor, frames)) != S_OK)
+ if ((hr = ProcessOutputBuffer(stream, processor, framesAvail)) != S_OK)
{
LogHostError(hr);
goto thread_error;
@@ -5957,143 +6131,29 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
break; }
}
}
+
+ // Get next sleep time
+ nextSleepTime = GetNextSleepTime(&timer, &scheduler, startTime, sleepTime);
+
+ #ifdef PA_WASAPI_LOG_TIME_SLOTS
+ startWaitTime = SystemTimer_GetTime(&timer);
+ #endif
}
}
else
{
-#if 0
- // Processing Loop
- while (WaitForSingleObject(stream->hCloseRequest, 1) == WAIT_TIMEOUT)
+ // Processing Loop (full-duplex)
+ while (WaitForSingleObject(stream->hCloseRequest, nextSleepTime) == WAIT_TIMEOUT)
{
- UINT32 i_frames = 0, i_processed = 0;
+ UINT32 i_frames = 0, i_processed = 0, o_frames = 0;
BYTE *i_data = NULL, *o_data = NULL, *o_data_host = NULL;
DWORD i_flags = 0;
- UINT32 o_frames = 0;
+
+ startTime = SystemTimer_GetTime(&timer);
- // get host input buffer
- if ((hr = IAudioCaptureClient_GetBuffer(stream->captureClient, &i_data, &i_frames, &i_flags, NULL, NULL)) != S_OK)
- {
- if (hr == AUDCLNT_S_BUFFER_EMPTY)
- continue; // no data in capture buffer
-
- LogHostError(hr);
- break;
- }
-
- // get available frames
- if ((hr = _PollGetOutputFramesAvailable(stream, &o_frames)) != S_OK)
- {
- // release input buffer
- IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);
-
- LogHostError(hr);
- break;
- }
-
- // process equal ammount of frames
- if (o_frames >= i_frames)
- {
- // process input ammount of frames
- UINT32 o_processed = i_frames;
-
- // get host output buffer
- if ((hr = IAudioRenderClient_GetBuffer(stream->procRCClient, o_processed, &o_data)) == S_OK)
- {
- // processed amount of i_frames
- i_processed = i_frames;
- o_data_host = o_data;
-
- // convert output mono
- if (stream->out.monoMixer)
- {
- UINT32 mono_frames_size = o_processed * (stream->out.wavex.Format.wBitsPerSample / 8);
- // expand buffer
- if (mono_frames_size > stream->out.monoBufferSize)
- {
- stream->out.monoBuffer = PaWasapi_ReallocateMemory(stream->out.monoBuffer, (stream->out.monoBufferSize = mono_frames_size));
- if (stream->out.monoBuffer == NULL)
- {
- // release input buffer
- IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);
- // release output buffer
- IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);
-
- LogPaError(paInsufficientMemory);
- break;
- }
- }
-
- // replace buffer pointer
- o_data = (BYTE *)stream->out.monoBuffer;
- }
-
- // convert input mono
- if (stream->in.monoMixer)
- {
- UINT32 mono_frames_size = i_processed * (stream->in.wavex.Format.wBitsPerSample / 8);
- // expand buffer
- if (mono_frames_size > stream->in.monoBufferSize)
- {
- stream->in.monoBuffer = PaWasapi_ReallocateMemory(stream->in.monoBuffer, (stream->in.monoBufferSize = mono_frames_size));
- if (stream->in.monoBuffer == NULL)
- {
- // release input buffer
- IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);
- // release output buffer
- IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);
-
- LogPaError(paInsufficientMemory);
- break;
- }
- }
-
- // mix 2 to 1 input channels
- stream->in.monoMixer(stream->in.monoBuffer, i_data, i_processed);
-
- // replace buffer pointer
- i_data = (BYTE *)stream->in.monoBuffer;
- }
-
- // process
- processor[S_FULLDUPLEX].processor(i_data, i_processed, o_data, o_processed, processor[S_FULLDUPLEX].userData);
-
- // mix 1 to 2 output channels
- if (stream->out.monoBuffer)
- stream->out.monoMixer(o_data_host, stream->out.monoBuffer, o_processed);
-
- // release host output buffer
- if ((hr = IAudioRenderClient_ReleaseBuffer(stream->renderClient, o_processed, 0)) != S_OK)
- LogHostError(hr);
- }
- else
- {
- if (stream->out.shareMode != AUDCLNT_SHAREMODE_SHARED)
- LogHostError(hr); // be silent in shared mode, try again next time
- }
- }
-
- // release host input buffer
- if ((hr = IAudioCaptureClient_ReleaseBuffer(stream->captureClient, i_processed)) != S_OK)
- {
- LogHostError(hr);
- break;
- }
- }
-#else
- // Processing Loop
- UINT32 next_sleep = sleep_ms;
- while (WaitForSingleObject(stream->hCloseRequest, next_sleep) == WAIT_TIMEOUT)
- {
- UINT32 i_frames = 0, i_processed = 0;
- BYTE *i_data = NULL, *o_data = NULL, *o_data_host = NULL;
- DWORD i_flags = 0;
- UINT32 o_frames = 0;
-
- // Get next sleep time
- if (sleep_ms == 0)
- {
- next_sleep = ThreadIdleScheduler_NextSleep(&scheduler);
- }
+ #ifdef PA_WASAPI_LOG_TIME_SLOTS
+ printf("[%d|%d],", nextSleepTime, (INT32)(startTime - startWaitTime));
+ #endif
// get available frames
if ((hr = _PollGetOutputFramesAvailable(stream, &o_frames)) != S_OK)
@@ -6216,8 +6276,14 @@ fd_release_buffer_in:
if (i_processed == 0)
break;
}
+
+ // Get next sleep time
+ nextSleepTime = GetNextSleepTime(&timer, &scheduler, startTime, sleepTime);
+
+ #ifdef PA_WASAPI_LOG_TIME_SLOTS
+ startWaitTime = SystemTimer_GetTime(&timer);
+ #endif
}
-#endif
}
thread_end:
@@ -6226,11 +6292,10 @@ thread_end:
_StreamOnStop(stream);
// Release unmarshaled COM pointers
- ReleaseUnmarshaledComPointers(stream);
+ FinishComPointers(stream, threadComInitialized);
- // Cleanup COM for this thread
- if (bThreadComInitialized == TRUE)
- CoUninitialize();
+ // Restore system timer granularity
+ SystemTimer_RestoreGranularity(&timer);
// Notify: not running
stream->running = FALSE;
@@ -6269,35 +6334,3 @@ void PaWasapi_FreeMemory(void *ptr)
{
free(ptr);
}
-
-//#endif //VC 2005
-
-
-
-
-#if 0
- if(bFirst) {
- float masteur;
- hr = stream->outVol->GetMasterVolumeLevelScalar(&masteur);
- if (hr != S_OK)
- LogHostError(hr);
- float chan1, chan2;
- hr = stream->outVol->GetChannelVolumeLevelScalar(0, &chan1);
- if (hr != S_OK)
- LogHostError(hr);
- hr = stream->outVol->GetChannelVolumeLevelScalar(1, &chan2);
- if (hr != S_OK)
- LogHostError(hr);
-
- BOOL bMute;
- hr = stream->outVol->GetMute(&bMute);
- if (hr != S_OK)
- LogHostError(hr);
-
- stream->outVol->SetMasterVolumeLevelScalar(0.5, NULL);
- stream->outVol->SetChannelVolumeLevelScalar(0, 0.5, NULL);
- stream->outVol->SetChannelVolumeLevelScalar(1, 0.5, NULL);
- stream->outVol->SetMute(FALSE, NULL);
- bFirst = FALSE;
- }
-#endif
From dcc2f7fa48d0e15febdfae71b5038b4a7bd1f4fb Mon Sep 17 00:00:00 2001
From: dmitrykos
Date: Sat, 3 Oct 2020 23:21:11 +0300
Subject: [PATCH 013/157] wasapi: Fix paInvalidSampleRate (and any other) error
code is replaced with paInvalidDevice if audio client failed to be created
due to some reason.
---
src/hostapi/wasapi/pa_win_wasapi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index 17846bd..f23fd58 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -3705,11 +3705,11 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->in.params.wow64_workaround = paWasapi->useWOW64Workaround;
// Create and activate audio client
- if (FAILED(hr = ActivateAudioClientInput(stream)))
+ if ((result = ActivateAudioClientInput(stream)) != paNoError)
{
- LogPaError(result = paInvalidDevice);
+ LogPaError(result);
goto error;
- }
+ }
// Get closest format
hostInputSampleFormat = PaUtil_SelectClosestAvailableFormat(WaveToPaFormat(&stream->in.wavex), inputSampleFormat);
@@ -3839,11 +3839,11 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->out.params.wow64_workaround = paWasapi->useWOW64Workaround;
// Create and activate audio client
- if (FAILED(hr = ActivateAudioClientOutput(stream)))
+ if ((result = ActivateAudioClientOutput(stream)) != paNoError)
{
- LogPaError(result = paInvalidDevice);
+ LogPaError(result);
goto error;
- }
+ }
// Get closest format
hostOutputSampleFormat = PaUtil_SelectClosestAvailableFormat(WaveToPaFormat(&stream->out.wavex), outputSampleFormat);
From 2a7f8fcd7a5f64835be907c5dd56dc962793e7b8 Mon Sep 17 00:00:00 2001
From: Phil Burk
Date: Sat, 3 Oct 2020 16:54:12 -0700
Subject: [PATCH 014/157] build: add new Mac SDKs to configure
Add SDK 10.14 and 10.15 to configure.in
Removed i386 and PPC architectures on Mac because they are
deprecated and make fails if they are used.
The configure file was generated from the configure.in
file by entering this on Linux:
aclocal
autoconf
Fixes 308
---
configure | Bin 576035 -> 576931 bytes
configure.in | 22 ++++++++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/configure b/configure
index e1703271b253ccf2d992b39eff5420e16a83d319..34a341bdd51bb1616ed8d3eb63ae12868f780726 100755
GIT binary patch
delta 621
zcmZ2HMS1aT&lqu9G=<4F;qe?5pa4DdOAajt|2qv6`thF903ZXQCW-2HoCdU^PrIy(uJH^@>
zD241eTP?VGP)}iqpbG%`F=&pqO+YaQMF%nmi4A1NAWVTvz!@5pnXFk`}Pfq9K{&`^yJp9
delta 168
zcmZ2HTY2#mOT}hnq<`?bDg`02AZofI35r~<9m>Gy!fS7gr
z&Dm_HR`VDdY1J6(833`N=H!Wsq^BQnXHVI#<-vZRbNYJ^c9H3O9T)|s{|siIE}Us>
zVWv=FVHR&@qEJwf48q%|gs{&Mn10@sU10i}ICdV9^2FlAf=vC~%)In+-ORk?oYIuk
OcD+>g?Ru#kr5OOqkwV-6
diff --git a/configure.in b/configure.in
index b2129ba..90a811c 100644
--- a/configure.in
+++ b/configure.in
@@ -210,7 +210,7 @@ case "${host_os}" in
if test "x$enable_mac_universal" = "xyes" ; then
case `xcodebuild -version | sed -n 's/Xcode \(.*\)/\1/p'` in
- [12]*|3.0|3.1)
+ 3.0|3.1)
dnl In pre-3.2 versions of Xcode, xcodebuild doesn't
dnl support -sdk, so we can't use that to look for
dnl SDKs. However, in those versions of Xcode, the
@@ -261,6 +261,12 @@ case "${host_os}" in
elif xcodebuild -version -sdk macosx10.13 Path >/dev/null 2>&1 ; then
mac_version_min="-mmacosx-version-min=10.4"
mac_sysroot="-isysroot `xcodebuild -version -sdk macosx10.13 Path`"
+ elif xcodebuild -version -sdk macosx10.14 Path >/dev/null 2>&1 ; then
+ mac_version_min="-mmacosx-version-min=10.4"
+ mac_sysroot="-isysroot `xcodebuild -version -sdk macosx10.14 Path`"
+ elif xcodebuild -version -sdk macosx10.15 Path >/dev/null 2>&1 ; then
+ mac_version_min="-mmacosx-version-min=10.4"
+ mac_sysroot="-isysroot `xcodebuild -version -sdk macosx10.15 Path`"
else
AC_MSG_ERROR([Could not find 10.5 to 10.13 SDK.])
fi
@@ -269,7 +275,7 @@ case "${host_os}" in
dnl Pick which architectures to build for based on what
dnl the compiler supports.
mac_arches=""
- for arch in i386 x86_64 ppc ppc64
+ for arch in x86_64
do
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -arch $arch"
@@ -319,12 +325,12 @@ case "${host_os}" in
DLL_LIBS="${DLL_LIBS} -lwinmm -lm -lole32 -luuid"
CFLAGS="$CFLAGS -ffast-math -fomit-frame-pointer -I\$(top_srcdir)/src/hostapi/asio -I$ASIODIR/host/pc -I$ASIODIR/common -I$ASIODIR/host -UPA_USE_ASIO -DPA_USE_ASIO=1 -DWINDOWS"
- dnl Setting the windows version flags below resolves a conflict between Interlocked*
- dnl definitions in mingw winbase.h and Interlocked* hacks in ASIO SDK combase.h
+ dnl Setting the windows version flags below resolves a conflict between Interlocked*
+ dnl definitions in mingw winbase.h and Interlocked* hacks in ASIO SDK combase.h
dnl combase.h is included by asiodrvr.h
- dnl PortAudio does not actually require Win XP (winver 501) APIs
+ dnl PortAudio does not actually require Win XP (winver 501) APIs
CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0501 -DWINVER=0x0501"
-
+
CXXFLAGS="$CFLAGS"
fi
@@ -383,7 +389,7 @@ case "${host_os}" in
dnl The _REENTRANT option for pthread safety. Perhaps not necessary but it 'll do no harm.
dnl
THREAD_CFLAGS="-D_REENTRANT"
-
+
OTHER_OBJS="pa_sgi/pa_sgi.o src/os/unix/pa_unix_hostapis.o src/os/unix/pa_unix_util.o"
dnl SGI books say -lpthread should be the last of the libs mentioned.
@@ -397,7 +403,7 @@ case "${host_os}" in
dnl Unix configuration
CFLAGS="$CFLAGS -I\$(top_srcdir)/src/os/unix"
-
+
AC_CHECK_LIB(pthread, pthread_create,[have_pthread="yes"],
AC_MSG_ERROR([libpthread not found!]))
From e90b19ef2b56f92e8bf79017a9cc2669e20f2e16 Mon Sep 17 00:00:00 2001
From: Phil Burk
Date: Sun, 4 Oct 2020 11:06:03 -0700
Subject: [PATCH 015/157] docs: change Assembla links to GitHub
Fixes #298
---
doc/src/mainpage.dox | 18 ++++++++++--------
doc/src/tutorial/compile_windows_mingw.dox | 7 +++++--
doc/src/tutorial/tutorial_start.dox | 6 ++++--
3 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/doc/src/mainpage.dox b/doc/src/mainpage.dox
index 7a54d32..53e0060 100644
--- a/doc/src/mainpage.dox
+++ b/doc/src/mainpage.dox
@@ -34,9 +34,9 @@ Documentation for non-portable platform-specific host API extensions
- The PortAudio website
-- Our mailing list for users and developers
+- Our mailing list for users and developers
-- The PortAudio wiki
+- The PortAudio wiki
@section developer_resources Developer Resources
@@ -44,18 +44,20 @@ Documentation for non-portable platform-specific host API extensions
- @ref srcguide
@endif
-- Our wiki and issue tracking system
+- Our repository on GitHub
-- Developer guidelines
+- Developer guidelines
-- Implementation style guidelines
-
-If you're interested in helping out with PortAudio development we're more than happy for you to be involved. Just drop by the PortAudio mailing list and ask how you can help. Or check out the starter tickets.
+- Implementation style guidelines
+If you're interested in helping out with PortAudio development we're more than happy for you to be involved.
+Just drop by the PortAudio mailing list and ask how you can help.
+Or check out these
+recommended starter issues.
@section older_api_versions Older API Versions
This documentation covers the current API version: PortAudio V19, API version 2.0. API 2.0 differs in a number of ways from previous versions (most often encountered in PortAudio V18), please consult the enhancement proposals for details of what was added/changed for V19:
http://www.portaudio.com/docs/proposals/index.html
-*/
\ No newline at end of file
+*/
diff --git a/doc/src/tutorial/compile_windows_mingw.dox b/doc/src/tutorial/compile_windows_mingw.dox
index d521b7b..30143dc 100644
--- a/doc/src/tutorial/compile_windows_mingw.dox
+++ b/doc/src/tutorial/compile_windows_mingw.dox
@@ -3,7 +3,10 @@
@section comp_mingw1 Portaudio for Windows With MinGW
-This document contains old or out-of-date information. Please see a draft of new MinGW information on our Wiki: PortAudio Wiki: Notes about building PortAudio with MinGW
+This document contains old or out-of-date information. Please see
+a draft of new MinGW information on our
+Wiki:
+PortAudio Wiki: Notes about building PortAudio with MinGW
= MinGW/MSYS =
@@ -50,4 +53,4 @@ To update your copy or check out a fresh copy of the source
Back to the Tutorial: \ref tutorial_start
-*/
\ No newline at end of file
+*/
diff --git a/doc/src/tutorial/tutorial_start.dox b/doc/src/tutorial/tutorial_start.dox
index f920178..42fa4bf 100644
--- a/doc/src/tutorial/tutorial_start.dox
+++ b/doc/src/tutorial/tutorial_start.dox
@@ -37,7 +37,9 @@ Below are the steps to writing a PortAudio application using the callback techni
In addition to this "Callback" architecture, V19 also supports a "Blocking I/O" model which uses read and write calls which may be more familiar to non-audio programmers. Note that at this time, not all APIs support this functionality.
-In this tutorial, we'll show how to use the callback architecture to play a sawtooth wave. Much of the tutorial is taken from the file paex_saw.c, which is part of the PortAudio distribution. When you're done with this tutorial, you'll be armed with the basic knowledge you need to write an audio program. If you need more sample code, look in the "examples" and "test" directory of the PortAudio distribution. Another great source of info is the portaudio.h Doxygen page, which documents the entire V19 API. Also see the page for tips on programming PortAudio on the PortAudio wiki.
+In this tutorial, we'll show how to use the callback architecture to play a sawtooth wave. Much of the tutorial is taken from the file paex_saw.c, which is part of the PortAudio distribution. When you're done with this tutorial, you'll be armed with the basic knowledge you need to write an audio program. If you need more sample code, look in the "examples" and "test" directory of the PortAudio distribution. Another great source of info is the portaudio.h Doxygen page, which documents the entire V19 API.
+Also see the page for tips on programming PortAudio
+on the PortAudio wiki.
@section tut_start4 Programming Tutorial Contents
@@ -56,4 +58,4 @@ Once you have a basic understanding of how to use PortAudio, you might be intere
Next: \ref writing_a_callback
-*/
\ No newline at end of file
+*/
From 19f638da5ac187ba17787c1a8d456642b024a297 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 1 Oct 2020 14:08:39 +1000
Subject: [PATCH 016/157] wdmks: ensure that pins that failed creation by
PinNew() are set to NULL. Note that PaUtil_AllocateMemory currently calls
GlobalAlloc without the GMEM_ZEROINIT flag, so there was no guarantee that
filter->pins[pinId] was zero.
---
src/hostapi/wdmks/pa_win_wdmks.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/hostapi/wdmks/pa_win_wdmks.c b/src/hostapi/wdmks/pa_win_wdmks.c
index 70a48d8..2403ed5 100644
--- a/src/hostapi/wdmks/pa_win_wdmks.c
+++ b/src/hostapi/wdmks/pa_win_wdmks.c
@@ -2844,6 +2844,10 @@ PaError FilterInitializePins( PaWinWdmFilter* filter )
filter->pins[pinId] = newPin;
++filter->validPinCount;
}
+ else
+ {
+ filter->pins[pinId] = 0;
+ }
}
if (filter->validPinCount == 0)
From aa6ff975af2aedfad878aa40c85edbfa0176d034 Mon Sep 17 00:00:00 2001
From: dmitrykos
Date: Fri, 9 Oct 2020 00:57:23 +0300
Subject: [PATCH 017/157] wasapi: Replace tabs with 4-spaces to comply with
PortAudio code style guidelines
(http://github.com/PortAudio/portaudio/wiki/ImplementationStyleGuidelines).
---
src/hostapi/wasapi/pa_win_wasapi.c | 7328 ++++++++++++++--------------
1 file changed, 3664 insertions(+), 3664 deletions(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index f23fd58..cdefe13 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -51,7 +51,7 @@
// Max device count (if defined) causes max constant device count in the device list that
// enables PaWasapi_UpdateDeviceList() API and makes it possible to update WASAPI list dynamically
#ifndef PA_WASAPI_MAX_CONST_DEVICE_COUNT
- #define PA_WASAPI_MAX_CONST_DEVICE_COUNT 0 // Force basic behavior by defining 0 if not defined by user
+ #define PA_WASAPI_MAX_CONST_DEVICE_COUNT 0 // Force basic behavior by defining 0 if not defined by user
#endif
// Fallback from Event to the Polling method in case if latency is higher than 21.33ms, as it allows to use
@@ -66,8 +66,8 @@
// WinRT
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
- #define PA_WINRT
- #define INITGUID
+ #define PA_WINRT
+ #define INITGUID
#endif
// WASAPI
@@ -75,22 +75,22 @@
// https://github.com/mxe/mxe/commit/f4bbc45682f021948bdaefd9fd476e2a04c4740f
#include // must be before other Wasapi headers
#if defined(_MSC_VER) && (_MSC_VER >= 1400) || defined(__MINGW64_VERSION_MAJOR)
- #include
- #define COBJMACROS
- #include
- #include
- #define INITGUID // Avoid additional linkage of static libs, excessive code will be optimized out by the compiler
+ #include
+ #define COBJMACROS
+ #include
+ #include
+ #define INITGUID // Avoid additional linkage of static libs, excessive code will be optimized out by the compiler
#ifndef _MSC_VER
- #include
+ #include
#endif
- #include
- #include
- #include // Used to get IKsJackDescription interface
- #undef INITGUID
+ #include
+ #include
+ #include // Used to get IKsJackDescription interface
+ #undef INITGUID
#endif
#ifndef __MWERKS__
- #include
- #include
+ #include
+ #include
#endif
#include "pa_util.h"
@@ -109,9 +109,9 @@
#undef WINVER
#undef _WIN32_WINNT
#define WINVER 0x0600 // VISTA
- #define _WIN32_WINNT WINVER
+ #define _WIN32_WINNT WINVER
- #ifndef _AVRT_ //<< fix MinGW dummy compile by defining missing type: AVRT_PRIORITY
+ #ifndef _AVRT_ //<< fix MinGW dummy compile by defining missing type: AVRT_PRIORITY
typedef enum _AVRT_PRIORITY
{
AVRT_PRIORITY_LOW = -1,
@@ -119,16 +119,16 @@
AVRT_PRIORITY_HIGH,
AVRT_PRIORITY_CRITICAL
} AVRT_PRIORITY, *PAVRT_PRIORITY;
- #endif
+ #endif
- #include // << for IID/CLSID
+ #include // << for IID/CLSID
#include
#include
- #ifndef __LPCGUID_DEFINED__
- #define __LPCGUID_DEFINED__
- typedef const GUID *LPCGUID;
- #endif
+ #ifndef __LPCGUID_DEFINED__
+ #define __LPCGUID_DEFINED__
+ typedef const GUID *LPCGUID;
+ #endif
#ifndef PROPERTYKEY_DEFINED
#define PROPERTYKEY_DEFINED
@@ -136,7 +136,7 @@
{
GUID fmtid;
DWORD pid;
- } PROPERTYKEY;
+ } PROPERTYKEY;
#endif
#ifdef __midl_proxy
@@ -156,7 +156,7 @@
{
unsigned long clSize;
unsigned char abData[ 1 ];
- } BYTE_BLOB;
+ } BYTE_BLOB;
typedef /* [unique] */ __RPC_unique_pointer BYTE_BLOB *UP_BYTE_BLOB;
typedef LONGLONG REFERENCE_TIME;
#define NONAMELESSUNION
@@ -182,7 +182,7 @@
#include
#include
#include
- #include // Used to get IKsJackDescription interface
+ #include // Used to get IKsJackDescription interface
#undef INITGUID
#endif // NTDDI_VERSION
@@ -190,32 +190,32 @@
// Missing declarations for WinRT
#ifdef PA_WINRT
- #define DEVICE_STATE_ACTIVE 0x00000001
+ #define DEVICE_STATE_ACTIVE 0x00000001
- typedef enum _EDataFlow
- {
- eRender = 0,
- eCapture = ( eRender + 1 ) ,
- eAll = ( eCapture + 1 ) ,
- EDataFlow_enum_count = ( eAll + 1 )
- }
- EDataFlow;
+ typedef enum _EDataFlow
+ {
+ eRender = 0,
+ eCapture = ( eRender + 1 ) ,
+ eAll = ( eCapture + 1 ) ,
+ EDataFlow_enum_count = ( eAll + 1 )
+ }
+ EDataFlow;
- typedef enum _EndpointFormFactor
- {
- RemoteNetworkDevice = 0,
- Speakers = ( RemoteNetworkDevice + 1 ) ,
- LineLevel = ( Speakers + 1 ) ,
- Headphones = ( LineLevel + 1 ) ,
- Microphone = ( Headphones + 1 ) ,
- Headset = ( Microphone + 1 ) ,
- Handset = ( Headset + 1 ) ,
- UnknownDigitalPassthrough = ( Handset + 1 ) ,
- SPDIF = ( UnknownDigitalPassthrough + 1 ) ,
- HDMI = ( SPDIF + 1 ) ,
- UnknownFormFactor = ( HDMI + 1 )
- }
- EndpointFormFactor;
+ typedef enum _EndpointFormFactor
+ {
+ RemoteNetworkDevice = 0,
+ Speakers = ( RemoteNetworkDevice + 1 ) ,
+ LineLevel = ( Speakers + 1 ) ,
+ Headphones = ( LineLevel + 1 ) ,
+ Microphone = ( Headphones + 1 ) ,
+ Headset = ( Microphone + 1 ) ,
+ Handset = ( Headset + 1 ) ,
+ UnknownDigitalPassthrough = ( Handset + 1 ) ,
+ SPDIF = ( UnknownDigitalPassthrough + 1 ) ,
+ HDMI = ( SPDIF + 1 ) ,
+ UnknownFormFactor = ( HDMI + 1 )
+ }
+ EndpointFormFactor;
#endif
@@ -261,15 +261,15 @@ __DEFINE_GUID(pa_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x
#ifdef __IAudioClient2_INTERFACE_DEFINED__
typedef enum _pa_AUDCLNT_STREAMOPTIONS {
- pa_AUDCLNT_STREAMOPTIONS_NONE = 0x00,
- pa_AUDCLNT_STREAMOPTIONS_RAW = 0x01,
- pa_AUDCLNT_STREAMOPTIONS_MATCH_FORMAT = 0x02
+ pa_AUDCLNT_STREAMOPTIONS_NONE = 0x00,
+ pa_AUDCLNT_STREAMOPTIONS_RAW = 0x01,
+ pa_AUDCLNT_STREAMOPTIONS_MATCH_FORMAT = 0x02
} pa_AUDCLNT_STREAMOPTIONS;
typedef struct _pa_AudioClientProperties {
- UINT32 cbSize;
- BOOL bIsOffload;
- AUDIO_STREAM_CATEGORY eCategory;
- pa_AUDCLNT_STREAMOPTIONS Options;
+ UINT32 cbSize;
+ BOOL bIsOffload;
+ AUDIO_STREAM_CATEGORY eCategory;
+ pa_AUDCLNT_STREAMOPTIONS Options;
} pa_AudioClientProperties;
#define PA_AUDIOCLIENTPROPERTIES_SIZE_CATEGORY (sizeof(pa_AudioClientProperties) - sizeof(pa_AUDCLNT_STREAMOPTIONS))
#define PA_AUDIOCLIENTPROPERTIES_SIZE_OPTIONS sizeof(pa_AudioClientProperties)
@@ -277,13 +277,13 @@ typedef struct _pa_AudioClientProperties {
/* use CreateThread for CYGWIN/Windows Mobile, _beginthreadex for all others */
#if !defined(__CYGWIN__) && !defined(_WIN32_WCE)
- #define CREATE_THREAD(PROC) (HANDLE)_beginthreadex( NULL, 0, (PROC), stream, 0, &stream->dwThreadId )
- #define PA_THREAD_FUNC static unsigned WINAPI
- #define PA_THREAD_ID unsigned
+ #define CREATE_THREAD(PROC) (HANDLE)_beginthreadex( NULL, 0, (PROC), stream, 0, &stream->dwThreadId )
+ #define PA_THREAD_FUNC static unsigned WINAPI
+ #define PA_THREAD_ID unsigned
#else
- #define CREATE_THREAD(PROC) CreateThread( NULL, 0, (PROC), stream, 0, &stream->dwThreadId )
- #define PA_THREAD_FUNC static DWORD WINAPI
- #define PA_THREAD_ID DWORD
+ #define CREATE_THREAD(PROC) CreateThread( NULL, 0, (PROC), stream, 0, &stream->dwThreadId )
+ #define PA_THREAD_FUNC static DWORD WINAPI
+ #define PA_THREAD_ID DWORD
#endif
// Thread function forward decl.
@@ -292,27 +292,27 @@ PA_THREAD_FUNC ProcThreadPoll(void *param);
// Error codes (availabe since Windows 7)
#ifndef AUDCLNT_E_BUFFER_ERROR
- #define AUDCLNT_E_BUFFER_ERROR AUDCLNT_ERR(0x018)
+ #define AUDCLNT_E_BUFFER_ERROR AUDCLNT_ERR(0x018)
#endif
#ifndef AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED
- #define AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED AUDCLNT_ERR(0x019)
+ #define AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED AUDCLNT_ERR(0x019)
#endif
#ifndef AUDCLNT_E_INVALID_DEVICE_PERIOD
- #define AUDCLNT_E_INVALID_DEVICE_PERIOD AUDCLNT_ERR(0x020)
+ #define AUDCLNT_E_INVALID_DEVICE_PERIOD AUDCLNT_ERR(0x020)
#endif
// Stream flags (availabe since Windows 7)
#ifndef AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY
- #define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000
+ #define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000
#endif
#ifndef AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM
- #define AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000
+ #define AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000
#endif
#define MAX_STR_LEN 512
#ifdef PA_WINRT
- #define PA_WASAPI_DEVICE_ID_LEN 4096
+ #define PA_WASAPI_DEVICE_ID_LEN 4096
#endif
enum { S_INPUT = 0, S_OUTPUT = 1, S_COUNT = 2, S_FULLDUPLEX = 0 };
@@ -430,10 +430,10 @@ typedef struct PaWasapiDeviceInfo
IMMDevice *device;
#endif
- // from GetId
+ // from GetId
WCHAR szDeviceID[MAX_STR_LEN];
- // from GetState
+ // from GetState
DWORD state;
// Fields filled from IAudioDevice (_prior_ to Initialize)
@@ -441,17 +441,17 @@ typedef struct PaWasapiDeviceInfo
REFERENCE_TIME DefaultDevicePeriod;
REFERENCE_TIME MinimumDevicePeriod;
- // Default format (setup through Control Panel by user)
- WAVEFORMATEXTENSIBLE DefaultFormat;
+ // Default format (setup through Control Panel by user)
+ WAVEFORMATEXTENSIBLE DefaultFormat;
- // Mix format (internal format used by WASAPI audio engine)
- WAVEFORMATEXTENSIBLE MixFormat;
+ // Mix format (internal format used by WASAPI audio engine)
+ WAVEFORMATEXTENSIBLE MixFormat;
// Fields filled from IMMEndpoint'sGetDataFlow
EDataFlow flow;
- // Formfactor
- EndpointFormFactor formFactor;
+ // Formfactor
+ EndpointFormFactor formFactor;
}
PaWasapiDeviceInfo;
@@ -477,8 +477,8 @@ typedef struct
PaWasapiDeviceInfo *devInfo;
- // is TRUE when WOW64 Vista/7 Workaround is needed
- BOOL useWOW64Workaround;
+ // is TRUE when WOW64 Vista/7 Workaround is needed
+ BOOL useWOW64Workaround;
}
PaWasapiHostApiRepresentation;
@@ -486,14 +486,14 @@ PaWasapiHostApiRepresentation;
/* PaWasapiAudioClientParams - audio client parameters */
typedef struct PaWasapiAudioClientParams
{
- PaWasapiDeviceInfo *device_info;
- PaStreamParameters stream_params;
- PaWasapiStreamInfo wasapi_params;
- UINT32 frames_per_buffer;
- double sample_rate;
- BOOL blocking;
- BOOL full_duplex;
- BOOL wow64_workaround;
+ PaWasapiDeviceInfo *device_info;
+ PaStreamParameters stream_params;
+ PaWasapiStreamInfo wasapi_params;
+ UINT32 frames_per_buffer;
+ double sample_rate;
+ BOOL blocking;
+ BOOL full_duplex;
+ BOOL wow64_workaround;
}
PaWasapiAudioClientParams;
@@ -503,34 +503,34 @@ typedef struct PaWasapiSubStream
{
IAudioClient *clientParent;
#ifndef PA_WINRT
- IStream *clientStream;
+ IStream *clientStream;
#endif
- IAudioClient *clientProc;
+ IAudioClient *clientProc;
WAVEFORMATEXTENSIBLE wavex;
UINT32 bufferSize;
REFERENCE_TIME deviceLatency;
REFERENCE_TIME period;
- double latencySeconds;
- UINT32 framesPerHostCallback;
- AUDCLNT_SHAREMODE shareMode;
- UINT32 streamFlags; // AUDCLNT_STREAMFLAGS_EVENTCALLBACK, ...
- UINT32 flags;
- PaWasapiAudioClientParams params; //!< parameters
+ double latencySeconds;
+ UINT32 framesPerHostCallback;
+ AUDCLNT_SHAREMODE shareMode;
+ UINT32 streamFlags; // AUDCLNT_STREAMFLAGS_EVENTCALLBACK, ...
+ UINT32 flags;
+ PaWasapiAudioClientParams params; //!< parameters
- // Buffers
- UINT32 buffers; //!< number of buffers used (from host side)
- UINT32 framesPerBuffer; //!< number of frames per 1 buffer
- BOOL userBufferAndHostMatch;
+ // Buffers
+ UINT32 buffers; //!< number of buffers used (from host side)
+ UINT32 framesPerBuffer; //!< number of frames per 1 buffer
+ BOOL userBufferAndHostMatch;
- // Used for Mono >> Stereo workaround, if driver does not support it
- // (in Exclusive mode WASAPI usually refuses to operate with Mono (1-ch)
- void *monoBuffer; //!< pointer to buffer
- UINT32 monoBufferSize; //!< buffer size in bytes
- MixMonoToStereoF monoMixer; //!< pointer to mixer function
+ // Used for Mono >> Stereo workaround, if driver does not support it
+ // (in Exclusive mode WASAPI usually refuses to operate with Mono (1-ch)
+ void *monoBuffer; //!< pointer to buffer
+ UINT32 monoBufferSize; //!< buffer size in bytes
+ MixMonoToStereoF monoMixer; //!< pointer to mixer function
- PaUtilRingBuffer *tailBuffer; //!< buffer with trailing sample for blocking mode operations (only for Input)
- void *tailBufferMemory; //!< tail buffer memory region
+ PaUtilRingBuffer *tailBuffer; //!< buffer with trailing sample for blocking mode operations (only for Input)
+ void *tailBufferMemory; //!< tail buffer memory region
}
PaWasapiSubStream;
@@ -546,65 +546,65 @@ PaWasapiHostProcessor;
// ------------------------------------------------------------------------------------------
typedef struct PaWasapiStream
{
- /* IMPLEMENT ME: rename this */
+ /* IMPLEMENT ME: rename this */
PaUtilStreamRepresentation streamRepresentation;
PaUtilCpuLoadMeasurer cpuLoadMeasurer;
PaUtilBufferProcessor bufferProcessor;
// input
- PaWasapiSubStream in;
+ PaWasapiSubStream in;
IAudioCaptureClient *captureClientParent;
#ifndef PA_WINRT
- IStream *captureClientStream;
+ IStream *captureClientStream;
#endif
- IAudioCaptureClient *captureClient;
+ IAudioCaptureClient *captureClient;
IAudioEndpointVolume *inVol;
- // output
- PaWasapiSubStream out;
+ // output
+ PaWasapiSubStream out;
IAudioRenderClient *renderClientParent;
#ifndef PA_WINRT
- IStream *renderClientStream;
+ IStream *renderClientStream;
#endif
- IAudioRenderClient *renderClient;
- IAudioEndpointVolume *outVol;
+ IAudioRenderClient *renderClient;
+ IAudioEndpointVolume *outVol;
- // event handles for event-driven processing mode
- HANDLE event[S_COUNT];
+ // event handles for event-driven processing mode
+ HANDLE event[S_COUNT];
- // buffer mode
- PaUtilHostBufferSizeMode bufferMode;
+ // buffer mode
+ PaUtilHostBufferSizeMode bufferMode;
- // must be volatile to avoid race condition on user query while
- // thread is being started
+ // must be volatile to avoid race condition on user query while
+ // thread is being started
volatile BOOL running;
PA_THREAD_ID dwThreadId;
HANDLE hThread;
- HANDLE hCloseRequest;
- HANDLE hThreadStart; //!< signalled by thread on start
- HANDLE hThreadExit; //!< signalled by thread on exit
- HANDLE hBlockingOpStreamRD;
- HANDLE hBlockingOpStreamWR;
+ HANDLE hCloseRequest;
+ HANDLE hThreadStart; //!< signalled by thread on start
+ HANDLE hThreadExit; //!< signalled by thread on exit
+ HANDLE hBlockingOpStreamRD;
+ HANDLE hBlockingOpStreamWR;
// Host callback Output overrider
- PaWasapiHostProcessor hostProcessOverrideOutput;
+ PaWasapiHostProcessor hostProcessOverrideOutput;
// Host callback Input overrider
- PaWasapiHostProcessor hostProcessOverrideInput;
+ PaWasapiHostProcessor hostProcessOverrideInput;
- // Defines blocking/callback interface used
- BOOL bBlocking;
+ // Defines blocking/callback interface used
+ BOOL bBlocking;
- // Av Task (MM thread management)
- HANDLE hAvTask;
+ // Av Task (MM thread management)
+ HANDLE hAvTask;
- // Thread priority level
- PaWasapiThreadPriority nThreadPriority;
+ // Thread priority level
+ PaWasapiThreadPriority nThreadPriority;
- // State handler
- PaWasapiStreamStateCallback fnStateHandler;
- void *pStateHandlerUserData;
+ // State handler
+ PaWasapiStreamStateCallback fnStateHandler;
+ void *pStateHandlerUserData;
}
PaWasapiStream;
@@ -638,143 +638,143 @@ static HRESULT __LogHostError(HRESULT res, const char *func, const char *file, i
{
const char *text = NULL;
switch (res)
- {
- case S_OK: return res;
- case E_POINTER :text ="E_POINTER"; break;
- case E_INVALIDARG :text ="E_INVALIDARG"; break;
+ {
+ case S_OK: return res;
+ case E_POINTER :text ="E_POINTER"; break;
+ case E_INVALIDARG :text ="E_INVALIDARG"; break;
- case AUDCLNT_E_NOT_INITIALIZED :text ="AUDCLNT_E_NOT_INITIALIZED"; break;
- case AUDCLNT_E_ALREADY_INITIALIZED :text ="AUDCLNT_E_ALREADY_INITIALIZED"; break;
- case AUDCLNT_E_WRONG_ENDPOINT_TYPE :text ="AUDCLNT_E_WRONG_ENDPOINT_TYPE"; break;
- case AUDCLNT_E_DEVICE_INVALIDATED :text ="AUDCLNT_E_DEVICE_INVALIDATED"; break;
- case AUDCLNT_E_NOT_STOPPED :text ="AUDCLNT_E_NOT_STOPPED"; break;
- case AUDCLNT_E_BUFFER_TOO_LARGE :text ="AUDCLNT_E_BUFFER_TOO_LARGE"; break;
- case AUDCLNT_E_OUT_OF_ORDER :text ="AUDCLNT_E_OUT_OF_ORDER"; break;
- case AUDCLNT_E_UNSUPPORTED_FORMAT :text ="AUDCLNT_E_UNSUPPORTED_FORMAT"; break;
- case AUDCLNT_E_INVALID_SIZE :text ="AUDCLNT_E_INVALID_SIZE"; break;
- case AUDCLNT_E_DEVICE_IN_USE :text ="AUDCLNT_E_DEVICE_IN_USE"; break;
- case AUDCLNT_E_BUFFER_OPERATION_PENDING :text ="AUDCLNT_E_BUFFER_OPERATION_PENDING"; break;
- case AUDCLNT_E_THREAD_NOT_REGISTERED :text ="AUDCLNT_E_THREAD_NOT_REGISTERED"; break;
- case AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED :text ="AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED"; break;
- case AUDCLNT_E_ENDPOINT_CREATE_FAILED :text ="AUDCLNT_E_ENDPOINT_CREATE_FAILED"; break;
- case AUDCLNT_E_SERVICE_NOT_RUNNING :text ="AUDCLNT_E_SERVICE_NOT_RUNNING"; break;
- case AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED :text ="AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED"; break;
- case AUDCLNT_E_EXCLUSIVE_MODE_ONLY :text ="AUDCLNT_E_EXCLUSIVE_MODE_ONLY"; break;
- case AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL :text ="AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL"; break;
- case AUDCLNT_E_EVENTHANDLE_NOT_SET :text ="AUDCLNT_E_EVENTHANDLE_NOT_SET"; break;
- case AUDCLNT_E_INCORRECT_BUFFER_SIZE :text ="AUDCLNT_E_INCORRECT_BUFFER_SIZE"; break;
- case AUDCLNT_E_BUFFER_SIZE_ERROR :text ="AUDCLNT_E_BUFFER_SIZE_ERROR"; break;
- case AUDCLNT_E_CPUUSAGE_EXCEEDED :text ="AUDCLNT_E_CPUUSAGE_EXCEEDED"; break;
- case AUDCLNT_E_BUFFER_ERROR :text ="AUDCLNT_E_BUFFER_ERROR"; break;
- case AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED :text ="AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED"; break;
- case AUDCLNT_E_INVALID_DEVICE_PERIOD :text ="AUDCLNT_E_INVALID_DEVICE_PERIOD"; break;
+ case AUDCLNT_E_NOT_INITIALIZED :text ="AUDCLNT_E_NOT_INITIALIZED"; break;
+ case AUDCLNT_E_ALREADY_INITIALIZED :text ="AUDCLNT_E_ALREADY_INITIALIZED"; break;
+ case AUDCLNT_E_WRONG_ENDPOINT_TYPE :text ="AUDCLNT_E_WRONG_ENDPOINT_TYPE"; break;
+ case AUDCLNT_E_DEVICE_INVALIDATED :text ="AUDCLNT_E_DEVICE_INVALIDATED"; break;
+ case AUDCLNT_E_NOT_STOPPED :text ="AUDCLNT_E_NOT_STOPPED"; break;
+ case AUDCLNT_E_BUFFER_TOO_LARGE :text ="AUDCLNT_E_BUFFER_TOO_LARGE"; break;
+ case AUDCLNT_E_OUT_OF_ORDER :text ="AUDCLNT_E_OUT_OF_ORDER"; break;
+ case AUDCLNT_E_UNSUPPORTED_FORMAT :text ="AUDCLNT_E_UNSUPPORTED_FORMAT"; break;
+ case AUDCLNT_E_INVALID_SIZE :text ="AUDCLNT_E_INVALID_SIZE"; break;
+ case AUDCLNT_E_DEVICE_IN_USE :text ="AUDCLNT_E_DEVICE_IN_USE"; break;
+ case AUDCLNT_E_BUFFER_OPERATION_PENDING :text ="AUDCLNT_E_BUFFER_OPERATION_PENDING"; break;
+ case AUDCLNT_E_THREAD_NOT_REGISTERED :text ="AUDCLNT_E_THREAD_NOT_REGISTERED"; break;
+ case AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED :text ="AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED"; break;
+ case AUDCLNT_E_ENDPOINT_CREATE_FAILED :text ="AUDCLNT_E_ENDPOINT_CREATE_FAILED"; break;
+ case AUDCLNT_E_SERVICE_NOT_RUNNING :text ="AUDCLNT_E_SERVICE_NOT_RUNNING"; break;
+ case AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED :text ="AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED"; break;
+ case AUDCLNT_E_EXCLUSIVE_MODE_ONLY :text ="AUDCLNT_E_EXCLUSIVE_MODE_ONLY"; break;
+ case AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL :text ="AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL"; break;
+ case AUDCLNT_E_EVENTHANDLE_NOT_SET :text ="AUDCLNT_E_EVENTHANDLE_NOT_SET"; break;
+ case AUDCLNT_E_INCORRECT_BUFFER_SIZE :text ="AUDCLNT_E_INCORRECT_BUFFER_SIZE"; break;
+ case AUDCLNT_E_BUFFER_SIZE_ERROR :text ="AUDCLNT_E_BUFFER_SIZE_ERROR"; break;
+ case AUDCLNT_E_CPUUSAGE_EXCEEDED :text ="AUDCLNT_E_CPUUSAGE_EXCEEDED"; break;
+ case AUDCLNT_E_BUFFER_ERROR :text ="AUDCLNT_E_BUFFER_ERROR"; break;
+ case AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED :text ="AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED"; break;
+ case AUDCLNT_E_INVALID_DEVICE_PERIOD :text ="AUDCLNT_E_INVALID_DEVICE_PERIOD"; break;
#ifdef AUDCLNT_E_INVALID_STREAM_FLAG
- case AUDCLNT_E_INVALID_STREAM_FLAG :text ="AUDCLNT_E_INVALID_STREAM_FLAG"; break;
+ case AUDCLNT_E_INVALID_STREAM_FLAG :text ="AUDCLNT_E_INVALID_STREAM_FLAG"; break;
#endif
#ifdef AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE
- case AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE :text ="AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE"; break;
+ case AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE :text ="AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE"; break;
#endif
#ifdef AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES
- case AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES :text ="AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES"; break;
+ case AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES :text ="AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES"; break;
#endif
#ifdef AUDCLNT_E_OFFLOAD_MODE_ONLY
- case AUDCLNT_E_OFFLOAD_MODE_ONLY :text ="AUDCLNT_E_OFFLOAD_MODE_ONLY"; break;
+ case AUDCLNT_E_OFFLOAD_MODE_ONLY :text ="AUDCLNT_E_OFFLOAD_MODE_ONLY"; break;
#endif
#ifdef AUDCLNT_E_NONOFFLOAD_MODE_ONLY
- case AUDCLNT_E_NONOFFLOAD_MODE_ONLY :text ="AUDCLNT_E_NONOFFLOAD_MODE_ONLY"; break;
+ case AUDCLNT_E_NONOFFLOAD_MODE_ONLY :text ="AUDCLNT_E_NONOFFLOAD_MODE_ONLY"; break;
#endif
#ifdef AUDCLNT_E_RESOURCES_INVALIDATED
- case AUDCLNT_E_RESOURCES_INVALIDATED :text ="AUDCLNT_E_RESOURCES_INVALIDATED"; break;
+ case AUDCLNT_E_RESOURCES_INVALIDATED :text ="AUDCLNT_E_RESOURCES_INVALIDATED"; break;
#endif
#ifdef AUDCLNT_E_RAW_MODE_UNSUPPORTED
- case AUDCLNT_E_RAW_MODE_UNSUPPORTED :text ="AUDCLNT_E_RAW_MODE_UNSUPPORTED"; break;
+ case AUDCLNT_E_RAW_MODE_UNSUPPORTED :text ="AUDCLNT_E_RAW_MODE_UNSUPPORTED"; break;
#endif
#ifdef AUDCLNT_E_ENGINE_PERIODICITY_LOCKED
- case AUDCLNT_E_ENGINE_PERIODICITY_LOCKED :text ="AUDCLNT_E_ENGINE_PERIODICITY_LOCKED"; break;
+ case AUDCLNT_E_ENGINE_PERIODICITY_LOCKED :text ="AUDCLNT_E_ENGINE_PERIODICITY_LOCKED"; break;
#endif
#ifdef AUDCLNT_E_ENGINE_FORMAT_LOCKED
- case AUDCLNT_E_ENGINE_FORMAT_LOCKED :text ="AUDCLNT_E_ENGINE_FORMAT_LOCKED"; break;
+ case AUDCLNT_E_ENGINE_FORMAT_LOCKED :text ="AUDCLNT_E_ENGINE_FORMAT_LOCKED"; break;
#endif
- case AUDCLNT_S_BUFFER_EMPTY :text ="AUDCLNT_S_BUFFER_EMPTY"; break;
- case AUDCLNT_S_THREAD_ALREADY_REGISTERED :text ="AUDCLNT_S_THREAD_ALREADY_REGISTERED"; break;
- case AUDCLNT_S_POSITION_STALLED :text ="AUDCLNT_S_POSITION_STALLED"; break;
+ case AUDCLNT_S_BUFFER_EMPTY :text ="AUDCLNT_S_BUFFER_EMPTY"; break;
+ case AUDCLNT_S_THREAD_ALREADY_REGISTERED :text ="AUDCLNT_S_THREAD_ALREADY_REGISTERED"; break;
+ case AUDCLNT_S_POSITION_STALLED :text ="AUDCLNT_S_POSITION_STALLED"; break;
- // other windows common errors:
- case CO_E_NOTINITIALIZED :text ="CO_E_NOTINITIALIZED: you must call CoInitialize() before Pa_OpenStream()"; break;
+ // other windows common errors:
+ case CO_E_NOTINITIALIZED :text ="CO_E_NOTINITIALIZED: you must call CoInitialize() before Pa_OpenStream()"; break;
- default:
- text = "UNKNOWN ERROR";
+ default:
+ text = "UNKNOWN ERROR";
}
- PRINT(("WASAPI ERROR HRESULT: 0x%X : %s\n [FUNCTION: %s FILE: %s {LINE: %d}]\n", res, text, func, file, line));
+ PRINT(("WASAPI ERROR HRESULT: 0x%X : %s\n [FUNCTION: %s FILE: %s {LINE: %d}]\n", res, text, func, file, line));
#ifndef PA_ENABLE_DEBUG_OUTPUT
- (void)func; (void)file; (void)line;
+ (void)func; (void)file; (void)line;
#endif
- PA_SKELETON_SET_LAST_HOST_ERROR(res, text);
- return res;
+ PA_SKELETON_SET_LAST_HOST_ERROR(res, text);
+ return res;
}
// ------------------------------------------------------------------------------------------
#define LogPaError(PAERR) __LogPaError(PAERR, __FUNCTION__, __FILE__, __LINE__)
static PaError __LogPaError(PaError err, const char *func, const char *file, int line)
{
- if (err == paNoError)
- return err;
+ if (err == paNoError)
+ return err;
- PRINT(("WASAPI ERROR PAERROR: %i : %s\n [FUNCTION: %s FILE: %s {LINE: %d}]\n", err, Pa_GetErrorText(err), func, file, line));
+ PRINT(("WASAPI ERROR PAERROR: %i : %s\n [FUNCTION: %s FILE: %s {LINE: %d}]\n", err, Pa_GetErrorText(err), func, file, line));
#ifndef PA_ENABLE_DEBUG_OUTPUT
- (void)func; (void)file; (void)line;
+ (void)func; (void)file; (void)line;
#endif
- return err;
+ return err;
}
// ------------------------------------------------------------------------------------------
/*! \class ThreadSleepScheduler
Allows to emulate thread sleep of less than 1 millisecond under Windows. Scheduler
- calculates number of times the thread must run untill next sleep of 1 millisecond.
- It does not make thread sleeping for real number of microseconds but rather controls
- how many of imaginary microseconds the thread task can allow thread to sleep.
+ calculates number of times the thread must run untill next sleep of 1 millisecond.
+ It does not make thread sleeping for real number of microseconds but rather controls
+ how many of imaginary microseconds the thread task can allow thread to sleep.
*/
typedef struct ThreadIdleScheduler
{
- UINT32 m_idle_microseconds; //!< number of microseconds to sleep
- UINT32 m_next_sleep; //!< next sleep round
- UINT32 m_i; //!< current round iterator position
- UINT32 m_resolution; //!< resolution in number of milliseconds
+ UINT32 m_idle_microseconds; //!< number of microseconds to sleep
+ UINT32 m_next_sleep; //!< next sleep round
+ UINT32 m_i; //!< current round iterator position
+ UINT32 m_resolution; //!< resolution in number of milliseconds
}
ThreadIdleScheduler;
//! Setup scheduler.
static void ThreadIdleScheduler_Setup(ThreadIdleScheduler *sched, UINT32 resolution, UINT32 microseconds)
{
- assert(microseconds != 0);
- assert(resolution != 0);
- assert((resolution * 1000) >= microseconds);
+ assert(microseconds != 0);
+ assert(resolution != 0);
+ assert((resolution * 1000) >= microseconds);
- memset(sched, 0, sizeof(*sched));
+ memset(sched, 0, sizeof(*sched));
- sched->m_idle_microseconds = microseconds;
- sched->m_resolution = resolution;
- sched->m_next_sleep = (resolution * 1000) / microseconds;
+ sched->m_idle_microseconds = microseconds;
+ sched->m_resolution = resolution;
+ sched->m_next_sleep = (resolution * 1000) / microseconds;
}
//! Iterate and check if can sleep.
static inline UINT32 ThreadIdleScheduler_NextSleep(ThreadIdleScheduler *sched)
{
- // advance and check if thread can sleep
- if (++sched->m_i == sched->m_next_sleep)
- {
- sched->m_i = 0;
- return sched->m_resolution;
- }
- return 0;
+ // advance and check if thread can sleep
+ if (++sched->m_i == sched->m_next_sleep)
+ {
+ sched->m_i = 0;
+ return sched->m_resolution;
+ }
+ return 0;
}
// ------------------------------------------------------------------------------------------
typedef struct _SystemTimer
{
- UINT32 granularity;
+ UINT32 granularity;
} SystemTimer;
static LARGE_INTEGER g_SystemTimerFrequency;
@@ -784,66 +784,66 @@ static BOOL g_SystemTimerUseQpc = FALSE;
static BOOL SystemTimer_SetGranularity(SystemTimer *timer, UINT32 granularity)
{
#ifndef PA_WINRT
- TIMECAPS caps;
+ TIMECAPS caps;
- timer->granularity = granularity;
+ timer->granularity = granularity;
- if (timeGetDevCaps(&caps, sizeof(caps)) == MMSYSERR_NOERROR)
- {
- if (timer->granularity < caps.wPeriodMin)
- timer->granularity = caps.wPeriodMin;
- }
+ if (timeGetDevCaps(&caps, sizeof(caps)) == MMSYSERR_NOERROR)
+ {
+ if (timer->granularity < caps.wPeriodMin)
+ timer->granularity = caps.wPeriodMin;
+ }
if (timeBeginPeriod(timer->granularity) != TIMERR_NOERROR)
- {
+ {
PRINT(("SetSystemTimer: timeBeginPeriod(1) failed!\n"));
- timer->granularity = 0;
- return FALSE;
+ timer->granularity = 0;
+ return FALSE;
}
#endif
- return TRUE;
+ return TRUE;
}
//! Restore granularity of the system timer.
static void SystemTimer_RestoreGranularity(SystemTimer *timer)
{
#ifndef PA_WINRT
- if (timer->granularity != 0)
- {
- if (timeEndPeriod(timer->granularity) != TIMERR_NOERROR)
- {
- PRINT(("RestoreSystemTimer: timeEndPeriod(1) failed!\n"));
- }
- }
+ if (timer->granularity != 0)
+ {
+ if (timeEndPeriod(timer->granularity) != TIMERR_NOERROR)
+ {
+ PRINT(("RestoreSystemTimer: timeEndPeriod(1) failed!\n"));
+ }
+ }
#endif
}
//! Initialize high-resolution time getter.
static void SystemTimer_InitializeTimeGetter()
{
- g_SystemTimerUseQpc = QueryPerformanceFrequency(&g_SystemTimerFrequency);
+ g_SystemTimerUseQpc = QueryPerformanceFrequency(&g_SystemTimerFrequency);
}
//! Get high-resolution time in milliseconds (using QPC by default).
static inline LONGLONG SystemTimer_GetTime(SystemTimer *timer)
{
- // QPC: https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
- if (g_SystemTimerUseQpc)
- {
- LARGE_INTEGER now;
- QueryPerformanceCounter(&now);
- return (now.QuadPart * 1000LL) / g_SystemTimerFrequency.QuadPart;
- }
- else
- {
- #ifdef PA_WINRT
- return GetTickCount64();
- #else
- return timeGetTime();
- #endif
- }
+ // QPC: https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
+ if (g_SystemTimerUseQpc)
+ {
+ LARGE_INTEGER now;
+ QueryPerformanceCounter(&now);
+ return (now.QuadPart * 1000LL) / g_SystemTimerFrequency.QuadPart;
+ }
+ else
+ {
+ #ifdef PA_WINRT
+ return GetTickCount64();
+ #else
+ return timeGetTime();
+ #endif
+ }
}
// ------------------------------------------------------------------------------------------
@@ -852,7 +852,7 @@ static inline LONGLONG SystemTimer_GetTime(SystemTimer *timer)
// 1 nano = 0.000000001 seconds
//100 nano = 0.0000001 seconds
//100 nano = 0.0001 milliseconds
- return ((double)ref)*0.0001;
+ return ((double)ref) * 0.0001;
}*/
// ------------------------------------------------------------------------------------------
@@ -861,7 +861,7 @@ static double nano100ToSeconds(REFERENCE_TIME ref)
// 1 nano = 0.000000001 seconds
//100 nano = 0.0000001 seconds
//100 nano = 0.0001 milliseconds
- return ((double)ref)*0.0000001;
+ return ((double)ref) * 0.0000001;
}
// ------------------------------------------------------------------------------------------
@@ -870,7 +870,7 @@ static double nano100ToSeconds(REFERENCE_TIME ref)
// 1 nano = 0.000000001 seconds
//100 nano = 0.0000001 seconds
//100 nano = 0.0001 milliseconds
- return (REFERENCE_TIME)(ref/0.0001);
+ return (REFERENCE_TIME)(ref / 0.0001);
}*/
// ------------------------------------------------------------------------------------------
@@ -879,14 +879,14 @@ static REFERENCE_TIME SecondsTonano100(double ref)
// 1 nano = 0.000000001 seconds
//100 nano = 0.0000001 seconds
//100 nano = 0.0001 milliseconds
- return (REFERENCE_TIME)(ref/0.0000001);
+ return (REFERENCE_TIME)(ref / 0.0000001);
}
// ------------------------------------------------------------------------------------------
// Makes Hns period from frames and sample rate
static REFERENCE_TIME MakeHnsPeriod(UINT32 nFrames, DWORD nSamplesPerSec)
{
- return (REFERENCE_TIME)((10000.0 * 1000 / nSamplesPerSec * nFrames) + 0.5);
+ return (REFERENCE_TIME)((10000.0 * 1000 / nSamplesPerSec * nFrames) + 0.5);
}
// ------------------------------------------------------------------------------------------
@@ -894,17 +894,17 @@ static REFERENCE_TIME MakeHnsPeriod(UINT32 nFrames, DWORD nSamplesPerSec)
// Note: paCustomFormat stands for 8.24 format (24-bits inside 32-bit containers)
static WORD PaSampleFormatToBitsPerSample(PaSampleFormat format_id)
{
- switch (format_id & ~paNonInterleaved)
- {
- case paFloat32:
- case paInt32: return 32;
- case paCustomFormat:
- case paInt24: return 24;
- case paInt16: return 16;
- case paInt8:
- case paUInt8: return 8;
- }
- return 0;
+ switch (format_id & ~paNonInterleaved)
+ {
+ case paFloat32:
+ case paInt32: return 32;
+ case paCustomFormat:
+ case paInt24: return 24;
+ case paInt16: return 16;
+ case paInt8:
+ case paUInt8: return 8;
+ }
+ return 0;
}
// ------------------------------------------------------------------------------------------
@@ -913,22 +913,22 @@ static WORD PaSampleFormatToBitsPerSample(PaSampleFormat format_id)
// Note: paCustomFormat stands for 8.24 format (24-bits inside 32-bit containers)
static PaSampleFormat GetSampleFormatForIO(PaSampleFormat format_id)
{
- return ((format_id & ~paNonInterleaved) == paCustomFormat ?
- (paInt32 | (format_id & paNonInterleaved ? paNonInterleaved : 0)) : format_id);
+ return ((format_id & ~paNonInterleaved) == paCustomFormat ?
+ (paInt32 | (format_id & paNonInterleaved ? paNonInterleaved : 0)) : format_id);
}
// ------------------------------------------------------------------------------------------
// Converts Hns period into number of frames
static UINT32 MakeFramesFromHns(REFERENCE_TIME hnsPeriod, UINT32 nSamplesPerSec)
{
- UINT32 nFrames = (UINT32)( // frames =
- 1.0 * hnsPeriod * // hns *
- nSamplesPerSec / // (frames / s) /
- 1000 / // (ms / s) /
- 10000 // (hns / s) /
- + 0.5 // rounding
+ UINT32 nFrames = (UINT32)( // frames =
+ 1.0 * hnsPeriod * // hns *
+ nSamplesPerSec / // (frames / s) /
+ 1000 / // (ms / s) /
+ 10000 // (hns / s) /
+ + 0.5 // rounding
);
- return nFrames;
+ return nFrames;
}
// Aligning function type
@@ -938,27 +938,27 @@ typedef UINT32 (*ALIGN_FUNC) (UINT32 v, UINT32 align);
// Aligns 'v' backwards
static UINT32 ALIGN_BWD(UINT32 v, UINT32 align)
{
- return ((v - (align ? v % align : 0)));
+ return ((v - (align ? v % align : 0)));
}
// ------------------------------------------------------------------------------------------
// Aligns 'v' forward
static UINT32 ALIGN_FWD(UINT32 v, UINT32 align)
{
- UINT32 remainder = (align ? (v % align) : 0);
- if (remainder == 0)
- return v;
- return v + (align - remainder);
+ UINT32 remainder = (align ? (v % align) : 0);
+ if (remainder == 0)
+ return v;
+ return v + (align - remainder);
}
// ------------------------------------------------------------------------------------------
// Get next value power of 2
static UINT32 ALIGN_NEXT_POW2(UINT32 v)
{
- UINT32 v2 = 1;
- while (v > (v2 <<= 1)) { }
- v = v2;
- return v;
+ UINT32 v2 = 1;
+ while (v > (v2 <<= 1)) { }
+ v = v2;
+ return v;
}
// ------------------------------------------------------------------------------------------
@@ -966,28 +966,28 @@ static UINT32 ALIGN_NEXT_POW2(UINT32 v)
// is misaligned. This problem was solved in Windows 7 were AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED
// is thrown although we must align for Vista anyway.
static UINT32 AlignFramesPerBuffer(UINT32 nFrames, UINT32 nSamplesPerSec, UINT32 nBlockAlign,
- ALIGN_FUNC pAlignFunc)
+ ALIGN_FUNC pAlignFunc)
{
#define HDA_PACKET_SIZE (128)
- long frame_bytes = nFrames * nBlockAlign;
- long packets;
- (void)nSamplesPerSec;
+ long frame_bytes = nFrames * nBlockAlign;
+ long packets;
+ (void)nSamplesPerSec;
- // align to packet size
- frame_bytes = pAlignFunc(frame_bytes, HDA_PACKET_SIZE); // use ALIGN_FWD if bigger but safer period is more desired
+ // align to packet size
+ frame_bytes = pAlignFunc(frame_bytes, HDA_PACKET_SIZE); // use ALIGN_FWD if bigger but safer period is more desired
- // atlest 1 frame must be available
- if (frame_bytes < HDA_PACKET_SIZE)
- frame_bytes = HDA_PACKET_SIZE;
+ // atlest 1 frame must be available
+ if (frame_bytes < HDA_PACKET_SIZE)
+ frame_bytes = HDA_PACKET_SIZE;
- nFrames = frame_bytes / nBlockAlign;
- packets = frame_bytes / HDA_PACKET_SIZE;
+ nFrames = frame_bytes / nBlockAlign;
+ packets = frame_bytes / HDA_PACKET_SIZE;
- frame_bytes = packets * HDA_PACKET_SIZE;
- nFrames = frame_bytes / nBlockAlign;
+ frame_bytes = packets * HDA_PACKET_SIZE;
+ nFrames = frame_bytes / nBlockAlign;
- return nFrames;
+ return nFrames;
#undef HDA_PACKET_SIZE
}
@@ -995,16 +995,16 @@ static UINT32 AlignFramesPerBuffer(UINT32 nFrames, UINT32 nSamplesPerSec, UINT32
// ------------------------------------------------------------------------------------------
static UINT32 GetFramesSleepTime(REFERENCE_TIME nFrames, REFERENCE_TIME nSamplesPerSec)
{
- REFERENCE_TIME nDuration;
- if (nSamplesPerSec == 0)
- return 0;
+ REFERENCE_TIME nDuration;
+ if (nSamplesPerSec == 0)
+ return 0;
#define REFTIMES_PER_SEC 10000000LL
#define REFTIMES_PER_MILLISEC 10000LL
- // Calculate the actual duration of the allocated buffer.
- nDuration = (REFTIMES_PER_SEC * nFrames) / nSamplesPerSec;
- return (UINT32)(nDuration / REFTIMES_PER_MILLISEC);
+ // Calculate the actual duration of the allocated buffer.
+ nDuration = (REFTIMES_PER_SEC * nFrames) / nSamplesPerSec;
+ return (UINT32)(nDuration / REFTIMES_PER_MILLISEC);
#undef REFTIMES_PER_SEC
#undef REFTIMES_PER_MILLISEC
@@ -1013,16 +1013,16 @@ static UINT32 GetFramesSleepTime(REFERENCE_TIME nFrames, REFERENCE_TIME nSamples
// ------------------------------------------------------------------------------------------
static UINT32 GetFramesSleepTimeMicroseconds(REFERENCE_TIME nFrames, REFERENCE_TIME nSamplesPerSec)
{
- REFERENCE_TIME nDuration;
- if (nSamplesPerSec == 0)
- return 0;
+ REFERENCE_TIME nDuration;
+ if (nSamplesPerSec == 0)
+ return 0;
#define REFTIMES_PER_SEC 10000000LL
#define REFTIMES_PER_MILLISEC 10000LL
- // Calculate the actual duration of the allocated buffer.
- nDuration = (REFTIMES_PER_SEC * nFrames) / nSamplesPerSec;
- return (UINT32)(nDuration / 10);
+ // Calculate the actual duration of the allocated buffer.
+ nDuration = (REFTIMES_PER_SEC * nFrames) / nSamplesPerSec;
+ return (UINT32)(nDuration / 10);
#undef REFTIMES_PER_SEC
#undef REFTIMES_PER_MILLISEC
@@ -1040,15 +1040,15 @@ static BOOL SetupAVRT()
_GetProc(pAvRtDeleteThreadOrderingGroup, FAvRtDeleteThreadOrderingGroup, "AvRtDeleteThreadOrderingGroup");
_GetProc(pAvRtWaitOnThreadOrderingGroup, FAvRtWaitOnThreadOrderingGroup, "AvRtWaitOnThreadOrderingGroup");
_GetProc(pAvSetMmThreadCharacteristics, FAvSetMmThreadCharacteristics, "AvSetMmThreadCharacteristicsA");
- _GetProc(pAvRevertMmThreadCharacteristics,FAvRevertMmThreadCharacteristics,"AvRevertMmThreadCharacteristics");
+ _GetProc(pAvRevertMmThreadCharacteristics,FAvRevertMmThreadCharacteristics,"AvRevertMmThreadCharacteristics");
_GetProc(pAvSetMmThreadPriority, FAvSetMmThreadPriority, "AvSetMmThreadPriority");
- return pAvRtCreateThreadOrderingGroup &&
- pAvRtDeleteThreadOrderingGroup &&
- pAvRtWaitOnThreadOrderingGroup &&
- pAvSetMmThreadCharacteristics &&
- pAvRevertMmThreadCharacteristics &&
- pAvSetMmThreadPriority;
+ return pAvRtCreateThreadOrderingGroup &&
+ pAvRtDeleteThreadOrderingGroup &&
+ pAvRtWaitOnThreadOrderingGroup &&
+ pAvSetMmThreadCharacteristics &&
+ pAvRevertMmThreadCharacteristics &&
+ pAvSetMmThreadPriority;
}
#endif
@@ -1056,9 +1056,9 @@ static BOOL SetupAVRT()
static void CloseAVRT()
{
#ifndef PA_WINRT
- if (hDInputDLL != NULL)
- FreeLibrary(hDInputDLL);
- hDInputDLL = NULL;
+ if (hDInputDLL != NULL)
+ FreeLibrary(hDInputDLL);
+ hDInputDLL = NULL;
#endif
}
@@ -1067,10 +1067,10 @@ static BOOL IsWow64()
{
#ifndef PA_WINRT
- // http://msdn.microsoft.com/en-us/library/ms684139(VS.85).aspx
+ // http://msdn.microsoft.com/en-us/library/ms684139(VS.85).aspx
- typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
- LPFN_ISWOW64PROCESS fnIsWow64Process;
+ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
+ LPFN_ISWOW64PROCESS fnIsWow64Process;
BOOL bIsWow64 = FALSE;
@@ -1082,16 +1082,16 @@ static BOOL IsWow64()
GetModuleHandleA("kernel32"), "IsWow64Process");
if (fnIsWow64Process == NULL)
- return FALSE;
+ return FALSE;
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
- return FALSE;
+ return FALSE;
return bIsWow64;
#else
- return FALSE;
+ return FALSE;
#endif
}
@@ -1099,277 +1099,277 @@ static BOOL IsWow64()
// ------------------------------------------------------------------------------------------
typedef enum EWindowsVersion
{
- WINDOWS_UNKNOWN = 0,
- WINDOWS_VISTA_SERVER2008,
- WINDOWS_7_SERVER2008R2,
- WINDOWS_8_SERVER2012,
- WINDOWS_8_1_SERVER2012R2,
- WINDOWS_10_SERVER2016,
- WINDOWS_FUTURE
+ WINDOWS_UNKNOWN = 0,
+ WINDOWS_VISTA_SERVER2008,
+ WINDOWS_7_SERVER2008R2,
+ WINDOWS_8_SERVER2012,
+ WINDOWS_8_1_SERVER2012R2,
+ WINDOWS_10_SERVER2016,
+ WINDOWS_FUTURE
}
EWindowsVersion;
// Alternative way for checking Windows version (allows to check version on Windows 8.1 and up)
#ifndef PA_WINRT
static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
{
- typedef ULONGLONG (NTAPI *LPFN_VERSETCONDITIONMASK)(ULONGLONG ConditionMask, DWORD TypeMask, BYTE Condition);
- typedef BOOL (WINAPI *LPFN_VERIFYVERSIONINFO)(LPOSVERSIONINFOEXA lpVersionInformation, DWORD dwTypeMask, DWORDLONG dwlConditionMask);
+ typedef ULONGLONG (NTAPI *LPFN_VERSETCONDITIONMASK)(ULONGLONG ConditionMask, DWORD TypeMask, BYTE Condition);
+ typedef BOOL (WINAPI *LPFN_VERIFYVERSIONINFO)(LPOSVERSIONINFOEXA lpVersionInformation, DWORD dwTypeMask, DWORDLONG dwlConditionMask);
- LPFN_VERSETCONDITIONMASK fnVerSetConditionMask;
- LPFN_VERIFYVERSIONINFO fnVerifyVersionInfo;
- OSVERSIONINFOEXA osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 };
- DWORDLONG dwlConditionMask;
+ LPFN_VERSETCONDITIONMASK fnVerSetConditionMask;
+ LPFN_VERIFYVERSIONINFO fnVerifyVersionInfo;
+ OSVERSIONINFOEXA osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 };
+ DWORDLONG dwlConditionMask;
- fnVerSetConditionMask = (LPFN_VERSETCONDITIONMASK)GetProcAddress(GetModuleHandleA("kernel32"), "VerSetConditionMask");
- fnVerifyVersionInfo = (LPFN_VERIFYVERSIONINFO)GetProcAddress(GetModuleHandleA("kernel32"), "VerifyVersionInfoA");
+ fnVerSetConditionMask = (LPFN_VERSETCONDITIONMASK)GetProcAddress(GetModuleHandleA("kernel32"), "VerSetConditionMask");
+ fnVerifyVersionInfo = (LPFN_VERIFYVERSIONINFO)GetProcAddress(GetModuleHandleA("kernel32"), "VerifyVersionInfoA");
- if ((fnVerSetConditionMask == NULL) || (fnVerifyVersionInfo == NULL))
- return FALSE;
+ if ((fnVerSetConditionMask == NULL) || (fnVerifyVersionInfo == NULL))
+ return FALSE;
- dwlConditionMask = fnVerSetConditionMask(
- fnVerSetConditionMask(
- fnVerSetConditionMask(
- 0, VER_MAJORVERSION, VER_GREATER_EQUAL),
- VER_MINORVERSION, VER_GREATER_EQUAL),
- VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
+ dwlConditionMask = fnVerSetConditionMask(
+ fnVerSetConditionMask(
+ fnVerSetConditionMask(
+ 0, VER_MAJORVERSION, VER_GREATER_EQUAL),
+ VER_MINORVERSION, VER_GREATER_EQUAL),
+ VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
- osvi.dwMajorVersion = wMajorVersion;
- osvi.dwMinorVersion = wMinorVersion;
- osvi.wServicePackMajor = wServicePackMajor;
+ osvi.dwMajorVersion = wMajorVersion;
+ osvi.dwMinorVersion = wMinorVersion;
+ osvi.wServicePackMajor = wServicePackMajor;
- return (fnVerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE);
+ return (fnVerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE);
}
#endif
// Get Windows version
static EWindowsVersion GetWindowsVersion()
{
#ifndef PA_WINRT
- static EWindowsVersion version = WINDOWS_UNKNOWN;
+ static EWindowsVersion version = WINDOWS_UNKNOWN;
- if (version == WINDOWS_UNKNOWN)
- {
- DWORD dwMajorVersion = 0xFFFFFFFFU, dwMinorVersion = 0, dwBuild = 0;
-
- // RTL_OSVERSIONINFOW equals OSVERSIONINFOW but it is missing inb MinGW winnt.h header,
- // thus use OSVERSIONINFOW for greater portability
- typedef NTSTATUS (WINAPI *LPFN_RTLGETVERSION)(POSVERSIONINFOW lpVersionInformation);
- LPFN_RTLGETVERSION fnRtlGetVersion;
+ if (version == WINDOWS_UNKNOWN)
+ {
+ DWORD dwMajorVersion = 0xFFFFFFFFU, dwMinorVersion = 0, dwBuild = 0;
+
+ // RTL_OSVERSIONINFOW equals OSVERSIONINFOW but it is missing inb MinGW winnt.h header,
+ // thus use OSVERSIONINFOW for greater portability
+ typedef NTSTATUS (WINAPI *LPFN_RTLGETVERSION)(POSVERSIONINFOW lpVersionInformation);
+ LPFN_RTLGETVERSION fnRtlGetVersion;
- #define NTSTATUS_SUCCESS ((NTSTATUS)0x00000000L)
+ #define NTSTATUS_SUCCESS ((NTSTATUS)0x00000000L)
- // RtlGetVersion must be able to provide true Windows version (Windows 10 may be reported as Windows 8
- // by GetVersion API)
- if ((fnRtlGetVersion = (LPFN_RTLGETVERSION)GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion")) != NULL)
- {
- OSVERSIONINFOW ver = { sizeof(OSVERSIONINFOW), 0, 0, 0, 0, {0} };
+ // RtlGetVersion must be able to provide true Windows version (Windows 10 may be reported as Windows 8
+ // by GetVersion API)
+ if ((fnRtlGetVersion = (LPFN_RTLGETVERSION)GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion")) != NULL)
+ {
+ OSVERSIONINFOW ver = { sizeof(OSVERSIONINFOW), 0, 0, 0, 0, {0} };
- PRINT(("WASAPI: getting Windows version with RtlGetVersion()\n"));
+ PRINT(("WASAPI: getting Windows version with RtlGetVersion()\n"));
- if (fnRtlGetVersion(&ver) == NTSTATUS_SUCCESS)
- {
- dwMajorVersion = ver.dwMajorVersion;
- dwMinorVersion = ver.dwMinorVersion;
- dwBuild = ver.dwBuildNumber;
- }
- }
+ if (fnRtlGetVersion(&ver) == NTSTATUS_SUCCESS)
+ {
+ dwMajorVersion = ver.dwMajorVersion;
+ dwMinorVersion = ver.dwMinorVersion;
+ dwBuild = ver.dwBuildNumber;
+ }
+ }
- #undef NTSTATUS_SUCCESS
+ #undef NTSTATUS_SUCCESS
- // fallback to GetVersion if RtlGetVersion is missing
- if (dwMajorVersion == 0xFFFFFFFFU)
- {
- typedef DWORD (WINAPI *LPFN_GETVERSION)(VOID);
- LPFN_GETVERSION fnGetVersion;
+ // fallback to GetVersion if RtlGetVersion is missing
+ if (dwMajorVersion == 0xFFFFFFFFU)
+ {
+ typedef DWORD (WINAPI *LPFN_GETVERSION)(VOID);
+ LPFN_GETVERSION fnGetVersion;
- if ((fnGetVersion = (LPFN_GETVERSION)GetProcAddress(GetModuleHandleA("kernel32"), "GetVersion")) != NULL)
- {
- DWORD dwVersion;
+ if ((fnGetVersion = (LPFN_GETVERSION)GetProcAddress(GetModuleHandleA("kernel32"), "GetVersion")) != NULL)
+ {
+ DWORD dwVersion;
- PRINT(("WASAPI: getting Windows version with GetVersion()\n"));
+ PRINT(("WASAPI: getting Windows version with GetVersion()\n"));
- dwVersion = fnGetVersion();
+ dwVersion = fnGetVersion();
- dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
- dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
+ dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
+ dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
- if (dwVersion < 0x80000000)
- dwBuild = (DWORD)(HIWORD(dwVersion));
- }
- }
+ if (dwVersion < 0x80000000)
+ dwBuild = (DWORD)(HIWORD(dwVersion));
+ }
+ }
- if (dwMajorVersion != 0xFFFFFFFFU)
- {
- switch (dwMajorVersion)
- {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- break; // skip lower
- case 6:
- switch (dwMinorVersion)
- {
- case 0: version = WINDOWS_VISTA_SERVER2008; break;
- case 1: version = WINDOWS_7_SERVER2008R2; break;
- case 2: version = WINDOWS_8_SERVER2012; break;
- case 3: version = WINDOWS_8_1_SERVER2012R2; break;
- default: version = WINDOWS_FUTURE; break;
- }
- break;
- case 10:
- switch (dwMinorVersion)
- {
- case 0: version = WINDOWS_10_SERVER2016; break;
- default: version = WINDOWS_FUTURE; break;
- }
- break;
- default:
- version = WINDOWS_FUTURE;
- break;
- }
- }
- // fallback to VerifyVersionInfo if RtlGetVersion and GetVersion are missing
- else
- {
- PRINT(("WASAPI: getting Windows version with VerifyVersionInfo()\n"));
+ if (dwMajorVersion != 0xFFFFFFFFU)
+ {
+ switch (dwMajorVersion)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ break; // skip lower
+ case 6:
+ switch (dwMinorVersion)
+ {
+ case 0: version = WINDOWS_VISTA_SERVER2008; break;
+ case 1: version = WINDOWS_7_SERVER2008R2; break;
+ case 2: version = WINDOWS_8_SERVER2012; break;
+ case 3: version = WINDOWS_8_1_SERVER2012R2; break;
+ default: version = WINDOWS_FUTURE; break;
+ }
+ break;
+ case 10:
+ switch (dwMinorVersion)
+ {
+ case 0: version = WINDOWS_10_SERVER2016; break;
+ default: version = WINDOWS_FUTURE; break;
+ }
+ break;
+ default:
+ version = WINDOWS_FUTURE;
+ break;
+ }
+ }
+ // fallback to VerifyVersionInfo if RtlGetVersion and GetVersion are missing
+ else
+ {
+ PRINT(("WASAPI: getting Windows version with VerifyVersionInfo()\n"));
- if (IsWindowsVersionOrGreater(10, 0, 0))
- version = WINDOWS_10_SERVER2016;
- else
- if (IsWindowsVersionOrGreater(6, 3, 0))
- version = WINDOWS_8_1_SERVER2012R2;
- else
- if (IsWindowsVersionOrGreater(6, 2, 0))
- version = WINDOWS_8_SERVER2012;
- else
- if (IsWindowsVersionOrGreater(6, 1, 0))
- version = WINDOWS_7_SERVER2008R2;
- else
- if (IsWindowsVersionOrGreater(6, 0, 0))
- version = WINDOWS_VISTA_SERVER2008;
- else
- version = WINDOWS_FUTURE;
- }
+ if (IsWindowsVersionOrGreater(10, 0, 0))
+ version = WINDOWS_10_SERVER2016;
+ else
+ if (IsWindowsVersionOrGreater(6, 3, 0))
+ version = WINDOWS_8_1_SERVER2012R2;
+ else
+ if (IsWindowsVersionOrGreater(6, 2, 0))
+ version = WINDOWS_8_SERVER2012;
+ else
+ if (IsWindowsVersionOrGreater(6, 1, 0))
+ version = WINDOWS_7_SERVER2008R2;
+ else
+ if (IsWindowsVersionOrGreater(6, 0, 0))
+ version = WINDOWS_VISTA_SERVER2008;
+ else
+ version = WINDOWS_FUTURE;
+ }
- PRINT(("WASAPI: Windows version = %d\n", version));
- }
+ PRINT(("WASAPI: Windows version = %d\n", version));
+ }
- return version;
+ return version;
#else
- #if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
- return WINDOWS_10_SERVER2016;
- #else
- return WINDOWS_8_SERVER2012;
- #endif
+ #if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
+ return WINDOWS_10_SERVER2016;
+ #else
+ return WINDOWS_8_SERVER2012;
+ #endif
#endif
}
// ------------------------------------------------------------------------------------------
static BOOL UseWOW64Workaround()
{
- // note: WOW64 bug is common to Windows Vista x64, thus we fall back to safe Poll-driven
- // method. Windows 7 x64 seems has WOW64 bug fixed.
+ // note: WOW64 bug is common to Windows Vista x64, thus we fall back to safe Poll-driven
+ // method. Windows 7 x64 seems has WOW64 bug fixed.
- return (IsWow64() && (GetWindowsVersion() == WINDOWS_VISTA_SERVER2008));
+ return (IsWow64() && (GetWindowsVersion() == WINDOWS_VISTA_SERVER2008));
}
// ------------------------------------------------------------------------------------------
static UINT32 GetAudioClientVersion()
{
- if (GetWindowsVersion() >= WINDOWS_10_SERVER2016)
- return 3;
- else
- if (GetWindowsVersion() >= WINDOWS_8_SERVER2012)
- return 2;
+ if (GetWindowsVersion() >= WINDOWS_10_SERVER2016)
+ return 3;
+ else
+ if (GetWindowsVersion() >= WINDOWS_8_SERVER2012)
+ return 2;
- return 1;
+ return 1;
}
// ------------------------------------------------------------------------------------------
static const IID *GetAudioClientIID()
{
- static const IID *cli_iid = NULL;
- if (cli_iid == NULL)
- {
- UINT32 cli_version = GetAudioClientVersion();
- switch (cli_version)
- {
- case 3: cli_iid = &pa_IID_IAudioClient3; break;
- case 2: cli_iid = &pa_IID_IAudioClient2; break;
- default: cli_iid = &pa_IID_IAudioClient; break;
- }
+ static const IID *cli_iid = NULL;
+ if (cli_iid == NULL)
+ {
+ UINT32 cli_version = GetAudioClientVersion();
+ switch (cli_version)
+ {
+ case 3: cli_iid = &pa_IID_IAudioClient3; break;
+ case 2: cli_iid = &pa_IID_IAudioClient2; break;
+ default: cli_iid = &pa_IID_IAudioClient; break;
+ }
- PRINT(("WASAPI: IAudioClient version = %d\n", cli_version));
- }
+ PRINT(("WASAPI: IAudioClient version = %d\n", cli_version));
+ }
- return cli_iid;
+ return cli_iid;
}
// ------------------------------------------------------------------------------------------
typedef enum EMixDirection
{
- MIX_DIR__1TO2, //!< mix one channel to L and R
- MIX_DIR__2TO1, //!< mix L and R channels to one channel
- MIX_DIR__2TO1_L //!< mix only L channel (of total 2 channels) to one channel
+ MIX_DIR__1TO2, //!< mix one channel to L and R
+ MIX_DIR__2TO1, //!< mix L and R channels to one channel
+ MIX_DIR__2TO1_L //!< mix only L channel (of total 2 channels) to one channel
}
EMixDirection;
// ------------------------------------------------------------------------------------------
#define _WASAPI_MONO_TO_STEREO_MIXER_1_TO_2(TYPE)\
- TYPE * __restrict to = (TYPE *)__to;\
- const TYPE * __restrict from = (const TYPE *)__from;\
- const TYPE * __restrict end = from + count;\
- while (from != end)\
- {\
- to[0] = to[1] = *from ++;\
- to += 2;\
- }
+ TYPE * __restrict to = (TYPE *)__to;\
+ const TYPE * __restrict from = (const TYPE *)__from;\
+ const TYPE * __restrict end = from + count;\
+ while (from != end)\
+ {\
+ to[0] = to[1] = *from ++;\
+ to += 2;\
+ }
// ------------------------------------------------------------------------------------------
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_FLT32(TYPE)\
- TYPE * __restrict to = (TYPE *)__to;\
- const TYPE * __restrict from = (const TYPE *)__from;\
- const TYPE * __restrict end = to + count;\
- while (to != end)\
- {\
- *to ++ = (TYPE)((float)(from[0] + from[1]) * 0.5f);\
- from += 2;\
- }
+ TYPE * __restrict to = (TYPE *)__to;\
+ const TYPE * __restrict from = (const TYPE *)__from;\
+ const TYPE * __restrict end = to + count;\
+ while (to != end)\
+ {\
+ *to ++ = (TYPE)((float)(from[0] + from[1]) * 0.5f);\
+ from += 2;\
+ }
// ------------------------------------------------------------------------------------------
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_INT32(TYPE)\
- TYPE * __restrict to = (TYPE *)__to;\
- const TYPE * __restrict from = (const TYPE *)__from;\
- const TYPE * __restrict end = to + count;\
- while (to != end)\
- {\
- *to ++ = (TYPE)(((INT32)from[0] + (INT32)from[1]) >> 1);\
- from += 2;\
- }
+ TYPE * __restrict to = (TYPE *)__to;\
+ const TYPE * __restrict from = (const TYPE *)__from;\
+ const TYPE * __restrict end = to + count;\
+ while (to != end)\
+ {\
+ *to ++ = (TYPE)(((INT32)from[0] + (INT32)from[1]) >> 1);\
+ from += 2;\
+ }
// ------------------------------------------------------------------------------------------
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_INT64(TYPE)\
- TYPE * __restrict to = (TYPE *)__to;\
- const TYPE * __restrict from = (const TYPE *)__from;\
- const TYPE * __restrict end = to + count;\
- while (to != end)\
- {\
- *to ++ = (TYPE)(((INT64)from[0] + (INT64)from[1]) >> 1);\
- from += 2;\
- }
+ TYPE * __restrict to = (TYPE *)__to;\
+ const TYPE * __restrict from = (const TYPE *)__from;\
+ const TYPE * __restrict end = to + count;\
+ while (to != end)\
+ {\
+ *to ++ = (TYPE)(((INT64)from[0] + (INT64)from[1]) >> 1);\
+ from += 2;\
+ }
// ------------------------------------------------------------------------------------------
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_L(TYPE)\
- TYPE * __restrict to = (TYPE *)__to;\
- const TYPE * __restrict from = (const TYPE *)__from;\
- const TYPE * __restrict end = to + count;\
- while (to != end)\
- {\
- *to ++ = from[0];\
- from += 2;\
- }
+ TYPE * __restrict to = (TYPE *)__to;\
+ const TYPE * __restrict from = (const TYPE *)__from;\
+ const TYPE * __restrict end = to + count;\
+ while (to != end)\
+ {\
+ *to ++ = from[0];\
+ from += 2;\
+ }
// ------------------------------------------------------------------------------------------
static void _MixMonoToStereo_1TO2_8(void *__to, const void *__from, UINT32 count) { _WASAPI_MONO_TO_STEREO_MIXER_1_TO_2(BYTE); }
@@ -1379,19 +1379,19 @@ static void _MixMonoToStereo_1TO2_32(void *__to, const void *__from, UINT32 coun
static void _MixMonoToStereo_1TO2_32f(void *__to, const void *__from, UINT32 count) { _WASAPI_MONO_TO_STEREO_MIXER_1_TO_2(float); }
static void _MixMonoToStereo_1TO2_24(void *__to, const void *__from, UINT32 count)
{
- const UCHAR * __restrict from = (const UCHAR *)__from;
- UCHAR * __restrict to = (UCHAR *)__to;
- const UCHAR * __restrict end = to + (count * (2 * 3));
+ const UCHAR * __restrict from = (const UCHAR *)__from;
+ UCHAR * __restrict to = (UCHAR *)__to;
+ const UCHAR * __restrict end = to + (count * (2 * 3));
- while (to != end)
- {
- to[0] = to[3] = from[0];
- to[1] = to[4] = from[1];
- to[2] = to[5] = from[2];
+ while (to != end)
+ {
+ to[0] = to[3] = from[0];
+ to[1] = to[4] = from[1];
+ to[2] = to[5] = from[2];
- from += 3;
- to += (2 * 3);
- }
+ from += 3;
+ to += (2 * 3);
+ }
}
// ------------------------------------------------------------------------------------------
@@ -1402,13 +1402,13 @@ static void _MixMonoToStereo_2TO1_32(void *__to, const void *__from, UINT32 coun
static void _MixMonoToStereo_2TO1_32f(void *__to, const void *__from, UINT32 count) { _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_FLT32(float); }
static void _MixMonoToStereo_2TO1_24(void *__to, const void *__from, UINT32 count)
{
- const UCHAR * __restrict from = (const UCHAR *)__from;
- UCHAR * __restrict to = (UCHAR *)__to;
- const UCHAR * __restrict end = to + (count * 3);
- PaInt32 tempL, tempR, tempM;
+ const UCHAR * __restrict from = (const UCHAR *)__from;
+ UCHAR * __restrict to = (UCHAR *)__to;
+ const UCHAR * __restrict end = to + (count * 3);
+ PaInt32 tempL, tempR, tempM;
- while (to != end)
- {
+ while (to != end)
+ {
tempL = (((PaInt32)from[0]) << 8);
tempL = tempL | (((PaInt32)from[1]) << 16);
tempL = tempL | (((PaInt32)from[2]) << 24);
@@ -1417,15 +1417,15 @@ static void _MixMonoToStereo_2TO1_24(void *__to, const void *__from, UINT32 coun
tempR = tempR | (((PaInt32)from[4]) << 16);
tempR = tempR | (((PaInt32)from[5]) << 24);
- tempM = (tempL + tempR) >> 1;
+ tempM = (tempL + tempR) >> 1;
- to[0] = (UCHAR)(tempM >> 8);
- to[1] = (UCHAR)(tempM >> 16);
- to[2] = (UCHAR)(tempM >> 24);
+ to[0] = (UCHAR)(tempM >> 8);
+ to[1] = (UCHAR)(tempM >> 16);
+ to[2] = (UCHAR)(tempM >> 24);
- from += (2 * 3);
- to += 3;
- }
+ from += (2 * 3);
+ to += 3;
+ }
}
// ------------------------------------------------------------------------------------------
@@ -1436,132 +1436,132 @@ static void _MixMonoToStereo_2TO1_32_L(void *__to, const void *__from, UINT32 co
static void _MixMonoToStereo_2TO1_32f_L(void *__to, const void *__from, UINT32 count) { _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_L(float); }
static void _MixMonoToStereo_2TO1_24_L(void *__to, const void *__from, UINT32 count)
{
- const UCHAR * __restrict from = (const UCHAR *)__from;
- UCHAR * __restrict to = (UCHAR *)__to;
- const UCHAR * __restrict end = to + (count * 3);
+ const UCHAR * __restrict from = (const UCHAR *)__from;
+ UCHAR * __restrict to = (UCHAR *)__to;
+ const UCHAR * __restrict end = to + (count * 3);
- while (to != end)
- {
- to[0] = from[0];
- to[1] = from[1];
- to[2] = from[2];
+ while (to != end)
+ {
+ to[0] = from[0];
+ to[1] = from[1];
+ to[2] = from[2];
- from += (2 * 3);
- to += 3;
- }
+ from += (2 * 3);
+ to += 3;
+ }
}
// ------------------------------------------------------------------------------------------
static MixMonoToStereoF GetMonoToStereoMixer(const WAVEFORMATEXTENSIBLE *fmtext, EMixDirection dir)
{
- PaSampleFormat format = WaveToPaFormat(fmtext);
-
- switch (dir)
- {
- case MIX_DIR__1TO2:
- switch (format & ~paNonInterleaved)
- {
- case paUInt8: return _MixMonoToStereo_1TO2_8;
- case paInt16: return _MixMonoToStereo_1TO2_16;
- case paInt24: return (fmtext->Format.wBitsPerSample == 32 ? _MixMonoToStereo_1TO2_8_24 : _MixMonoToStereo_1TO2_24);
- case paInt32: return _MixMonoToStereo_1TO2_32;
- case paFloat32: return _MixMonoToStereo_1TO2_32f;
- }
- break;
+ PaSampleFormat format = WaveToPaFormat(fmtext);
+
+ switch (dir)
+ {
+ case MIX_DIR__1TO2:
+ switch (format & ~paNonInterleaved)
+ {
+ case paUInt8: return _MixMonoToStereo_1TO2_8;
+ case paInt16: return _MixMonoToStereo_1TO2_16;
+ case paInt24: return (fmtext->Format.wBitsPerSample == 32 ? _MixMonoToStereo_1TO2_8_24 : _MixMonoToStereo_1TO2_24);
+ case paInt32: return _MixMonoToStereo_1TO2_32;
+ case paFloat32: return _MixMonoToStereo_1TO2_32f;
+ }
+ break;
- case MIX_DIR__2TO1:
- switch (format & ~paNonInterleaved)
- {
- case paUInt8: return _MixMonoToStereo_2TO1_8;
- case paInt16: return _MixMonoToStereo_2TO1_16;
- case paInt24: return (fmtext->Format.wBitsPerSample == 32 ? _MixMonoToStereo_2TO1_8_24 : _MixMonoToStereo_2TO1_24);
- case paInt32: return _MixMonoToStereo_2TO1_32;
- case paFloat32: return _MixMonoToStereo_2TO1_32f;
- }
- break;
+ case MIX_DIR__2TO1:
+ switch (format & ~paNonInterleaved)
+ {
+ case paUInt8: return _MixMonoToStereo_2TO1_8;
+ case paInt16: return _MixMonoToStereo_2TO1_16;
+ case paInt24: return (fmtext->Format.wBitsPerSample == 32 ? _MixMonoToStereo_2TO1_8_24 : _MixMonoToStereo_2TO1_24);
+ case paInt32: return _MixMonoToStereo_2TO1_32;
+ case paFloat32: return _MixMonoToStereo_2TO1_32f;
+ }
+ break;
- case MIX_DIR__2TO1_L:
- switch (format & ~paNonInterleaved)
- {
- case paUInt8: return _MixMonoToStereo_2TO1_8_L;
- case paInt16: return _MixMonoToStereo_2TO1_16_L;
- case paInt24: return (fmtext->Format.wBitsPerSample == 32 ? _MixMonoToStereo_2TO1_8_24_L : _MixMonoToStereo_2TO1_24_L);
- case paInt32: return _MixMonoToStereo_2TO1_32_L;
- case paFloat32: return _MixMonoToStereo_2TO1_32f_L;
- }
- break;
- }
+ case MIX_DIR__2TO1_L:
+ switch (format & ~paNonInterleaved)
+ {
+ case paUInt8: return _MixMonoToStereo_2TO1_8_L;
+ case paInt16: return _MixMonoToStereo_2TO1_16_L;
+ case paInt24: return (fmtext->Format.wBitsPerSample == 32 ? _MixMonoToStereo_2TO1_8_24_L : _MixMonoToStereo_2TO1_24_L);
+ case paInt32: return _MixMonoToStereo_2TO1_32_L;
+ case paFloat32: return _MixMonoToStereo_2TO1_32f_L;
+ }
+ break;
+ }
- return NULL;
+ return NULL;
}
// ------------------------------------------------------------------------------------------
#ifdef PA_WINRT
typedef struct PaActivateAudioInterfaceCompletionHandler
{
- IActivateAudioInterfaceCompletionHandler parent;
- volatile LONG refs;
- volatile LONG done;
- struct
- {
- const IID *iid;
- void **obj;
- }
- in;
- struct
- {
- HRESULT hr;
- }
- out;
+ IActivateAudioInterfaceCompletionHandler parent;
+ volatile LONG refs;
+ volatile LONG done;
+ struct
+ {
+ const IID *iid;
+ void **obj;
+ }
+ in;
+ struct
+ {
+ HRESULT hr;
+ }
+ out;
}
PaActivateAudioInterfaceCompletionHandler;
static HRESULT (STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_QueryInterface)(
IActivateAudioInterfaceCompletionHandler *This, REFIID riid, void **ppvObject)
{
- PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
+ PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
- // From MSDN:
- // "The IAgileObject interface is a marker interface that indicates that an object
- // is free threaded and can be called from any apartment."
- if (IsEqualIID(riid, &IID_IUnknown) ||
- IsEqualIID(riid, &IID_IAgileObject))
- {
- IActivateAudioInterfaceCompletionHandler_AddRef((IActivateAudioInterfaceCompletionHandler *)handler);
- (*ppvObject) = handler;
- return S_OK;
- }
+ // From MSDN:
+ // "The IAgileObject interface is a marker interface that indicates that an object
+ // is free threaded and can be called from any apartment."
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IAgileObject))
+ {
+ IActivateAudioInterfaceCompletionHandler_AddRef((IActivateAudioInterfaceCompletionHandler *)handler);
+ (*ppvObject) = handler;
+ return S_OK;
+ }
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
static ULONG (STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_AddRef)(
IActivateAudioInterfaceCompletionHandler *This)
{
- PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
+ PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
- return InterlockedIncrement(&handler->refs);
+ return InterlockedIncrement(&handler->refs);
}
static ULONG (STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_Release)(
IActivateAudioInterfaceCompletionHandler *This)
{
- PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
- ULONG refs;
+ PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
+ ULONG refs;
- if ((refs = InterlockedDecrement(&handler->refs)) == 0)
- {
- PaUtil_FreeMemory(handler->parent.lpVtbl);
- PaUtil_FreeMemory(handler);
- }
+ if ((refs = InterlockedDecrement(&handler->refs)) == 0)
+ {
+ PaUtil_FreeMemory(handler->parent.lpVtbl);
+ PaUtil_FreeMemory(handler);
+ }
- return refs;
+ return refs;
}
static HRESULT (STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_ActivateCompleted)(
IActivateAudioInterfaceCompletionHandler *This, IActivateAudioInterfaceAsyncOperation *activateOperation)
{
- PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
+ PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
HRESULT hr = S_OK;
HRESULT hrActivateResult = S_OK;
@@ -1575,33 +1575,33 @@ static HRESULT (STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_Acti
IUnknown_QueryInterface(punkAudioInterface, handler->in.iid, handler->in.obj);
if ((*handler->in.obj) == NULL)
hrActivateResult = E_FAIL;
- }
- SAFE_RELEASE(punkAudioInterface);
+ }
+ SAFE_RELEASE(punkAudioInterface);
- if (SUCCEEDED(hr))
- handler->out.hr = hrActivateResult;
- else
- handler->out.hr = hr;
-
- // Got client object, stop busy waiting in ActivateAudioInterface
- InterlockedExchange(&handler->done, TRUE);
+ if (SUCCEEDED(hr))
+ handler->out.hr = hrActivateResult;
+ else
+ handler->out.hr = hr;
+
+ // Got client object, stop busy waiting in ActivateAudioInterface
+ InterlockedExchange(&handler->done, TRUE);
- return hr;
+ return hr;
}
static IActivateAudioInterfaceCompletionHandler *CreateActivateAudioInterfaceCompletionHandler(const IID *iid, void **obj)
{
- PaActivateAudioInterfaceCompletionHandler *handler = PaUtil_AllocateMemory(sizeof(PaActivateAudioInterfaceCompletionHandler));
- ZeroMemory(handler, sizeof(*handler));
- handler->parent.lpVtbl = PaUtil_AllocateMemory(sizeof(*handler->parent.lpVtbl));
- handler->parent.lpVtbl->QueryInterface = &PaActivateAudioInterfaceCompletionHandler_QueryInterface;
- handler->parent.lpVtbl->AddRef = &PaActivateAudioInterfaceCompletionHandler_AddRef;
- handler->parent.lpVtbl->Release = &PaActivateAudioInterfaceCompletionHandler_Release;
- handler->parent.lpVtbl->ActivateCompleted = &PaActivateAudioInterfaceCompletionHandler_ActivateCompleted;
- handler->refs = 1;
- handler->in.iid = iid;
- handler->in.obj = obj;
- return (IActivateAudioInterfaceCompletionHandler *)handler;
+ PaActivateAudioInterfaceCompletionHandler *handler = PaUtil_AllocateMemory(sizeof(PaActivateAudioInterfaceCompletionHandler));
+ ZeroMemory(handler, sizeof(*handler));
+ handler->parent.lpVtbl = PaUtil_AllocateMemory(sizeof(*handler->parent.lpVtbl));
+ handler->parent.lpVtbl->QueryInterface = &PaActivateAudioInterfaceCompletionHandler_QueryInterface;
+ handler->parent.lpVtbl->AddRef = &PaActivateAudioInterfaceCompletionHandler_AddRef;
+ handler->parent.lpVtbl->Release = &PaActivateAudioInterfaceCompletionHandler_Release;
+ handler->parent.lpVtbl->ActivateCompleted = &PaActivateAudioInterfaceCompletionHandler_ActivateCompleted;
+ handler->refs = 1;
+ handler->in.iid = iid;
+ handler->in.obj = obj;
+ return (IActivateAudioInterfaceCompletionHandler *)handler;
}
#endif
@@ -1610,108 +1610,108 @@ static IActivateAudioInterfaceCompletionHandler *CreateActivateAudioInterfaceCom
static HRESULT ActivateAudioInterface_WINRT(EDataFlow flow, const IID *iid, void **obj)
{
#define PA_WASAPI_DEVICE_PATH_LEN 64
-
- PaError result = paNoError;
- HRESULT hr = S_OK;
- IActivateAudioInterfaceAsyncOperation *asyncOp = NULL;
- IActivateAudioInterfaceCompletionHandler *handler = CreateActivateAudioInterfaceCompletionHandler(iid, obj);
- PaActivateAudioInterfaceCompletionHandler *handlerImpl = (PaActivateAudioInterfaceCompletionHandler *)handler;
- OLECHAR tmp[PA_WASAPI_DEVICE_PATH_LEN] = { 0 };
- OLECHAR *devicePath = tmp;
+
+ PaError result = paNoError;
+ HRESULT hr = S_OK;
+ IActivateAudioInterfaceAsyncOperation *asyncOp = NULL;
+ IActivateAudioInterfaceCompletionHandler *handler = CreateActivateAudioInterfaceCompletionHandler(iid, obj);
+ PaActivateAudioInterfaceCompletionHandler *handlerImpl = (PaActivateAudioInterfaceCompletionHandler *)handler;
+ OLECHAR tmp[PA_WASAPI_DEVICE_PATH_LEN] = { 0 };
+ OLECHAR *devicePath = tmp;
- // Get device path in form L"{DEVICE_GUID}"
- switch (flow)
- {
- case eRender:
- if (g_DefaultRenderId[0] != 0)
- devicePath = g_DefaultRenderId;
- else
- StringFromGUID2(&DEVINTERFACE_AUDIO_RENDER, devicePath, PA_WASAPI_DEVICE_PATH_LEN - 1);
- break;
- case eCapture:
- if (g_DefaultCaptureId[0] != 0)
- devicePath = g_DefaultCaptureId;
- else
- StringFromGUID2(&DEVINTERFACE_AUDIO_CAPTURE, devicePath, PA_WASAPI_DEVICE_PATH_LEN - 1);
- break;
- default:
- return S_FALSE;
- }
+ // Get device path in form L"{DEVICE_GUID}"
+ switch (flow)
+ {
+ case eRender:
+ if (g_DefaultRenderId[0] != 0)
+ devicePath = g_DefaultRenderId;
+ else
+ StringFromGUID2(&DEVINTERFACE_AUDIO_RENDER, devicePath, PA_WASAPI_DEVICE_PATH_LEN - 1);
+ break;
+ case eCapture:
+ if (g_DefaultCaptureId[0] != 0)
+ devicePath = g_DefaultCaptureId;
+ else
+ StringFromGUID2(&DEVINTERFACE_AUDIO_CAPTURE, devicePath, PA_WASAPI_DEVICE_PATH_LEN - 1);
+ break;
+ default:
+ return S_FALSE;
+ }
- // Async operation will call back to IActivateAudioInterfaceCompletionHandler::ActivateCompleted
- // which must be an agile interface implementation
+ // Async operation will call back to IActivateAudioInterfaceCompletionHandler::ActivateCompleted
+ // which must be an agile interface implementation
hr = ActivateAudioInterfaceAsync(devicePath, iid, NULL, handler, &asyncOp);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- // Wait in busy loop for async operation to complete
- // Use Interlocked API here to ensure that ->done variable is read every time through the loop
- while (SUCCEEDED(hr) && !InterlockedOr(&handlerImpl->done, 0))
- {
- Sleep(1);
- }
+ // Wait in busy loop for async operation to complete
+ // Use Interlocked API here to ensure that ->done variable is read every time through the loop
+ while (SUCCEEDED(hr) && !InterlockedOr(&handlerImpl->done, 0))
+ {
+ Sleep(1);
+ }
- hr = handlerImpl->out.hr;
+ hr = handlerImpl->out.hr;
error:
- SAFE_RELEASE(asyncOp);
- SAFE_RELEASE(handler);
+ SAFE_RELEASE(asyncOp);
+ SAFE_RELEASE(handler);
return hr;
-
+
#undef PA_WASAPI_DEVICE_PATH_LEN
}
#endif
// ------------------------------------------------------------------------------------------
static HRESULT ActivateAudioInterface(const PaWasapiDeviceInfo *deviceInfo, const PaWasapiStreamInfo *streamInfo,
- IAudioClient **client)
+ IAudioClient **client)
{
- HRESULT hr;
+ HRESULT hr;
#ifndef PA_WINRT
- if (FAILED(hr = IMMDevice_Activate(deviceInfo->device, GetAudioClientIID(), CLSCTX_ALL, NULL, (void **)client)))
- return hr;
+ if (FAILED(hr = IMMDevice_Activate(deviceInfo->device, GetAudioClientIID(), CLSCTX_ALL, NULL, (void **)client)))
+ return hr;
#else
- if (FAILED(hr = ActivateAudioInterface_WINRT(deviceInfo->flow, GetAudioClientIID(), (void **)client)))
- return hr;
+ if (FAILED(hr = ActivateAudioInterface_WINRT(deviceInfo->flow, GetAudioClientIID(), (void **)client)))
+ return hr;
#endif
- // Set audio client options (applicable only to IAudioClient2+): options may affect the audio format
- // support by IAudioClient implementation and therefore we should set them before GetClosestFormat()
- // in order to correctly match the requested format
+ // Set audio client options (applicable only to IAudioClient2+): options may affect the audio format
+ // support by IAudioClient implementation and therefore we should set them before GetClosestFormat()
+ // in order to correctly match the requested format
#ifdef __IAudioClient2_INTERFACE_DEFINED__
- if ((streamInfo != NULL) && (GetAudioClientVersion() >= 2))
- {
- pa_AudioClientProperties audioProps = { 0 };
- audioProps.cbSize = sizeof(pa_AudioClientProperties);
- audioProps.bIsOffload = FALSE;
- audioProps.eCategory = (AUDIO_STREAM_CATEGORY)streamInfo->streamCategory;
- switch (streamInfo->streamOption)
- {
- case eStreamOptionRaw:
- if (GetWindowsVersion() >= WINDOWS_8_1_SERVER2012R2)
- audioProps.Options = pa_AUDCLNT_STREAMOPTIONS_RAW;
- break;
- case eStreamOptionMatchFormat:
- if (GetWindowsVersion() >= WINDOWS_10_SERVER2016)
- audioProps.Options = pa_AUDCLNT_STREAMOPTIONS_MATCH_FORMAT;
- break;
- }
+ if ((streamInfo != NULL) && (GetAudioClientVersion() >= 2))
+ {
+ pa_AudioClientProperties audioProps = { 0 };
+ audioProps.cbSize = sizeof(pa_AudioClientProperties);
+ audioProps.bIsOffload = FALSE;
+ audioProps.eCategory = (AUDIO_STREAM_CATEGORY)streamInfo->streamCategory;
+ switch (streamInfo->streamOption)
+ {
+ case eStreamOptionRaw:
+ if (GetWindowsVersion() >= WINDOWS_8_1_SERVER2012R2)
+ audioProps.Options = pa_AUDCLNT_STREAMOPTIONS_RAW;
+ break;
+ case eStreamOptionMatchFormat:
+ if (GetWindowsVersion() >= WINDOWS_10_SERVER2016)
+ audioProps.Options = pa_AUDCLNT_STREAMOPTIONS_MATCH_FORMAT;
+ break;
+ }
- if (FAILED(hr = IAudioClient2_SetClientProperties((IAudioClient2 *)(*client), (AudioClientProperties *)&audioProps)))
- {
- PRINT(("WASAPI: IAudioClient2_SetClientProperties(IsOffload = %d, Category = %d, Options = %d) failed\n", audioProps.bIsOffload, audioProps.eCategory, audioProps.Options));
- LogHostError(hr);
- }
- else
- {
- PRINT(("WASAPI: IAudioClient2 set properties: IsOffload = %d, Category = %d, Options = %d\n", audioProps.bIsOffload, audioProps.eCategory, audioProps.Options));
- }
- }
+ if (FAILED(hr = IAudioClient2_SetClientProperties((IAudioClient2 *)(*client), (AudioClientProperties *)&audioProps)))
+ {
+ PRINT(("WASAPI: IAudioClient2_SetClientProperties(IsOffload = %d, Category = %d, Options = %d) failed\n", audioProps.bIsOffload, audioProps.eCategory, audioProps.Options));
+ LogHostError(hr);
+ }
+ else
+ {
+ PRINT(("WASAPI: IAudioClient2 set properties: IsOffload = %d, Category = %d, Options = %d\n", audioProps.bIsOffload, audioProps.eCategory, audioProps.Options));
+ }
+ }
#endif
- return S_OK;
+ return S_OK;
}
// ------------------------------------------------------------------------------------------
@@ -1720,8 +1720,8 @@ static HRESULT ActivateAudioInterface(const PaWasapiDeviceInfo *deviceInfo, cons
#if !defined(WDK_NTDDI_VERSION) || (WDK_NTDDI_VERSION < NTDDI_WIN10_RS2)
static DWORD SignalObjectAndWait(HANDLE hObjectToSignal, HANDLE hObjectToWaitOn, DWORD dwMilliseconds, BOOL bAlertable)
{
- SetEvent(hObjectToSignal);
- return WaitForSingleObjectEx(hObjectToWaitOn, dwMilliseconds, bAlertable);
+ SetEvent(hObjectToSignal);
+ return WaitForSingleObjectEx(hObjectToWaitOn, dwMilliseconds, bAlertable);
}
#endif
#endif
@@ -1729,40 +1729,40 @@ static DWORD SignalObjectAndWait(HANDLE hObjectToSignal, HANDLE hObjectToWaitOn,
// ------------------------------------------------------------------------------------------
static void NotifyStateChanged(PaWasapiStream *stream, UINT32 flags, HRESULT hr)
{
- if (stream->fnStateHandler == NULL)
- return;
+ if (stream->fnStateHandler == NULL)
+ return;
- if (FAILED(hr))
- flags |= paWasapiStreamStateError;
-
- stream->fnStateHandler((PaStream *)stream, flags, hr, stream->pStateHandlerUserData);
+ if (FAILED(hr))
+ flags |= paWasapiStreamStateError;
+
+ stream->fnStateHandler((PaStream *)stream, flags, hr, stream->pStateHandlerUserData);
}
// ------------------------------------------------------------------------------------------
static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostApiIndex hostApiIndex)
{
- PaUtilHostApiRepresentation *hostApi = (PaUtilHostApiRepresentation *)paWasapi;
+ PaUtilHostApiRepresentation *hostApi = (PaUtilHostApiRepresentation *)paWasapi;
PaError result = paNoError;
PaDeviceInfo *deviceInfoArray;
HRESULT hr = S_OK;
- UINT i;
+ UINT i;
#ifndef PA_WINRT
IMMDeviceCollection* pEndPoints = NULL;
- IMMDeviceEnumerator *pEnumerator = NULL;
+ IMMDeviceEnumerator *pEnumerator = NULL;
#endif
- IAudioClient *tmpClient;
+ IAudioClient *tmpClient;
- // Make sure device list empty
- if ((paWasapi->deviceCount != 0) || (hostApi->info.deviceCount != 0))
- return paInternalError;
+ // Make sure device list empty
+ if ((paWasapi->deviceCount != 0) || (hostApi->info.deviceCount != 0))
+ return paInternalError;
#ifndef PA_WINRT
hr = CoCreateInstance(&pa_CLSID_IMMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER,
&pa_IID_IMMDeviceEnumerator, (void **)&pEnumerator);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
// getting default device ids in the eMultimedia "role"
{
@@ -1770,79 +1770,79 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
IMMDevice *defaultRenderer = NULL;
hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(pEnumerator, eRender, eMultimedia, &defaultRenderer);
if (hr != S_OK)
- {
- if (hr != E_NOTFOUND) {
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- }
- }
- else
- {
- WCHAR *pszDeviceId = NULL;
- hr = IMMDevice_GetId(defaultRenderer, &pszDeviceId);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- wcsncpy(paWasapi->defaultRenderer, pszDeviceId, MAX_STR_LEN-1);
- CoTaskMemFree(pszDeviceId);
- IMMDevice_Release(defaultRenderer);
- }
+ {
+ if (hr != E_NOTFOUND) {
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ }
+ }
+ else
+ {
+ WCHAR *pszDeviceId = NULL;
+ hr = IMMDevice_GetId(defaultRenderer, &pszDeviceId);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ wcsncpy(paWasapi->defaultRenderer, pszDeviceId, MAX_STR_LEN-1);
+ CoTaskMemFree(pszDeviceId);
+ IMMDevice_Release(defaultRenderer);
+ }
}
{
IMMDevice *defaultCapturer = NULL;
hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(pEnumerator, eCapture, eMultimedia, &defaultCapturer);
if (hr != S_OK)
- {
- if (hr != E_NOTFOUND) {
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- }
- }
- else
- {
- WCHAR *pszDeviceId = NULL;
- hr = IMMDevice_GetId(defaultCapturer, &pszDeviceId);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- wcsncpy(paWasapi->defaultCapturer, pszDeviceId, MAX_STR_LEN-1);
- CoTaskMemFree(pszDeviceId);
- IMMDevice_Release(defaultCapturer);
- }
+ {
+ if (hr != E_NOTFOUND) {
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ }
+ }
+ else
+ {
+ WCHAR *pszDeviceId = NULL;
+ hr = IMMDevice_GetId(defaultCapturer, &pszDeviceId);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ wcsncpy(paWasapi->defaultCapturer, pszDeviceId, MAX_STR_LEN-1);
+ CoTaskMemFree(pszDeviceId);
+ IMMDevice_Release(defaultCapturer);
+ }
}
}
hr = IMMDeviceEnumerator_EnumAudioEndpoints(pEnumerator, eAll, DEVICE_STATE_ACTIVE, &pEndPoints);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
hr = IMMDeviceCollection_GetCount(pEndPoints, &paWasapi->deviceCount);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
#else
- // Determine number of available devices by activating AudioClient for render and capture data flows
- if (SUCCEEDED(ActivateAudioInterface_WINRT(eRender, GetAudioClientIID(), &tmpClient)))
- {
- paWasapi->deviceCount++;
- SAFE_RELEASE(tmpClient);
- }
- if (SUCCEEDED(ActivateAudioInterface_WINRT(eCapture, GetAudioClientIID(), &tmpClient)))
- {
- paWasapi->deviceCount++;
- SAFE_RELEASE(tmpClient);
- }
+ // Determine number of available devices by activating AudioClient for render and capture data flows
+ if (SUCCEEDED(ActivateAudioInterface_WINRT(eRender, GetAudioClientIID(), &tmpClient)))
+ {
+ paWasapi->deviceCount++;
+ SAFE_RELEASE(tmpClient);
+ }
+ if (SUCCEEDED(ActivateAudioInterface_WINRT(eCapture, GetAudioClientIID(), &tmpClient)))
+ {
+ paWasapi->deviceCount++;
+ SAFE_RELEASE(tmpClient);
+ }
#endif
paWasapi->devInfo = (PaWasapiDeviceInfo *)PaUtil_GroupAllocateMemory(
- paWasapi->allocations, sizeof(PaWasapiDeviceInfo) * paWasapi->deviceCount);
+ paWasapi->allocations, sizeof(PaWasapiDeviceInfo) * paWasapi->deviceCount);
if (paWasapi->devInfo == NULL)
- {
+ {
result = paInsufficientMemory;
goto error;
}
@@ -1850,16 +1850,16 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
if (paWasapi->deviceCount > 0)
{
- UINT32 deviceCount = paWasapi->deviceCount;
- #if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
- if (deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT)
- deviceCount = PA_WASAPI_MAX_CONST_DEVICE_COUNT;
- #endif
+ UINT32 deviceCount = paWasapi->deviceCount;
+ #if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
+ if (deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT)
+ deviceCount = PA_WASAPI_MAX_CONST_DEVICE_COUNT;
+ #endif
hostApi->deviceInfos = (PaDeviceInfo **)PaUtil_GroupAllocateMemory(
paWasapi->allocations, sizeof(PaDeviceInfo *) * deviceCount);
if (hostApi->deviceInfos == NULL)
- {
+ {
result = paInsufficientMemory;
goto error;
}
@@ -1868,83 +1868,83 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
deviceInfoArray = (PaDeviceInfo *)PaUtil_GroupAllocateMemory(
paWasapi->allocations, sizeof(PaDeviceInfo) * deviceCount);
if (deviceInfoArray == NULL)
- {
+ {
result = paInsufficientMemory;
goto error;
}
- memset(deviceInfoArray, 0, sizeof(PaDeviceInfo) * deviceCount);
+ memset(deviceInfoArray, 0, sizeof(PaDeviceInfo) * deviceCount);
for (i = 0; i < paWasapi->deviceCount; ++i)
- {
+ {
PaDeviceInfo *deviceInfo = &deviceInfoArray[i];
deviceInfo->structVersion = 2;
deviceInfo->hostApi = hostApiIndex;
- PA_DEBUG(("WASAPI: device idx: %02d\n", i));
- PA_DEBUG(("WASAPI: ---------------\n"));
+ PA_DEBUG(("WASAPI: device idx: %02d\n", i));
+ PA_DEBUG(("WASAPI: ---------------\n"));
- #ifndef PA_WINRT
+ #ifndef PA_WINRT
hr = IMMDeviceCollection_Item(pEndPoints, i, &paWasapi->devInfo[i].device);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
// getting ID
{
WCHAR *pszDeviceId = NULL;
hr = IMMDevice_GetId(paWasapi->devInfo[i].device, &pszDeviceId);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hr, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hr, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
wcsncpy(paWasapi->devInfo[i].szDeviceID, pszDeviceId, MAX_STR_LEN-1);
CoTaskMemFree(pszDeviceId);
if (lstrcmpW(paWasapi->devInfo[i].szDeviceID, paWasapi->defaultCapturer) == 0)
- {// we found the default input!
+ {// we found the default input!
hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
}
if (lstrcmpW(paWasapi->devInfo[i].szDeviceID, paWasapi->defaultRenderer) == 0)
- {// we found the default output!
+ {// we found the default output!
hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
}
}
hr = IMMDevice_GetState(paWasapi->devInfo[i].device, &paWasapi->devInfo[i].state);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
if (paWasapi->devInfo[i].state != DEVICE_STATE_ACTIVE)
- {
+ {
PRINT(("WASAPI device: %d is not currently available (state:%d)\n", i, paWasapi->devInfo[i].state));
}
{
IPropertyStore *pProperty;
hr = IMMDevice_OpenPropertyStore(paWasapi->devInfo[i].device, STGM_READ, &pProperty);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
// "Friendly" Name
{
PROPVARIANT value;
PropVariantInit(&value);
hr = IPropertyStore_GetValue(pProperty, &PKEY_Device_FriendlyName, &value);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1)) == NULL)
- {
+ {
result = paInsufficientMemory;
goto error;
}
- if (value.pwszVal)
- WideCharToMultiByte(CP_UTF8, 0, value.pwszVal, (int)wcslen(value.pwszVal), (char *)deviceInfo->name, MAX_STR_LEN - 1, 0, 0);
- else
- _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "baddev%d", i);
+ if (value.pwszVal)
+ WideCharToMultiByte(CP_UTF8, 0, value.pwszVal, (int)wcslen(value.pwszVal), (char *)deviceInfo->name, MAX_STR_LEN - 1, 0, 0);
+ else
+ _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "baddev%d", i);
PropVariantClear(&value);
- PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
+ PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
}
// Default format
@@ -1952,10 +1952,10 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
PROPVARIANT value;
PropVariantInit(&value);
hr = IPropertyStore_GetValue(pProperty, &PKEY_AudioEngine_DeviceFormat, &value);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- memcpy(&paWasapi->devInfo[i].DefaultFormat, value.blob.pBlobData, min(sizeof(paWasapi->devInfo[i].DefaultFormat), value.blob.cbSize));
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ memcpy(&paWasapi->devInfo[i].DefaultFormat, value.blob.pBlobData, min(sizeof(paWasapi->devInfo[i].DefaultFormat), value.blob.cbSize));
// cleanup
PropVariantClear(&value);
}
@@ -1965,203 +1965,203 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
PROPVARIANT value;
PropVariantInit(&value);
hr = IPropertyStore_GetValue(pProperty, &PKEY_AudioEndpoint_FormFactor, &value);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- // set
- #if defined(DUMMYUNIONNAME) && defined(NONAMELESSUNION)
- // avoid breaking strict-aliasing rules in such line: (EndpointFormFactor)(*((UINT *)(((WORD *)&value.wReserved3)+1)));
- UINT v;
- memcpy(&v, (((WORD *)&value.wReserved3)+1), sizeof(v));
- paWasapi->devInfo[i].formFactor = (EndpointFormFactor)v;
- #else
- paWasapi->devInfo[i].formFactor = (EndpointFormFactor)value.uintVal;
- #endif
- PA_DEBUG(("WASAPI:%d| form-factor[%d]\n", i, paWasapi->devInfo[i].formFactor));
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // set
+ #if defined(DUMMYUNIONNAME) && defined(NONAMELESSUNION)
+ // avoid breaking strict-aliasing rules in such line: (EndpointFormFactor)(*((UINT *)(((WORD *)&value.wReserved3)+1)));
+ UINT v;
+ memcpy(&v, (((WORD *)&value.wReserved3)+1), sizeof(v));
+ paWasapi->devInfo[i].formFactor = (EndpointFormFactor)v;
+ #else
+ paWasapi->devInfo[i].formFactor = (EndpointFormFactor)value.uintVal;
+ #endif
+ PA_DEBUG(("WASAPI:%d| form-factor[%d]\n", i, paWasapi->devInfo[i].formFactor));
// cleanup
PropVariantClear(&value);
}
- SAFE_RELEASE(pProperty);
+ SAFE_RELEASE(pProperty);
}
-
+
// Endpoint data
{
IMMEndpoint *endpoint = NULL;
hr = IMMDevice_QueryInterface(paWasapi->devInfo[i].device, &pa_IID_IMMEndpoint, (void **)&endpoint);
if (SUCCEEDED(hr))
- {
+ {
hr = IMMEndpoint_GetDataFlow(endpoint, &paWasapi->devInfo[i].flow);
SAFE_RELEASE(endpoint);
}
}
- #endif
+ #endif
// Getting a temporary IAudioClient for more fields
// we make sure NOT to call Initialize yet!
{
- #ifdef PA_WINRT
- // Set flow as ActivateAudioInterface depends on it and selects corresponding
- // direction for the Audio Client
- paWasapi->devInfo[i].flow = (i == 0 ? eRender : eCapture);
- #endif
+ #ifdef PA_WINRT
+ // Set flow as ActivateAudioInterface depends on it and selects corresponding
+ // direction for the Audio Client
+ paWasapi->devInfo[i].flow = (i == 0 ? eRender : eCapture);
+ #endif
- // Create temp Audio Client instance to query additional details
+ // Create temp Audio Client instance to query additional details
hr = ActivateAudioInterface(&paWasapi->devInfo[i], NULL, &tmpClient);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- // Get latency
+ // Get latency
hr = IAudioClient_GetDevicePeriod(tmpClient,
&paWasapi->devInfo[i].DefaultDevicePeriod,
&paWasapi->devInfo[i].MinimumDevicePeriod);
- if (FAILED(hr))
- {
- PA_DEBUG(("WASAPI:%d| failed getting min/default periods by IAudioClient::GetDevicePeriod() with error[%08X], will use 30000/100000 hns\n", i, (UINT32)hr));
+ if (FAILED(hr))
+ {
+ PA_DEBUG(("WASAPI:%d| failed getting min/default periods by IAudioClient::GetDevicePeriod() with error[%08X], will use 30000/100000 hns\n", i, (UINT32)hr));
- // assign WASAPI common values
- paWasapi->devInfo[i].DefaultDevicePeriod = 100000;
- paWasapi->devInfo[i].MinimumDevicePeriod = 30000;
+ // assign WASAPI common values
+ paWasapi->devInfo[i].DefaultDevicePeriod = 100000;
+ paWasapi->devInfo[i].MinimumDevicePeriod = 30000;
- // ignore error, let continue further without failing with paInternalError
- hr = S_OK;
- }
-
- // Get mix format
- {
- WAVEFORMATEX *mixFormat;
+ // ignore error, let continue further without failing with paInternalError
+ hr = S_OK;
+ }
+
+ // Get mix format
+ {
+ WAVEFORMATEX *mixFormat;
- hr = IAudioClient_GetMixFormat(tmpClient, &mixFormat);
- if (SUCCEEDED(hr))
- {
- memcpy(&paWasapi->devInfo[i].MixFormat, mixFormat, min(sizeof(paWasapi->devInfo[i].MixFormat), (sizeof(*mixFormat) + mixFormat->cbSize)));
- CoTaskMemFree(mixFormat);
- }
- }
+ hr = IAudioClient_GetMixFormat(tmpClient, &mixFormat);
+ if (SUCCEEDED(hr))
+ {
+ memcpy(&paWasapi->devInfo[i].MixFormat, mixFormat, min(sizeof(paWasapi->devInfo[i].MixFormat), (sizeof(*mixFormat) + mixFormat->cbSize)));
+ CoTaskMemFree(mixFormat);
+ }
+ }
- // Register WINRT device
- #ifdef PA_WINRT
- if (SUCCEEDED(hr))
- {
- // Default device
- if (i == 0)
- hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
- else
- hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
+ // Register WINRT device
+ #ifdef PA_WINRT
+ if (SUCCEEDED(hr))
+ {
+ // Default device
+ if (i == 0)
+ hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
+ else
+ hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
- // State
- paWasapi->devInfo[i].state = DEVICE_STATE_ACTIVE;
+ // State
+ paWasapi->devInfo[i].state = DEVICE_STATE_ACTIVE;
- // Default format is always a mix format
- paWasapi->devInfo[i].DefaultFormat = paWasapi->devInfo[i].MixFormat;
+ // Default format is always a mix format
+ paWasapi->devInfo[i].DefaultFormat = paWasapi->devInfo[i].MixFormat;
- // Form-factor
- paWasapi->devInfo[i].formFactor = UnknownFormFactor;
+ // Form-factor
+ paWasapi->devInfo[i].formFactor = UnknownFormFactor;
- // Name
+ // Name
if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1)) == NULL)
- {
- SAFE_RELEASE(tmpClient);
+ {
+ SAFE_RELEASE(tmpClient);
result = paInsufficientMemory;
goto error;
}
- _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "WASAPI_%s:%d", (i == 0 ? "Output" : "Input"), i);
- PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
- }
- #endif
+ _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "WASAPI_%s:%d", (i == 0 ? "Output" : "Input"), i);
+ PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
+ }
+ #endif
- // Release tmp client
- SAFE_RELEASE(tmpClient);
+ // Release tmp client
+ SAFE_RELEASE(tmpClient);
- if (hr != S_OK)
- {
- //davidv: this happened with my hardware, previously for that same device in DirectSound:
- //Digital Output (Realtek AC'97 Audio)'s GUID: {0x38f2cf50,0x7b4c,0x4740,0x86,0xeb,0xd4,0x38,0x66,0xd8,0xc8, 0x9f}
- //so something must be _really_ wrong with this device, TODO handle this better. We kind of need GetMixFormat
- LogHostError(hr);
- // We need to set the result to a value otherwise we will return paNoError
- result = paInternalError;
- goto error;
- }
+ if (hr != S_OK)
+ {
+ //davidv: this happened with my hardware, previously for that same device in DirectSound:
+ //Digital Output (Realtek AC'97 Audio)'s GUID: {0x38f2cf50,0x7b4c,0x4740,0x86,0xeb,0xd4,0x38,0x66,0xd8,0xc8, 0x9f}
+ //so something must be _really_ wrong with this device, TODO handle this better. We kind of need GetMixFormat
+ LogHostError(hr);
+ // We need to set the result to a value otherwise we will return paNoError
+ result = paInternalError;
+ goto error;
+ }
}
-
+
// we can now fill in portaudio device data
deviceInfo->maxInputChannels = 0;
deviceInfo->maxOutputChannels = 0;
- deviceInfo->defaultSampleRate = paWasapi->devInfo[i].MixFormat.Format.nSamplesPerSec;
+ deviceInfo->defaultSampleRate = paWasapi->devInfo[i].MixFormat.Format.nSamplesPerSec;
switch (paWasapi->devInfo[i].flow)
- {
- case eRender: {
- deviceInfo->maxOutputChannels = paWasapi->devInfo[i].MixFormat.Format.nChannels;
+ {
+ case eRender: {
+ deviceInfo->maxOutputChannels = paWasapi->devInfo[i].MixFormat.Format.nChannels;
deviceInfo->defaultHighOutputLatency = nano100ToSeconds(paWasapi->devInfo[i].DefaultDevicePeriod);
deviceInfo->defaultLowOutputLatency = nano100ToSeconds(paWasapi->devInfo[i].MinimumDevicePeriod);
- PA_DEBUG(("WASAPI:%d| def.SR[%d] max.CH[%d] latency{hi[%f] lo[%f]}\n", i, (UINT32)deviceInfo->defaultSampleRate,
- deviceInfo->maxOutputChannels, (float)deviceInfo->defaultHighOutputLatency, (float)deviceInfo->defaultLowOutputLatency));
- break;}
- case eCapture: {
- deviceInfo->maxInputChannels = paWasapi->devInfo[i].MixFormat.Format.nChannels;
+ PA_DEBUG(("WASAPI:%d| def.SR[%d] max.CH[%d] latency{hi[%f] lo[%f]}\n", i, (UINT32)deviceInfo->defaultSampleRate,
+ deviceInfo->maxOutputChannels, (float)deviceInfo->defaultHighOutputLatency, (float)deviceInfo->defaultLowOutputLatency));
+ break;}
+ case eCapture: {
+ deviceInfo->maxInputChannels = paWasapi->devInfo[i].MixFormat.Format.nChannels;
deviceInfo->defaultHighInputLatency = nano100ToSeconds(paWasapi->devInfo[i].DefaultDevicePeriod);
deviceInfo->defaultLowInputLatency = nano100ToSeconds(paWasapi->devInfo[i].MinimumDevicePeriod);
- PA_DEBUG(("WASAPI:%d| def.SR[%d] max.CH[%d] latency{hi[%f] lo[%f]}\n", i, (UINT32)deviceInfo->defaultSampleRate,
- deviceInfo->maxInputChannels, (float)deviceInfo->defaultHighInputLatency, (float)deviceInfo->defaultLowInputLatency));
- break; }
+ PA_DEBUG(("WASAPI:%d| def.SR[%d] max.CH[%d] latency{hi[%f] lo[%f]}\n", i, (UINT32)deviceInfo->defaultSampleRate,
+ deviceInfo->maxInputChannels, (float)deviceInfo->defaultHighInputLatency, (float)deviceInfo->defaultLowInputLatency));
+ break; }
default:
PRINT(("WASAPI:%d| bad Data Flow!\n", i));
- // We need to set the result to a value otherwise we will return paNoError
- result = paInternalError;
+ // We need to set the result to a value otherwise we will return paNoError
+ result = paInternalError;
//continue; // do not skip from list, allow to initialize
- break;
+ break;
}
hostApi->deviceInfos[i] = deviceInfo;
++hostApi->info.deviceCount;
}
- #if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
- if (hostApi->info.deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT)
- {
- for (i = hostApi->info.deviceCount; i < PA_WASAPI_MAX_CONST_DEVICE_COUNT; ++i)
- {
- PaDeviceInfo *deviceInfo = &deviceInfoArray[i];
- deviceInfo->structVersion = 2;
- deviceInfo->hostApi = hostApiIndex;
+ #if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
+ if (hostApi->info.deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT)
+ {
+ for (i = hostApi->info.deviceCount; i < PA_WASAPI_MAX_CONST_DEVICE_COUNT; ++i)
+ {
+ PaDeviceInfo *deviceInfo = &deviceInfoArray[i];
+ deviceInfo->structVersion = 2;
+ deviceInfo->hostApi = hostApiIndex;
if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, 1)) == NULL)
- {
+ {
result = paInsufficientMemory;
goto error;
}
- ((char *)deviceInfo->name)[0] = 0;
+ ((char *)deviceInfo->name)[0] = 0;
- hostApi->deviceInfos[i] = deviceInfo;
- ++hostApi->info.deviceCount;
- }
- }
- #endif
+ hostApi->deviceInfos[i] = deviceInfo;
+ ++hostApi->info.deviceCount;
+ }
+ }
+ #endif
}
#ifndef PA_WINRT
SAFE_RELEASE(pEndPoints);
- SAFE_RELEASE(pEnumerator);
+ SAFE_RELEASE(pEnumerator);
#endif
- PRINT(("WASAPI: device list created ok\n"));
+ PRINT(("WASAPI: device list created ok\n"));
return paNoError;
error:
- PRINT(("WASAPI: failed %s error[%d|%s]\n", __FUNCTION__, result, Pa_GetErrorText(result)));
+ PRINT(("WASAPI: failed %s error[%d|%s]\n", __FUNCTION__, result, Pa_GetErrorText(result)));
#ifndef PA_WINRT
SAFE_RELEASE(pEndPoints);
- SAFE_RELEASE(pEnumerator);
+ SAFE_RELEASE(pEnumerator);
#endif
-
- // Safety if error was not set so that we do not think initialize was a success
- if (result == paNoError)
- result = paInternalError;
+
+ // Safety if error was not set so that we do not think initialize was a success
+ if (result == paNoError)
+ result = paInternalError;
return result;
}
@@ -2174,7 +2174,7 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
#ifndef PA_WINRT
if (!SetupAVRT())
- {
+ {
PRINT(("WASAPI: No AVRT! (not VISTA?)\n"));
return paNoError;
}
@@ -2182,46 +2182,46 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
paWasapi = (PaWasapiHostApiRepresentation *)PaUtil_AllocateMemory(sizeof(PaWasapiHostApiRepresentation));
if (paWasapi == NULL)
- {
+ {
result = paInsufficientMemory;
goto error;
- }
+ }
memset(paWasapi, 0, sizeof(PaWasapiHostApiRepresentation)); /* ensure all fields are zeroed. especially paWasapi->allocations */
- // Initialize COM subsystem
+ // Initialize COM subsystem
result = PaWinUtil_CoInitialize(paWASAPI, &paWasapi->comInitializationResult);
if (result != paNoError)
goto error;
- // Create memory group
+ // Create memory group
paWasapi->allocations = PaUtil_CreateAllocationGroup();
if (paWasapi->allocations == NULL)
- {
+ {
result = paInsufficientMemory;
goto error;
}
- // Fill basic interface info
+ // Fill basic interface info
*hostApi = &paWasapi->inheritedHostApiRep;
- (*hostApi)->info.structVersion = 1;
- (*hostApi)->info.type = paWASAPI;
- (*hostApi)->info.name = "Windows WASAPI";
- (*hostApi)->info.deviceCount = 0;
- (*hostApi)->info.defaultInputDevice = paNoDevice;
+ (*hostApi)->info.structVersion = 1;
+ (*hostApi)->info.type = paWASAPI;
+ (*hostApi)->info.name = "Windows WASAPI";
+ (*hostApi)->info.deviceCount = 0;
+ (*hostApi)->info.defaultInputDevice = paNoDevice;
(*hostApi)->info.defaultOutputDevice = paNoDevice;
- (*hostApi)->Terminate = Terminate;
+ (*hostApi)->Terminate = Terminate;
(*hostApi)->OpenStream = OpenStream;
(*hostApi)->IsFormatSupported = IsFormatSupported;
- // Fill the device list
- if ((result = CreateDeviceList(paWasapi, hostApiIndex)) != paNoError)
- goto error;
+ // Fill the device list
+ if ((result = CreateDeviceList(paWasapi, hostApiIndex)) != paNoError)
+ goto error;
- // Detect if platform workaround is required
- paWasapi->useWOW64Workaround = UseWOW64Workaround();
+ // Detect if platform workaround is required
+ paWasapi->useWOW64Workaround = UseWOW64Workaround();
- // Initialize time getter
- SystemTimer_InitializeTimeGetter();
+ // Initialize time getter
+ SystemTimer_InitializeTimeGetter();
PaUtil_InitializeStreamInterface( &paWasapi->callbackStreamInterface, CloseStream, StartStream,
StopStream, AbortStream, IsStreamStopped, IsStreamActive,
@@ -2234,15 +2234,15 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
GetStreamTime, PaUtil_DummyGetCpuLoad,
ReadStream, WriteStream, GetStreamReadAvailable, GetStreamWriteAvailable );
- PRINT(("WASAPI: initialized ok\n"));
+ PRINT(("WASAPI: initialized ok\n"));
return paNoError;
error:
- PRINT(("WASAPI: failed %s error[%d|%s]\n", __FUNCTION__, result, Pa_GetErrorText(result)));
+ PRINT(("WASAPI: failed %s error[%d|%s]\n", __FUNCTION__, result, Pa_GetErrorText(result)));
- Terminate((PaUtilHostApiRepresentation *)paWasapi);
+ Terminate((PaUtilHostApiRepresentation *)paWasapi);
return result;
}
@@ -2250,295 +2250,295 @@ error:
// ------------------------------------------------------------------------------------------
static void ReleaseWasapiDeviceInfoList( PaWasapiHostApiRepresentation *paWasapi )
{
- UINT32 i;
+ UINT32 i;
- // Release device info bound objects
+ // Release device info bound objects
for (i = 0; i < paWasapi->deviceCount; ++i)
- {
- #ifndef PA_WINRT
+ {
+ #ifndef PA_WINRT
SAFE_RELEASE(paWasapi->devInfo[i].device);
- #endif
+ #endif
}
- // Free device info
- if (paWasapi->allocations != NULL)
- PaUtil_GroupFreeMemory(paWasapi->allocations, paWasapi->devInfo);
+ // Free device info
+ if (paWasapi->allocations != NULL)
+ PaUtil_GroupFreeMemory(paWasapi->allocations, paWasapi->devInfo);
- // Be ready for a device list reinitialization and if its creation is failed pointers must not be dangling
- paWasapi->devInfo = NULL;
- paWasapi->deviceCount = 0;
+ // Be ready for a device list reinitialization and if its creation is failed pointers must not be dangling
+ paWasapi->devInfo = NULL;
+ paWasapi->deviceCount = 0;
}
// ------------------------------------------------------------------------------------------
static void Terminate( PaUtilHostApiRepresentation *hostApi )
{
PaWasapiHostApiRepresentation *paWasapi = (PaWasapiHostApiRepresentation*)hostApi;
- if (paWasapi == NULL)
- return;
+ if (paWasapi == NULL)
+ return;
- // Release device list
- ReleaseWasapiDeviceInfoList(paWasapi);
+ // Release device list
+ ReleaseWasapiDeviceInfoList(paWasapi);
- // Free allocations and memory group itself
+ // Free allocations and memory group itself
if (paWasapi->allocations != NULL)
- {
+ {
PaUtil_FreeAllAllocations(paWasapi->allocations);
PaUtil_DestroyAllocationGroup(paWasapi->allocations);
}
- // Release COM subsystem
+ // Release COM subsystem
PaWinUtil_CoUninitialize(paWASAPI, &paWasapi->comInitializationResult);
- // Free API representation
+ // Free API representation
PaUtil_FreeMemory(paWasapi);
- // Close AVRT
- CloseAVRT();
+ // Close AVRT
+ CloseAVRT();
}
// ------------------------------------------------------------------------------------------
static PaWasapiHostApiRepresentation *_GetHostApi(PaError *ret)
{
- PaError error;
- PaUtilHostApiRepresentation *pApi;
+ PaError error;
+ PaUtilHostApiRepresentation *pApi;
- if ((error = PaUtil_GetHostApiRepresentation(&pApi, paWASAPI)) != paNoError)
- {
- if (ret != NULL)
- (*ret) = error;
+ if ((error = PaUtil_GetHostApiRepresentation(&pApi, paWASAPI)) != paNoError)
+ {
+ if (ret != NULL)
+ (*ret) = error;
- return NULL;
- }
+ return NULL;
+ }
- return (PaWasapiHostApiRepresentation *)pApi;
+ return (PaWasapiHostApiRepresentation *)pApi;
}
// ------------------------------------------------------------------------------------------
static PaError UpdateDeviceList()
{
- int i;
- PaError ret;
- PaWasapiHostApiRepresentation *paWasapi;
- PaUtilHostApiRepresentation *hostApi;
+ int i;
+ PaError ret;
+ PaWasapiHostApiRepresentation *paWasapi;
+ PaUtilHostApiRepresentation *hostApi;
- // Get API
- hostApi = (PaUtilHostApiRepresentation *)(paWasapi = _GetHostApi(&ret));
- if (paWasapi == NULL)
- return paNotInitialized;
+ // Get API
+ hostApi = (PaUtilHostApiRepresentation *)(paWasapi = _GetHostApi(&ret));
+ if (paWasapi == NULL)
+ return paNotInitialized;
- // Make sure initialized properly
- if (paWasapi->allocations == NULL)
- return paNotInitialized;
+ // Make sure initialized properly
+ if (paWasapi->allocations == NULL)
+ return paNotInitialized;
- // Release WASAPI internal device info list
- ReleaseWasapiDeviceInfoList(paWasapi);
+ // Release WASAPI internal device info list
+ ReleaseWasapiDeviceInfoList(paWasapi);
- // Release external device info list
- if (hostApi->deviceInfos != NULL)
- {
- for (i = 0; i < hostApi->info.deviceCount; ++i)
- {
- PaUtil_GroupFreeMemory(paWasapi->allocations, (void *)hostApi->deviceInfos[i]->name);
- }
- PaUtil_GroupFreeMemory(paWasapi->allocations, hostApi->deviceInfos[0]);
- PaUtil_GroupFreeMemory(paWasapi->allocations, hostApi->deviceInfos);
+ // Release external device info list
+ if (hostApi->deviceInfos != NULL)
+ {
+ for (i = 0; i < hostApi->info.deviceCount; ++i)
+ {
+ PaUtil_GroupFreeMemory(paWasapi->allocations, (void *)hostApi->deviceInfos[i]->name);
+ }
+ PaUtil_GroupFreeMemory(paWasapi->allocations, hostApi->deviceInfos[0]);
+ PaUtil_GroupFreeMemory(paWasapi->allocations, hostApi->deviceInfos);
- // Be ready for a device list reinitialization and if its creation is failed pointers must not be dangling
- hostApi->deviceInfos = NULL;
- hostApi->info.deviceCount = 0;
- hostApi->info.defaultInputDevice = paNoDevice;
- hostApi->info.defaultOutputDevice = paNoDevice;
- }
+ // Be ready for a device list reinitialization and if its creation is failed pointers must not be dangling
+ hostApi->deviceInfos = NULL;
+ hostApi->info.deviceCount = 0;
+ hostApi->info.defaultInputDevice = paNoDevice;
+ hostApi->info.defaultOutputDevice = paNoDevice;
+ }
- // Fill possibly updated device list
- if ((ret = CreateDeviceList(paWasapi, Pa_HostApiTypeIdToHostApiIndex(paWASAPI))) != paNoError)
- return ret;
+ // Fill possibly updated device list
+ if ((ret = CreateDeviceList(paWasapi, Pa_HostApiTypeIdToHostApiIndex(paWASAPI))) != paNoError)
+ return ret;
- return paNoError;
+ return paNoError;
}
// ------------------------------------------------------------------------------------------
#if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
PaError PaWasapi_UpdateDeviceList()
{
- return UpdateDeviceList();
+ return UpdateDeviceList();
}
#endif
// ------------------------------------------------------------------------------------------
int PaWasapi_GetDeviceCurrentFormat( PaStream *pStream, void *pFormat, unsigned int formatSize, int bOutput )
{
- UINT32 size;
- WAVEFORMATEXTENSIBLE *format;
+ UINT32 size;
+ WAVEFORMATEXTENSIBLE *format;
- PaWasapiStream *stream = (PaWasapiStream *)pStream;
- if (stream == NULL)
- return paBadStreamPtr;
-
- format = (bOutput == TRUE ? &stream->out.wavex : &stream->in.wavex);
+ PaWasapiStream *stream = (PaWasapiStream *)pStream;
+ if (stream == NULL)
+ return paBadStreamPtr;
+
+ format = (bOutput == TRUE ? &stream->out.wavex : &stream->in.wavex);
- size = min(formatSize, (UINT32)sizeof(*format));
- memcpy(pFormat, format, size);
+ size = min(formatSize, (UINT32)sizeof(*format));
+ memcpy(pFormat, format, size);
- return size;
+ return size;
}
// ------------------------------------------------------------------------------------------
int PaWasapi_GetDeviceDefaultFormat( void *pFormat, unsigned int formatSize, PaDeviceIndex device )
{
- PaError ret;
- PaWasapiHostApiRepresentation *paWasapi;
- UINT32 size;
- PaDeviceIndex index;
+ PaError ret;
+ PaWasapiHostApiRepresentation *paWasapi;
+ UINT32 size;
+ PaDeviceIndex index;
- if (pFormat == NULL)
- return paBadBufferPtr;
- if (formatSize <= 0)
- return paBufferTooSmall;
+ if (pFormat == NULL)
+ return paBadBufferPtr;
+ if (formatSize <= 0)
+ return paBufferTooSmall;
- // Get API
- paWasapi = _GetHostApi(&ret);
- if (paWasapi == NULL)
- return ret;
+ // Get API
+ paWasapi = _GetHostApi(&ret);
+ if (paWasapi == NULL)
+ return ret;
- // Get device index
- ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
+ // Get device index
+ ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
if (ret != paNoError)
return ret;
- // Validate index
- if ((UINT32)index >= paWasapi->deviceCount)
- return paInvalidDevice;
-
- size = min(formatSize, (UINT32)sizeof(paWasapi->devInfo[ index ].DefaultFormat));
- memcpy(pFormat, &paWasapi->devInfo[ index ].DefaultFormat, size);
+ // Validate index
+ if ((UINT32)index >= paWasapi->deviceCount)
+ return paInvalidDevice;
+
+ size = min(formatSize, (UINT32)sizeof(paWasapi->devInfo[ index ].DefaultFormat));
+ memcpy(pFormat, &paWasapi->devInfo[ index ].DefaultFormat, size);
- return size;
+ return size;
}
// ------------------------------------------------------------------------------------------
int PaWasapi_GetDeviceMixFormat( void *pFormat, unsigned int formatSize, PaDeviceIndex device )
{
- PaError ret;
- PaWasapiHostApiRepresentation *paWasapi;
- UINT32 size;
- PaDeviceIndex index;
+ PaError ret;
+ PaWasapiHostApiRepresentation *paWasapi;
+ UINT32 size;
+ PaDeviceIndex index;
- if (pFormat == NULL)
- return paBadBufferPtr;
- if (formatSize <= 0)
- return paBufferTooSmall;
+ if (pFormat == NULL)
+ return paBadBufferPtr;
+ if (formatSize <= 0)
+ return paBufferTooSmall;
- // Get API
- paWasapi = _GetHostApi(&ret);
- if (paWasapi == NULL)
- return ret;
+ // Get API
+ paWasapi = _GetHostApi(&ret);
+ if (paWasapi == NULL)
+ return ret;
- // Get device index
- ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
+ // Get device index
+ ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
if (ret != paNoError)
return ret;
- // Validate index
- if ((UINT32)index >= paWasapi->deviceCount)
- return paInvalidDevice;
-
- size = min(formatSize, (UINT32)sizeof(paWasapi->devInfo[ index ].MixFormat));
- memcpy(pFormat, &paWasapi->devInfo[ index ].MixFormat, size);
+ // Validate index
+ if ((UINT32)index >= paWasapi->deviceCount)
+ return paInvalidDevice;
+
+ size = min(formatSize, (UINT32)sizeof(paWasapi->devInfo[ index ].MixFormat));
+ memcpy(pFormat, &paWasapi->devInfo[ index ].MixFormat, size);
- return size;
+ return size;
}
// ------------------------------------------------------------------------------------------
int PaWasapi_GetDeviceRole( PaDeviceIndex device )
{
- PaError ret;
- PaDeviceIndex index;
+ PaError ret;
+ PaDeviceIndex index;
- // Get API
- PaWasapiHostApiRepresentation *paWasapi = _GetHostApi(&ret);
- if (paWasapi == NULL)
- return paNotInitialized;
+ // Get API
+ PaWasapiHostApiRepresentation *paWasapi = _GetHostApi(&ret);
+ if (paWasapi == NULL)
+ return paNotInitialized;
- // Get device index
- ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
+ // Get device index
+ ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
if (ret != paNoError)
return ret;
- // Validate index
- if ((UINT32)index >= paWasapi->deviceCount)
- return paInvalidDevice;
+ // Validate index
+ if ((UINT32)index >= paWasapi->deviceCount)
+ return paInvalidDevice;
- return paWasapi->devInfo[ index ].formFactor;
+ return paWasapi->devInfo[ index ].formFactor;
}
// ------------------------------------------------------------------------------------------
PaError PaWasapi_GetFramesPerHostBuffer( PaStream *pStream, unsigned int *pInput, unsigned int *pOutput )
{
PaWasapiStream *stream = (PaWasapiStream *)pStream;
- if (stream == NULL)
- return paBadStreamPtr;
+ if (stream == NULL)
+ return paBadStreamPtr;
- if (pInput != NULL)
- (*pInput) = stream->in.framesPerHostCallback;
+ if (pInput != NULL)
+ (*pInput) = stream->in.framesPerHostCallback;
- if (pOutput != NULL)
- (*pOutput) = stream->out.framesPerHostCallback;
+ if (pOutput != NULL)
+ (*pOutput) = stream->out.framesPerHostCallback;
- return paNoError;
+ return paNoError;
}
// ------------------------------------------------------------------------------------------
static void LogWAVEFORMATEXTENSIBLE(const WAVEFORMATEXTENSIBLE *in)
{
const WAVEFORMATEX *old = (WAVEFORMATEX *)in;
- switch (old->wFormatTag)
- {
- case WAVE_FORMAT_EXTENSIBLE: {
+ switch (old->wFormatTag)
+ {
+ case WAVE_FORMAT_EXTENSIBLE: {
- PRINT(("wFormatTag =WAVE_FORMAT_EXTENSIBLE\n"));
+ PRINT(("wFormatTag =WAVE_FORMAT_EXTENSIBLE\n"));
- if (IsEqualGUID(&in->SubFormat, &pa_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT))
- {
- PRINT(("SubFormat =KSDATAFORMAT_SUBTYPE_IEEE_FLOAT\n"));
- }
- else
- if (IsEqualGUID(&in->SubFormat, &pa_KSDATAFORMAT_SUBTYPE_PCM))
- {
- PRINT(("SubFormat =KSDATAFORMAT_SUBTYPE_PCM\n"));
- }
- else
- {
- PRINT(("SubFormat =CUSTOM GUID{%d:%d:%d:%d%d%d%d%d%d%d%d}\n",
- in->SubFormat.Data1,
- in->SubFormat.Data2,
- in->SubFormat.Data3,
- (int)in->SubFormat.Data4[0],
- (int)in->SubFormat.Data4[1],
- (int)in->SubFormat.Data4[2],
- (int)in->SubFormat.Data4[3],
- (int)in->SubFormat.Data4[4],
- (int)in->SubFormat.Data4[5],
- (int)in->SubFormat.Data4[6],
- (int)in->SubFormat.Data4[7]));
- }
- PRINT(("Samples.wValidBitsPerSample =%d\n", in->Samples.wValidBitsPerSample));
- PRINT(("dwChannelMask =0x%X\n",in->dwChannelMask));
+ if (IsEqualGUID(&in->SubFormat, &pa_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT))
+ {
+ PRINT(("SubFormat =KSDATAFORMAT_SUBTYPE_IEEE_FLOAT\n"));
+ }
+ else
+ if (IsEqualGUID(&in->SubFormat, &pa_KSDATAFORMAT_SUBTYPE_PCM))
+ {
+ PRINT(("SubFormat =KSDATAFORMAT_SUBTYPE_PCM\n"));
+ }
+ else
+ {
+ PRINT(("SubFormat =CUSTOM GUID{%d:%d:%d:%d%d%d%d%d%d%d%d}\n",
+ in->SubFormat.Data1,
+ in->SubFormat.Data2,
+ in->SubFormat.Data3,
+ (int)in->SubFormat.Data4[0],
+ (int)in->SubFormat.Data4[1],
+ (int)in->SubFormat.Data4[2],
+ (int)in->SubFormat.Data4[3],
+ (int)in->SubFormat.Data4[4],
+ (int)in->SubFormat.Data4[5],
+ (int)in->SubFormat.Data4[6],
+ (int)in->SubFormat.Data4[7]));
+ }
+ PRINT(("Samples.wValidBitsPerSample =%d\n", in->Samples.wValidBitsPerSample));
+ PRINT(("dwChannelMask =0x%X\n",in->dwChannelMask));
- break; }
+ break; }
- case WAVE_FORMAT_PCM: PRINT(("wFormatTag =WAVE_FORMAT_PCM\n")); break;
- case WAVE_FORMAT_IEEE_FLOAT: PRINT(("wFormatTag =WAVE_FORMAT_IEEE_FLOAT\n")); break;
- default:
- PRINT(("wFormatTag =UNKNOWN(%d)\n",old->wFormatTag)); break;
- }
+ case WAVE_FORMAT_PCM: PRINT(("wFormatTag =WAVE_FORMAT_PCM\n")); break;
+ case WAVE_FORMAT_IEEE_FLOAT: PRINT(("wFormatTag =WAVE_FORMAT_IEEE_FLOAT\n")); break;
+ default:
+ PRINT(("wFormatTag =UNKNOWN(%d)\n",old->wFormatTag)); break;
+ }
- PRINT(("nChannels =%d\n",old->nChannels));
- PRINT(("nSamplesPerSec =%d\n",old->nSamplesPerSec));
- PRINT(("nAvgBytesPerSec=%d\n",old->nAvgBytesPerSec));
- PRINT(("nBlockAlign =%d\n",old->nBlockAlign));
- PRINT(("wBitsPerSample =%d\n",old->wBitsPerSample));
- PRINT(("cbSize =%d\n",old->cbSize));
+ PRINT(("nChannels =%d\n",old->nChannels));
+ PRINT(("nSamplesPerSec =%d\n",old->nSamplesPerSec));
+ PRINT(("nAvgBytesPerSec=%d\n",old->nAvgBytesPerSec));
+ PRINT(("nBlockAlign =%d\n",old->nBlockAlign));
+ PRINT(("wBitsPerSample =%d\n",old->wBitsPerSample));
+ PRINT(("cbSize =%d\n",old->cbSize));
}
// ------------------------------------------------------------------------------------------
@@ -2547,38 +2547,38 @@ PaSampleFormat WaveToPaFormat(const WAVEFORMATEXTENSIBLE *fmtext)
const WAVEFORMATEX *fmt = (WAVEFORMATEX *)fmtext;
switch (fmt->wFormatTag)
- {
+ {
case WAVE_FORMAT_EXTENSIBLE: {
if (IsEqualGUID(&fmtext->SubFormat, &pa_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT))
- {
+ {
if (fmtext->Samples.wValidBitsPerSample == 32)
return paFloat32;
}
else
- if (IsEqualGUID(&fmtext->SubFormat, &pa_KSDATAFORMAT_SUBTYPE_PCM))
- {
+ if (IsEqualGUID(&fmtext->SubFormat, &pa_KSDATAFORMAT_SUBTYPE_PCM))
+ {
switch (fmt->wBitsPerSample)
- {
- case 32: return paInt32;
+ {
+ case 32: return paInt32;
case 24: return paInt24;
case 16: return paInt16;
- case 8: return paUInt8;
+ case 8: return paUInt8;
}
}
- break; }
+ break; }
case WAVE_FORMAT_IEEE_FLOAT:
- return paFloat32;
+ return paFloat32;
case WAVE_FORMAT_PCM: {
switch (fmt->wBitsPerSample)
- {
+ {
case 32: return paInt32;
case 24: return paInt24;
case 16: return paInt16;
case 8: return paUInt8;
}
- break; }
+ break; }
}
return paCustomFormat;
@@ -2588,50 +2588,50 @@ PaSampleFormat WaveToPaFormat(const WAVEFORMATEXTENSIBLE *fmtext)
static PaError MakeWaveFormatFromParams(WAVEFORMATEXTENSIBLE *wavex, const PaStreamParameters *params,
double sampleRate, BOOL packedOnly)
{
- WORD bitsPerSample;
- WAVEFORMATEX *old;
- DWORD channelMask = 0;
- BOOL useExtensible = (params->channelCount > 2); // format is always forced for >2 channels format
- PaWasapiStreamInfo *streamInfo = (PaWasapiStreamInfo *)params->hostApiSpecificStreamInfo;
+ WORD bitsPerSample;
+ WAVEFORMATEX *old;
+ DWORD channelMask = 0;
+ BOOL useExtensible = (params->channelCount > 2); // format is always forced for >2 channels format
+ PaWasapiStreamInfo *streamInfo = (PaWasapiStreamInfo *)params->hostApiSpecificStreamInfo;
- // Convert PaSampleFormat to valid data bits
- if ((bitsPerSample = PaSampleFormatToBitsPerSample(params->sampleFormat)) == 0)
- return paSampleFormatNotSupported;
+ // Convert PaSampleFormat to valid data bits
+ if ((bitsPerSample = PaSampleFormatToBitsPerSample(params->sampleFormat)) == 0)
+ return paSampleFormatNotSupported;
- // Use user assigned channel mask
- if ((streamInfo != NULL) && (streamInfo->flags & paWinWasapiUseChannelMask))
- {
- channelMask = streamInfo->channelMask;
- useExtensible = TRUE;
- }
+ // Use user assigned channel mask
+ if ((streamInfo != NULL) && (streamInfo->flags & paWinWasapiUseChannelMask))
+ {
+ channelMask = streamInfo->channelMask;
+ useExtensible = TRUE;
+ }
memset(wavex, 0, sizeof(*wavex));
- old = (WAVEFORMATEX *)wavex;
+ old = (WAVEFORMATEX *)wavex;
old->nChannels = (WORD)params->channelCount;
old->nSamplesPerSec = (DWORD)sampleRate;
- old->wBitsPerSample = bitsPerSample;
+ old->wBitsPerSample = bitsPerSample;
- // according to MSDN for WAVEFORMATEX structure for WAVE_FORMAT_PCM:
- // "If wFormatTag is WAVE_FORMAT_PCM, then wBitsPerSample should be equal to 8 or 16."
- if ((bitsPerSample != 8) && (bitsPerSample != 16))
- {
- // Normally 20 or 24 bits must go in 32 bit containers (ints) but in Exclusive mode some devices require
- // packed version of the format, e.g. for example 24-bit in 3-bytes
- old->wBitsPerSample = (packedOnly ? bitsPerSample : 32);
- useExtensible = TRUE;
- }
+ // according to MSDN for WAVEFORMATEX structure for WAVE_FORMAT_PCM:
+ // "If wFormatTag is WAVE_FORMAT_PCM, then wBitsPerSample should be equal to 8 or 16."
+ if ((bitsPerSample != 8) && (bitsPerSample != 16))
+ {
+ // Normally 20 or 24 bits must go in 32 bit containers (ints) but in Exclusive mode some devices require
+ // packed version of the format, e.g. for example 24-bit in 3-bytes
+ old->wBitsPerSample = (packedOnly ? bitsPerSample : 32);
+ useExtensible = TRUE;
+ }
// WAVEFORMATEX
if (!useExtensible)
- {
- old->wFormatTag = WAVE_FORMAT_PCM;
+ {
+ old->wFormatTag = WAVE_FORMAT_PCM;
}
// WAVEFORMATEXTENSIBLE
else
- {
+ {
old->wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- old->cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
+ old->cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
if ((params->sampleFormat & ~paNonInterleaved) == paFloat32)
wavex->SubFormat = pa_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
@@ -2640,40 +2640,40 @@ static PaError MakeWaveFormatFromParams(WAVEFORMATEXTENSIBLE *wavex, const PaStr
wavex->Samples.wValidBitsPerSample = bitsPerSample;
- // Set channel mask
- if (channelMask != 0)
- {
- wavex->dwChannelMask = channelMask;
- }
- else
- {
- switch (params->channelCount)
- {
- case 1: wavex->dwChannelMask = PAWIN_SPEAKER_MONO; break;
- case 2: wavex->dwChannelMask = PAWIN_SPEAKER_STEREO; break;
- case 3: wavex->dwChannelMask = PAWIN_SPEAKER_STEREO|SPEAKER_LOW_FREQUENCY; break;
- case 4: wavex->dwChannelMask = PAWIN_SPEAKER_QUAD; break;
- case 5: wavex->dwChannelMask = PAWIN_SPEAKER_QUAD|SPEAKER_LOW_FREQUENCY; break;
+ // Set channel mask
+ if (channelMask != 0)
+ {
+ wavex->dwChannelMask = channelMask;
+ }
+ else
+ {
+ switch (params->channelCount)
+ {
+ case 1: wavex->dwChannelMask = PAWIN_SPEAKER_MONO; break;
+ case 2: wavex->dwChannelMask = PAWIN_SPEAKER_STEREO; break;
+ case 3: wavex->dwChannelMask = PAWIN_SPEAKER_STEREO|SPEAKER_LOW_FREQUENCY; break;
+ case 4: wavex->dwChannelMask = PAWIN_SPEAKER_QUAD; break;
+ case 5: wavex->dwChannelMask = PAWIN_SPEAKER_QUAD|SPEAKER_LOW_FREQUENCY; break;
#ifdef PAWIN_SPEAKER_5POINT1_SURROUND
- case 6: wavex->dwChannelMask = PAWIN_SPEAKER_5POINT1_SURROUND; break;
+ case 6: wavex->dwChannelMask = PAWIN_SPEAKER_5POINT1_SURROUND; break;
#else
- case 6: wavex->dwChannelMask = PAWIN_SPEAKER_5POINT1; break;
+ case 6: wavex->dwChannelMask = PAWIN_SPEAKER_5POINT1; break;
#endif
#ifdef PAWIN_SPEAKER_5POINT1_SURROUND
- case 7: wavex->dwChannelMask = PAWIN_SPEAKER_5POINT1_SURROUND|SPEAKER_BACK_CENTER; break;
+ case 7: wavex->dwChannelMask = PAWIN_SPEAKER_5POINT1_SURROUND|SPEAKER_BACK_CENTER; break;
#else
- case 7: wavex->dwChannelMask = PAWIN_SPEAKER_5POINT1|SPEAKER_BACK_CENTER; break;
-#endif
+ case 7: wavex->dwChannelMask = PAWIN_SPEAKER_5POINT1|SPEAKER_BACK_CENTER; break;
+#endif
#ifdef PAWIN_SPEAKER_7POINT1_SURROUND
- case 8: wavex->dwChannelMask = PAWIN_SPEAKER_7POINT1_SURROUND; break;
+ case 8: wavex->dwChannelMask = PAWIN_SPEAKER_7POINT1_SURROUND; break;
#else
- case 8: wavex->dwChannelMask = PAWIN_SPEAKER_7POINT1; break;
+ case 8: wavex->dwChannelMask = PAWIN_SPEAKER_7POINT1; break;
#endif
- default: wavex->dwChannelMask = 0;
- }
- }
- }
+ default: wavex->dwChannelMask = 0;
+ }
+ }
+ }
old->nBlockAlign = old->nChannels * (old->wBitsPerSample / 8);
old->nAvgBytesPerSec = old->nSamplesPerSec * old->nBlockAlign;
@@ -2683,164 +2683,164 @@ static PaError MakeWaveFormatFromParams(WAVEFORMATEXTENSIBLE *wavex, const PaStr
// ------------------------------------------------------------------------------------------
static HRESULT GetAlternativeSampleFormatExclusive(IAudioClient *client, double sampleRate,
- const PaStreamParameters *params, WAVEFORMATEXTENSIBLE *outWavex, BOOL packedSampleFormatOnly)
+ const PaStreamParameters *params, WAVEFORMATEXTENSIBLE *outWavex, BOOL packedSampleFormatOnly)
{
- HRESULT hr = !S_OK;
- AUDCLNT_SHAREMODE shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
- WAVEFORMATEXTENSIBLE testFormat;
- PaStreamParameters testParams;
- int i;
- static const PaSampleFormat bestToWorst[] = { paInt32, paInt24, paFloat32, paInt16 };
+ HRESULT hr = !S_OK;
+ AUDCLNT_SHAREMODE shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
+ WAVEFORMATEXTENSIBLE testFormat;
+ PaStreamParameters testParams;
+ int i;
+ static const PaSampleFormat bestToWorst[] = { paInt32, paInt24, paFloat32, paInt16 };
- // Try combination Stereo (2 channels) and then we will use our custom mono-stereo mixer
- if (params->channelCount == 1)
- {
- testParams = (*params);
- testParams.channelCount = 2;
+ // Try combination Stereo (2 channels) and then we will use our custom mono-stereo mixer
+ if (params->channelCount == 1)
+ {
+ testParams = (*params);
+ testParams.channelCount = 2;
- if (MakeWaveFormatFromParams(&testFormat, &testParams, sampleRate, packedSampleFormatOnly) == paNoError)
- {
- if ((hr = IAudioClient_IsFormatSupported(client, shareMode, &testFormat.Format, NULL)) == S_OK)
- {
- (*outWavex) = testFormat;
- return hr;
- }
- }
+ if (MakeWaveFormatFromParams(&testFormat, &testParams, sampleRate, packedSampleFormatOnly) == paNoError)
+ {
+ if ((hr = IAudioClient_IsFormatSupported(client, shareMode, &testFormat.Format, NULL)) == S_OK)
+ {
+ (*outWavex) = testFormat;
+ return hr;
+ }
+ }
- // Try selecting suitable sample type
- for (i = 0; i < STATIC_ARRAY_SIZE(bestToWorst); ++i)
- {
- testParams.sampleFormat = bestToWorst[i];
+ // Try selecting suitable sample type
+ for (i = 0; i < STATIC_ARRAY_SIZE(bestToWorst); ++i)
+ {
+ testParams.sampleFormat = bestToWorst[i];
- if (MakeWaveFormatFromParams(&testFormat, &testParams, sampleRate, packedSampleFormatOnly) == paNoError)
- {
- if ((hr = IAudioClient_IsFormatSupported(client, shareMode, &testFormat.Format, NULL)) == S_OK)
- {
- (*outWavex) = testFormat;
- return hr;
- }
- }
- }
- }
+ if (MakeWaveFormatFromParams(&testFormat, &testParams, sampleRate, packedSampleFormatOnly) == paNoError)
+ {
+ if ((hr = IAudioClient_IsFormatSupported(client, shareMode, &testFormat.Format, NULL)) == S_OK)
+ {
+ (*outWavex) = testFormat;
+ return hr;
+ }
+ }
+ }
+ }
- // Try selecting suitable sample type
- testParams = (*params);
- for (i = 0; i < STATIC_ARRAY_SIZE(bestToWorst); ++i)
- {
- testParams.sampleFormat = bestToWorst[i];
+ // Try selecting suitable sample type
+ testParams = (*params);
+ for (i = 0; i < STATIC_ARRAY_SIZE(bestToWorst); ++i)
+ {
+ testParams.sampleFormat = bestToWorst[i];
- if (MakeWaveFormatFromParams(&testFormat, &testParams, sampleRate, packedSampleFormatOnly) == paNoError)
- {
- if ((hr = IAudioClient_IsFormatSupported(client, shareMode, &testFormat.Format, NULL)) == S_OK)
- {
- (*outWavex) = testFormat;
- return hr;
- }
- }
- }
-
- return hr;
+ if (MakeWaveFormatFromParams(&testFormat, &testParams, sampleRate, packedSampleFormatOnly) == paNoError)
+ {
+ if ((hr = IAudioClient_IsFormatSupported(client, shareMode, &testFormat.Format, NULL)) == S_OK)
+ {
+ (*outWavex) = testFormat;
+ return hr;
+ }
+ }
+ }
+
+ return hr;
}
// ------------------------------------------------------------------------------------------
static PaError GetClosestFormat(IAudioClient *client, double sampleRate, const PaStreamParameters *_params,
- AUDCLNT_SHAREMODE shareMode, WAVEFORMATEXTENSIBLE *outWavex, BOOL output)
+ AUDCLNT_SHAREMODE shareMode, WAVEFORMATEXTENSIBLE *outWavex, BOOL output)
{
- PaWasapiStreamInfo *streamInfo = (PaWasapiStreamInfo *)_params->hostApiSpecificStreamInfo;
- WAVEFORMATEX *sharedClosestMatch = NULL;
- HRESULT hr = !S_OK;
- PaStreamParameters params = (*_params);
- const BOOL explicitFormat = (streamInfo != NULL) && ((streamInfo->flags & paWinWasapiExplicitSampleFormat) == paWinWasapiExplicitSampleFormat);
- (void)output;
+ PaWasapiStreamInfo *streamInfo = (PaWasapiStreamInfo *)_params->hostApiSpecificStreamInfo;
+ WAVEFORMATEX *sharedClosestMatch = NULL;
+ HRESULT hr = !S_OK;
+ PaStreamParameters params = (*_params);
+ const BOOL explicitFormat = (streamInfo != NULL) && ((streamInfo->flags & paWinWasapiExplicitSampleFormat) == paWinWasapiExplicitSampleFormat);
+ (void)output;
- /* It was not noticed that 24-bit Input producing no output while device accepts this format.
- To fix this issue let's ask for 32-bits and let PA converters convert host 32-bit data
- to 24-bit for user-space. The bug concerns Vista, if Windows 7 supports 24-bits for Input
- please report to PortAudio developers to exclude Windows 7.
- */
- /*if ((params.sampleFormat == paInt24) && (output == FALSE))
- params.sampleFormat = paFloat32;*/ // <<< The silence was due to missing Int32_To_Int24_Dither implementation
+ /* It was not noticed that 24-bit Input producing no output while device accepts this format.
+ To fix this issue let's ask for 32-bits and let PA converters convert host 32-bit data
+ to 24-bit for user-space. The bug concerns Vista, if Windows 7 supports 24-bits for Input
+ please report to PortAudio developers to exclude Windows 7.
+ */
+ /*if ((params.sampleFormat == paInt24) && (output == FALSE))
+ params.sampleFormat = paFloat32;*/ // <<< The silence was due to missing Int32_To_Int24_Dither implementation
- // Try standard approach, e.g. if data is > 16 bits it will be packed into 32-bit containers
+ // Try standard approach, e.g. if data is > 16 bits it will be packed into 32-bit containers
MakeWaveFormatFromParams(outWavex, ¶ms, sampleRate, FALSE);
-
- // If built-in PCM converter requested then shared mode format will always succeed
- if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) &&
- (shareMode == AUDCLNT_SHAREMODE_SHARED) &&
- ((streamInfo != NULL) && (streamInfo->flags & paWinWasapiAutoConvert)))
- return paFormatIsSupported;
+
+ // If built-in PCM converter requested then shared mode format will always succeed
+ if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) &&
+ (shareMode == AUDCLNT_SHAREMODE_SHARED) &&
+ ((streamInfo != NULL) && (streamInfo->flags & paWinWasapiAutoConvert)))
+ return paFormatIsSupported;
- hr = IAudioClient_IsFormatSupported(client, shareMode, &outWavex->Format, (shareMode == AUDCLNT_SHAREMODE_SHARED ? &sharedClosestMatch : NULL));
-
- // Exclusive mode can require packed format for some devices
- if ((hr != S_OK) && (shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE))
- {
- // Enforce packed only format, e.g. data bits will not be packed into 32-bit containers in any case
- MakeWaveFormatFromParams(outWavex, ¶ms, sampleRate, TRUE);
- hr = IAudioClient_IsFormatSupported(client, shareMode, &outWavex->Format, NULL);
- }
+ hr = IAudioClient_IsFormatSupported(client, shareMode, &outWavex->Format, (shareMode == AUDCLNT_SHAREMODE_SHARED ? &sharedClosestMatch : NULL));
+
+ // Exclusive mode can require packed format for some devices
+ if ((hr != S_OK) && (shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE))
+ {
+ // Enforce packed only format, e.g. data bits will not be packed into 32-bit containers in any case
+ MakeWaveFormatFromParams(outWavex, ¶ms, sampleRate, TRUE);
+ hr = IAudioClient_IsFormatSupported(client, shareMode, &outWavex->Format, NULL);
+ }
- if (hr == S_OK)
- {
- return paFormatIsSupported;
- }
- else
- if (sharedClosestMatch != NULL)
- {
- WORD bitsPerSample;
+ if (hr == S_OK)
+ {
+ return paFormatIsSupported;
+ }
+ else
+ if (sharedClosestMatch != NULL)
+ {
+ WORD bitsPerSample;
- if (sharedClosestMatch->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
- memcpy(outWavex, sharedClosestMatch, sizeof(WAVEFORMATEXTENSIBLE));
- else
- memcpy(outWavex, sharedClosestMatch, sizeof(WAVEFORMATEX));
+ if (sharedClosestMatch->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+ memcpy(outWavex, sharedClosestMatch, sizeof(WAVEFORMATEXTENSIBLE));
+ else
+ memcpy(outWavex, sharedClosestMatch, sizeof(WAVEFORMATEX));
- CoTaskMemFree(sharedClosestMatch);
- sharedClosestMatch = NULL;
+ CoTaskMemFree(sharedClosestMatch);
+ sharedClosestMatch = NULL;
- // Validate SampleRate
- if ((DWORD)sampleRate != outWavex->Format.nSamplesPerSec)
- return paInvalidSampleRate;
+ // Validate SampleRate
+ if ((DWORD)sampleRate != outWavex->Format.nSamplesPerSec)
+ return paInvalidSampleRate;
- // Validate Channel count
- if ((WORD)params.channelCount != outWavex->Format.nChannels)
- {
- // If mono, then driver does not support 1 channel, we use internal workaround
- // of tiny software mixing functionality, e.g. we provide to user buffer 1 channel
- // but then mix into 2 for device buffer
- if ((params.channelCount == 1) && (outWavex->Format.nChannels == 2))
- return paFormatIsSupported;
- else
- return paInvalidChannelCount;
- }
+ // Validate Channel count
+ if ((WORD)params.channelCount != outWavex->Format.nChannels)
+ {
+ // If mono, then driver does not support 1 channel, we use internal workaround
+ // of tiny software mixing functionality, e.g. we provide to user buffer 1 channel
+ // but then mix into 2 for device buffer
+ if ((params.channelCount == 1) && (outWavex->Format.nChannels == 2))
+ return paFormatIsSupported;
+ else
+ return paInvalidChannelCount;
+ }
- // Validate Sample format
- if ((bitsPerSample = PaSampleFormatToBitsPerSample(params.sampleFormat)) == 0)
- return paSampleFormatNotSupported;
+ // Validate Sample format
+ if ((bitsPerSample = PaSampleFormatToBitsPerSample(params.sampleFormat)) == 0)
+ return paSampleFormatNotSupported;
- // Accepted format
- return paFormatIsSupported;
- }
- else
- if ((shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) && !explicitFormat)
- {
- // Try standard approach, e.g. if data is > 16 bits it will be packed into 32-bit containers
- if ((hr = GetAlternativeSampleFormatExclusive(client, sampleRate, ¶ms, outWavex, FALSE)) == S_OK)
- return paFormatIsSupported;
+ // Accepted format
+ return paFormatIsSupported;
+ }
+ else
+ if ((shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) && !explicitFormat)
+ {
+ // Try standard approach, e.g. if data is > 16 bits it will be packed into 32-bit containers
+ if ((hr = GetAlternativeSampleFormatExclusive(client, sampleRate, ¶ms, outWavex, FALSE)) == S_OK)
+ return paFormatIsSupported;
- // Enforce packed only format, e.g. data bits will not be packed into 32-bit containers in any case
- if ((hr = GetAlternativeSampleFormatExclusive(client, sampleRate, ¶ms, outWavex, TRUE)) == S_OK)
- return paFormatIsSupported;
+ // Enforce packed only format, e.g. data bits will not be packed into 32-bit containers in any case
+ if ((hr = GetAlternativeSampleFormatExclusive(client, sampleRate, ¶ms, outWavex, TRUE)) == S_OK)
+ return paFormatIsSupported;
- // Log failure
- LogHostError(hr);
- }
- else
- {
- // Exclusive mode and requested strict format, WASAPI did not accept this sample format
- LogHostError(hr);
- }
+ // Log failure
+ LogHostError(hr);
+ }
+ else
+ {
+ // Exclusive mode and requested strict format, WASAPI did not accept this sample format
+ LogHostError(hr);
+ }
- return paInvalidSampleRate;
+ return paInvalidSampleRate;
}
// ------------------------------------------------------------------------------------------
@@ -2849,17 +2849,17 @@ static PaError IsStreamParamsValid(struct PaUtilHostApiRepresentation *hostApi,
const PaStreamParameters *outputParameters,
double sampleRate)
{
- if (hostApi == NULL)
- return paHostApiNotFound;
- if ((UINT32)sampleRate == 0)
- return paInvalidSampleRate;
+ if (hostApi == NULL)
+ return paHostApiNotFound;
+ if ((UINT32)sampleRate == 0)
+ return paInvalidSampleRate;
- if (inputParameters != NULL)
+ if (inputParameters != NULL)
{
/* all standard sample formats are supported by the buffer adapter,
this implementation doesn't support any custom sample formats */
- // Note: paCustomFormat is now 8.24 (24-bits in 32-bit containers)
- //if (inputParameters->sampleFormat & paCustomFormat)
+ // Note: paCustomFormat is now 8.24 (24-bits in 32-bit containers)
+ //if (inputParameters->sampleFormat & paCustomFormat)
// return paSampleFormatNotSupported;
/* unless alternate device specification is supported, reject the use of
@@ -2873,15 +2873,15 @@ static PaError IsStreamParamsValid(struct PaUtilHostApiRepresentation *hostApi,
/* validate inputStreamInfo */
if (inputParameters->hostApiSpecificStreamInfo)
- {
- PaWasapiStreamInfo *inputStreamInfo = (PaWasapiStreamInfo *)inputParameters->hostApiSpecificStreamInfo;
- if ((inputStreamInfo->size != sizeof(PaWasapiStreamInfo)) ||
- (inputStreamInfo->version != 1) ||
+ {
+ PaWasapiStreamInfo *inputStreamInfo = (PaWasapiStreamInfo *)inputParameters->hostApiSpecificStreamInfo;
+ if ((inputStreamInfo->size != sizeof(PaWasapiStreamInfo)) ||
+ (inputStreamInfo->version != 1) ||
(inputStreamInfo->hostApiType != paWASAPI))
- {
- return paIncompatibleHostApiSpecificStreamInfo;
- }
- }
+ {
+ return paIncompatibleHostApiSpecificStreamInfo;
+ }
+ }
return paNoError;
}
@@ -2890,7 +2890,7 @@ static PaError IsStreamParamsValid(struct PaUtilHostApiRepresentation *hostApi,
{
/* all standard sample formats are supported by the buffer adapter,
this implementation doesn't support any custom sample formats */
- // Note: paCustomFormat is now 8.24 (24-bits in 32-bit containers)
+ // Note: paCustomFormat is now 8.24 (24-bits in 32-bit containers)
//if (outputParameters->sampleFormat & paCustomFormat)
// return paSampleFormatNotSupported;
@@ -2906,19 +2906,19 @@ static PaError IsStreamParamsValid(struct PaUtilHostApiRepresentation *hostApi,
/* validate outputStreamInfo */
if(outputParameters->hostApiSpecificStreamInfo)
{
- PaWasapiStreamInfo *outputStreamInfo = (PaWasapiStreamInfo *)outputParameters->hostApiSpecificStreamInfo;
- if ((outputStreamInfo->size != sizeof(PaWasapiStreamInfo)) ||
- (outputStreamInfo->version != 1) ||
+ PaWasapiStreamInfo *outputStreamInfo = (PaWasapiStreamInfo *)outputParameters->hostApiSpecificStreamInfo;
+ if ((outputStreamInfo->size != sizeof(PaWasapiStreamInfo)) ||
+ (outputStreamInfo->version != 1) ||
(outputStreamInfo->hostApiType != paWASAPI))
- {
- return paIncompatibleHostApiSpecificStreamInfo;
- }
+ {
+ return paIncompatibleHostApiSpecificStreamInfo;
+ }
}
- return paNoError;
+ return paNoError;
}
- return (inputParameters || outputParameters ? paNoError : paInternalError);
+ return (inputParameters || outputParameters ? paNoError : paInternalError);
}
// ------------------------------------------------------------------------------------------
@@ -2927,63 +2927,63 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
const PaStreamParameters *outputParameters,
double sampleRate )
{
- IAudioClient *tmpClient = NULL;
- PaWasapiHostApiRepresentation *paWasapi = (PaWasapiHostApiRepresentation*)hostApi;
- PaWasapiStreamInfo *inputStreamInfo = NULL, *outputStreamInfo = NULL;
+ IAudioClient *tmpClient = NULL;
+ PaWasapiHostApiRepresentation *paWasapi = (PaWasapiHostApiRepresentation*)hostApi;
+ PaWasapiStreamInfo *inputStreamInfo = NULL, *outputStreamInfo = NULL;
- // Validate PaStreamParameters
- PaError error;
- if ((error = IsStreamParamsValid(hostApi, inputParameters, outputParameters, sampleRate)) != paNoError)
- return error;
+ // Validate PaStreamParameters
+ PaError error;
+ if ((error = IsStreamParamsValid(hostApi, inputParameters, outputParameters, sampleRate)) != paNoError)
+ return error;
if (inputParameters != NULL)
{
- WAVEFORMATEXTENSIBLE wavex;
- HRESULT hr;
- PaError answer;
- AUDCLNT_SHAREMODE shareMode = AUDCLNT_SHAREMODE_SHARED;
- inputStreamInfo = (PaWasapiStreamInfo *)inputParameters->hostApiSpecificStreamInfo;
+ WAVEFORMATEXTENSIBLE wavex;
+ HRESULT hr;
+ PaError answer;
+ AUDCLNT_SHAREMODE shareMode = AUDCLNT_SHAREMODE_SHARED;
+ inputStreamInfo = (PaWasapiStreamInfo *)inputParameters->hostApiSpecificStreamInfo;
- if (inputStreamInfo && (inputStreamInfo->flags & paWinWasapiExclusive))
- shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
+ if (inputStreamInfo && (inputStreamInfo->flags & paWinWasapiExclusive))
+ shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
- hr = ActivateAudioInterface(&paWasapi->devInfo[inputParameters->device], inputStreamInfo, &tmpClient);
- if (hr != S_OK)
- {
- LogHostError(hr);
- return paInvalidDevice;
- }
+ hr = ActivateAudioInterface(&paWasapi->devInfo[inputParameters->device], inputStreamInfo, &tmpClient);
+ if (hr != S_OK)
+ {
+ LogHostError(hr);
+ return paInvalidDevice;
+ }
- answer = GetClosestFormat(tmpClient, sampleRate, inputParameters, shareMode, &wavex, FALSE);
- SAFE_RELEASE(tmpClient);
+ answer = GetClosestFormat(tmpClient, sampleRate, inputParameters, shareMode, &wavex, FALSE);
+ SAFE_RELEASE(tmpClient);
- if (answer != paFormatIsSupported)
- return answer;
+ if (answer != paFormatIsSupported)
+ return answer;
}
if (outputParameters != NULL)
{
- HRESULT hr;
- WAVEFORMATEXTENSIBLE wavex;
- PaError answer;
- AUDCLNT_SHAREMODE shareMode = AUDCLNT_SHAREMODE_SHARED;
+ HRESULT hr;
+ WAVEFORMATEXTENSIBLE wavex;
+ PaError answer;
+ AUDCLNT_SHAREMODE shareMode = AUDCLNT_SHAREMODE_SHARED;
outputStreamInfo = (PaWasapiStreamInfo *)outputParameters->hostApiSpecificStreamInfo;
- if (outputStreamInfo && (outputStreamInfo->flags & paWinWasapiExclusive))
- shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
+ if (outputStreamInfo && (outputStreamInfo->flags & paWinWasapiExclusive))
+ shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
- hr = ActivateAudioInterface(&paWasapi->devInfo[outputParameters->device], outputStreamInfo, &tmpClient);
- if (hr != S_OK)
- {
- LogHostError(hr);
- return paInvalidDevice;
- }
+ hr = ActivateAudioInterface(&paWasapi->devInfo[outputParameters->device], outputStreamInfo, &tmpClient);
+ if (hr != S_OK)
+ {
+ LogHostError(hr);
+ return paInvalidDevice;
+ }
- answer = GetClosestFormat(tmpClient, sampleRate, outputParameters, shareMode, &wavex, TRUE);
- SAFE_RELEASE(tmpClient);
+ answer = GetClosestFormat(tmpClient, sampleRate, outputParameters, shareMode, &wavex, TRUE);
+ SAFE_RELEASE(tmpClient);
- if (answer != paFormatIsSupported)
- return answer;
+ if (answer != paFormatIsSupported)
+ return answer;
}
return paFormatIsSupported;
@@ -2992,438 +2992,438 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
// ------------------------------------------------------------------------------------------
static PaUint32 _GetFramesPerHostBuffer(PaUint32 userFramesPerBuffer, PaTime suggestedLatency, double sampleRate, PaUint32 TimerJitterMs)
{
- PaUint32 frames = userFramesPerBuffer + max( userFramesPerBuffer, (PaUint32)(suggestedLatency * sampleRate) );
+ PaUint32 frames = userFramesPerBuffer + max( userFramesPerBuffer, (PaUint32)(suggestedLatency * sampleRate) );
frames += (PaUint32)((sampleRate * 0.001) * TimerJitterMs);
- return frames;
+ return frames;
}
// ------------------------------------------------------------------------------------------
static void _RecalculateBuffersCount(PaWasapiSubStream *sub, UINT32 userFramesPerBuffer, UINT32 framesPerLatency, BOOL fullDuplex)
{
- // Count buffers (must be at least 1)
- sub->buffers = (userFramesPerBuffer ? framesPerLatency / userFramesPerBuffer : 0);
- if (sub->buffers == 0)
- sub->buffers = 1;
+ // Count buffers (must be at least 1)
+ sub->buffers = (userFramesPerBuffer ? framesPerLatency / userFramesPerBuffer : 0);
+ if (sub->buffers == 0)
+ sub->buffers = 1;
- // Determine amount of buffers used:
- // - Full-duplex mode will lead to period difference, thus only 1.
- // - Input mode, only 1, as WASAPI allows extraction of only 1 packet.
- // - For Shared mode we use double buffering.
- if ((sub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) || fullDuplex)
- {
- // Exclusive mode does not allow >1 buffers be used for Event interface, e.g. GetBuffer
- // call must acquire max buffer size and it all must be processed.
- if (sub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)
- sub->userBufferAndHostMatch = 1;
+ // Determine amount of buffers used:
+ // - Full-duplex mode will lead to period difference, thus only 1.
+ // - Input mode, only 1, as WASAPI allows extraction of only 1 packet.
+ // - For Shared mode we use double buffering.
+ if ((sub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) || fullDuplex)
+ {
+ // Exclusive mode does not allow >1 buffers be used for Event interface, e.g. GetBuffer
+ // call must acquire max buffer size and it all must be processed.
+ if (sub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)
+ sub->userBufferAndHostMatch = 1;
- // Use paUtilBoundedHostBufferSize because exclusive mode will starve and produce
- // bad quality of audio
- sub->buffers = 1;
- }
+ // Use paUtilBoundedHostBufferSize because exclusive mode will starve and produce
+ // bad quality of audio
+ sub->buffers = 1;
+ }
}
// ------------------------------------------------------------------------------------------
static void _CalculateAlignedPeriod(PaWasapiSubStream *pSub, UINT32 *nFramesPerLatency, ALIGN_FUNC pAlignFunc)
{
- // Align frames to HD Audio packet size of 128 bytes for Exclusive mode only.
- // Not aligning on Windows Vista will cause Event timeout, although Windows 7 will
- // return AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED error to realign buffer. Aligning is necessary
- // for Exclusive mode only! when audio data is feeded directly to hardware.
- if (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE)
- {
- (*nFramesPerLatency) = AlignFramesPerBuffer((*nFramesPerLatency),
- pSub->wavex.Format.nSamplesPerSec, pSub->wavex.Format.nBlockAlign, pAlignFunc);
- }
+ // Align frames to HD Audio packet size of 128 bytes for Exclusive mode only.
+ // Not aligning on Windows Vista will cause Event timeout, although Windows 7 will
+ // return AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED error to realign buffer. Aligning is necessary
+ // for Exclusive mode only! when audio data is feeded directly to hardware.
+ if (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE)
+ {
+ (*nFramesPerLatency) = AlignFramesPerBuffer((*nFramesPerLatency),
+ pSub->wavex.Format.nSamplesPerSec, pSub->wavex.Format.nBlockAlign, pAlignFunc);
+ }
- // Calculate period
- pSub->period = MakeHnsPeriod((*nFramesPerLatency), pSub->wavex.Format.nSamplesPerSec);
+ // Calculate period
+ pSub->period = MakeHnsPeriod((*nFramesPerLatency), pSub->wavex.Format.nSamplesPerSec);
}
// ------------------------------------------------------------------------------------------
static void _CalculatePeriodicity(PaWasapiSubStream *pSub, BOOL output, REFERENCE_TIME *periodicity)
{
- // Note: according Microsoft docs for IAudioClient::Initialize we can set periodicity of the buffer
- // only for Exclusive mode. By setting periodicity almost equal to the user buffer frames we can
- // achieve high quality (less glitchy) low-latency audio.
- if (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE)
- {
- const PaWasapiDeviceInfo *pInfo = pSub->params.device_info;
+ // Note: according Microsoft docs for IAudioClient::Initialize we can set periodicity of the buffer
+ // only for Exclusive mode. By setting periodicity almost equal to the user buffer frames we can
+ // achieve high quality (less glitchy) low-latency audio.
+ if (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE)
+ {
+ const PaWasapiDeviceInfo *pInfo = pSub->params.device_info;
- // By default periodicity equals to the full buffer (legacy PA WASAPI's behavior)
- (*periodicity) = pSub->period;
+ // By default periodicity equals to the full buffer (legacy PA WASAPI's behavior)
+ (*periodicity) = pSub->period;
- // Try make buffer ready for I/O once we request the buffer readiness for it. Only Polling mode
- // because for Event mode buffer size and periodicity must be equal according Microsoft
- // documentation for IAudioClient::Initialize.
- //
- // TO-DO: try spread to capture and full-duplex cases (not tested and therefore disabled)
- //
- if (((pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0) &&
- (output && !pSub->params.full_duplex))
- {
- UINT32 alignedFrames;
- REFERENCE_TIME userPeriodicity;
+ // Try make buffer ready for I/O once we request the buffer readiness for it. Only Polling mode
+ // because for Event mode buffer size and periodicity must be equal according Microsoft
+ // documentation for IAudioClient::Initialize.
+ //
+ // TO-DO: try spread to capture and full-duplex cases (not tested and therefore disabled)
+ //
+ if (((pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0) &&
+ (output && !pSub->params.full_duplex))
+ {
+ UINT32 alignedFrames;
+ REFERENCE_TIME userPeriodicity;
- // Align frames backwards, so device will likely make buffer read ready when we are ready
- // to read it (our sheduling will wait for amount of millisoconds of frames_per_buffer)
- alignedFrames = AlignFramesPerBuffer(pSub->params.frames_per_buffer,
- pSub->wavex.Format.nSamplesPerSec, pSub->wavex.Format.nBlockAlign, ALIGN_BWD);
+ // Align frames backwards, so device will likely make buffer read ready when we are ready
+ // to read it (our sheduling will wait for amount of millisoconds of frames_per_buffer)
+ alignedFrames = AlignFramesPerBuffer(pSub->params.frames_per_buffer,
+ pSub->wavex.Format.nSamplesPerSec, pSub->wavex.Format.nBlockAlign, ALIGN_BWD);
- userPeriodicity = MakeHnsPeriod(alignedFrames, pSub->wavex.Format.nSamplesPerSec);
+ userPeriodicity = MakeHnsPeriod(alignedFrames, pSub->wavex.Format.nSamplesPerSec);
- // Must not be larger than buffer size
- if (userPeriodicity > pSub->period)
- userPeriodicity = pSub->period;
+ // Must not be larger than buffer size
+ if (userPeriodicity > pSub->period)
+ userPeriodicity = pSub->period;
- // Must not be smaller than minimum supported by the device
- if (userPeriodicity < pInfo->MinimumDevicePeriod)
- userPeriodicity = pInfo->MinimumDevicePeriod;
-
- (*periodicity) = userPeriodicity;
- }
- }
- else
- (*periodicity) = 0;
+ // Must not be smaller than minimum supported by the device
+ if (userPeriodicity < pInfo->MinimumDevicePeriod)
+ userPeriodicity = pInfo->MinimumDevicePeriod;
+
+ (*periodicity) = userPeriodicity;
+ }
+ }
+ else
+ (*periodicity) = 0;
}
// ------------------------------------------------------------------------------------------
static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSub, BOOL output, PaError *pa_error)
{
- PaError error;
+ PaError error;
HRESULT hr;
- const PaWasapiDeviceInfo *pInfo = pSub->params.device_info;
- const PaStreamParameters *params = &pSub->params.stream_params;
- const double sampleRate = pSub->params.sample_rate;
- const BOOL fullDuplex = pSub->params.full_duplex;
- const UINT32 userFramesPerBuffer = pSub->params.frames_per_buffer;
- UINT32 framesPerLatency = userFramesPerBuffer;
- IAudioClient *audioClient = NULL;
- REFERENCE_TIME eventPeriodicity = 0;
+ const PaWasapiDeviceInfo *pInfo = pSub->params.device_info;
+ const PaStreamParameters *params = &pSub->params.stream_params;
+ const double sampleRate = pSub->params.sample_rate;
+ const BOOL fullDuplex = pSub->params.full_duplex;
+ const UINT32 userFramesPerBuffer = pSub->params.frames_per_buffer;
+ UINT32 framesPerLatency = userFramesPerBuffer;
+ IAudioClient *audioClient = NULL;
+ REFERENCE_TIME eventPeriodicity = 0;
- // Assume default failure due to some reason
- (*pa_error) = paInvalidDevice;
+ // Assume default failure due to some reason
+ (*pa_error) = paInvalidDevice;
- // Validate parameters
+ // Validate parameters
if (!pSub || !pInfo || !params)
- {
- (*pa_error) = paBadStreamPtr;
+ {
+ (*pa_error) = paBadStreamPtr;
return E_POINTER;
- }
- if ((UINT32)sampleRate == 0)
- {
- (*pa_error) = paInvalidSampleRate;
+ }
+ if ((UINT32)sampleRate == 0)
+ {
+ (*pa_error) = paInvalidSampleRate;
return E_INVALIDARG;
- }
+ }
// Get the audio client
- if (FAILED(hr = ActivateAudioInterface(pInfo, &pSub->params.wasapi_params, &audioClient)))
- {
- (*pa_error) = paInsufficientMemory;
- LogHostError(hr);
- goto done;
- }
+ if (FAILED(hr = ActivateAudioInterface(pInfo, &pSub->params.wasapi_params, &audioClient)))
+ {
+ (*pa_error) = paInsufficientMemory;
+ LogHostError(hr);
+ goto done;
+ }
- // Get closest format
- if ((error = GetClosestFormat(audioClient, sampleRate, params, pSub->shareMode, &pSub->wavex, output)) != paFormatIsSupported)
- {
- (*pa_error) = error;
- LogHostError(hr = AUDCLNT_E_UNSUPPORTED_FORMAT);
- goto done; // fail, format not supported
- }
+ // Get closest format
+ if ((error = GetClosestFormat(audioClient, sampleRate, params, pSub->shareMode, &pSub->wavex, output)) != paFormatIsSupported)
+ {
+ (*pa_error) = error;
+ LogHostError(hr = AUDCLNT_E_UNSUPPORTED_FORMAT);
+ goto done; // fail, format not supported
+ }
- // Check for Mono <<>> Stereo workaround
- if ((params->channelCount == 1) && (pSub->wavex.Format.nChannels == 2))
- {
- // select mixer
- pSub->monoMixer = GetMonoToStereoMixer(&pSub->wavex, (pInfo->flow == eRender ? MIX_DIR__1TO2 : MIX_DIR__2TO1_L));
- if (pSub->monoMixer == NULL)
- {
- (*pa_error) = paInvalidChannelCount;
- LogHostError(hr = AUDCLNT_E_UNSUPPORTED_FORMAT);
- goto done; // fail, no mixer for format
- }
- }
+ // Check for Mono <<>> Stereo workaround
+ if ((params->channelCount == 1) && (pSub->wavex.Format.nChannels == 2))
+ {
+ // select mixer
+ pSub->monoMixer = GetMonoToStereoMixer(&pSub->wavex, (pInfo->flow == eRender ? MIX_DIR__1TO2 : MIX_DIR__2TO1_L));
+ if (pSub->monoMixer == NULL)
+ {
+ (*pa_error) = paInvalidChannelCount;
+ LogHostError(hr = AUDCLNT_E_UNSUPPORTED_FORMAT);
+ goto done; // fail, no mixer for format
+ }
+ }
- // Calculate host buffer size
- if ((pSub->shareMode != AUDCLNT_SHAREMODE_EXCLUSIVE) &&
- (!pSub->streamFlags || ((pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0)))
- {
- framesPerLatency = _GetFramesPerHostBuffer(userFramesPerBuffer,
- params->suggestedLatency, pSub->wavex.Format.nSamplesPerSec, 0/*,
- (pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK ? 0 : 1)*/);
- }
- else
- {
- #ifdef PA_WASAPI_FORCE_POLL_IF_LARGE_BUFFER
- REFERENCE_TIME overall;
- #endif
+ // Calculate host buffer size
+ if ((pSub->shareMode != AUDCLNT_SHAREMODE_EXCLUSIVE) &&
+ (!pSub->streamFlags || ((pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0)))
+ {
+ framesPerLatency = _GetFramesPerHostBuffer(userFramesPerBuffer,
+ params->suggestedLatency, pSub->wavex.Format.nSamplesPerSec, 0/*,
+ (pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK ? 0 : 1)*/);
+ }
+ else
+ {
+ #ifdef PA_WASAPI_FORCE_POLL_IF_LARGE_BUFFER
+ REFERENCE_TIME overall;
+ #endif
- // Work 1:1 with user buffer (only polling allows to use >1)
- framesPerLatency += MakeFramesFromHns(SecondsTonano100(params->suggestedLatency), pSub->wavex.Format.nSamplesPerSec);
+ // Work 1:1 with user buffer (only polling allows to use >1)
+ framesPerLatency += MakeFramesFromHns(SecondsTonano100(params->suggestedLatency), pSub->wavex.Format.nSamplesPerSec);
- // Force Polling if overall latency is >= 21.33ms as it allows to use 100% CPU in a callback,
- // or user specified latency parameter.
- #ifdef PA_WASAPI_FORCE_POLL_IF_LARGE_BUFFER
- overall = MakeHnsPeriod(framesPerLatency, pSub->wavex.Format.nSamplesPerSec);
- if (overall >= (106667 * 2)/*21.33ms*/)
- {
- framesPerLatency = _GetFramesPerHostBuffer(userFramesPerBuffer,
- params->suggestedLatency, pSub->wavex.Format.nSamplesPerSec, 0/*,
- (streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK ? 0 : 1)*/);
+ // Force Polling if overall latency is >= 21.33ms as it allows to use 100% CPU in a callback,
+ // or user specified latency parameter.
+ #ifdef PA_WASAPI_FORCE_POLL_IF_LARGE_BUFFER
+ overall = MakeHnsPeriod(framesPerLatency, pSub->wavex.Format.nSamplesPerSec);
+ if (overall >= (106667 * 2)/*21.33ms*/)
+ {
+ framesPerLatency = _GetFramesPerHostBuffer(userFramesPerBuffer,
+ params->suggestedLatency, pSub->wavex.Format.nSamplesPerSec, 0/*,
+ (streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK ? 0 : 1)*/);
- // Use Polling interface
- pSub->streamFlags &= ~AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
- PRINT(("WASAPI: CreateAudioClient: forcing POLL mode\n"));
- }
- #endif
- }
+ // Use Polling interface
+ pSub->streamFlags &= ~AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
+ PRINT(("WASAPI: CreateAudioClient: forcing POLL mode\n"));
+ }
+ #endif
+ }
- // For full-duplex output resize buffer to be the same as for input
- if (output && fullDuplex)
- framesPerLatency = pStream->in.framesPerHostCallback;
+ // For full-duplex output resize buffer to be the same as for input
+ if (output && fullDuplex)
+ framesPerLatency = pStream->in.framesPerHostCallback;
- // Avoid 0 frames
- if (framesPerLatency == 0)
- framesPerLatency = MakeFramesFromHns(pInfo->DefaultDevicePeriod, pSub->wavex.Format.nSamplesPerSec);
+ // Avoid 0 frames
+ if (framesPerLatency == 0)
+ framesPerLatency = MakeFramesFromHns(pInfo->DefaultDevicePeriod, pSub->wavex.Format.nSamplesPerSec);
- // Exclusive Input stream renders data in 6 packets, we must set then the size of
- // single packet, total buffer size, e.g. required latency will be PacketSize * 6
- if (!output && (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE))
- {
- // Do it only for Polling mode
- if ((pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0)
- framesPerLatency /= WASAPI_PACKETS_PER_INPUT_BUFFER;
- }
+ // Exclusive Input stream renders data in 6 packets, we must set then the size of
+ // single packet, total buffer size, e.g. required latency will be PacketSize * 6
+ if (!output && (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE))
+ {
+ // Do it only for Polling mode
+ if ((pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0)
+ framesPerLatency /= WASAPI_PACKETS_PER_INPUT_BUFFER;
+ }
- // Calculate aligned period
- _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
+ // Calculate aligned period
+ _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
- /*! Enforce min/max period for device in Shared mode to avoid bad audio quality.
+ /*! Enforce min/max period for device in Shared mode to avoid bad audio quality.
Avoid doing so for Exclusive mode as alignment will suffer.
- */
- if (pSub->shareMode == AUDCLNT_SHAREMODE_SHARED)
- {
- if (pSub->period < pInfo->DefaultDevicePeriod)
- {
- pSub->period = pInfo->DefaultDevicePeriod;
+ */
+ if (pSub->shareMode == AUDCLNT_SHAREMODE_SHARED)
+ {
+ if (pSub->period < pInfo->DefaultDevicePeriod)
+ {
+ pSub->period = pInfo->DefaultDevicePeriod;
- // Recalculate aligned period
- framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
- _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
- }
- }
- else
- {
- if (pSub->period < pInfo->MinimumDevicePeriod)
- {
- pSub->period = pInfo->MinimumDevicePeriod;
+ // Recalculate aligned period
+ framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
+ _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
+ }
+ }
+ else
+ {
+ if (pSub->period < pInfo->MinimumDevicePeriod)
+ {
+ pSub->period = pInfo->MinimumDevicePeriod;
- // Recalculate aligned period
- framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
- _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_FWD);
- }
- }
+ // Recalculate aligned period
+ framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
+ _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_FWD);
+ }
+ }
- /*! Windows 7 does not allow to set latency lower than minimal device period and will
- return error: AUDCLNT_E_INVALID_DEVICE_PERIOD. Under Vista we enforce the same behavior
- manually for unified behavior on all platforms.
- */
- {
- /*! AUDCLNT_E_BUFFER_SIZE_ERROR: Applies to Windows 7 and later.
- Indicates that the buffer duration value requested by an exclusive-mode client is
- out of range. The requested duration value for pull mode must not be greater than
- 500 milliseconds; for push mode the duration value must not be greater than 2 seconds.
- */
- if (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE)
- {
- static const REFERENCE_TIME MAX_BUFFER_EVENT_DURATION = 500 * 10000;
- static const REFERENCE_TIME MAX_BUFFER_POLL_DURATION = 2000 * 10000;
+ /*! Windows 7 does not allow to set latency lower than minimal device period and will
+ return error: AUDCLNT_E_INVALID_DEVICE_PERIOD. Under Vista we enforce the same behavior
+ manually for unified behavior on all platforms.
+ */
+ {
+ /*! AUDCLNT_E_BUFFER_SIZE_ERROR: Applies to Windows 7 and later.
+ Indicates that the buffer duration value requested by an exclusive-mode client is
+ out of range. The requested duration value for pull mode must not be greater than
+ 500 milliseconds; for push mode the duration value must not be greater than 2 seconds.
+ */
+ if (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE)
+ {
+ static const REFERENCE_TIME MAX_BUFFER_EVENT_DURATION = 500 * 10000;
+ static const REFERENCE_TIME MAX_BUFFER_POLL_DURATION = 2000 * 10000;
- // Pull mode, max 500ms
- if (pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)
- {
- if (pSub->period > MAX_BUFFER_EVENT_DURATION)
- {
- pSub->period = MAX_BUFFER_EVENT_DURATION;
+ // Pull mode, max 500ms
+ if (pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)
+ {
+ if (pSub->period > MAX_BUFFER_EVENT_DURATION)
+ {
+ pSub->period = MAX_BUFFER_EVENT_DURATION;
- // Recalculate aligned period
- framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
- _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
- }
- }
- // Push mode, max 2000ms
- else
- {
- if (pSub->period > MAX_BUFFER_POLL_DURATION)
- {
- pSub->period = MAX_BUFFER_POLL_DURATION;
+ // Recalculate aligned period
+ framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
+ _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
+ }
+ }
+ // Push mode, max 2000ms
+ else
+ {
+ if (pSub->period > MAX_BUFFER_POLL_DURATION)
+ {
+ pSub->period = MAX_BUFFER_POLL_DURATION;
- // Recalculate aligned period
- framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
- _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
- }
- }
- }
- }
+ // Recalculate aligned period
+ framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
+ _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
+ }
+ }
+ }
+ }
- // Set device scheduling period (always 0 in Shared mode according Microsoft docs)
- _CalculatePeriodicity(pSub, output, &eventPeriodicity);
-
- // Open the stream and associate it with an audio session
+ // Set device scheduling period (always 0 in Shared mode according Microsoft docs)
+ _CalculatePeriodicity(pSub, output, &eventPeriodicity);
+
+ // Open the stream and associate it with an audio session
hr = IAudioClient_Initialize(audioClient,
pSub->shareMode,
pSub->streamFlags,
- pSub->period,
- eventPeriodicity,
- &pSub->wavex.Format,
+ pSub->period,
+ eventPeriodicity,
+ &pSub->wavex.Format,
NULL);
-
- // [Output only] Check if buffer size is the one we requested in Exclusive mode, for UAC1 USB DACs WASAPI
- // can allocate internal buffer equal to 8 times of pSub->period that has to be corrected in order to match
- // the requested latency
- if (output && SUCCEEDED(hr) && (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE))
- {
- UINT32 maxBufferFrames;
-
- if (FAILED(hr = IAudioClient_GetBufferSize(audioClient, &maxBufferFrames)))
- {
- (*pa_error) = paInvalidDevice;
- LogHostError(hr);
- goto done;
- }
-
- // For Exclusive mode for UAC1 devices maxBufferFrames may be framesPerLatency * 8 but check any difference
- // to be able to guarantee the latency user requested and also resulted framesPerLatency may be bigger than
- // 2 seconds that will cause audio client not operational (GetCurrentPadding() will return always 0)
- if (maxBufferFrames >= (framesPerLatency * 2))
- {
- UINT32 ratio = maxBufferFrames / framesPerLatency;
-
- PRINT(("WASAPI: CreateAudioClient: detected %d times larger buffer than requested, correct to match user latency\n", ratio));
-
- // Get new aligned frames lowered by calculated ratio
- framesPerLatency = MakeFramesFromHns(pSub->period / ratio, pSub->wavex.Format.nSamplesPerSec);
- _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
-
- // Make sure we are not below the minimum period
- if (pSub->period < pInfo->MinimumDevicePeriod)
- pSub->period = pInfo->MinimumDevicePeriod;
-
- // Release previous client
- SAFE_RELEASE(audioClient);
-
- // Create a new audio client
- if (FAILED(hr = ActivateAudioInterface(pInfo, &pSub->params.wasapi_params, &audioClient)))
- {
- (*pa_error) = paInsufficientMemory;
- LogHostError(hr);
- goto done;
- }
-
- // Set device scheduling period (always 0 in Shared mode according Microsoft docs)
- _CalculatePeriodicity(pSub, output, &eventPeriodicity);
-
- // Open the stream and associate it with an audio session
- hr = IAudioClient_Initialize(audioClient,
- pSub->shareMode,
- pSub->streamFlags,
- pSub->period,
- eventPeriodicity,
- &pSub->wavex.Format,
- NULL);
- }
- }
-
- /*! WASAPI is tricky on large device buffer, sometimes 2000ms can be allocated sometimes
- less. There is no known guaranteed level thus we make subsequent tries by decreasing
- buffer by 100ms per try.
- */
- while ((hr == E_OUTOFMEMORY) && (pSub->period > (100 * 10000)))
- {
- PRINT(("WASAPI: CreateAudioClient: decreasing buffer size to %d milliseconds\n", (pSub->period / 10000)));
-
- // Decrease by 100ms and try again
- pSub->period -= (100 * 10000);
-
- // Recalculate aligned period
- framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
- _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
-
- // Release the previous allocations
- SAFE_RELEASE(audioClient);
-
- // Create a new audio client
- if (FAILED(hr = ActivateAudioInterface(pInfo, &pSub->params.wasapi_params, &audioClient)))
- {
- (*pa_error) = paInsufficientMemory;
- LogHostError(hr);
- goto done;
- }
-
- // Set device scheduling period (always 0 in Shared mode according Microsoft docs)
- _CalculatePeriodicity(pSub, output, &eventPeriodicity);
-
- // Open the stream and associate it with an audio session
- hr = IAudioClient_Initialize(audioClient,
- pSub->shareMode,
- pSub->streamFlags,
- pSub->period,
- eventPeriodicity,
- &pSub->wavex.Format,
- NULL);
- }
-
- /*! WASAPI buffer size or alignment failure. Fallback to using default size and alignment.
- */
- if ((hr == AUDCLNT_E_BUFFER_SIZE_ERROR) || (hr == AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED))
- {
- // Use default
- pSub->period = pInfo->DefaultDevicePeriod;
-
- PRINT(("WASAPI: CreateAudioClient: correcting buffer size/alignment to device default\n"));
-
- // Release the previous allocations
- SAFE_RELEASE(audioClient);
-
- // Create a new audio client
- if (FAILED(hr = ActivateAudioInterface(pInfo, &pSub->params.wasapi_params, &audioClient)))
- {
- (*pa_error) = paInsufficientMemory;
- LogHostError(hr);
- goto done;
- }
-
- // Set device scheduling period (always 0 in Shared mode according Microsoft docs)
- _CalculatePeriodicity(pSub, output, &eventPeriodicity);
-
- // Open the stream and associate it with an audio session
- hr = IAudioClient_Initialize(audioClient,
- pSub->shareMode,
- pSub->streamFlags,
- pSub->period,
- eventPeriodicity,
- &pSub->wavex.Format,
- NULL);
- }
-
- // Error has no workaround, fail completely
- if (FAILED(hr))
+
+ // [Output only] Check if buffer size is the one we requested in Exclusive mode, for UAC1 USB DACs WASAPI
+ // can allocate internal buffer equal to 8 times of pSub->period that has to be corrected in order to match
+ // the requested latency
+ if (output && SUCCEEDED(hr) && (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE))
{
- (*pa_error) = paInvalidDevice;
- LogHostError(hr);
- goto done;
+ UINT32 maxBufferFrames;
+
+ if (FAILED(hr = IAudioClient_GetBufferSize(audioClient, &maxBufferFrames)))
+ {
+ (*pa_error) = paInvalidDevice;
+ LogHostError(hr);
+ goto done;
+ }
+
+ // For Exclusive mode for UAC1 devices maxBufferFrames may be framesPerLatency * 8 but check any difference
+ // to be able to guarantee the latency user requested and also resulted framesPerLatency may be bigger than
+ // 2 seconds that will cause audio client not operational (GetCurrentPadding() will return always 0)
+ if (maxBufferFrames >= (framesPerLatency * 2))
+ {
+ UINT32 ratio = maxBufferFrames / framesPerLatency;
+
+ PRINT(("WASAPI: CreateAudioClient: detected %d times larger buffer than requested, correct to match user latency\n", ratio));
+
+ // Get new aligned frames lowered by calculated ratio
+ framesPerLatency = MakeFramesFromHns(pSub->period / ratio, pSub->wavex.Format.nSamplesPerSec);
+ _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
+
+ // Make sure we are not below the minimum period
+ if (pSub->period < pInfo->MinimumDevicePeriod)
+ pSub->period = pInfo->MinimumDevicePeriod;
+
+ // Release previous client
+ SAFE_RELEASE(audioClient);
+
+ // Create a new audio client
+ if (FAILED(hr = ActivateAudioInterface(pInfo, &pSub->params.wasapi_params, &audioClient)))
+ {
+ (*pa_error) = paInsufficientMemory;
+ LogHostError(hr);
+ goto done;
+ }
+
+ // Set device scheduling period (always 0 in Shared mode according Microsoft docs)
+ _CalculatePeriodicity(pSub, output, &eventPeriodicity);
+
+ // Open the stream and associate it with an audio session
+ hr = IAudioClient_Initialize(audioClient,
+ pSub->shareMode,
+ pSub->streamFlags,
+ pSub->period,
+ eventPeriodicity,
+ &pSub->wavex.Format,
+ NULL);
+ }
+ }
+
+ /*! WASAPI is tricky on large device buffer, sometimes 2000ms can be allocated sometimes
+ less. There is no known guaranteed level thus we make subsequent tries by decreasing
+ buffer by 100ms per try.
+ */
+ while ((hr == E_OUTOFMEMORY) && (pSub->period > (100 * 10000)))
+ {
+ PRINT(("WASAPI: CreateAudioClient: decreasing buffer size to %d milliseconds\n", (pSub->period / 10000)));
+
+ // Decrease by 100ms and try again
+ pSub->period -= (100 * 10000);
+
+ // Recalculate aligned period
+ framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);
+ _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
+
+ // Release the previous allocations
+ SAFE_RELEASE(audioClient);
+
+ // Create a new audio client
+ if (FAILED(hr = ActivateAudioInterface(pInfo, &pSub->params.wasapi_params, &audioClient)))
+ {
+ (*pa_error) = paInsufficientMemory;
+ LogHostError(hr);
+ goto done;
+ }
+
+ // Set device scheduling period (always 0 in Shared mode according Microsoft docs)
+ _CalculatePeriodicity(pSub, output, &eventPeriodicity);
+
+ // Open the stream and associate it with an audio session
+ hr = IAudioClient_Initialize(audioClient,
+ pSub->shareMode,
+ pSub->streamFlags,
+ pSub->period,
+ eventPeriodicity,
+ &pSub->wavex.Format,
+ NULL);
+ }
+
+ /*! WASAPI buffer size or alignment failure. Fallback to using default size and alignment.
+ */
+ if ((hr == AUDCLNT_E_BUFFER_SIZE_ERROR) || (hr == AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED))
+ {
+ // Use default
+ pSub->period = pInfo->DefaultDevicePeriod;
+
+ PRINT(("WASAPI: CreateAudioClient: correcting buffer size/alignment to device default\n"));
+
+ // Release the previous allocations
+ SAFE_RELEASE(audioClient);
+
+ // Create a new audio client
+ if (FAILED(hr = ActivateAudioInterface(pInfo, &pSub->params.wasapi_params, &audioClient)))
+ {
+ (*pa_error) = paInsufficientMemory;
+ LogHostError(hr);
+ goto done;
+ }
+
+ // Set device scheduling period (always 0 in Shared mode according Microsoft docs)
+ _CalculatePeriodicity(pSub, output, &eventPeriodicity);
+
+ // Open the stream and associate it with an audio session
+ hr = IAudioClient_Initialize(audioClient,
+ pSub->shareMode,
+ pSub->streamFlags,
+ pSub->period,
+ eventPeriodicity,
+ &pSub->wavex.Format,
+ NULL);
+ }
+
+ // Error has no workaround, fail completely
+ if (FAILED(hr))
+ {
+ (*pa_error) = paInvalidDevice;
+ LogHostError(hr);
+ goto done;
}
// Set client
- pSub->clientParent = audioClient;
+ pSub->clientParent = audioClient;
IAudioClient_AddRef(pSub->clientParent);
- // Recalculate buffers count
- _RecalculateBuffersCount(pSub, userFramesPerBuffer, MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec),
- fullDuplex);
+ // Recalculate buffers count
+ _RecalculateBuffersCount(pSub, userFramesPerBuffer, MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec),
+ fullDuplex);
- // No error, client is succesfully created
- (*pa_error) = paNoError;
+ // No error, client is succesfully created
+ (*pa_error) = paNoError;
done:
@@ -3435,22 +3435,22 @@ done:
// ------------------------------------------------------------------------------------------
static PaError ActivateAudioClientOutput(PaWasapiStream *stream)
{
- HRESULT hr;
- PaError result;
- UINT32 maxBufferSize;
- PaTime bufferLatency;
- const UINT32 framesPerBuffer = stream->out.params.frames_per_buffer;
+ HRESULT hr;
+ PaError result;
+ UINT32 maxBufferSize;
+ PaTime bufferLatency;
+ const UINT32 framesPerBuffer = stream->out.params.frames_per_buffer;
- // Create Audio client
+ // Create Audio client
if (FAILED(hr = CreateAudioClient(stream, &stream->out, TRUE, &result)))
- {
- LogPaError(result);
- goto error;
+ {
+ LogPaError(result);
+ goto error;
}
- LogWAVEFORMATEXTENSIBLE(&stream->out.wavex);
+ LogWAVEFORMATEXTENSIBLE(&stream->out.wavex);
- // Activate volume
- stream->outVol = NULL;
+ // Activate volume
+ stream->outVol = NULL;
/*hr = info->device->Activate(
__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL,
(void**)&stream->outVol);
@@ -3459,65 +3459,65 @@ static PaError ActivateAudioClientOutput(PaWasapiStream *stream)
// Get max possible buffer size to check if it is not less than that we request
if (FAILED(hr = IAudioClient_GetBufferSize(stream->out.clientParent, &maxBufferSize)))
- {
- LogHostError(hr);
- LogPaError(result = paInvalidDevice);
- goto error;
- }
+ {
+ LogHostError(hr);
+ LogPaError(result = paInvalidDevice);
+ goto error;
+ }
// Correct buffer to max size if it maxed out result of GetBufferSize
- stream->out.bufferSize = maxBufferSize;
+ stream->out.bufferSize = maxBufferSize;
- // Get interface latency (actually uneeded as we calculate latency from the size of maxBufferSize)
+ // Get interface latency (actually uneeded as we calculate latency from the size of maxBufferSize)
if (FAILED(hr = IAudioClient_GetStreamLatency(stream->out.clientParent, &stream->out.deviceLatency)))
- {
- LogHostError(hr);
- LogPaError(result = paInvalidDevice);
- goto error;
- }
- //stream->out.latencySeconds = nano100ToSeconds(stream->out.deviceLatency);
+ {
+ LogHostError(hr);
+ LogPaError(result = paInvalidDevice);
+ goto error;
+ }
+ //stream->out.latencySeconds = nano100ToSeconds(stream->out.deviceLatency);
// Number of frames that are required at each period
- stream->out.framesPerHostCallback = maxBufferSize;
+ stream->out.framesPerHostCallback = maxBufferSize;
- // Calculate frames per single buffer, if buffers > 1 then always framesPerBuffer
- stream->out.framesPerBuffer =
- (stream->out.userBufferAndHostMatch ? stream->out.framesPerHostCallback : framesPerBuffer);
+ // Calculate frames per single buffer, if buffers > 1 then always framesPerBuffer
+ stream->out.framesPerBuffer =
+ (stream->out.userBufferAndHostMatch ? stream->out.framesPerHostCallback : framesPerBuffer);
- // Calculate buffer latency
- bufferLatency = (PaTime)maxBufferSize / stream->out.wavex.Format.nSamplesPerSec;
+ // Calculate buffer latency
+ bufferLatency = (PaTime)maxBufferSize / stream->out.wavex.Format.nSamplesPerSec;
- // Append buffer latency to interface latency in shared mode (see GetStreamLatency notes)
- stream->out.latencySeconds = bufferLatency;
+ // Append buffer latency to interface latency in shared mode (see GetStreamLatency notes)
+ stream->out.latencySeconds = bufferLatency;
- PRINT(("WASAPI::OpenStream(output): framesPerUser[ %d ] framesPerHost[ %d ] latency[ %.02fms ] exclusive[ %s ] wow64_fix[ %s ] mode[ %s ]\n", (UINT32)framesPerBuffer, (UINT32)stream->out.framesPerHostCallback, (float)(stream->out.latencySeconds*1000.0f), (stream->out.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE ? "YES" : "NO"), (stream->out.params.wow64_workaround ? "YES" : "NO"), (stream->out.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK ? "EVENT" : "POLL")));
+ PRINT(("WASAPI::OpenStream(output): framesPerUser[ %d ] framesPerHost[ %d ] latency[ %.02fms ] exclusive[ %s ] wow64_fix[ %s ] mode[ %s ]\n", (UINT32)framesPerBuffer, (UINT32)stream->out.framesPerHostCallback, (float)(stream->out.latencySeconds*1000.0f), (stream->out.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE ? "YES" : "NO"), (stream->out.params.wow64_workaround ? "YES" : "NO"), (stream->out.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK ? "EVENT" : "POLL")));
- return paNoError;
+ return paNoError;
error:
- return result;
+ return result;
}
// ------------------------------------------------------------------------------------------
static PaError ActivateAudioClientInput(PaWasapiStream *stream)
{
- HRESULT hr;
- PaError result;
- UINT32 maxBufferSize;
- PaTime bufferLatency;
- const UINT32 framesPerBuffer = stream->in.params.frames_per_buffer;
+ HRESULT hr;
+ PaError result;
+ UINT32 maxBufferSize;
+ PaTime bufferLatency;
+ const UINT32 framesPerBuffer = stream->in.params.frames_per_buffer;
- // Create Audio client
+ // Create Audio client
if (FAILED(hr = CreateAudioClient(stream, &stream->in, FALSE, &result)))
- {
- LogPaError(result);
- goto error;
+ {
+ LogPaError(result);
+ goto error;
}
- LogWAVEFORMATEXTENSIBLE(&stream->in.wavex);
+ LogWAVEFORMATEXTENSIBLE(&stream->in.wavex);
- // Create volume mgr
- stream->inVol = NULL;
+ // Create volume mgr
+ stream->inVol = NULL;
/*hr = info->device->Activate(
__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL,
(void**)&stream->inVol);
@@ -3526,45 +3526,45 @@ static PaError ActivateAudioClientInput(PaWasapiStream *stream)
// Get max possible buffer size to check if it is not less than that we request
if (FAILED(hr = IAudioClient_GetBufferSize(stream->in.clientParent, &maxBufferSize)))
- {
- LogHostError(hr);
- LogPaError(result = paInvalidDevice);
- goto error;
- }
+ {
+ LogHostError(hr);
+ LogPaError(result = paInvalidDevice);
+ goto error;
+ }
// Correct buffer to max size if it maxed out result of GetBufferSize
- stream->in.bufferSize = maxBufferSize;
+ stream->in.bufferSize = maxBufferSize;
- // Get interface latency (actually uneeded as we calculate latency from the size
- // of maxBufferSize).
+ // Get interface latency (actually uneeded as we calculate latency from the size
+ // of maxBufferSize).
if (FAILED(hr = IAudioClient_GetStreamLatency(stream->in.clientParent, &stream->in.deviceLatency)))
- {
- LogHostError(hr);
- LogPaError(result = paInvalidDevice);
- goto error;
- }
- //stream->in.latencySeconds = nano100ToSeconds(stream->in.deviceLatency);
+ {
+ LogHostError(hr);
+ LogPaError(result = paInvalidDevice);
+ goto error;
+ }
+ //stream->in.latencySeconds = nano100ToSeconds(stream->in.deviceLatency);
// Number of frames that are required at each period
- stream->in.framesPerHostCallback = maxBufferSize;
+ stream->in.framesPerHostCallback = maxBufferSize;
- // Calculate frames per single buffer, if buffers > 1 then always framesPerBuffer
- stream->in.framesPerBuffer =
- (stream->in.userBufferAndHostMatch ? stream->in.framesPerHostCallback : framesPerBuffer);
+ // Calculate frames per single buffer, if buffers > 1 then always framesPerBuffer
+ stream->in.framesPerBuffer =
+ (stream->in.userBufferAndHostMatch ? stream->in.framesPerHostCallback : framesPerBuffer);
- // Calculate buffer latency
- bufferLatency = (PaTime)maxBufferSize / stream->in.wavex.Format.nSamplesPerSec;
+ // Calculate buffer latency
+ bufferLatency = (PaTime)maxBufferSize / stream->in.wavex.Format.nSamplesPerSec;
- // Append buffer latency to interface latency in shared mode (see GetStreamLatency notes)
- stream->in.latencySeconds = bufferLatency;
+ // Append buffer latency to interface latency in shared mode (see GetStreamLatency notes)
+ stream->in.latencySeconds = bufferLatency;
- PRINT(("WASAPI::OpenStream(input): framesPerUser[ %d ] framesPerHost[ %d ] latency[ %.02fms ] exclusive[ %s ] wow64_fix[ %s ] mode[ %s ]\n", (UINT32)framesPerBuffer, (UINT32)stream->in.framesPerHostCallback, (float)(stream->in.latencySeconds*1000.0f), (stream->in.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE ? "YES" : "NO"), (stream->in.params.wow64_workaround ? "YES" : "NO"), (stream->in.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK ? "EVENT" : "POLL")));
+ PRINT(("WASAPI::OpenStream(input): framesPerUser[ %d ] framesPerHost[ %d ] latency[ %.02fms ] exclusive[ %s ] wow64_fix[ %s ] mode[ %s ]\n", (UINT32)framesPerBuffer, (UINT32)stream->in.framesPerHostCallback, (float)(stream->in.latencySeconds*1000.0f), (stream->in.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE ? "YES" : "NO"), (stream->in.params.wow64_workaround ? "YES" : "NO"), (stream->in.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK ? "EVENT" : "POLL")));
- return paNoError;
+ return paNoError;
error:
- return result;
+ return result;
}
// ------------------------------------------------------------------------------------------
@@ -3579,139 +3579,139 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
void *userData )
{
PaError result = paNoError;
- HRESULT hr;
+ HRESULT hr;
PaWasapiHostApiRepresentation *paWasapi = (PaWasapiHostApiRepresentation*)hostApi;
PaWasapiStream *stream = NULL;
int inputChannelCount, outputChannelCount;
PaSampleFormat inputSampleFormat, outputSampleFormat;
PaSampleFormat hostInputSampleFormat, hostOutputSampleFormat;
- PaWasapiStreamInfo *inputStreamInfo = NULL, *outputStreamInfo = NULL;
- PaWasapiDeviceInfo *info = NULL;
- ULONG framesPerHostCallback;
- PaUtilHostBufferSizeMode bufferMode;
- const BOOL fullDuplex = ((inputParameters != NULL) && (outputParameters != NULL));
- BOOL useInputBufferProcessor = (inputParameters != NULL), useOutputBufferProcessor = (outputParameters != NULL);
+ PaWasapiStreamInfo *inputStreamInfo = NULL, *outputStreamInfo = NULL;
+ PaWasapiDeviceInfo *info = NULL;
+ ULONG framesPerHostCallback;
+ PaUtilHostBufferSizeMode bufferMode;
+ const BOOL fullDuplex = ((inputParameters != NULL) && (outputParameters != NULL));
+ BOOL useInputBufferProcessor = (inputParameters != NULL), useOutputBufferProcessor = (outputParameters != NULL);
- // validate PaStreamParameters
- if ((result = IsStreamParamsValid(hostApi, inputParameters, outputParameters, sampleRate)) != paNoError)
- return LogPaError(result);
+ // validate PaStreamParameters
+ if ((result = IsStreamParamsValid(hostApi, inputParameters, outputParameters, sampleRate)) != paNoError)
+ return LogPaError(result);
// Validate platform specific flags
if ((streamFlags & paPlatformSpecificFlags) != 0)
- {
- LogPaError(result = paInvalidFlag); /* unexpected platform specific flag */
- goto error;
- }
+ {
+ LogPaError(result = paInvalidFlag); /* unexpected platform specific flag */
+ goto error;
+ }
- // Allocate memory for PaWasapiStream
+ // Allocate memory for PaWasapiStream
if ((stream = (PaWasapiStream *)PaUtil_AllocateMemory(sizeof(PaWasapiStream))) == NULL)
- {
+ {
LogPaError(result = paInsufficientMemory);
goto error;
}
- // Default thread priority is Audio: for exclusive mode we will use Pro Audio.
- stream->nThreadPriority = eThreadPriorityAudio;
+ // Default thread priority is Audio: for exclusive mode we will use Pro Audio.
+ stream->nThreadPriority = eThreadPriorityAudio;
- // Set default number of frames: paFramesPerBufferUnspecified
- if (framesPerBuffer == paFramesPerBufferUnspecified)
- {
- UINT32 framesPerBufferIn = 0, framesPerBufferOut = 0;
- if (inputParameters != NULL)
- {
- info = &paWasapi->devInfo[inputParameters->device];
- framesPerBufferIn = MakeFramesFromHns(info->DefaultDevicePeriod, (UINT32)sampleRate);
- }
- if (outputParameters != NULL)
- {
- info = &paWasapi->devInfo[outputParameters->device];
- framesPerBufferOut = MakeFramesFromHns(info->DefaultDevicePeriod, (UINT32)sampleRate);
- }
- // choosing maximum default size
- framesPerBuffer = max(framesPerBufferIn, framesPerBufferOut);
- }
- if (framesPerBuffer == 0)
- framesPerBuffer = ((UINT32)sampleRate / 100) * 2;
+ // Set default number of frames: paFramesPerBufferUnspecified
+ if (framesPerBuffer == paFramesPerBufferUnspecified)
+ {
+ UINT32 framesPerBufferIn = 0, framesPerBufferOut = 0;
+ if (inputParameters != NULL)
+ {
+ info = &paWasapi->devInfo[inputParameters->device];
+ framesPerBufferIn = MakeFramesFromHns(info->DefaultDevicePeriod, (UINT32)sampleRate);
+ }
+ if (outputParameters != NULL)
+ {
+ info = &paWasapi->devInfo[outputParameters->device];
+ framesPerBufferOut = MakeFramesFromHns(info->DefaultDevicePeriod, (UINT32)sampleRate);
+ }
+ // choosing maximum default size
+ framesPerBuffer = max(framesPerBufferIn, framesPerBufferOut);
+ }
+ if (framesPerBuffer == 0)
+ framesPerBuffer = ((UINT32)sampleRate / 100) * 2;
- // Try create device: Input
- if (inputParameters != NULL)
+ // Try create device: Input
+ if (inputParameters != NULL)
{
inputChannelCount = inputParameters->channelCount;
inputSampleFormat = GetSampleFormatForIO(inputParameters->sampleFormat);
info = &paWasapi->devInfo[inputParameters->device];
- // default Shared Mode
- stream->in.shareMode = AUDCLNT_SHAREMODE_SHARED;
+ // default Shared Mode
+ stream->in.shareMode = AUDCLNT_SHAREMODE_SHARED;
- // PaWasapiStreamInfo
- if (inputParameters->hostApiSpecificStreamInfo != NULL)
- {
- memcpy(&stream->in.params.wasapi_params, inputParameters->hostApiSpecificStreamInfo, min(sizeof(stream->in.params.wasapi_params), ((PaWasapiStreamInfo *)inputParameters->hostApiSpecificStreamInfo)->size));
- stream->in.params.wasapi_params.size = sizeof(stream->in.params.wasapi_params);
+ // PaWasapiStreamInfo
+ if (inputParameters->hostApiSpecificStreamInfo != NULL)
+ {
+ memcpy(&stream->in.params.wasapi_params, inputParameters->hostApiSpecificStreamInfo, min(sizeof(stream->in.params.wasapi_params), ((PaWasapiStreamInfo *)inputParameters->hostApiSpecificStreamInfo)->size));
+ stream->in.params.wasapi_params.size = sizeof(stream->in.params.wasapi_params);
- stream->in.params.stream_params.hostApiSpecificStreamInfo = &stream->in.params.wasapi_params;
- inputStreamInfo = &stream->in.params.wasapi_params;
+ stream->in.params.stream_params.hostApiSpecificStreamInfo = &stream->in.params.wasapi_params;
+ inputStreamInfo = &stream->in.params.wasapi_params;
- stream->in.flags = inputStreamInfo->flags;
+ stream->in.flags = inputStreamInfo->flags;
- // Exclusive Mode
- if (inputStreamInfo->flags & paWinWasapiExclusive)
- {
- // Boost thread priority
- stream->nThreadPriority = eThreadPriorityProAudio;
- // Make Exclusive
- stream->in.shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
- }
+ // Exclusive Mode
+ if (inputStreamInfo->flags & paWinWasapiExclusive)
+ {
+ // Boost thread priority
+ stream->nThreadPriority = eThreadPriorityProAudio;
+ // Make Exclusive
+ stream->in.shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
+ }
- // explicit thread priority level
- if (inputStreamInfo->flags & paWinWasapiThreadPriority)
- {
- if ((inputStreamInfo->threadPriority > eThreadPriorityNone) &&
- (inputStreamInfo->threadPriority <= eThreadPriorityWindowManager))
- stream->nThreadPriority = inputStreamInfo->threadPriority;
- }
+ // explicit thread priority level
+ if (inputStreamInfo->flags & paWinWasapiThreadPriority)
+ {
+ if ((inputStreamInfo->threadPriority > eThreadPriorityNone) &&
+ (inputStreamInfo->threadPriority <= eThreadPriorityWindowManager))
+ stream->nThreadPriority = inputStreamInfo->threadPriority;
+ }
- // redirect processing to custom user callback, ignore PA buffer processor
- useInputBufferProcessor = !(inputStreamInfo->flags & paWinWasapiRedirectHostProcessor);
- }
+ // redirect processing to custom user callback, ignore PA buffer processor
+ useInputBufferProcessor = !(inputStreamInfo->flags & paWinWasapiRedirectHostProcessor);
+ }
- // Choose processing mode
- stream->in.streamFlags = (stream->in.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE ? AUDCLNT_STREAMFLAGS_EVENTCALLBACK : 0);
- if (paWasapi->useWOW64Workaround)
- stream->in.streamFlags = 0; // polling interface
- else
- if (streamCallback == NULL)
- stream->in.streamFlags = 0; // polling interface
- else
- if ((inputStreamInfo != NULL) && (inputStreamInfo->flags & paWinWasapiPolling))
- stream->in.streamFlags = 0; // polling interface
- else
- if (fullDuplex)
- stream->in.streamFlags = 0; // polling interface is implemented for full-duplex mode also
+ // Choose processing mode
+ stream->in.streamFlags = (stream->in.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE ? AUDCLNT_STREAMFLAGS_EVENTCALLBACK : 0);
+ if (paWasapi->useWOW64Workaround)
+ stream->in.streamFlags = 0; // polling interface
+ else
+ if (streamCallback == NULL)
+ stream->in.streamFlags = 0; // polling interface
+ else
+ if ((inputStreamInfo != NULL) && (inputStreamInfo->flags & paWinWasapiPolling))
+ stream->in.streamFlags = 0; // polling interface
+ else
+ if (fullDuplex)
+ stream->in.streamFlags = 0; // polling interface is implemented for full-duplex mode also
- // Use built-in PCM converter (channel count and sample rate) if requested
- if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) &&
- (stream->in.shareMode == AUDCLNT_SHAREMODE_SHARED) &&
- ((inputStreamInfo != NULL) && (inputStreamInfo->flags & paWinWasapiAutoConvert)))
- stream->in.streamFlags |= (AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY);
+ // Use built-in PCM converter (channel count and sample rate) if requested
+ if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) &&
+ (stream->in.shareMode == AUDCLNT_SHAREMODE_SHARED) &&
+ ((inputStreamInfo != NULL) && (inputStreamInfo->flags & paWinWasapiAutoConvert)))
+ stream->in.streamFlags |= (AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY);
- // Fill parameters for Audio Client creation
- stream->in.params.device_info = info;
- stream->in.params.stream_params = (*inputParameters);
- stream->in.params.frames_per_buffer = framesPerBuffer;
- stream->in.params.sample_rate = sampleRate;
- stream->in.params.blocking = (streamCallback == NULL);
- stream->in.params.full_duplex = fullDuplex;
- stream->in.params.wow64_workaround = paWasapi->useWOW64Workaround;
+ // Fill parameters for Audio Client creation
+ stream->in.params.device_info = info;
+ stream->in.params.stream_params = (*inputParameters);
+ stream->in.params.frames_per_buffer = framesPerBuffer;
+ stream->in.params.sample_rate = sampleRate;
+ stream->in.params.blocking = (streamCallback == NULL);
+ stream->in.params.full_duplex = fullDuplex;
+ stream->in.params.wow64_workaround = paWasapi->useWOW64Workaround;
- // Create and activate audio client
- if ((result = ActivateAudioClientInput(stream)) != paNoError)
- {
- LogPaError(result);
- goto error;
- }
+ // Create and activate audio client
+ if ((result = ActivateAudioClientInput(stream)) != paNoError)
+ {
+ LogPaError(result);
+ goto error;
+ }
- // Get closest format
+ // Get closest format
hostInputSampleFormat = PaUtil_SelectClosestAvailableFormat(WaveToPaFormat(&stream->in.wavex), inputSampleFormat);
// Set user-side custom host processor
@@ -3722,130 +3722,130 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->hostProcessOverrideInput.userData = userData;
}
- // Only get IAudioCaptureClient input once here instead of getting it at multiple places based on the use
- if (FAILED(hr = IAudioClient_GetService(stream->in.clientParent, &pa_IID_IAudioCaptureClient, (void **)&stream->captureClientParent)))
- {
- LogHostError(hr);
- LogPaError(result = paUnanticipatedHostError);
- goto error;
- }
+ // Only get IAudioCaptureClient input once here instead of getting it at multiple places based on the use
+ if (FAILED(hr = IAudioClient_GetService(stream->in.clientParent, &pa_IID_IAudioCaptureClient, (void **)&stream->captureClientParent)))
+ {
+ LogHostError(hr);
+ LogPaError(result = paUnanticipatedHostError);
+ goto error;
+ }
- // Create ring buffer for blocking mode (It is needed because we fetch Input packets, not frames,
- // and thus we have to save partial packet if such remains unread)
- if (stream->in.params.blocking == TRUE)
- {
- UINT32 bufferFrames = ALIGN_NEXT_POW2((stream->in.framesPerHostCallback / WASAPI_PACKETS_PER_INPUT_BUFFER) * 2);
- UINT32 frameSize = stream->in.wavex.Format.nBlockAlign;
+ // Create ring buffer for blocking mode (It is needed because we fetch Input packets, not frames,
+ // and thus we have to save partial packet if such remains unread)
+ if (stream->in.params.blocking == TRUE)
+ {
+ UINT32 bufferFrames = ALIGN_NEXT_POW2((stream->in.framesPerHostCallback / WASAPI_PACKETS_PER_INPUT_BUFFER) * 2);
+ UINT32 frameSize = stream->in.wavex.Format.nBlockAlign;
- // buffer
- if ((stream->in.tailBuffer = PaUtil_AllocateMemory(sizeof(PaUtilRingBuffer))) == NULL)
- {
- LogPaError(result = paInsufficientMemory);
- goto error;
- }
- memset(stream->in.tailBuffer, 0, sizeof(PaUtilRingBuffer));
+ // buffer
+ if ((stream->in.tailBuffer = PaUtil_AllocateMemory(sizeof(PaUtilRingBuffer))) == NULL)
+ {
+ LogPaError(result = paInsufficientMemory);
+ goto error;
+ }
+ memset(stream->in.tailBuffer, 0, sizeof(PaUtilRingBuffer));
- // buffer memory region
- stream->in.tailBufferMemory = PaUtil_AllocateMemory(frameSize * bufferFrames);
- if (stream->in.tailBufferMemory == NULL)
- {
- LogPaError(result = paInsufficientMemory);
- goto error;
- }
+ // buffer memory region
+ stream->in.tailBufferMemory = PaUtil_AllocateMemory(frameSize * bufferFrames);
+ if (stream->in.tailBufferMemory == NULL)
+ {
+ LogPaError(result = paInsufficientMemory);
+ goto error;
+ }
- // initialize
- if (PaUtil_InitializeRingBuffer(stream->in.tailBuffer, frameSize, bufferFrames, stream->in.tailBufferMemory) != 0)
- {
- LogPaError(result = paInternalError);
- goto error;
- }
- }
- }
+ // initialize
+ if (PaUtil_InitializeRingBuffer(stream->in.tailBuffer, frameSize, bufferFrames, stream->in.tailBufferMemory) != 0)
+ {
+ LogPaError(result = paInternalError);
+ goto error;
+ }
+ }
+ }
else
{
inputChannelCount = 0;
inputSampleFormat = hostInputSampleFormat = paInt16; /* Surpress 'uninitialised var' warnings. */
}
- // Try create device: Output
+ // Try create device: Output
if (outputParameters != NULL)
{
outputChannelCount = outputParameters->channelCount;
outputSampleFormat = GetSampleFormatForIO(outputParameters->sampleFormat);
- info = &paWasapi->devInfo[outputParameters->device];
+ info = &paWasapi->devInfo[outputParameters->device];
- // default Shared Mode
- stream->out.shareMode = AUDCLNT_SHAREMODE_SHARED;
+ // default Shared Mode
+ stream->out.shareMode = AUDCLNT_SHAREMODE_SHARED;
- // set PaWasapiStreamInfo
- if (outputParameters->hostApiSpecificStreamInfo != NULL)
- {
- memcpy(&stream->out.params.wasapi_params, outputParameters->hostApiSpecificStreamInfo, min(sizeof(stream->out.params.wasapi_params), ((PaWasapiStreamInfo *)outputParameters->hostApiSpecificStreamInfo)->size));
- stream->out.params.wasapi_params.size = sizeof(stream->out.params.wasapi_params);
+ // set PaWasapiStreamInfo
+ if (outputParameters->hostApiSpecificStreamInfo != NULL)
+ {
+ memcpy(&stream->out.params.wasapi_params, outputParameters->hostApiSpecificStreamInfo, min(sizeof(stream->out.params.wasapi_params), ((PaWasapiStreamInfo *)outputParameters->hostApiSpecificStreamInfo)->size));
+ stream->out.params.wasapi_params.size = sizeof(stream->out.params.wasapi_params);
- stream->out.params.stream_params.hostApiSpecificStreamInfo = &stream->out.params.wasapi_params;
- outputStreamInfo = &stream->out.params.wasapi_params;
+ stream->out.params.stream_params.hostApiSpecificStreamInfo = &stream->out.params.wasapi_params;
+ outputStreamInfo = &stream->out.params.wasapi_params;
- stream->out.flags = outputStreamInfo->flags;
+ stream->out.flags = outputStreamInfo->flags;
- // Exclusive Mode
- if (outputStreamInfo->flags & paWinWasapiExclusive)
- {
- // Boost thread priority
- stream->nThreadPriority = eThreadPriorityProAudio;
- // Make Exclusive
- stream->out.shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
- }
+ // Exclusive Mode
+ if (outputStreamInfo->flags & paWinWasapiExclusive)
+ {
+ // Boost thread priority
+ stream->nThreadPriority = eThreadPriorityProAudio;
+ // Make Exclusive
+ stream->out.shareMode = AUDCLNT_SHAREMODE_EXCLUSIVE;
+ }
- // explicit thread priority level
- if (outputStreamInfo->flags & paWinWasapiThreadPriority)
- {
- if ((outputStreamInfo->threadPriority > eThreadPriorityNone) &&
- (outputStreamInfo->threadPriority <= eThreadPriorityWindowManager))
- stream->nThreadPriority = outputStreamInfo->threadPriority;
- }
+ // explicit thread priority level
+ if (outputStreamInfo->flags & paWinWasapiThreadPriority)
+ {
+ if ((outputStreamInfo->threadPriority > eThreadPriorityNone) &&
+ (outputStreamInfo->threadPriority <= eThreadPriorityWindowManager))
+ stream->nThreadPriority = outputStreamInfo->threadPriority;
+ }
- // redirect processing to custom user callback, ignore PA buffer processor
- useOutputBufferProcessor = !(outputStreamInfo->flags & paWinWasapiRedirectHostProcessor);
- }
+ // redirect processing to custom user callback, ignore PA buffer processor
+ useOutputBufferProcessor = !(outputStreamInfo->flags & paWinWasapiRedirectHostProcessor);
+ }
- // Choose processing mode
- stream->out.streamFlags = (stream->out.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE ? AUDCLNT_STREAMFLAGS_EVENTCALLBACK : 0);
- if (paWasapi->useWOW64Workaround)
- stream->out.streamFlags = 0; // polling interface
- else
- if (streamCallback == NULL)
- stream->out.streamFlags = 0; // polling interface
- else
- if ((outputStreamInfo != NULL) && (outputStreamInfo->flags & paWinWasapiPolling))
- stream->out.streamFlags = 0; // polling interface
- else
- if (fullDuplex)
- stream->out.streamFlags = 0; // polling interface is implemented for full-duplex mode also
+ // Choose processing mode
+ stream->out.streamFlags = (stream->out.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE ? AUDCLNT_STREAMFLAGS_EVENTCALLBACK : 0);
+ if (paWasapi->useWOW64Workaround)
+ stream->out.streamFlags = 0; // polling interface
+ else
+ if (streamCallback == NULL)
+ stream->out.streamFlags = 0; // polling interface
+ else
+ if ((outputStreamInfo != NULL) && (outputStreamInfo->flags & paWinWasapiPolling))
+ stream->out.streamFlags = 0; // polling interface
+ else
+ if (fullDuplex)
+ stream->out.streamFlags = 0; // polling interface is implemented for full-duplex mode also
- // Use built-in PCM converter (channel count and sample rate) if requested
- if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) &&
- (stream->out.shareMode == AUDCLNT_SHAREMODE_SHARED) &&
- ((outputStreamInfo != NULL) && (outputStreamInfo->flags & paWinWasapiAutoConvert)))
- stream->out.streamFlags |= (AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY);
+ // Use built-in PCM converter (channel count and sample rate) if requested
+ if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) &&
+ (stream->out.shareMode == AUDCLNT_SHAREMODE_SHARED) &&
+ ((outputStreamInfo != NULL) && (outputStreamInfo->flags & paWinWasapiAutoConvert)))
+ stream->out.streamFlags |= (AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY);
- // Fill parameters for Audio Client creation
- stream->out.params.device_info = info;
- stream->out.params.stream_params = (*outputParameters);
- stream->out.params.frames_per_buffer = framesPerBuffer;
- stream->out.params.sample_rate = sampleRate;
- stream->out.params.blocking = (streamCallback == NULL);
- stream->out.params.full_duplex = fullDuplex;
- stream->out.params.wow64_workaround = paWasapi->useWOW64Workaround;
+ // Fill parameters for Audio Client creation
+ stream->out.params.device_info = info;
+ stream->out.params.stream_params = (*outputParameters);
+ stream->out.params.frames_per_buffer = framesPerBuffer;
+ stream->out.params.sample_rate = sampleRate;
+ stream->out.params.blocking = (streamCallback == NULL);
+ stream->out.params.full_duplex = fullDuplex;
+ stream->out.params.wow64_workaround = paWasapi->useWOW64Workaround;
- // Create and activate audio client
- if ((result = ActivateAudioClientOutput(stream)) != paNoError)
- {
- LogPaError(result);
- goto error;
- }
+ // Create and activate audio client
+ if ((result = ActivateAudioClientOutput(stream)) != paNoError)
+ {
+ LogPaError(result);
+ goto error;
+ }
- // Get closest format
+ // Get closest format
hostOutputSampleFormat = PaUtil_SelectClosestAvailableFormat(WaveToPaFormat(&stream->out.wavex), outputSampleFormat);
// Set user-side custom host processor
@@ -3856,137 +3856,137 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->hostProcessOverrideOutput.userData = userData;
}
- // Only get IAudioCaptureClient output once here instead of getting it at multiple places based on the use
- if (FAILED(hr = IAudioClient_GetService(stream->out.clientParent, &pa_IID_IAudioRenderClient, (void **)&stream->renderClientParent)))
- {
- LogHostError(hr);
- LogPaError(result = paUnanticipatedHostError);
- goto error;
- }
- }
+ // Only get IAudioCaptureClient output once here instead of getting it at multiple places based on the use
+ if (FAILED(hr = IAudioClient_GetService(stream->out.clientParent, &pa_IID_IAudioRenderClient, (void **)&stream->renderClientParent)))
+ {
+ LogHostError(hr);
+ LogPaError(result = paUnanticipatedHostError);
+ goto error;
+ }
+ }
else
{
outputChannelCount = 0;
outputSampleFormat = hostOutputSampleFormat = paInt16; /* Surpress 'uninitialized var' warnings. */
}
- // log full-duplex
- if (fullDuplex)
- PRINT(("WASAPI::OpenStream: full-duplex mode\n"));
+ // log full-duplex
+ if (fullDuplex)
+ PRINT(("WASAPI::OpenStream: full-duplex mode\n"));
- // paWinWasapiPolling must be on/or not on both streams
- if ((inputParameters != NULL) && (outputParameters != NULL))
- {
- if ((inputStreamInfo != NULL) && (outputStreamInfo != NULL))
- {
- if (((inputStreamInfo->flags & paWinWasapiPolling) &&
- !(outputStreamInfo->flags & paWinWasapiPolling))
- ||
- (!(inputStreamInfo->flags & paWinWasapiPolling) &&
- (outputStreamInfo->flags & paWinWasapiPolling)))
- {
- LogPaError(result = paInvalidFlag);
- goto error;
- }
- }
- }
+ // paWinWasapiPolling must be on/or not on both streams
+ if ((inputParameters != NULL) && (outputParameters != NULL))
+ {
+ if ((inputStreamInfo != NULL) && (outputStreamInfo != NULL))
+ {
+ if (((inputStreamInfo->flags & paWinWasapiPolling) &&
+ !(outputStreamInfo->flags & paWinWasapiPolling))
+ ||
+ (!(inputStreamInfo->flags & paWinWasapiPolling) &&
+ (outputStreamInfo->flags & paWinWasapiPolling)))
+ {
+ LogPaError(result = paInvalidFlag);
+ goto error;
+ }
+ }
+ }
- // Initialize stream representation
+ // Initialize stream representation
if (streamCallback)
{
- stream->bBlocking = FALSE;
+ stream->bBlocking = FALSE;
PaUtil_InitializeStreamRepresentation(&stream->streamRepresentation,
&paWasapi->callbackStreamInterface,
- streamCallback, userData);
+ streamCallback, userData);
}
else
{
- stream->bBlocking = TRUE;
+ stream->bBlocking = TRUE;
PaUtil_InitializeStreamRepresentation(&stream->streamRepresentation,
&paWasapi->blockingStreamInterface,
- streamCallback, userData);
+ streamCallback, userData);
}
- // Initialize CPU measurer
+ // Initialize CPU measurer
PaUtil_InitializeCpuLoadMeasurer(&stream->cpuLoadMeasurer, sampleRate);
- if (outputParameters && inputParameters)
- {
- // serious problem #1 - No, Not a problem, especially concerning Exclusive mode.
- // Input device in exclusive mode somehow is getting large buffer always, thus we
- // adjust Output latency to reflect it, thus period will differ but playback will be
- // normal.
- /*if (stream->in.period != stream->out.period)
- {
- PRINT(("WASAPI: OpenStream: period discrepancy\n"));
- LogPaError(result = paBadIODeviceCombination);
- goto error;
- }*/
+ if (outputParameters && inputParameters)
+ {
+ // serious problem #1 - No, Not a problem, especially concerning Exclusive mode.
+ // Input device in exclusive mode somehow is getting large buffer always, thus we
+ // adjust Output latency to reflect it, thus period will differ but playback will be
+ // normal.
+ /*if (stream->in.period != stream->out.period)
+ {
+ PRINT(("WASAPI: OpenStream: period discrepancy\n"));
+ LogPaError(result = paBadIODeviceCombination);
+ goto error;
+ }*/
- // serious problem #2 - No, Not a problem, as framesPerHostCallback take into account
- // sample size while it is not a problem for PA full-duplex, we must care of
- // preriod only!
- /*if (stream->out.framesPerHostCallback != stream->in.framesPerHostCallback)
- {
- PRINT(("WASAPI: OpenStream: framesPerHostCallback discrepancy\n"));
- goto error;
- }*/
- }
+ // serious problem #2 - No, Not a problem, as framesPerHostCallback take into account
+ // sample size while it is not a problem for PA full-duplex, we must care of
+ // preriod only!
+ /*if (stream->out.framesPerHostCallback != stream->in.framesPerHostCallback)
+ {
+ PRINT(("WASAPI: OpenStream: framesPerHostCallback discrepancy\n"));
+ goto error;
+ }*/
+ }
- // Calculate frames per host for processor
- framesPerHostCallback = (outputParameters ? stream->out.framesPerBuffer : stream->in.framesPerBuffer);
+ // Calculate frames per host for processor
+ framesPerHostCallback = (outputParameters ? stream->out.framesPerBuffer : stream->in.framesPerBuffer);
- // Choose correct mode of buffer processing:
- // Exclusive/Shared non paWinWasapiPolling mode: paUtilFixedHostBufferSize - always fixed
- // Exclusive/Shared paWinWasapiPolling mode: paUtilBoundedHostBufferSize - may vary for Exclusive or Full-duplex
- bufferMode = paUtilFixedHostBufferSize;
- if (inputParameters) // !!! WASAPI IAudioCaptureClient::GetBuffer extracts not number of frames but 1 packet, thus we always must adapt
- bufferMode = paUtilBoundedHostBufferSize;
- else
- if (outputParameters)
- {
- if ((stream->out.buffers == 1) &&
- (!stream->out.streamFlags || ((stream->out.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0)))
- bufferMode = paUtilBoundedHostBufferSize;
- }
- stream->bufferMode = bufferMode;
+ // Choose correct mode of buffer processing:
+ // Exclusive/Shared non paWinWasapiPolling mode: paUtilFixedHostBufferSize - always fixed
+ // Exclusive/Shared paWinWasapiPolling mode: paUtilBoundedHostBufferSize - may vary for Exclusive or Full-duplex
+ bufferMode = paUtilFixedHostBufferSize;
+ if (inputParameters) // !!! WASAPI IAudioCaptureClient::GetBuffer extracts not number of frames but 1 packet, thus we always must adapt
+ bufferMode = paUtilBoundedHostBufferSize;
+ else
+ if (outputParameters)
+ {
+ if ((stream->out.buffers == 1) &&
+ (!stream->out.streamFlags || ((stream->out.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0)))
+ bufferMode = paUtilBoundedHostBufferSize;
+ }
+ stream->bufferMode = bufferMode;
// Initialize buffer processor
- if (useInputBufferProcessor || useOutputBufferProcessor)
- {
- result = PaUtil_InitializeBufferProcessor(
- &stream->bufferProcessor,
- inputChannelCount,
- inputSampleFormat,
- hostInputSampleFormat,
- outputChannelCount,
- outputSampleFormat,
- hostOutputSampleFormat,
- sampleRate,
- streamFlags,
- framesPerBuffer,
- framesPerHostCallback,
- bufferMode,
- streamCallback,
- userData);
- if (result != paNoError)
- {
- LogPaError(result);
- goto error;
- }
- }
+ if (useInputBufferProcessor || useOutputBufferProcessor)
+ {
+ result = PaUtil_InitializeBufferProcessor(
+ &stream->bufferProcessor,
+ inputChannelCount,
+ inputSampleFormat,
+ hostInputSampleFormat,
+ outputChannelCount,
+ outputSampleFormat,
+ hostOutputSampleFormat,
+ sampleRate,
+ streamFlags,
+ framesPerBuffer,
+ framesPerHostCallback,
+ bufferMode,
+ streamCallback,
+ userData);
+ if (result != paNoError)
+ {
+ LogPaError(result);
+ goto error;
+ }
+ }
- // Set Input latency
+ // Set Input latency
stream->streamRepresentation.streamInfo.inputLatency =
(useInputBufferProcessor ? PaUtil_GetBufferProcessorInputLatencyFrames(&stream->bufferProcessor) / sampleRate : 0)
- + (inputParameters != NULL ? stream->in.latencySeconds : 0);
+ + (inputParameters != NULL ? stream->in.latencySeconds : 0);
- // Set Output latency
+ // Set Output latency
stream->streamRepresentation.streamInfo.outputLatency =
(useOutputBufferProcessor ? PaUtil_GetBufferProcessorOutputLatencyFrames(&stream->bufferProcessor) / sampleRate : 0)
- + (outputParameters != NULL ? stream->out.latencySeconds : 0);
+ + (outputParameters != NULL ? stream->out.latencySeconds : 0);
- // Set SR
+ // Set SR
stream->streamRepresentation.streamInfo.sampleRate = sampleRate;
(*s) = (PaStream *)stream;
@@ -3995,7 +3995,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
error:
if (stream != NULL)
- CloseStream(stream);
+ CloseStream(stream);
return result;
}
@@ -4006,32 +4006,32 @@ static PaError CloseStream( PaStream* s )
PaError result = paNoError;
PaWasapiStream *stream = (PaWasapiStream*)s;
- // abort active stream
- if (IsStreamActive(s))
- {
- result = AbortStream(s);
- }
+ // abort active stream
+ if (IsStreamActive(s))
+ {
+ result = AbortStream(s);
+ }
SAFE_RELEASE(stream->captureClientParent);
SAFE_RELEASE(stream->renderClientParent);
SAFE_RELEASE(stream->out.clientParent);
SAFE_RELEASE(stream->in.clientParent);
- SAFE_RELEASE(stream->inVol);
- SAFE_RELEASE(stream->outVol);
+ SAFE_RELEASE(stream->inVol);
+ SAFE_RELEASE(stream->outVol);
- CloseHandle(stream->event[S_INPUT]);
- CloseHandle(stream->event[S_OUTPUT]);
+ CloseHandle(stream->event[S_INPUT]);
+ CloseHandle(stream->event[S_OUTPUT]);
- _StreamCleanup(stream);
+ _StreamCleanup(stream);
- PaWasapi_FreeMemory(stream->in.monoBuffer);
- PaWasapi_FreeMemory(stream->out.monoBuffer);
+ PaWasapi_FreeMemory(stream->in.monoBuffer);
+ PaWasapi_FreeMemory(stream->out.monoBuffer);
- PaUtil_FreeMemory(stream->in.tailBuffer);
- PaUtil_FreeMemory(stream->in.tailBufferMemory);
+ PaUtil_FreeMemory(stream->in.tailBuffer);
+ PaUtil_FreeMemory(stream->in.tailBufferMemory);
- PaUtil_FreeMemory(stream->out.tailBuffer);
- PaUtil_FreeMemory(stream->out.tailBufferMemory);
+ PaUtil_FreeMemory(stream->out.tailBuffer);
+ PaUtil_FreeMemory(stream->out.tailBufferMemory);
PaUtil_TerminateBufferProcessor(&stream->bufferProcessor);
PaUtil_TerminateStreamRepresentation(&stream->streamRepresentation);
@@ -4044,23 +4044,23 @@ static PaError CloseStream( PaStream* s )
HRESULT UnmarshalSubStreamComPointers(PaWasapiSubStream *substream)
{
#ifndef PA_WINRT
- HRESULT hResult = S_OK;
- HRESULT hFirstBadResult = S_OK;
- substream->clientProc = NULL;
+ HRESULT hResult = S_OK;
+ HRESULT hFirstBadResult = S_OK;
+ substream->clientProc = NULL;
- // IAudioClient
- hResult = CoGetInterfaceAndReleaseStream(substream->clientStream, GetAudioClientIID(), (LPVOID*)&substream->clientProc);
- substream->clientStream = NULL;
- if (hResult != S_OK)
- {
- hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
- }
+ // IAudioClient
+ hResult = CoGetInterfaceAndReleaseStream(substream->clientStream, GetAudioClientIID(), (LPVOID*)&substream->clientProc);
+ substream->clientStream = NULL;
+ if (hResult != S_OK)
+ {
+ hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
+ }
- return hFirstBadResult;
+ return hFirstBadResult;
#else
- (void)substream;
- return S_OK;
+ (void)substream;
+ return S_OK;
#endif
}
@@ -4068,120 +4068,120 @@ HRESULT UnmarshalSubStreamComPointers(PaWasapiSubStream *substream)
HRESULT UnmarshalStreamComPointers(PaWasapiStream *stream)
{
#ifndef PA_WINRT
- HRESULT hResult = S_OK;
- HRESULT hFirstBadResult = S_OK;
- stream->captureClient = NULL;
- stream->renderClient = NULL;
- stream->in.clientProc = NULL;
- stream->out.clientProc = NULL;
+ HRESULT hResult = S_OK;
+ HRESULT hFirstBadResult = S_OK;
+ stream->captureClient = NULL;
+ stream->renderClient = NULL;
+ stream->in.clientProc = NULL;
+ stream->out.clientProc = NULL;
- if (NULL != stream->in.clientParent)
- {
- // SubStream pointers
- hResult = UnmarshalSubStreamComPointers(&stream->in);
- if (hResult != S_OK)
- {
- hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
- }
+ if (NULL != stream->in.clientParent)
+ {
+ // SubStream pointers
+ hResult = UnmarshalSubStreamComPointers(&stream->in);
+ if (hResult != S_OK)
+ {
+ hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
+ }
- // IAudioCaptureClient
- hResult = CoGetInterfaceAndReleaseStream(stream->captureClientStream, &pa_IID_IAudioCaptureClient, (LPVOID*)&stream->captureClient);
- stream->captureClientStream = NULL;
- if (hResult != S_OK)
- {
- hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
- }
- }
+ // IAudioCaptureClient
+ hResult = CoGetInterfaceAndReleaseStream(stream->captureClientStream, &pa_IID_IAudioCaptureClient, (LPVOID*)&stream->captureClient);
+ stream->captureClientStream = NULL;
+ if (hResult != S_OK)
+ {
+ hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
+ }
+ }
- if (NULL != stream->out.clientParent)
- {
- // SubStream pointers
- hResult = UnmarshalSubStreamComPointers(&stream->out);
- if (hResult != S_OK)
- {
- hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
- }
+ if (NULL != stream->out.clientParent)
+ {
+ // SubStream pointers
+ hResult = UnmarshalSubStreamComPointers(&stream->out);
+ if (hResult != S_OK)
+ {
+ hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
+ }
- // IAudioRenderClient
- hResult = CoGetInterfaceAndReleaseStream(stream->renderClientStream, &pa_IID_IAudioRenderClient, (LPVOID*)&stream->renderClient);
- stream->renderClientStream = NULL;
- if (hResult != S_OK)
- {
- hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
- }
- }
+ // IAudioRenderClient
+ hResult = CoGetInterfaceAndReleaseStream(stream->renderClientStream, &pa_IID_IAudioRenderClient, (LPVOID*)&stream->renderClient);
+ stream->renderClientStream = NULL;
+ if (hResult != S_OK)
+ {
+ hFirstBadResult = (hFirstBadResult == S_OK) ? hResult : hFirstBadResult;
+ }
+ }
- return hFirstBadResult;
+ return hFirstBadResult;
#else
- if (stream->in.clientParent != NULL)
- {
- stream->in.clientProc = stream->in.clientParent;
- IAudioClient_AddRef(stream->in.clientParent);
- }
+ if (stream->in.clientParent != NULL)
+ {
+ stream->in.clientProc = stream->in.clientParent;
+ IAudioClient_AddRef(stream->in.clientParent);
+ }
- if (stream->out.clientParent != NULL)
- {
- stream->out.clientProc = stream->out.clientParent;
- IAudioClient_AddRef(stream->out.clientParent);
- }
+ if (stream->out.clientParent != NULL)
+ {
+ stream->out.clientProc = stream->out.clientParent;
+ IAudioClient_AddRef(stream->out.clientParent);
+ }
- if (stream->renderClientParent != NULL)
- {
- stream->renderClient = stream->renderClientParent;
- IAudioRenderClient_AddRef(stream->renderClientParent);
- }
+ if (stream->renderClientParent != NULL)
+ {
+ stream->renderClient = stream->renderClientParent;
+ IAudioRenderClient_AddRef(stream->renderClientParent);
+ }
- if (stream->captureClientParent != NULL)
- {
- stream->captureClient = stream->captureClientParent;
- IAudioCaptureClient_AddRef(stream->captureClientParent);
- }
+ if (stream->captureClientParent != NULL)
+ {
+ stream->captureClient = stream->captureClientParent;
+ IAudioCaptureClient_AddRef(stream->captureClientParent);
+ }
- return S_OK;
+ return S_OK;
#endif
}
// -----------------------------------------------------------------------------------------
void ReleaseUnmarshaledSubComPointers(PaWasapiSubStream *substream)
{
- SAFE_RELEASE(substream->clientProc);
+ SAFE_RELEASE(substream->clientProc);
}
// -----------------------------------------------------------------------------------------
void ReleaseUnmarshaledComPointers(PaWasapiStream *stream)
{
- // Release AudioClient services first
- SAFE_RELEASE(stream->captureClient);
- SAFE_RELEASE(stream->renderClient);
+ // Release AudioClient services first
+ SAFE_RELEASE(stream->captureClient);
+ SAFE_RELEASE(stream->renderClient);
- // Release AudioClients
- ReleaseUnmarshaledSubComPointers(&stream->in);
- ReleaseUnmarshaledSubComPointers(&stream->out);
+ // Release AudioClients
+ ReleaseUnmarshaledSubComPointers(&stream->in);
+ ReleaseUnmarshaledSubComPointers(&stream->out);
}
// ------------------------------------------------------------------------------------------
HRESULT MarshalSubStreamComPointers(PaWasapiSubStream *substream)
{
#ifndef PA_WINRT
- HRESULT hResult;
- substream->clientStream = NULL;
+ HRESULT hResult;
+ substream->clientStream = NULL;
- // IAudioClient
- hResult = CoMarshalInterThreadInterfaceInStream(GetAudioClientIID(), (LPUNKNOWN)substream->clientParent, &substream->clientStream);
- if (hResult != S_OK)
- goto marshal_sub_error;
+ // IAudioClient
+ hResult = CoMarshalInterThreadInterfaceInStream(GetAudioClientIID(), (LPUNKNOWN)substream->clientParent, &substream->clientStream);
+ if (hResult != S_OK)
+ goto marshal_sub_error;
- return hResult;
+ return hResult;
- // If marshaling error occurred, make sure to release everything.
+ // If marshaling error occurred, make sure to release everything.
marshal_sub_error:
- UnmarshalSubStreamComPointers(substream);
- ReleaseUnmarshaledSubComPointers(substream);
- return hResult;
+ UnmarshalSubStreamComPointers(substream);
+ ReleaseUnmarshaledSubComPointers(substream);
+ return hResult;
#else
- (void)substream;
- return S_OK;
+ (void)substream;
+ return S_OK;
#endif
}
@@ -4189,214 +4189,214 @@ marshal_sub_error:
HRESULT MarshalStreamComPointers(PaWasapiStream *stream)
{
#ifndef PA_WINRT
- HRESULT hResult = S_OK;
- stream->captureClientStream = NULL;
- stream->in.clientStream = NULL;
- stream->renderClientStream = NULL;
- stream->out.clientStream = NULL;
+ HRESULT hResult = S_OK;
+ stream->captureClientStream = NULL;
+ stream->in.clientStream = NULL;
+ stream->renderClientStream = NULL;
+ stream->out.clientStream = NULL;
- if (NULL != stream->in.clientParent)
- {
- // SubStream pointers
- hResult = MarshalSubStreamComPointers(&stream->in);
- if (hResult != S_OK)
- goto marshal_error;
+ if (NULL != stream->in.clientParent)
+ {
+ // SubStream pointers
+ hResult = MarshalSubStreamComPointers(&stream->in);
+ if (hResult != S_OK)
+ goto marshal_error;
- // IAudioCaptureClient
- hResult = CoMarshalInterThreadInterfaceInStream(&pa_IID_IAudioCaptureClient, (LPUNKNOWN)stream->captureClientParent, &stream->captureClientStream);
- if (hResult != S_OK)
- goto marshal_error;
- }
+ // IAudioCaptureClient
+ hResult = CoMarshalInterThreadInterfaceInStream(&pa_IID_IAudioCaptureClient, (LPUNKNOWN)stream->captureClientParent, &stream->captureClientStream);
+ if (hResult != S_OK)
+ goto marshal_error;
+ }
- if (NULL != stream->out.clientParent)
- {
- // SubStream pointers
- hResult = MarshalSubStreamComPointers(&stream->out);
- if (hResult != S_OK)
- goto marshal_error;
+ if (NULL != stream->out.clientParent)
+ {
+ // SubStream pointers
+ hResult = MarshalSubStreamComPointers(&stream->out);
+ if (hResult != S_OK)
+ goto marshal_error;
- // IAudioRenderClient
- hResult = CoMarshalInterThreadInterfaceInStream(&pa_IID_IAudioRenderClient, (LPUNKNOWN)stream->renderClientParent, &stream->renderClientStream);
- if (hResult != S_OK)
- goto marshal_error;
- }
+ // IAudioRenderClient
+ hResult = CoMarshalInterThreadInterfaceInStream(&pa_IID_IAudioRenderClient, (LPUNKNOWN)stream->renderClientParent, &stream->renderClientStream);
+ if (hResult != S_OK)
+ goto marshal_error;
+ }
- return hResult;
+ return hResult;
- // If marshaling error occurred, make sure to release everything.
+ // If marshaling error occurred, make sure to release everything.
marshal_error:
- UnmarshalStreamComPointers(stream);
- ReleaseUnmarshaledComPointers(stream);
- return hResult;
+ UnmarshalStreamComPointers(stream);
+ ReleaseUnmarshaledComPointers(stream);
+ return hResult;
#else
- (void)stream;
- return S_OK;
+ (void)stream;
+ return S_OK;
#endif
}
// ------------------------------------------------------------------------------------------
static PaError StartStream( PaStream *s )
{
- HRESULT hr;
+ HRESULT hr;
PaWasapiStream *stream = (PaWasapiStream*)s;
- PaError result = paNoError;
+ PaError result = paNoError;
- // check if stream is active already
- if (IsStreamActive(s))
- return paStreamIsNotStopped;
+ // check if stream is active already
+ if (IsStreamActive(s))
+ return paStreamIsNotStopped;
PaUtil_ResetBufferProcessor(&stream->bufferProcessor);
- // Cleanup handles (may be necessary if stream was stopped by itself due to error)
- _StreamCleanup(stream);
+ // Cleanup handles (may be necessary if stream was stopped by itself due to error)
+ _StreamCleanup(stream);
- // Create close event
- if ((stream->hCloseRequest = CreateEvent(NULL, TRUE, FALSE, NULL)) == NULL)
- {
- result = paInsufficientMemory;
- goto start_error;
- }
+ // Create close event
+ if ((stream->hCloseRequest = CreateEvent(NULL, TRUE, FALSE, NULL)) == NULL)
+ {
+ result = paInsufficientMemory;
+ goto start_error;
+ }
- // Create thread
- if (!stream->bBlocking)
- {
- // Create thread events
- stream->hThreadStart = CreateEvent(NULL, TRUE, FALSE, NULL);
- stream->hThreadExit = CreateEvent(NULL, TRUE, FALSE, NULL);
- if ((stream->hThreadStart == NULL) || (stream->hThreadExit == NULL))
- {
- result = paInsufficientMemory;
- goto start_error;
- }
+ // Create thread
+ if (!stream->bBlocking)
+ {
+ // Create thread events
+ stream->hThreadStart = CreateEvent(NULL, TRUE, FALSE, NULL);
+ stream->hThreadExit = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if ((stream->hThreadStart == NULL) || (stream->hThreadExit == NULL))
+ {
+ result = paInsufficientMemory;
+ goto start_error;
+ }
- // Marshal WASAPI interface pointers for safe use in thread created below.
- if ((hr = MarshalStreamComPointers(stream)) != S_OK)
- {
- PRINT(("Failed marshaling stream COM pointers."));
- result = paUnanticipatedHostError;
- goto nonblocking_start_error;
- }
+ // Marshal WASAPI interface pointers for safe use in thread created below.
+ if ((hr = MarshalStreamComPointers(stream)) != S_OK)
+ {
+ PRINT(("Failed marshaling stream COM pointers."));
+ result = paUnanticipatedHostError;
+ goto nonblocking_start_error;
+ }
- if ((stream->in.clientParent && (stream->in.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)) ||
- (stream->out.clientParent && (stream->out.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)))
- {
- if ((stream->hThread = CREATE_THREAD(ProcThreadEvent)) == NULL)
- {
- PRINT(("Failed creating thread: ProcThreadEvent."));
- result = paUnanticipatedHostError;
- goto nonblocking_start_error;
- }
- }
- else
- {
- if ((stream->hThread = CREATE_THREAD(ProcThreadPoll)) == NULL)
- {
- PRINT(("Failed creating thread: ProcThreadPoll."));
- result = paUnanticipatedHostError;
- goto nonblocking_start_error;
- }
- }
+ if ((stream->in.clientParent && (stream->in.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)) ||
+ (stream->out.clientParent && (stream->out.streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)))
+ {
+ if ((stream->hThread = CREATE_THREAD(ProcThreadEvent)) == NULL)
+ {
+ PRINT(("Failed creating thread: ProcThreadEvent."));
+ result = paUnanticipatedHostError;
+ goto nonblocking_start_error;
+ }
+ }
+ else
+ {
+ if ((stream->hThread = CREATE_THREAD(ProcThreadPoll)) == NULL)
+ {
+ PRINT(("Failed creating thread: ProcThreadPoll."));
+ result = paUnanticipatedHostError;
+ goto nonblocking_start_error;
+ }
+ }
- // Wait for thread to start
- if (WaitForSingleObject(stream->hThreadStart, 60*1000) == WAIT_TIMEOUT)
- {
- PRINT(("Failed starting thread: timeout."));
- result = paUnanticipatedHostError;
- goto nonblocking_start_error;
- }
- }
- else
- {
- // Create blocking operation events (non-signaled event means - blocking operation is pending)
- if (stream->out.clientParent != NULL)
- {
- if ((stream->hBlockingOpStreamWR = CreateEvent(NULL, TRUE, TRUE, NULL)) == NULL)
- {
- result = paInsufficientMemory;
- goto start_error;
- }
- }
- if (stream->in.clientParent != NULL)
- {
- if ((stream->hBlockingOpStreamRD = CreateEvent(NULL, TRUE, TRUE, NULL)) == NULL)
- {
- result = paInsufficientMemory;
- goto start_error;
- }
- }
+ // Wait for thread to start
+ if (WaitForSingleObject(stream->hThreadStart, 60*1000) == WAIT_TIMEOUT)
+ {
+ PRINT(("Failed starting thread: timeout."));
+ result = paUnanticipatedHostError;
+ goto nonblocking_start_error;
+ }
+ }
+ else
+ {
+ // Create blocking operation events (non-signaled event means - blocking operation is pending)
+ if (stream->out.clientParent != NULL)
+ {
+ if ((stream->hBlockingOpStreamWR = CreateEvent(NULL, TRUE, TRUE, NULL)) == NULL)
+ {
+ result = paInsufficientMemory;
+ goto start_error;
+ }
+ }
+ if (stream->in.clientParent != NULL)
+ {
+ if ((stream->hBlockingOpStreamRD = CreateEvent(NULL, TRUE, TRUE, NULL)) == NULL)
+ {
+ result = paInsufficientMemory;
+ goto start_error;
+ }
+ }
- // Initialize event & start INPUT stream
- if (stream->in.clientParent != NULL)
- {
- if ((hr = IAudioClient_Start(stream->in.clientParent)) != S_OK)
- {
- LogHostError(hr);
- result = paUnanticipatedHostError;
- goto start_error;
- }
- }
+ // Initialize event & start INPUT stream
+ if (stream->in.clientParent != NULL)
+ {
+ if ((hr = IAudioClient_Start(stream->in.clientParent)) != S_OK)
+ {
+ LogHostError(hr);
+ result = paUnanticipatedHostError;
+ goto start_error;
+ }
+ }
- // Initialize event & start OUTPUT stream
- if (stream->out.clientParent != NULL)
- {
- // Start
- if ((hr = IAudioClient_Start(stream->out.clientParent)) != S_OK)
- {
- LogHostError(hr);
- result = paUnanticipatedHostError;
- goto start_error;
- }
- }
+ // Initialize event & start OUTPUT stream
+ if (stream->out.clientParent != NULL)
+ {
+ // Start
+ if ((hr = IAudioClient_Start(stream->out.clientParent)) != S_OK)
+ {
+ LogHostError(hr);
+ result = paUnanticipatedHostError;
+ goto start_error;
+ }
+ }
- // Set parent to working pointers to use shared functions.
- stream->captureClient = stream->captureClientParent;
- stream->renderClient = stream->renderClientParent;
- stream->in.clientProc = stream->in.clientParent;
- stream->out.clientProc = stream->out.clientParent;
+ // Set parent to working pointers to use shared functions.
+ stream->captureClient = stream->captureClientParent;
+ stream->renderClient = stream->renderClientParent;
+ stream->in.clientProc = stream->in.clientParent;
+ stream->out.clientProc = stream->out.clientParent;
- // Signal: stream running.
- stream->running = TRUE;
- }
+ // Signal: stream running.
+ stream->running = TRUE;
+ }
return result;
nonblocking_start_error:
- // Set hThreadExit event to prevent blocking during cleanup
- SetEvent(stream->hThreadExit);
- UnmarshalStreamComPointers(stream);
- ReleaseUnmarshaledComPointers(stream);
+ // Set hThreadExit event to prevent blocking during cleanup
+ SetEvent(stream->hThreadExit);
+ UnmarshalStreamComPointers(stream);
+ ReleaseUnmarshaledComPointers(stream);
start_error:
- StopStream(s);
- return result;
+ StopStream(s);
+ return result;
}
// ------------------------------------------------------------------------------------------
void _StreamFinish(PaWasapiStream *stream)
{
- // Issue command to thread to stop processing and wait for thread exit
- if (!stream->bBlocking)
- {
- SignalObjectAndWait(stream->hCloseRequest, stream->hThreadExit, INFINITE, FALSE);
- }
- else
- // Blocking mode does not own thread
- {
- // Signal close event and wait for each of 2 blocking operations to complete
- if (stream->out.clientParent)
- SignalObjectAndWait(stream->hCloseRequest, stream->hBlockingOpStreamWR, INFINITE, TRUE);
- if (stream->out.clientParent)
- SignalObjectAndWait(stream->hCloseRequest, stream->hBlockingOpStreamRD, INFINITE, TRUE);
+ // Issue command to thread to stop processing and wait for thread exit
+ if (!stream->bBlocking)
+ {
+ SignalObjectAndWait(stream->hCloseRequest, stream->hThreadExit, INFINITE, FALSE);
+ }
+ else
+ // Blocking mode does not own thread
+ {
+ // Signal close event and wait for each of 2 blocking operations to complete
+ if (stream->out.clientParent)
+ SignalObjectAndWait(stream->hCloseRequest, stream->hBlockingOpStreamWR, INFINITE, TRUE);
+ if (stream->out.clientParent)
+ SignalObjectAndWait(stream->hCloseRequest, stream->hBlockingOpStreamRD, INFINITE, TRUE);
- // Process stop
- _StreamOnStop(stream);
- }
+ // Process stop
+ _StreamOnStop(stream);
+ }
- // Cleanup handles
- _StreamCleanup(stream);
+ // Cleanup handles
+ _StreamCleanup(stream);
stream->running = FALSE;
}
@@ -4404,35 +4404,35 @@ void _StreamFinish(PaWasapiStream *stream)
// ------------------------------------------------------------------------------------------
void _StreamCleanup(PaWasapiStream *stream)
{
- // Close thread handles to allow restart
- SAFE_CLOSE(stream->hThread);
- SAFE_CLOSE(stream->hThreadStart);
- SAFE_CLOSE(stream->hThreadExit);
- SAFE_CLOSE(stream->hCloseRequest);
- SAFE_CLOSE(stream->hBlockingOpStreamRD);
- SAFE_CLOSE(stream->hBlockingOpStreamWR);
+ // Close thread handles to allow restart
+ SAFE_CLOSE(stream->hThread);
+ SAFE_CLOSE(stream->hThreadStart);
+ SAFE_CLOSE(stream->hThreadExit);
+ SAFE_CLOSE(stream->hCloseRequest);
+ SAFE_CLOSE(stream->hBlockingOpStreamRD);
+ SAFE_CLOSE(stream->hBlockingOpStreamWR);
}
// ------------------------------------------------------------------------------------------
static PaError StopStream( PaStream *s )
{
- // Finish stream
- _StreamFinish((PaWasapiStream *)s);
+ // Finish stream
+ _StreamFinish((PaWasapiStream *)s);
return paNoError;
}
// ------------------------------------------------------------------------------------------
static PaError AbortStream( PaStream *s )
{
- // Finish stream
- _StreamFinish((PaWasapiStream *)s);
+ // Finish stream
+ _StreamFinish((PaWasapiStream *)s);
return paNoError;
}
// ------------------------------------------------------------------------------------------
static PaError IsStreamStopped( PaStream *s )
{
- return !((PaWasapiStream *)s)->running;
+ return !((PaWasapiStream *)s)->running;
}
// ------------------------------------------------------------------------------------------
@@ -4455,7 +4455,7 @@ static PaTime GetStreamTime( PaStream *s )
// ------------------------------------------------------------------------------------------
static double GetStreamCpuLoad( PaStream* s )
{
- return PaUtil_GetCpuLoad(&((PaWasapiStream *)s)->cpuLoadMeasurer);
+ return PaUtil_GetCpuLoad(&((PaWasapiStream *)s)->cpuLoadMeasurer);
}
// ------------------------------------------------------------------------------------------
@@ -4463,32 +4463,32 @@ static PaError ReadStream( PaStream* s, void *_buffer, unsigned long frames )
{
PaWasapiStream *stream = (PaWasapiStream*)s;
- HRESULT hr = S_OK;
- BYTE *user_buffer = (BYTE *)_buffer;
- BYTE *wasapi_buffer = NULL;
- DWORD flags = 0;
- UINT32 i, available, sleep = 0;
- unsigned long processed;
- ThreadIdleScheduler sched;
+ HRESULT hr = S_OK;
+ BYTE *user_buffer = (BYTE *)_buffer;
+ BYTE *wasapi_buffer = NULL;
+ DWORD flags = 0;
+ UINT32 i, available, sleep = 0;
+ unsigned long processed;
+ ThreadIdleScheduler sched;
- // validate
- if (!stream->running)
- return paStreamIsStopped;
- if (stream->captureClient == NULL)
- return paBadStreamPtr;
+ // validate
+ if (!stream->running)
+ return paStreamIsStopped;
+ if (stream->captureClient == NULL)
+ return paBadStreamPtr;
- // Notify blocking op has begun
- ResetEvent(stream->hBlockingOpStreamRD);
+ // Notify blocking op has begun
+ ResetEvent(stream->hBlockingOpStreamRD);
- // Use thread scheduling for 500 microseconds (emulated) when wait time for frames is less than
- // 1 milliseconds, emulation helps to normalize CPU consumption and avoids too busy waiting
- ThreadIdleScheduler_Setup(&sched, 1, 250/* microseconds */);
+ // Use thread scheduling for 500 microseconds (emulated) when wait time for frames is less than
+ // 1 milliseconds, emulation helps to normalize CPU consumption and avoids too busy waiting
+ ThreadIdleScheduler_Setup(&sched, 1, 250/* microseconds */);
// Make a local copy of the user buffer pointer(s), this is necessary
- // because PaUtil_CopyOutput() advances these pointers every time it is called
+ // because PaUtil_CopyOutput() advances these pointers every time it is called
if (!stream->bufferProcessor.userInputIsInterleaved)
{
- user_buffer = (BYTE *)alloca(sizeof(BYTE *) * stream->bufferProcessor.inputChannelCount);
+ user_buffer = (BYTE *)alloca(sizeof(BYTE *) * stream->bufferProcessor.inputChannelCount);
if (user_buffer == NULL)
return paInsufficientMemory;
@@ -4496,145 +4496,145 @@ static PaError ReadStream( PaStream* s, void *_buffer, unsigned long frames )
((BYTE **)user_buffer)[i] = ((BYTE **)_buffer)[i];
}
- // Findout if there are tail frames, flush them all before reading hardware
- if ((available = PaUtil_GetRingBufferReadAvailable(stream->in.tailBuffer)) != 0)
- {
- ring_buffer_size_t buf1_size = 0, buf2_size = 0, read, desired;
- void *buf1 = NULL, *buf2 = NULL;
+ // Findout if there are tail frames, flush them all before reading hardware
+ if ((available = PaUtil_GetRingBufferReadAvailable(stream->in.tailBuffer)) != 0)
+ {
+ ring_buffer_size_t buf1_size = 0, buf2_size = 0, read, desired;
+ void *buf1 = NULL, *buf2 = NULL;
- // Limit desired to amount of requested frames
- desired = available;
- if ((UINT32)desired > frames)
- desired = frames;
-
- // Get pointers to read regions
- read = PaUtil_GetRingBufferReadRegions(stream->in.tailBuffer, desired, &buf1, &buf1_size, &buf2, &buf2_size);
+ // Limit desired to amount of requested frames
+ desired = available;
+ if ((UINT32)desired > frames)
+ desired = frames;
+
+ // Get pointers to read regions
+ read = PaUtil_GetRingBufferReadRegions(stream->in.tailBuffer, desired, &buf1, &buf1_size, &buf2, &buf2_size);
- if (buf1 != NULL)
- {
- // Register available frames to processor
- PaUtil_SetInputFrameCount(&stream->bufferProcessor, buf1_size);
+ if (buf1 != NULL)
+ {
+ // Register available frames to processor
+ PaUtil_SetInputFrameCount(&stream->bufferProcessor, buf1_size);
- // Register host buffer pointer to processor
- PaUtil_SetInterleavedInputChannels(&stream->bufferProcessor, 0, buf1, stream->bufferProcessor.inputChannelCount);
+ // Register host buffer pointer to processor
+ PaUtil_SetInterleavedInputChannels(&stream->bufferProcessor, 0, buf1, stream->bufferProcessor.inputChannelCount);
- // Copy user data to host buffer (with conversion if applicable)
- processed = PaUtil_CopyInput(&stream->bufferProcessor, (void **)&user_buffer, buf1_size);
- frames -= processed;
- }
+ // Copy user data to host buffer (with conversion if applicable)
+ processed = PaUtil_CopyInput(&stream->bufferProcessor, (void **)&user_buffer, buf1_size);
+ frames -= processed;
+ }
- if (buf2 != NULL)
- {
- // Register available frames to processor
- PaUtil_SetInputFrameCount(&stream->bufferProcessor, buf2_size);
+ if (buf2 != NULL)
+ {
+ // Register available frames to processor
+ PaUtil_SetInputFrameCount(&stream->bufferProcessor, buf2_size);
- // Register host buffer pointer to processor
- PaUtil_SetInterleavedInputChannels(&stream->bufferProcessor, 0, buf2, stream->bufferProcessor.inputChannelCount);
+ // Register host buffer pointer to processor
+ PaUtil_SetInterleavedInputChannels(&stream->bufferProcessor, 0, buf2, stream->bufferProcessor.inputChannelCount);
- // Copy user data to host buffer (with conversion if applicable)
- processed = PaUtil_CopyInput(&stream->bufferProcessor, (void **)&user_buffer, buf2_size);
- frames -= processed;
- }
+ // Copy user data to host buffer (with conversion if applicable)
+ processed = PaUtil_CopyInput(&stream->bufferProcessor, (void **)&user_buffer, buf2_size);
+ frames -= processed;
+ }
- // Advance
- PaUtil_AdvanceRingBufferReadIndex(stream->in.tailBuffer, read);
- }
+ // Advance
+ PaUtil_AdvanceRingBufferReadIndex(stream->in.tailBuffer, read);
+ }
- // Read hardware
- while (frames != 0)
- {
- // Check if blocking call must be interrupted
- if (WaitForSingleObject(stream->hCloseRequest, sleep) != WAIT_TIMEOUT)
- break;
+ // Read hardware
+ while (frames != 0)
+ {
+ // Check if blocking call must be interrupted
+ if (WaitForSingleObject(stream->hCloseRequest, sleep) != WAIT_TIMEOUT)
+ break;
- // Get available frames (must be finding out available frames before call to IAudioCaptureClient_GetBuffer
- // othervise audio glitches will occur inExclusive mode as it seems that WASAPI has some scheduling/
- // processing problems when such busy polling with IAudioCaptureClient_GetBuffer occurs)
- if ((hr = _PollGetInputFramesAvailable(stream, &available)) != S_OK)
- {
- LogHostError(hr);
- return paUnanticipatedHostError;
- }
+ // Get available frames (must be finding out available frames before call to IAudioCaptureClient_GetBuffer
+ // othervise audio glitches will occur inExclusive mode as it seems that WASAPI has some scheduling/
+ // processing problems when such busy polling with IAudioCaptureClient_GetBuffer occurs)
+ if ((hr = _PollGetInputFramesAvailable(stream, &available)) != S_OK)
+ {
+ LogHostError(hr);
+ return paUnanticipatedHostError;
+ }
- // Wait for more frames to become available
- if (available == 0)
- {
- // Exclusive mode may require latency of 1 millisecond, thus we shall sleep
- // around 500 microseconds (emulated) to collect packets in time
- if (stream->in.shareMode != AUDCLNT_SHAREMODE_EXCLUSIVE)
- {
- UINT32 sleep_frames = (frames < stream->in.framesPerHostCallback ? frames : stream->in.framesPerHostCallback);
+ // Wait for more frames to become available
+ if (available == 0)
+ {
+ // Exclusive mode may require latency of 1 millisecond, thus we shall sleep
+ // around 500 microseconds (emulated) to collect packets in time
+ if (stream->in.shareMode != AUDCLNT_SHAREMODE_EXCLUSIVE)
+ {
+ UINT32 sleep_frames = (frames < stream->in.framesPerHostCallback ? frames : stream->in.framesPerHostCallback);
- sleep = GetFramesSleepTime(sleep_frames, stream->in.wavex.Format.nSamplesPerSec);
- sleep /= 4; // wait only for 1/4 of the buffer
+ sleep = GetFramesSleepTime(sleep_frames, stream->in.wavex.Format.nSamplesPerSec);
+ sleep /= 4; // wait only for 1/4 of the buffer
- // WASAPI input provides packets, thus expiring packet will result in bad audio
- // limit waiting time to 2 seconds (will always work for smallest buffer in Shared)
- if (sleep > 2)
- sleep = 2;
+ // WASAPI input provides packets, thus expiring packet will result in bad audio
+ // limit waiting time to 2 seconds (will always work for smallest buffer in Shared)
+ if (sleep > 2)
+ sleep = 2;
- // Avoid busy waiting, schedule next 1 millesecond wait
- if (sleep == 0)
- sleep = ThreadIdleScheduler_NextSleep(&sched);
- }
- else
- {
- if ((sleep = ThreadIdleScheduler_NextSleep(&sched)) != 0)
- {
- Sleep(sleep);
- sleep = 0;
- }
- }
+ // Avoid busy waiting, schedule next 1 millesecond wait
+ if (sleep == 0)
+ sleep = ThreadIdleScheduler_NextSleep(&sched);
+ }
+ else
+ {
+ if ((sleep = ThreadIdleScheduler_NextSleep(&sched)) != 0)
+ {
+ Sleep(sleep);
+ sleep = 0;
+ }
+ }
- continue;
- }
+ continue;
+ }
- // Get the available data in the shared buffer.
- if ((hr = IAudioCaptureClient_GetBuffer(stream->captureClient, &wasapi_buffer, &available, &flags, NULL, NULL)) != S_OK)
- {
- // Buffer size is too small, waiting
- if (hr != AUDCLNT_S_BUFFER_EMPTY)
- {
- LogHostError(hr);
- goto end;
- }
+ // Get the available data in the shared buffer.
+ if ((hr = IAudioCaptureClient_GetBuffer(stream->captureClient, &wasapi_buffer, &available, &flags, NULL, NULL)) != S_OK)
+ {
+ // Buffer size is too small, waiting
+ if (hr != AUDCLNT_S_BUFFER_EMPTY)
+ {
+ LogHostError(hr);
+ goto end;
+ }
- continue;
- }
+ continue;
+ }
- // Register available frames to processor
+ // Register available frames to processor
PaUtil_SetInputFrameCount(&stream->bufferProcessor, available);
- // Register host buffer pointer to processor
+ // Register host buffer pointer to processor
PaUtil_SetInterleavedInputChannels(&stream->bufferProcessor, 0, wasapi_buffer, stream->bufferProcessor.inputChannelCount);
- // Copy user data to host buffer (with conversion if applicable)
- processed = PaUtil_CopyInput(&stream->bufferProcessor, (void **)&user_buffer, frames);
- frames -= processed;
+ // Copy user data to host buffer (with conversion if applicable)
+ processed = PaUtil_CopyInput(&stream->bufferProcessor, (void **)&user_buffer, frames);
+ frames -= processed;
- // Save tail into buffer
- if ((frames == 0) && (available > processed))
- {
- UINT32 bytes_processed = processed * stream->in.wavex.Format.nBlockAlign;
- UINT32 frames_to_save = available - processed;
+ // Save tail into buffer
+ if ((frames == 0) && (available > processed))
+ {
+ UINT32 bytes_processed = processed * stream->in.wavex.Format.nBlockAlign;
+ UINT32 frames_to_save = available - processed;
- PaUtil_WriteRingBuffer(stream->in.tailBuffer, wasapi_buffer + bytes_processed, frames_to_save);
- }
+ PaUtil_WriteRingBuffer(stream->in.tailBuffer, wasapi_buffer + bytes_processed, frames_to_save);
+ }
- // Release host buffer
- if ((hr = IAudioCaptureClient_ReleaseBuffer(stream->captureClient, available)) != S_OK)
- {
- LogHostError(hr);
- goto end;
- }
- }
+ // Release host buffer
+ if ((hr = IAudioCaptureClient_ReleaseBuffer(stream->captureClient, available)) != S_OK)
+ {
+ LogHostError(hr);
+ goto end;
+ }
+ }
end:
- // Notify blocking op has ended
- SetEvent(stream->hBlockingOpStreamRD);
+ // Notify blocking op has ended
+ SetEvent(stream->hBlockingOpStreamRD);
- return (hr != S_OK ? paUnanticipatedHostError : paNoError);
+ return (hr != S_OK ? paUnanticipatedHostError : paNoError);
}
// ------------------------------------------------------------------------------------------
@@ -4642,29 +4642,29 @@ static PaError WriteStream( PaStream* s, const void *_buffer, unsigned long fram
{
PaWasapiStream *stream = (PaWasapiStream*)s;
- //UINT32 frames;
- const BYTE *user_buffer = (const BYTE *)_buffer;
- BYTE *wasapi_buffer;
- HRESULT hr = S_OK;
- UINT32 i, available, sleep = 0;
- unsigned long processed;
- ThreadIdleScheduler sched;
+ //UINT32 frames;
+ const BYTE *user_buffer = (const BYTE *)_buffer;
+ BYTE *wasapi_buffer;
+ HRESULT hr = S_OK;
+ UINT32 i, available, sleep = 0;
+ unsigned long processed;
+ ThreadIdleScheduler sched;
- // validate
- if (!stream->running)
- return paStreamIsStopped;
- if (stream->renderClient == NULL)
- return paBadStreamPtr;
+ // validate
+ if (!stream->running)
+ return paStreamIsStopped;
+ if (stream->renderClient == NULL)
+ return paBadStreamPtr;
- // Notify blocking op has begun
- ResetEvent(stream->hBlockingOpStreamWR);
+ // Notify blocking op has begun
+ ResetEvent(stream->hBlockingOpStreamWR);
- // Use thread scheduling for 500 microseconds (emulated) when wait time for frames is less than
- // 1 milliseconds, emulation helps to normalize CPU consumption and avoids too busy waiting
- ThreadIdleScheduler_Setup(&sched, 1, 500/* microseconds */);
+ // Use thread scheduling for 500 microseconds (emulated) when wait time for frames is less than
+ // 1 milliseconds, emulation helps to normalize CPU consumption and avoids too busy waiting
+ ThreadIdleScheduler_Setup(&sched, 1, 500/* microseconds */);
// Make a local copy of the user buffer pointer(s), this is necessary
- // because PaUtil_CopyOutput() advances these pointers every time it is called
+ // because PaUtil_CopyOutput() advances these pointers every time it is called
if (!stream->bufferProcessor.userOutputIsInterleaved)
{
user_buffer = (const BYTE *)alloca(sizeof(const BYTE *) * stream->bufferProcessor.outputChannelCount);
@@ -4675,85 +4675,85 @@ static PaError WriteStream( PaStream* s, const void *_buffer, unsigned long fram
((const BYTE **)user_buffer)[i] = ((const BYTE **)_buffer)[i];
}
- // Blocking (potentially, untill 'frames' are consumed) loop
- while (frames != 0)
- {
- // Check if blocking call must be interrupted
- if (WaitForSingleObject(stream->hCloseRequest, sleep) != WAIT_TIMEOUT)
- break;
+ // Blocking (potentially, untill 'frames' are consumed) loop
+ while (frames != 0)
+ {
+ // Check if blocking call must be interrupted
+ if (WaitForSingleObject(stream->hCloseRequest, sleep) != WAIT_TIMEOUT)
+ break;
- // Get frames available
- if ((hr = _PollGetOutputFramesAvailable(stream, &available)) != S_OK)
- {
- LogHostError(hr);
- goto end;
- }
+ // Get frames available
+ if ((hr = _PollGetOutputFramesAvailable(stream, &available)) != S_OK)
+ {
+ LogHostError(hr);
+ goto end;
+ }
- // Wait for more frames to become available
- if (available == 0)
- {
- UINT32 sleep_frames = (frames < stream->out.framesPerHostCallback ? frames : stream->out.framesPerHostCallback);
+ // Wait for more frames to become available
+ if (available == 0)
+ {
+ UINT32 sleep_frames = (frames < stream->out.framesPerHostCallback ? frames : stream->out.framesPerHostCallback);
- sleep = GetFramesSleepTime(sleep_frames, stream->out.wavex.Format.nSamplesPerSec);
- sleep /= 2; // wait only for half of the buffer
+ sleep = GetFramesSleepTime(sleep_frames, stream->out.wavex.Format.nSamplesPerSec);
+ sleep /= 2; // wait only for half of the buffer
- // Avoid busy waiting, schedule next 1 millesecond wait
- if (sleep == 0)
- sleep = ThreadIdleScheduler_NextSleep(&sched);
+ // Avoid busy waiting, schedule next 1 millesecond wait
+ if (sleep == 0)
+ sleep = ThreadIdleScheduler_NextSleep(&sched);
- continue;
- }
+ continue;
+ }
- // Keep in 'frames' range
- if (available > frames)
- available = frames;
+ // Keep in 'frames' range
+ if (available > frames)
+ available = frames;
- // Get pointer to host buffer
- if ((hr = IAudioRenderClient_GetBuffer(stream->renderClient, available, &wasapi_buffer)) != S_OK)
- {
- // Buffer size is too big, waiting
- if (hr == AUDCLNT_E_BUFFER_TOO_LARGE)
- continue;
+ // Get pointer to host buffer
+ if ((hr = IAudioRenderClient_GetBuffer(stream->renderClient, available, &wasapi_buffer)) != S_OK)
+ {
+ // Buffer size is too big, waiting
+ if (hr == AUDCLNT_E_BUFFER_TOO_LARGE)
+ continue;
- LogHostError(hr);
- goto end;
- }
+ LogHostError(hr);
+ goto end;
+ }
- // Keep waiting again (on Vista it was noticed that WASAPI could SOMETIMES return NULL pointer
- // to buffer without returning AUDCLNT_E_BUFFER_TOO_LARGE instead)
- if (wasapi_buffer == NULL)
- continue;
+ // Keep waiting again (on Vista it was noticed that WASAPI could SOMETIMES return NULL pointer
+ // to buffer without returning AUDCLNT_E_BUFFER_TOO_LARGE instead)
+ if (wasapi_buffer == NULL)
+ continue;
- // Register available frames to processor
+ // Register available frames to processor
PaUtil_SetOutputFrameCount(&stream->bufferProcessor, available);
- // Register host buffer pointer to processor
- PaUtil_SetInterleavedOutputChannels(&stream->bufferProcessor, 0, wasapi_buffer, stream->bufferProcessor.outputChannelCount);
+ // Register host buffer pointer to processor
+ PaUtil_SetInterleavedOutputChannels(&stream->bufferProcessor, 0, wasapi_buffer, stream->bufferProcessor.outputChannelCount);
- // Copy user data to host buffer (with conversion if applicable), this call will advance
- // pointer 'user_buffer' to consumed portion of data
- processed = PaUtil_CopyOutput(&stream->bufferProcessor, (const void **)&user_buffer, frames);
- frames -= processed;
+ // Copy user data to host buffer (with conversion if applicable), this call will advance
+ // pointer 'user_buffer' to consumed portion of data
+ processed = PaUtil_CopyOutput(&stream->bufferProcessor, (const void **)&user_buffer, frames);
+ frames -= processed;
- // Release host buffer
- if ((hr = IAudioRenderClient_ReleaseBuffer(stream->renderClient, available, 0)) != S_OK)
- {
- LogHostError(hr);
- goto end;
- }
- }
+ // Release host buffer
+ if ((hr = IAudioRenderClient_ReleaseBuffer(stream->renderClient, available, 0)) != S_OK)
+ {
+ LogHostError(hr);
+ goto end;
+ }
+ }
end:
- // Notify blocking op has ended
- SetEvent(stream->hBlockingOpStreamWR);
+ // Notify blocking op has ended
+ SetEvent(stream->hBlockingOpStreamWR);
- return (hr != S_OK ? paUnanticipatedHostError : paNoError);
+ return (hr != S_OK ? paUnanticipatedHostError : paNoError);
}
unsigned long PaUtil_GetOutputFrameCount( PaUtilBufferProcessor* bp )
{
- return bp->hostOutputFrameCount[0];
+ return bp->hostOutputFrameCount[0];
}
// ------------------------------------------------------------------------------------------
@@ -4761,24 +4761,24 @@ static signed long GetStreamReadAvailable( PaStream* s )
{
PaWasapiStream *stream = (PaWasapiStream*)s;
- HRESULT hr;
- UINT32 available = 0;
+ HRESULT hr;
+ UINT32 available = 0;
- // validate
- if (!stream->running)
- return paStreamIsStopped;
- if (stream->captureClient == NULL)
- return paBadStreamPtr;
+ // validate
+ if (!stream->running)
+ return paStreamIsStopped;
+ if (stream->captureClient == NULL)
+ return paBadStreamPtr;
- // available in hardware buffer
- if ((hr = _PollGetInputFramesAvailable(stream, &available)) != S_OK)
- {
- LogHostError(hr);
- return paUnanticipatedHostError;
- }
+ // available in hardware buffer
+ if ((hr = _PollGetInputFramesAvailable(stream, &available)) != S_OK)
+ {
+ LogHostError(hr);
+ return paUnanticipatedHostError;
+ }
- // available in software tail buffer
- available += PaUtil_GetRingBufferReadAvailable(stream->in.tailBuffer);
+ // available in software tail buffer
+ available += PaUtil_GetRingBufferReadAvailable(stream->in.tailBuffer);
return available;
}
@@ -4787,22 +4787,22 @@ static signed long GetStreamReadAvailable( PaStream* s )
static signed long GetStreamWriteAvailable( PaStream* s )
{
PaWasapiStream *stream = (PaWasapiStream*)s;
- HRESULT hr;
- UINT32 available = 0;
+ HRESULT hr;
+ UINT32 available = 0;
- // validate
- if (!stream->running)
- return paStreamIsStopped;
- if (stream->renderClient == NULL)
- return paBadStreamPtr;
+ // validate
+ if (!stream->running)
+ return paStreamIsStopped;
+ if (stream->renderClient == NULL)
+ return paBadStreamPtr;
- if ((hr = _PollGetOutputFramesAvailable(stream, &available)) != S_OK)
- {
- LogHostError(hr);
- return paUnanticipatedHostError;
- }
+ if ((hr = _PollGetOutputFramesAvailable(stream, &available)) != S_OK)
+ {
+ LogHostError(hr);
+ return paUnanticipatedHostError;
+ }
- return (signed long)available;
+ return (signed long)available;
}
@@ -4813,42 +4813,42 @@ static void WaspiHostProcessingLoop( void *inputBuffer, long inputFrames,
{
PaWasapiStream *stream = (PaWasapiStream*)userData;
PaStreamCallbackTimeInfo timeInfo = {0,0,0};
- PaStreamCallbackFlags flags = 0;
+ PaStreamCallbackFlags flags = 0;
int callbackResult;
unsigned long framesProcessed;
- HRESULT hr;
- UINT32 pending;
+ HRESULT hr;
+ UINT32 pending;
PaUtil_BeginCpuLoadMeasurement( &stream->cpuLoadMeasurer );
/*
- Pa_GetStreamTime:
+ Pa_GetStreamTime:
- generate timing information
- handle buffer slips
*/
- timeInfo.currentTime = PaUtil_GetTime();
- // Query input latency
- if (stream->in.clientProc != NULL)
- {
- PaTime pending_time;
- if ((hr = IAudioClient_GetCurrentPadding(stream->in.clientProc, &pending)) == S_OK)
- pending_time = (PaTime)pending / (PaTime)stream->in.wavex.Format.nSamplesPerSec;
- else
- pending_time = (PaTime)stream->in.latencySeconds;
+ timeInfo.currentTime = PaUtil_GetTime();
+ // Query input latency
+ if (stream->in.clientProc != NULL)
+ {
+ PaTime pending_time;
+ if ((hr = IAudioClient_GetCurrentPadding(stream->in.clientProc, &pending)) == S_OK)
+ pending_time = (PaTime)pending / (PaTime)stream->in.wavex.Format.nSamplesPerSec;
+ else
+ pending_time = (PaTime)stream->in.latencySeconds;
- timeInfo.inputBufferAdcTime = timeInfo.currentTime + pending_time;
- }
- // Query output current latency
- if (stream->out.clientProc != NULL)
- {
- PaTime pending_time;
- if ((hr = IAudioClient_GetCurrentPadding(stream->out.clientProc, &pending)) == S_OK)
- pending_time = (PaTime)pending / (PaTime)stream->out.wavex.Format.nSamplesPerSec;
- else
- pending_time = (PaTime)stream->out.latencySeconds;
+ timeInfo.inputBufferAdcTime = timeInfo.currentTime + pending_time;
+ }
+ // Query output current latency
+ if (stream->out.clientProc != NULL)
+ {
+ PaTime pending_time;
+ if ((hr = IAudioClient_GetCurrentPadding(stream->out.clientProc, &pending)) == S_OK)
+ pending_time = (PaTime)pending / (PaTime)stream->out.wavex.Format.nSamplesPerSec;
+ else
+ pending_time = (PaTime)stream->out.latencySeconds;
- timeInfo.outputBufferDacTime = timeInfo.currentTime + pending_time;
- }
+ timeInfo.outputBufferDacTime = timeInfo.currentTime + pending_time;
+ }
/*
If you need to byte swap or shift inputBuffer to convert it into a
@@ -4895,21 +4895,21 @@ static void WaspiHostProcessingLoop( void *inputBuffer, long inputFrames,
host format, do it here.
*/
- PaUtil_EndCpuLoadMeasurement( &stream->cpuLoadMeasurer, framesProcessed );
+ PaUtil_EndCpuLoadMeasurement( &stream->cpuLoadMeasurer, framesProcessed );
if (callbackResult == paContinue)
{
/* nothing special to do */
}
else
- if (callbackResult == paAbort)
+ if (callbackResult == paAbort)
{
- // stop stream
+ // stop stream
SetEvent(stream->hCloseRequest);
}
else
{
- // stop stream
+ // stop stream
SetEvent(stream->hCloseRequest);
}
}
@@ -4918,45 +4918,45 @@ static void WaspiHostProcessingLoop( void *inputBuffer, long inputFrames,
#ifndef PA_WINRT
static PaError MMCSS_activate(PaWasapiThreadPriority nPriorityClass, HANDLE *ret)
{
- static const char *mmcs_name[] =
- {
- NULL,
- "Audio",
- "Capture",
- "Distribution",
- "Games",
- "Playback",
- "Pro Audio",
- "Window Manager"
- };
+ static const char *mmcs_name[] =
+ {
+ NULL,
+ "Audio",
+ "Capture",
+ "Distribution",
+ "Games",
+ "Playback",
+ "Pro Audio",
+ "Window Manager"
+ };
DWORD task_idx = 0;
HANDLE hTask;
-
- if ((UINT32)nPriorityClass >= STATIC_ARRAY_SIZE(mmcs_name))
- return paUnanticipatedHostError;
-
+
+ if ((UINT32)nPriorityClass >= STATIC_ARRAY_SIZE(mmcs_name))
+ return paUnanticipatedHostError;
+
if ((hTask = pAvSetMmThreadCharacteristics(mmcs_name[nPriorityClass], &task_idx)) == NULL)
- {
+ {
PRINT(("WASAPI: AvSetMmThreadCharacteristics failed: error[%d]\n", GetLastError()));
- return paUnanticipatedHostError;
+ return paUnanticipatedHostError;
}
/*BOOL priority_ok = pAvSetMmThreadPriority(hTask, AVRT_PRIORITY_NORMAL);
if (priority_ok == FALSE)
- {
+ {
PRINT(("WASAPI: AvSetMmThreadPriority failed!\n"));
}*/
- // debug
+ // debug
{
- int cur_priority = GetThreadPriority(GetCurrentThread());
+ int cur_priority = GetThreadPriority(GetCurrentThread());
DWORD cur_priority_class = GetPriorityClass(GetCurrentProcess());
- PRINT(("WASAPI: thread[ priority-0x%X class-0x%X ]\n", cur_priority, cur_priority_class));
+ PRINT(("WASAPI: thread[ priority-0x%X class-0x%X ]\n", cur_priority, cur_priority_class));
}
- (*ret) = hTask;
- return paNoError;
+ (*ret) = hTask;
+ return paNoError;
}
#endif
@@ -4964,8 +4964,8 @@ static PaError MMCSS_activate(PaWasapiThreadPriority nPriorityClass, HANDLE *ret
#ifndef PA_WINRT
static void MMCSS_deactivate(HANDLE hTask)
{
- if (pAvRevertMmThreadCharacteristics(hTask) == FALSE)
- {
+ if (pAvRevertMmThreadCharacteristics(hTask) == FALSE)
+ {
PRINT(("WASAPI: AvRevertMmThreadCharacteristics failed!\n"));
}
}
@@ -4974,59 +4974,59 @@ static void MMCSS_deactivate(HANDLE hTask)
// ------------------------------------------------------------------------------------------
PaError PaWasapi_ThreadPriorityBoost(void **pTask, PaWasapiThreadPriority priorityClass)
{
- HANDLE task;
- PaError ret;
+ HANDLE task;
+ PaError ret;
- if (pTask == NULL)
- return paUnanticipatedHostError;
+ if (pTask == NULL)
+ return paUnanticipatedHostError;
#ifndef PA_WINRT
- if ((ret = MMCSS_activate(priorityClass, &task)) != paNoError)
- return ret;
+ if ((ret = MMCSS_activate(priorityClass, &task)) != paNoError)
+ return ret;
#else
- switch (priorityClass)
- {
- case eThreadPriorityAudio:
- case eThreadPriorityProAudio: {
+ switch (priorityClass)
+ {
+ case eThreadPriorityAudio:
+ case eThreadPriorityProAudio: {
- // Save previous thread priority
- intptr_t priority_prev = GetThreadPriority(GetCurrentThread());
+ // Save previous thread priority
+ intptr_t priority_prev = GetThreadPriority(GetCurrentThread());
- // Try set new thread priority
- if (SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) == FALSE)
- return paUnanticipatedHostError;
+ // Try set new thread priority
+ if (SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) == FALSE)
+ return paUnanticipatedHostError;
- // Memorize prev priority (pretend to be non NULL pointer by adding 0x80000000 mask)
- task = (HANDLE)(priority_prev | 0x80000000);
+ // Memorize prev priority (pretend to be non NULL pointer by adding 0x80000000 mask)
+ task = (HANDLE)(priority_prev | 0x80000000);
- ret = paNoError;
+ ret = paNoError;
- break; }
+ break; }
- default:
- return paUnanticipatedHostError;
- }
+ default:
+ return paUnanticipatedHostError;
+ }
#endif
- (*pTask) = task;
- return ret;
+ (*pTask) = task;
+ return ret;
}
// ------------------------------------------------------------------------------------------
PaError PaWasapi_ThreadPriorityRevert(void *pTask)
{
- if (pTask == NULL)
- return paUnanticipatedHostError;
+ if (pTask == NULL)
+ return paUnanticipatedHostError;
#ifndef PA_WINRT
- MMCSS_deactivate((HANDLE)pTask);
+ MMCSS_deactivate((HANDLE)pTask);
#else
- // Revert previous priority by removing 0x80000000 mask
- if (SetThreadPriority(GetCurrentThread(), (int)((intptr_t)pTask & ~0x80000000)) == FALSE)
- return paUnanticipatedHostError;
+ // Revert previous priority by removing 0x80000000 mask
+ if (SetThreadPriority(GetCurrentThread(), (int)((intptr_t)pTask & ~0x80000000)) == FALSE)
+ return paUnanticipatedHostError;
#endif
- return paNoError;
+ return paNoError;
}
// ------------------------------------------------------------------------------------------
@@ -5036,82 +5036,82 @@ PaError PaWasapi_ThreadPriorityRevert(void *pTask)
PaError PaWasapi_GetJackCount(PaDeviceIndex device, int *pJackCount)
{
#ifndef PA_WINRT
- PaError ret;
- HRESULT hr = S_OK;
- PaDeviceIndex index;
+ PaError ret;
+ HRESULT hr = S_OK;
+ PaDeviceIndex index;
IDeviceTopology *pDeviceTopology = NULL;
IConnector *pConnFrom = NULL;
IConnector *pConnTo = NULL;
IPart *pPart = NULL;
IKsJackDescription *pJackDesc = NULL;
- UINT jackCount = 0;
+ UINT jackCount = 0;
- PaWasapiHostApiRepresentation *paWasapi = _GetHostApi(&ret);
- if (paWasapi == NULL)
- return paNotInitialized;
+ PaWasapiHostApiRepresentation *paWasapi = _GetHostApi(&ret);
+ if (paWasapi == NULL)
+ return paNotInitialized;
- if (pJackCount == NULL)
- return paUnanticipatedHostError;
+ if (pJackCount == NULL)
+ return paUnanticipatedHostError;
- // Get device index
- ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
+ // Get device index
+ ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
if (ret != paNoError)
return ret;
- // Validate index
- if ((UINT32)index >= paWasapi->deviceCount)
- return paInvalidDevice;
+ // Validate index
+ if ((UINT32)index >= paWasapi->deviceCount)
+ return paInvalidDevice;
- // Get the endpoint device's IDeviceTopology interface
- hr = IMMDevice_Activate(paWasapi->devInfo[index].device, &pa_IID_IDeviceTopology,
- CLSCTX_INPROC_SERVER, NULL, (void**)&pDeviceTopology);
- IF_FAILED_JUMP(hr, error);
+ // Get the endpoint device's IDeviceTopology interface
+ hr = IMMDevice_Activate(paWasapi->devInfo[index].device, &pa_IID_IDeviceTopology,
+ CLSCTX_INPROC_SERVER, NULL, (void**)&pDeviceTopology);
+ IF_FAILED_JUMP(hr, error);
// The device topology for an endpoint device always contains just one connector (connector number 0)
- hr = IDeviceTopology_GetConnector(pDeviceTopology, 0, &pConnFrom);
- IF_FAILED_JUMP(hr, error);
+ hr = IDeviceTopology_GetConnector(pDeviceTopology, 0, &pConnFrom);
+ IF_FAILED_JUMP(hr, error);
// Step across the connection to the jack on the adapter
- hr = IConnector_GetConnectedTo(pConnFrom, &pConnTo);
+ hr = IConnector_GetConnectedTo(pConnFrom, &pConnTo);
if (HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr)
{
// The adapter device is not currently active
hr = E_NOINTERFACE;
}
- IF_FAILED_JUMP(hr, error);
+ IF_FAILED_JUMP(hr, error);
- // Get the connector's IPart interface
- hr = IConnector_QueryInterface(pConnTo, &pa_IID_IPart, (void**)&pPart);
- IF_FAILED_JUMP(hr, error);
+ // Get the connector's IPart interface
+ hr = IConnector_QueryInterface(pConnTo, &pa_IID_IPart, (void**)&pPart);
+ IF_FAILED_JUMP(hr, error);
- // Activate the connector's IKsJackDescription interface
- hr = IPart_Activate(pPart, CLSCTX_INPROC_SERVER, &pa_IID_IKsJackDescription, (void**)&pJackDesc);
- IF_FAILED_JUMP(hr, error);
+ // Activate the connector's IKsJackDescription interface
+ hr = IPart_Activate(pPart, CLSCTX_INPROC_SERVER, &pa_IID_IKsJackDescription, (void**)&pJackDesc);
+ IF_FAILED_JUMP(hr, error);
- // Return jack count for this device
- hr = IKsJackDescription_GetJackCount(pJackDesc, &jackCount);
- IF_FAILED_JUMP(hr, error);
+ // Return jack count for this device
+ hr = IKsJackDescription_GetJackCount(pJackDesc, &jackCount);
+ IF_FAILED_JUMP(hr, error);
- // Set.
- (*pJackCount) = jackCount;
+ // Set.
+ (*pJackCount) = jackCount;
- // Ok.
- ret = paNoError;
+ // Ok.
+ ret = paNoError;
error:
- SAFE_RELEASE(pDeviceTopology);
- SAFE_RELEASE(pConnFrom);
- SAFE_RELEASE(pConnTo);
- SAFE_RELEASE(pPart);
- SAFE_RELEASE(pJackDesc);
+ SAFE_RELEASE(pDeviceTopology);
+ SAFE_RELEASE(pConnFrom);
+ SAFE_RELEASE(pConnTo);
+ SAFE_RELEASE(pPart);
+ SAFE_RELEASE(pJackDesc);
- LogHostError(hr);
- return paNoError;
+ LogHostError(hr);
+ return paNoError;
#else
- (void)device;
- (void)pJackCount;
- return paUnanticipatedHostError;
+ (void)device;
+ (void)pJackCount;
+ return paUnanticipatedHostError;
#endif
}
@@ -5119,26 +5119,26 @@ error:
#ifndef PA_WINRT
static PaWasapiJackConnectionType _ConvertJackConnectionTypeWASAPIToPA(int connType)
{
- switch (connType)
- {
- case eConnTypeUnknown: return eJackConnTypeUnknown;
+ switch (connType)
+ {
+ case eConnTypeUnknown: return eJackConnTypeUnknown;
#ifdef _KS_
- case eConnType3Point5mm: return eJackConnType3Point5mm;
+ case eConnType3Point5mm: return eJackConnType3Point5mm;
#else
- case eConnTypeEighth: return eJackConnType3Point5mm;
+ case eConnTypeEighth: return eJackConnType3Point5mm;
#endif
- case eConnTypeQuarter: return eJackConnTypeQuarter;
- case eConnTypeAtapiInternal: return eJackConnTypeAtapiInternal;
- case eConnTypeRCA: return eJackConnTypeRCA;
- case eConnTypeOptical: return eJackConnTypeOptical;
- case eConnTypeOtherDigital: return eJackConnTypeOtherDigital;
- case eConnTypeOtherAnalog: return eJackConnTypeOtherAnalog;
- case eConnTypeMultichannelAnalogDIN: return eJackConnTypeMultichannelAnalogDIN;
- case eConnTypeXlrProfessional: return eJackConnTypeXlrProfessional;
- case eConnTypeRJ11Modem: return eJackConnTypeRJ11Modem;
- case eConnTypeCombination: return eJackConnTypeCombination;
- }
- return eJackConnTypeUnknown;
+ case eConnTypeQuarter: return eJackConnTypeQuarter;
+ case eConnTypeAtapiInternal: return eJackConnTypeAtapiInternal;
+ case eConnTypeRCA: return eJackConnTypeRCA;
+ case eConnTypeOptical: return eJackConnTypeOptical;
+ case eConnTypeOtherDigital: return eJackConnTypeOtherDigital;
+ case eConnTypeOtherAnalog: return eJackConnTypeOtherAnalog;
+ case eConnTypeMultichannelAnalogDIN: return eJackConnTypeMultichannelAnalogDIN;
+ case eConnTypeXlrProfessional: return eJackConnTypeXlrProfessional;
+ case eConnTypeRJ11Modem: return eJackConnTypeRJ11Modem;
+ case eConnTypeCombination: return eJackConnTypeCombination;
+ }
+ return eJackConnTypeUnknown;
}
#endif
@@ -5146,27 +5146,27 @@ static PaWasapiJackConnectionType _ConvertJackConnectionTypeWASAPIToPA(int connT
#ifndef PA_WINRT
static PaWasapiJackGeoLocation _ConvertJackGeoLocationWASAPIToPA(int geoLoc)
{
- switch (geoLoc)
- {
- case eGeoLocRear: return eJackGeoLocRear;
- case eGeoLocFront: return eJackGeoLocFront;
- case eGeoLocLeft: return eJackGeoLocLeft;
- case eGeoLocRight: return eJackGeoLocRight;
- case eGeoLocTop: return eJackGeoLocTop;
- case eGeoLocBottom: return eJackGeoLocBottom;
+ switch (geoLoc)
+ {
+ case eGeoLocRear: return eJackGeoLocRear;
+ case eGeoLocFront: return eJackGeoLocFront;
+ case eGeoLocLeft: return eJackGeoLocLeft;
+ case eGeoLocRight: return eJackGeoLocRight;
+ case eGeoLocTop: return eJackGeoLocTop;
+ case eGeoLocBottom: return eJackGeoLocBottom;
#ifdef _KS_
- case eGeoLocRearPanel: return eJackGeoLocRearPanel;
+ case eGeoLocRearPanel: return eJackGeoLocRearPanel;
#else
- case eGeoLocRearOPanel: return eJackGeoLocRearPanel;
+ case eGeoLocRearOPanel: return eJackGeoLocRearPanel;
#endif
- case eGeoLocRiser: return eJackGeoLocRiser;
- case eGeoLocInsideMobileLid: return eJackGeoLocInsideMobileLid;
- case eGeoLocDrivebay: return eJackGeoLocDrivebay;
- case eGeoLocHDMI: return eJackGeoLocHDMI;
- case eGeoLocOutsideMobileLid: return eJackGeoLocOutsideMobileLid;
- case eGeoLocATAPI: return eJackGeoLocATAPI;
- }
- return eJackGeoLocUnk;
+ case eGeoLocRiser: return eJackGeoLocRiser;
+ case eGeoLocInsideMobileLid: return eJackGeoLocInsideMobileLid;
+ case eGeoLocDrivebay: return eJackGeoLocDrivebay;
+ case eGeoLocHDMI: return eJackGeoLocHDMI;
+ case eGeoLocOutsideMobileLid: return eJackGeoLocOutsideMobileLid;
+ case eGeoLocATAPI: return eJackGeoLocATAPI;
+ }
+ return eJackGeoLocUnk;
}
#endif
@@ -5174,18 +5174,18 @@ static PaWasapiJackGeoLocation _ConvertJackGeoLocationWASAPIToPA(int geoLoc)
#ifndef PA_WINRT
static PaWasapiJackGenLocation _ConvertJackGenLocationWASAPIToPA(int genLoc)
{
- switch (genLoc)
- {
- case eGenLocPrimaryBox: return eJackGenLocPrimaryBox;
- case eGenLocInternal: return eJackGenLocInternal;
+ switch (genLoc)
+ {
+ case eGenLocPrimaryBox: return eJackGenLocPrimaryBox;
+ case eGenLocInternal: return eJackGenLocInternal;
#ifdef _KS_
- case eGenLocSeparate: return eJackGenLocSeparate;
+ case eGenLocSeparate: return eJackGenLocSeparate;
#else
- case eGenLocSeperate: return eJackGenLocSeparate;
+ case eGenLocSeperate: return eJackGenLocSeparate;
#endif
- case eGenLocOther: return eJackGenLocOther;
- }
- return eJackGenLocPrimaryBox;
+ case eGenLocOther: return eJackGenLocOther;
+ }
+ return eJackGenLocPrimaryBox;
}
#endif
@@ -5193,14 +5193,14 @@ static PaWasapiJackGenLocation _ConvertJackGenLocationWASAPIToPA(int genLoc)
#ifndef PA_WINRT
static PaWasapiJackPortConnection _ConvertJackPortConnectionWASAPIToPA(int portConn)
{
- switch (portConn)
- {
- case ePortConnJack: return eJackPortConnJack;
- case ePortConnIntegratedDevice: return eJackPortConnIntegratedDevice;
- case ePortConnBothIntegratedAndJack:return eJackPortConnBothIntegratedAndJack;
- case ePortConnUnknown: return eJackPortConnUnknown;
- }
- return eJackPortConnJack;
+ switch (portConn)
+ {
+ case ePortConnJack: return eJackPortConnJack;
+ case ePortConnIntegratedDevice: return eJackPortConnIntegratedDevice;
+ case ePortConnBothIntegratedAndJack: return eJackPortConnBothIntegratedAndJack;
+ case ePortConnUnknown: return eJackPortConnUnknown;
+ }
+ return eJackPortConnJack;
}
#endif
@@ -5211,378 +5211,378 @@ static PaWasapiJackPortConnection _ConvertJackPortConnectionWASAPIToPA(int portC
PaError PaWasapi_GetJackDescription(PaDeviceIndex device, int jackIndex, PaWasapiJackDescription *pJackDescription)
{
#ifndef PA_WINRT
- PaError ret;
- HRESULT hr = S_OK;
- PaDeviceIndex index;
+ PaError ret;
+ HRESULT hr = S_OK;
+ PaDeviceIndex index;
IDeviceTopology *pDeviceTopology = NULL;
IConnector *pConnFrom = NULL;
IConnector *pConnTo = NULL;
IPart *pPart = NULL;
IKsJackDescription *pJackDesc = NULL;
- KSJACK_DESCRIPTION jack = { 0 };
+ KSJACK_DESCRIPTION jack = { 0 };
- PaWasapiHostApiRepresentation *paWasapi = _GetHostApi(&ret);
- if (paWasapi == NULL)
- return paNotInitialized;
+ PaWasapiHostApiRepresentation *paWasapi = _GetHostApi(&ret);
+ if (paWasapi == NULL)
+ return paNotInitialized;
- // Get device index
- ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
+ // Get device index
+ ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, device, &paWasapi->inheritedHostApiRep);
if (ret != paNoError)
return ret;
- // Validate index
- if ((UINT32)index >= paWasapi->deviceCount)
- return paInvalidDevice;
+ // Validate index
+ if ((UINT32)index >= paWasapi->deviceCount)
+ return paInvalidDevice;
- // Get the endpoint device's IDeviceTopology interface
- hr = IMMDevice_Activate(paWasapi->devInfo[index].device, &pa_IID_IDeviceTopology,
- CLSCTX_INPROC_SERVER, NULL, (void**)&pDeviceTopology);
- IF_FAILED_JUMP(hr, error);
+ // Get the endpoint device's IDeviceTopology interface
+ hr = IMMDevice_Activate(paWasapi->devInfo[index].device, &pa_IID_IDeviceTopology,
+ CLSCTX_INPROC_SERVER, NULL, (void**)&pDeviceTopology);
+ IF_FAILED_JUMP(hr, error);
// The device topology for an endpoint device always contains just one connector (connector number 0)
- hr = IDeviceTopology_GetConnector(pDeviceTopology, 0, &pConnFrom);
- IF_FAILED_JUMP(hr, error);
+ hr = IDeviceTopology_GetConnector(pDeviceTopology, 0, &pConnFrom);
+ IF_FAILED_JUMP(hr, error);
// Step across the connection to the jack on the adapter
- hr = IConnector_GetConnectedTo(pConnFrom, &pConnTo);
+ hr = IConnector_GetConnectedTo(pConnFrom, &pConnTo);
if (HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr)
{
// The adapter device is not currently active
hr = E_NOINTERFACE;
}
- IF_FAILED_JUMP(hr, error);
+ IF_FAILED_JUMP(hr, error);
- // Get the connector's IPart interface
- hr = IConnector_QueryInterface(pConnTo, &pa_IID_IPart, (void**)&pPart);
- IF_FAILED_JUMP(hr, error);
+ // Get the connector's IPart interface
+ hr = IConnector_QueryInterface(pConnTo, &pa_IID_IPart, (void**)&pPart);
+ IF_FAILED_JUMP(hr, error);
- // Activate the connector's IKsJackDescription interface
- hr = IPart_Activate(pPart, CLSCTX_INPROC_SERVER, &pa_IID_IKsJackDescription, (void**)&pJackDesc);
- IF_FAILED_JUMP(hr, error);
+ // Activate the connector's IKsJackDescription interface
+ hr = IPart_Activate(pPart, CLSCTX_INPROC_SERVER, &pa_IID_IKsJackDescription, (void**)&pJackDesc);
+ IF_FAILED_JUMP(hr, error);
- // Test to return jack description struct for index 0
- hr = IKsJackDescription_GetJackDescription(pJackDesc, jackIndex, &jack);
- IF_FAILED_JUMP(hr, error);
+ // Test to return jack description struct for index 0
+ hr = IKsJackDescription_GetJackDescription(pJackDesc, jackIndex, &jack);
+ IF_FAILED_JUMP(hr, error);
- // Convert WASAPI values to PA format
- pJackDescription->channelMapping = jack.ChannelMapping;
- pJackDescription->color = jack.Color;
- pJackDescription->connectionType = _ConvertJackConnectionTypeWASAPIToPA(jack.ConnectionType);
- pJackDescription->genLocation = _ConvertJackGenLocationWASAPIToPA(jack.GenLocation);
- pJackDescription->geoLocation = _ConvertJackGeoLocationWASAPIToPA(jack.GeoLocation);
- pJackDescription->isConnected = jack.IsConnected;
- pJackDescription->portConnection = _ConvertJackPortConnectionWASAPIToPA(jack.PortConnection);
+ // Convert WASAPI values to PA format
+ pJackDescription->channelMapping = jack.ChannelMapping;
+ pJackDescription->color = jack.Color;
+ pJackDescription->connectionType = _ConvertJackConnectionTypeWASAPIToPA(jack.ConnectionType);
+ pJackDescription->genLocation = _ConvertJackGenLocationWASAPIToPA(jack.GenLocation);
+ pJackDescription->geoLocation = _ConvertJackGeoLocationWASAPIToPA(jack.GeoLocation);
+ pJackDescription->isConnected = jack.IsConnected;
+ pJackDescription->portConnection = _ConvertJackPortConnectionWASAPIToPA(jack.PortConnection);
- // Ok
- ret = paNoError;
+ // Ok
+ ret = paNoError;
error:
- SAFE_RELEASE(pDeviceTopology);
- SAFE_RELEASE(pConnFrom);
- SAFE_RELEASE(pConnTo);
- SAFE_RELEASE(pPart);
- SAFE_RELEASE(pJackDesc);
+ SAFE_RELEASE(pDeviceTopology);
+ SAFE_RELEASE(pConnFrom);
+ SAFE_RELEASE(pConnTo);
+ SAFE_RELEASE(pPart);
+ SAFE_RELEASE(pJackDesc);
- LogHostError(hr);
- return ret;
+ LogHostError(hr);
+ return ret;
#else
- (void)device;
- (void)jackIndex;
- (void)pJackDescription;
- return paUnanticipatedHostError;
+ (void)device;
+ (void)jackIndex;
+ (void)pJackDescription;
+ return paUnanticipatedHostError;
#endif
}
// ------------------------------------------------------------------------------------------
PaError PaWasapi_GetAudioClient(PaStream *pStream, void **pAudioClient, int bOutput)
{
- PaWasapiStream *stream = (PaWasapiStream *)pStream;
- if (stream == NULL)
- return paBadStreamPtr;
+ PaWasapiStream *stream = (PaWasapiStream *)pStream;
+ if (stream == NULL)
+ return paBadStreamPtr;
- if (pAudioClient == NULL)
- return paUnanticipatedHostError;
+ if (pAudioClient == NULL)
+ return paUnanticipatedHostError;
- (*pAudioClient) = (bOutput == TRUE ? stream->out.clientParent : stream->in.clientParent);
+ (*pAudioClient) = (bOutput == TRUE ? stream->out.clientParent : stream->in.clientParent);
- return paNoError;
+ return paNoError;
}
// ------------------------------------------------------------------------------------------
PaError PaWasapi_SetDefaultInterfaceId( unsigned short *pId, int bOutput )
{
#ifdef PA_WINRT
- int i;
+ int i;
- // Validate Id length
- if (pId != NULL)
- {
- for (i = 0; pId[i] != 0; ++i)
- {
- if (i >= PA_WASAPI_DEVICE_ID_LEN)
- return paBufferTooBig;
- }
- }
+ // Validate Id length
+ if (pId != NULL)
+ {
+ for (i = 0; pId[i] != 0; ++i)
+ {
+ if (i >= PA_WASAPI_DEVICE_ID_LEN)
+ return paBufferTooBig;
+ }
+ }
- // Set Id (or reset to all 0 if NULL is provided)
- if (bOutput)
- {
- memset(g_DefaultRenderId, 0, sizeof(g_DefaultRenderId));
- if (pId != NULL)
- {
- for (i = 0; (pId[i] != 0) && (i < STATIC_ARRAY_SIZE(g_DefaultRenderId)); ++i)
- g_DefaultRenderId[i] = pId[i];
- }
- }
- else
- {
- memset(g_DefaultCaptureId, 0, sizeof(g_DefaultCaptureId));
- if (pId != NULL)
- {
- for (i = 0; (pId[i] != 0) && (i < STATIC_ARRAY_SIZE(g_DefaultCaptureId)); ++i)
- g_DefaultCaptureId[i] = pId[i];
- }
- }
+ // Set Id (or reset to all 0 if NULL is provided)
+ if (bOutput)
+ {
+ memset(g_DefaultRenderId, 0, sizeof(g_DefaultRenderId));
+ if (pId != NULL)
+ {
+ for (i = 0; (pId[i] != 0) && (i < STATIC_ARRAY_SIZE(g_DefaultRenderId)); ++i)
+ g_DefaultRenderId[i] = pId[i];
+ }
+ }
+ else
+ {
+ memset(g_DefaultCaptureId, 0, sizeof(g_DefaultCaptureId));
+ if (pId != NULL)
+ {
+ for (i = 0; (pId[i] != 0) && (i < STATIC_ARRAY_SIZE(g_DefaultCaptureId)); ++i)
+ g_DefaultCaptureId[i] = pId[i];
+ }
+ }
- return paNoError;
+ return paNoError;
#else
- return paIncompatibleStreamHostApi;
+ return paIncompatibleStreamHostApi;
#endif
}
// ------------------------------------------------------------------------------------------
PaError PaWasapi_SetStreamStateHandler( PaStream *pStream, PaWasapiStreamStateCallback fnStateHandler, void *pUserData )
{
- PaWasapiStream *stream = (PaWasapiStream *)pStream;
- if (stream == NULL)
- return paBadStreamPtr;
+ PaWasapiStream *stream = (PaWasapiStream *)pStream;
+ if (stream == NULL)
+ return paBadStreamPtr;
- stream->fnStateHandler = fnStateHandler;
- stream->pStateHandlerUserData = pUserData;
+ stream->fnStateHandler = fnStateHandler;
+ stream->pStateHandlerUserData = pUserData;
- return paNoError;
+ return paNoError;
}
// ------------------------------------------------------------------------------------------
HRESULT _PollGetOutputFramesAvailable(PaWasapiStream *stream, UINT32 *available)
{
- HRESULT hr;
- UINT32 frames = stream->out.framesPerHostCallback,
- padding = 0;
+ HRESULT hr;
+ UINT32 frames = stream->out.framesPerHostCallback,
+ padding = 0;
- (*available) = 0;
+ (*available) = 0;
- // get read position
- if ((hr = IAudioClient_GetCurrentPadding(stream->out.clientProc, &padding)) != S_OK)
- return LogHostError(hr);
+ // get read position
+ if ((hr = IAudioClient_GetCurrentPadding(stream->out.clientProc, &padding)) != S_OK)
+ return LogHostError(hr);
- // get available
- frames -= padding;
+ // get available
+ frames -= padding;
- // set
- (*available) = frames;
- return hr;
+ // set
+ (*available) = frames;
+ return hr;
}
// ------------------------------------------------------------------------------------------
HRESULT _PollGetInputFramesAvailable(PaWasapiStream *stream, UINT32 *available)
{
- HRESULT hr;
+ HRESULT hr;
- (*available) = 0;
+ (*available) = 0;
- // GetCurrentPadding() has opposite meaning to Output stream
- if ((hr = IAudioClient_GetCurrentPadding(stream->in.clientProc, available)) != S_OK)
- return LogHostError(hr);
+ // GetCurrentPadding() has opposite meaning to Output stream
+ if ((hr = IAudioClient_GetCurrentPadding(stream->in.clientProc, available)) != S_OK)
+ return LogHostError(hr);
- return hr;
+ return hr;
}
// ------------------------------------------------------------------------------------------
static HRESULT ProcessOutputBuffer(PaWasapiStream *stream, PaWasapiHostProcessor *processor, UINT32 frames)
{
- HRESULT hr;
- BYTE *data = NULL;
+ HRESULT hr;
+ BYTE *data = NULL;
- // Get buffer
- if ((hr = IAudioRenderClient_GetBuffer(stream->renderClient, frames, &data)) != S_OK)
- {
- // Both modes, Shared and Exclusive, can fail with AUDCLNT_E_BUFFER_TOO_LARGE error
- #if 0
- if (stream->out.shareMode == AUDCLNT_SHAREMODE_SHARED)
- {
- // Using GetCurrentPadding to overcome AUDCLNT_E_BUFFER_TOO_LARGE in
- // shared mode results in no sound in Event-driven mode (MSDN does not
- // document this, or is it WASAPI bug?), thus we better
- // try to acquire buffer next time when GetBuffer allows to do so.
- #if 0
- // Get Read position
- UINT32 padding = 0;
- hr = IAudioClient_GetCurrentPadding(stream->out.clientProc, &padding);
- if (hr != S_OK)
- return LogHostError(hr);
+ // Get buffer
+ if ((hr = IAudioRenderClient_GetBuffer(stream->renderClient, frames, &data)) != S_OK)
+ {
+ // Both modes, Shared and Exclusive, can fail with AUDCLNT_E_BUFFER_TOO_LARGE error
+ #if 0
+ if (stream->out.shareMode == AUDCLNT_SHAREMODE_SHARED)
+ {
+ // Using GetCurrentPadding to overcome AUDCLNT_E_BUFFER_TOO_LARGE in
+ // shared mode results in no sound in Event-driven mode (MSDN does not
+ // document this, or is it WASAPI bug?), thus we better
+ // try to acquire buffer next time when GetBuffer allows to do so.
+ #if 0
+ // Get Read position
+ UINT32 padding = 0;
+ hr = IAudioClient_GetCurrentPadding(stream->out.clientProc, &padding);
+ if (hr != S_OK)
+ return LogHostError(hr);
- // Get frames to write
- frames -= padding;
- if (frames == 0)
- return S_OK;
+ // Get frames to write
+ frames -= padding;
+ if (frames == 0)
+ return S_OK;
- if ((hr = IAudioRenderClient_GetBuffer(stream->renderClient, frames, &data)) != S_OK)
- return LogHostError(hr);
- #else
- if (hr == AUDCLNT_E_BUFFER_TOO_LARGE)
- return S_OK; // be silent in shared mode, try again next time
- #endif
- }
- else
- return LogHostError(hr);
- #else
- if (hr == AUDCLNT_E_BUFFER_TOO_LARGE)
- return S_OK; // try again next time
+ if ((hr = IAudioRenderClient_GetBuffer(stream->renderClient, frames, &data)) != S_OK)
+ return LogHostError(hr);
+ #else
+ if (hr == AUDCLNT_E_BUFFER_TOO_LARGE)
+ return S_OK; // be silent in shared mode, try again next time
+ #endif
+ }
+ else
+ return LogHostError(hr);
+ #else
+ if (hr == AUDCLNT_E_BUFFER_TOO_LARGE)
+ return S_OK; // try again next time
- return LogHostError(hr);
- #endif
- }
+ return LogHostError(hr);
+ #endif
+ }
- // Process data
- if (stream->out.monoMixer != NULL)
- {
- // expand buffer
- UINT32 mono_frames_size = frames * (stream->out.wavex.Format.wBitsPerSample / 8);
- if (mono_frames_size > stream->out.monoBufferSize)
- {
- stream->out.monoBuffer = PaWasapi_ReallocateMemory(stream->out.monoBuffer, (stream->out.monoBufferSize = mono_frames_size));
- if (stream->out.monoBuffer == NULL)
- {
- hr = E_OUTOFMEMORY;
- LogHostError(hr);
- return hr;
- }
- }
+ // Process data
+ if (stream->out.monoMixer != NULL)
+ {
+ // expand buffer
+ UINT32 mono_frames_size = frames * (stream->out.wavex.Format.wBitsPerSample / 8);
+ if (mono_frames_size > stream->out.monoBufferSize)
+ {
+ stream->out.monoBuffer = PaWasapi_ReallocateMemory(stream->out.monoBuffer, (stream->out.monoBufferSize = mono_frames_size));
+ if (stream->out.monoBuffer == NULL)
+ {
+ hr = E_OUTOFMEMORY;
+ LogHostError(hr);
+ return hr;
+ }
+ }
- // process
- processor[S_OUTPUT].processor(NULL, 0, (BYTE *)stream->out.monoBuffer, frames, processor[S_OUTPUT].userData);
+ // process
+ processor[S_OUTPUT].processor(NULL, 0, (BYTE *)stream->out.monoBuffer, frames, processor[S_OUTPUT].userData);
- // mix 1 to 2 channels
- stream->out.monoMixer(data, stream->out.monoBuffer, frames);
- }
- else
- {
- processor[S_OUTPUT].processor(NULL, 0, data, frames, processor[S_OUTPUT].userData);
- }
+ // mix 1 to 2 channels
+ stream->out.monoMixer(data, stream->out.monoBuffer, frames);
+ }
+ else
+ {
+ processor[S_OUTPUT].processor(NULL, 0, data, frames, processor[S_OUTPUT].userData);
+ }
- // Release buffer
- if ((hr = IAudioRenderClient_ReleaseBuffer(stream->renderClient, frames, 0)) != S_OK)
- LogHostError(hr);
+ // Release buffer
+ if ((hr = IAudioRenderClient_ReleaseBuffer(stream->renderClient, frames, 0)) != S_OK)
+ LogHostError(hr);
- return hr;
+ return hr;
}
// ------------------------------------------------------------------------------------------
static HRESULT ProcessInputBuffer(PaWasapiStream *stream, PaWasapiHostProcessor *processor)
{
- HRESULT hr = S_OK;
- UINT32 frames;
- BYTE *data = NULL;
- DWORD flags = 0;
+ HRESULT hr = S_OK;
+ UINT32 frames;
+ BYTE *data = NULL;
+ DWORD flags = 0;
- for (;;)
- {
- // Check if blocking call must be interrupted
- if (WaitForSingleObject(stream->hCloseRequest, 0) != WAIT_TIMEOUT)
- break;
+ for (;;)
+ {
+ // Check if blocking call must be interrupted
+ if (WaitForSingleObject(stream->hCloseRequest, 0) != WAIT_TIMEOUT)
+ break;
- // Findout if any frames available
- frames = 0;
- if ((hr = _PollGetInputFramesAvailable(stream, &frames)) != S_OK)
- return hr;
+ // Findout if any frames available
+ frames = 0;
+ if ((hr = _PollGetInputFramesAvailable(stream, &frames)) != S_OK)
+ return hr;
- // Empty/consumed buffer
- if (frames == 0)
- break;
+ // Empty/consumed buffer
+ if (frames == 0)
+ break;
- // Get the available data in the shared buffer.
- if ((hr = IAudioCaptureClient_GetBuffer(stream->captureClient, &data, &frames, &flags, NULL, NULL)) != S_OK)
- {
- if (hr == AUDCLNT_S_BUFFER_EMPTY)
- {
- hr = S_OK;
- break; // Empty/consumed buffer
- }
+ // Get the available data in the shared buffer.
+ if ((hr = IAudioCaptureClient_GetBuffer(stream->captureClient, &data, &frames, &flags, NULL, NULL)) != S_OK)
+ {
+ if (hr == AUDCLNT_S_BUFFER_EMPTY)
+ {
+ hr = S_OK;
+ break; // Empty/consumed buffer
+ }
- return LogHostError(hr);
- break;
- }
+ return LogHostError(hr);
+ break;
+ }
- // Detect silence
- // if (flags & AUDCLNT_BUFFERFLAGS_SILENT)
- // data = NULL;
+ // Detect silence
+ // if (flags & AUDCLNT_BUFFERFLAGS_SILENT)
+ // data = NULL;
- // Process data
- if (stream->in.monoMixer != NULL)
- {
- // expand buffer
- UINT32 mono_frames_size = frames * (stream->in.wavex.Format.wBitsPerSample / 8);
- if (mono_frames_size > stream->in.monoBufferSize)
- {
- stream->in.monoBuffer = PaWasapi_ReallocateMemory(stream->in.monoBuffer, (stream->in.monoBufferSize = mono_frames_size));
- if (stream->in.monoBuffer == NULL)
- {
- hr = E_OUTOFMEMORY;
- LogHostError(hr);
- return hr;
- }
- }
+ // Process data
+ if (stream->in.monoMixer != NULL)
+ {
+ // expand buffer
+ UINT32 mono_frames_size = frames * (stream->in.wavex.Format.wBitsPerSample / 8);
+ if (mono_frames_size > stream->in.monoBufferSize)
+ {
+ stream->in.monoBuffer = PaWasapi_ReallocateMemory(stream->in.monoBuffer, (stream->in.monoBufferSize = mono_frames_size));
+ if (stream->in.monoBuffer == NULL)
+ {
+ hr = E_OUTOFMEMORY;
+ LogHostError(hr);
+ return hr;
+ }
+ }
- // mix 1 to 2 channels
- stream->in.monoMixer(stream->in.monoBuffer, data, frames);
+ // mix 1 to 2 channels
+ stream->in.monoMixer(stream->in.monoBuffer, data, frames);
- // process
- processor[S_INPUT].processor((BYTE *)stream->in.monoBuffer, frames, NULL, 0, processor[S_INPUT].userData);
- }
- else
- {
- processor[S_INPUT].processor(data, frames, NULL, 0, processor[S_INPUT].userData);
- }
+ // process
+ processor[S_INPUT].processor((BYTE *)stream->in.monoBuffer, frames, NULL, 0, processor[S_INPUT].userData);
+ }
+ else
+ {
+ processor[S_INPUT].processor(data, frames, NULL, 0, processor[S_INPUT].userData);
+ }
- // Release buffer
- if ((hr = IAudioCaptureClient_ReleaseBuffer(stream->captureClient, frames)) != S_OK)
- return LogHostError(hr);
+ // Release buffer
+ if ((hr = IAudioCaptureClient_ReleaseBuffer(stream->captureClient, frames)) != S_OK)
+ return LogHostError(hr);
- //break;
- }
+ //break;
+ }
- return hr;
+ return hr;
}
// ------------------------------------------------------------------------------------------
void _StreamOnStop(PaWasapiStream *stream)
{
- // Stop INPUT/OUTPUT clients
- if (!stream->bBlocking)
- {
- if (stream->in.clientProc != NULL)
- IAudioClient_Stop(stream->in.clientProc);
- if (stream->out.clientProc != NULL)
- IAudioClient_Stop(stream->out.clientProc);
- }
- else
- {
- if (stream->in.clientParent != NULL)
- IAudioClient_Stop(stream->in.clientParent);
- if (stream->out.clientParent != NULL)
- IAudioClient_Stop(stream->out.clientParent);
- }
+ // Stop INPUT/OUTPUT clients
+ if (!stream->bBlocking)
+ {
+ if (stream->in.clientProc != NULL)
+ IAudioClient_Stop(stream->in.clientProc);
+ if (stream->out.clientProc != NULL)
+ IAudioClient_Stop(stream->out.clientProc);
+ }
+ else
+ {
+ if (stream->in.clientParent != NULL)
+ IAudioClient_Stop(stream->in.clientParent);
+ if (stream->out.clientParent != NULL)
+ IAudioClient_Stop(stream->out.clientParent);
+ }
- // Restore thread priority
- if (stream->hAvTask != NULL)
- {
- PaWasapi_ThreadPriorityRevert(stream->hAvTask);
- stream->hAvTask = NULL;
- }
+ // Restore thread priority
+ if (stream->hAvTask != NULL)
+ {
+ PaWasapi_ThreadPriorityRevert(stream->hAvTask);
+ stream->hAvTask = NULL;
+ }
// Notify
if (stream->streamRepresentation.streamFinishedCallback != NULL)
@@ -5592,76 +5592,76 @@ void _StreamOnStop(PaWasapiStream *stream)
// ------------------------------------------------------------------------------------------
static BOOL PrepareComPointers(PaWasapiStream *stream, BOOL *threadComInitialized)
{
- HRESULT hr;
+ HRESULT hr;
- /*
- If COM is already initialized CoInitialize will either return
- FALSE, or RPC_E_CHANGED_MODE if it was initialized in a different
- threading mode. In either case we shouldn't consider it an error
- but we need to be careful to not call CoUninitialize() if
- RPC_E_CHANGED_MODE was returned.
- */
- hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
- if (FAILED(hr) && (hr != RPC_E_CHANGED_MODE))
- {
- PRINT(("WASAPI: failed ProcThreadEvent CoInitialize"));
- return FALSE;
- }
- if (hr != RPC_E_CHANGED_MODE)
- *threadComInitialized = TRUE;
+ /*
+ If COM is already initialized CoInitialize will either return
+ FALSE, or RPC_E_CHANGED_MODE if it was initialized in a different
+ threading mode. In either case we shouldn't consider it an error
+ but we need to be careful to not call CoUninitialize() if
+ RPC_E_CHANGED_MODE was returned.
+ */
+ hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ if (FAILED(hr) && (hr != RPC_E_CHANGED_MODE))
+ {
+ PRINT(("WASAPI: failed ProcThreadEvent CoInitialize"));
+ return FALSE;
+ }
+ if (hr != RPC_E_CHANGED_MODE)
+ *threadComInitialized = TRUE;
- // Unmarshal stream pointers for safe COM operation
- hr = UnmarshalStreamComPointers(stream);
- if (hr != S_OK)
- {
- PRINT(("WASAPI: Error unmarshaling stream COM pointers. HRESULT: %i\n", hr));
- CoUninitialize();
- return FALSE;
- }
+ // Unmarshal stream pointers for safe COM operation
+ hr = UnmarshalStreamComPointers(stream);
+ if (hr != S_OK)
+ {
+ PRINT(("WASAPI: Error unmarshaling stream COM pointers. HRESULT: %i\n", hr));
+ CoUninitialize();
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
// ------------------------------------------------------------------------------------------
static void FinishComPointers(PaWasapiStream *stream, BOOL threadComInitialized)
{
- // Release unmarshaled COM pointers
- ReleaseUnmarshaledComPointers(stream);
+ // Release unmarshaled COM pointers
+ ReleaseUnmarshaledComPointers(stream);
- // Cleanup COM for this thread
- if (threadComInitialized == TRUE)
- CoUninitialize();
+ // Cleanup COM for this thread
+ if (threadComInitialized == TRUE)
+ CoUninitialize();
}
// ------------------------------------------------------------------------------------------
PA_THREAD_FUNC ProcThreadEvent(void *param)
{
PaWasapiHostProcessor processor[S_COUNT];
- HRESULT hr;
- DWORD dwResult;
+ HRESULT hr;
+ DWORD dwResult;
PaWasapiStream *stream = (PaWasapiStream *)param;
- PaWasapiHostProcessor defaultProcessor;
- BOOL setEvent[S_COUNT] = { FALSE, FALSE };
- BOOL waitAllEvents = FALSE;
- BOOL threadComInitialized = FALSE;
- SystemTimer timer;
+ PaWasapiHostProcessor defaultProcessor;
+ BOOL setEvent[S_COUNT] = { FALSE, FALSE };
+ BOOL waitAllEvents = FALSE;
+ BOOL threadComInitialized = FALSE;
+ SystemTimer timer;
- // Notify: state
- NotifyStateChanged(stream, paWasapiStreamStateThreadPrepare, ERROR_SUCCESS);
+ // Notify: state
+ NotifyStateChanged(stream, paWasapiStreamStateThreadPrepare, ERROR_SUCCESS);
- // Prepare COM pointers
- if (!PrepareComPointers(stream, &threadComInitialized))
- return (UINT32)paUnanticipatedHostError;
+ // Prepare COM pointers
+ if (!PrepareComPointers(stream, &threadComInitialized))
+ return (UINT32)paUnanticipatedHostError;
- // Request fine (1 ms) granularity of the system timer functions for precise operation of waitable timers
- SystemTimer_SetGranularity(&timer, 1);
+ // Request fine (1 ms) granularity of the system timer functions for precise operation of waitable timers
+ SystemTimer_SetGranularity(&timer, 1);
- // Waiting on all events in case of Full-Duplex/Exclusive mode.
- if ((stream->in.clientProc != NULL) && (stream->out.clientProc != NULL))
- {
- waitAllEvents = (stream->in.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) &&
- (stream->out.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE);
- }
+ // Waiting on all events in case of Full-Duplex/Exclusive mode.
+ if ((stream->in.clientProc != NULL) && (stream->out.clientProc != NULL))
+ {
+ waitAllEvents = (stream->in.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) &&
+ (stream->out.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE);
+ }
// Setup data processors
defaultProcessor.processor = WaspiHostProcessingLoop;
@@ -5669,294 +5669,294 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
processor[S_INPUT] = (stream->hostProcessOverrideInput.processor != NULL ? stream->hostProcessOverrideInput : defaultProcessor);
processor[S_OUTPUT] = (stream->hostProcessOverrideOutput.processor != NULL ? stream->hostProcessOverrideOutput : defaultProcessor);
- // Boost thread priority
- PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);
+ // Boost thread priority
+ PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);
- // Create events
- if (stream->event[S_OUTPUT] == NULL)
- {
- stream->event[S_OUTPUT] = CreateEvent(NULL, FALSE, FALSE, NULL);
- setEvent[S_OUTPUT] = TRUE;
- }
- if (stream->event[S_INPUT] == NULL)
- {
- stream->event[S_INPUT] = CreateEvent(NULL, FALSE, FALSE, NULL);
- setEvent[S_INPUT] = TRUE;
- }
- if ((stream->event[S_OUTPUT] == NULL) || (stream->event[S_INPUT] == NULL))
- {
- PRINT(("WASAPI Thread: failed creating Input/Output event handle\n"));
- goto thread_error;
- }
-
- // Initialize event & start INPUT stream
- if (stream->in.clientProc)
- {
- // Create & set handle
- if (setEvent[S_INPUT])
- {
- if ((hr = IAudioClient_SetEventHandle(stream->in.clientProc, stream->event[S_INPUT])) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
- }
-
- // Start
- if ((hr = IAudioClient_Start(stream->in.clientProc)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
- }
-
- // Initialize event & start OUTPUT stream
- if (stream->out.clientProc)
- {
- // Create & set handle
- if (setEvent[S_OUTPUT])
- {
- if ((hr = IAudioClient_SetEventHandle(stream->out.clientProc, stream->event[S_OUTPUT])) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
- }
-
- // Preload buffer before start
- if ((hr = ProcessOutputBuffer(stream, processor, stream->out.framesPerBuffer)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
-
- // Start
- if ((hr = IAudioClient_Start(stream->out.clientProc)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
-
- }
-
- // Signal: stream running
- stream->running = TRUE;
-
- // Notify: thread started
- SetEvent(stream->hThreadStart);
-
- // Notify: state
- NotifyStateChanged(stream, paWasapiStreamStateThreadStart, ERROR_SUCCESS);
-
- // Processing Loop
- for (;;)
+ // Create events
+ if (stream->event[S_OUTPUT] == NULL)
{
- // 10 sec timeout (on timeout stream will auto-stop when processed by WAIT_TIMEOUT case)
+ stream->event[S_OUTPUT] = CreateEvent(NULL, FALSE, FALSE, NULL);
+ setEvent[S_OUTPUT] = TRUE;
+ }
+ if (stream->event[S_INPUT] == NULL)
+ {
+ stream->event[S_INPUT] = CreateEvent(NULL, FALSE, FALSE, NULL);
+ setEvent[S_INPUT] = TRUE;
+ }
+ if ((stream->event[S_OUTPUT] == NULL) || (stream->event[S_INPUT] == NULL))
+ {
+ PRINT(("WASAPI Thread: failed creating Input/Output event handle\n"));
+ goto thread_error;
+ }
+
+ // Initialize event & start INPUT stream
+ if (stream->in.clientProc)
+ {
+ // Create & set handle
+ if (setEvent[S_INPUT])
+ {
+ if ((hr = IAudioClient_SetEventHandle(stream->in.clientProc, stream->event[S_INPUT])) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
+ }
+
+ // Start
+ if ((hr = IAudioClient_Start(stream->in.clientProc)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
+ }
+
+ // Initialize event & start OUTPUT stream
+ if (stream->out.clientProc)
+ {
+ // Create & set handle
+ if (setEvent[S_OUTPUT])
+ {
+ if ((hr = IAudioClient_SetEventHandle(stream->out.clientProc, stream->event[S_OUTPUT])) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
+ }
+
+ // Preload buffer before start
+ if ((hr = ProcessOutputBuffer(stream, processor, stream->out.framesPerBuffer)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
+
+ // Start
+ if ((hr = IAudioClient_Start(stream->out.clientProc)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
+
+ }
+
+ // Signal: stream running
+ stream->running = TRUE;
+
+ // Notify: thread started
+ SetEvent(stream->hThreadStart);
+
+ // Notify: state
+ NotifyStateChanged(stream, paWasapiStreamStateThreadStart, ERROR_SUCCESS);
+
+ // Processing Loop
+ for (;;)
+ {
+ // 10 sec timeout (on timeout stream will auto-stop when processed by WAIT_TIMEOUT case)
dwResult = WaitForMultipleObjects(S_COUNT, stream->event, waitAllEvents, 10*1000);
- // Check for close event (after wait for buffers to avoid any calls to user
- // callback when hCloseRequest was set)
- if (WaitForSingleObject(stream->hCloseRequest, 0) != WAIT_TIMEOUT)
- break;
+ // Check for close event (after wait for buffers to avoid any calls to user
+ // callback when hCloseRequest was set)
+ if (WaitForSingleObject(stream->hCloseRequest, 0) != WAIT_TIMEOUT)
+ break;
- // Process S_INPUT/S_OUTPUT
- switch (dwResult)
- {
- case WAIT_TIMEOUT: {
- PRINT(("WASAPI Thread: WAIT_TIMEOUT - probably bad audio driver or Vista x64 bug: use paWinWasapiPolling instead\n"));
- goto thread_end;
- break; }
+ // Process S_INPUT/S_OUTPUT
+ switch (dwResult)
+ {
+ case WAIT_TIMEOUT: {
+ PRINT(("WASAPI Thread: WAIT_TIMEOUT - probably bad audio driver or Vista x64 bug: use paWinWasapiPolling instead\n"));
+ goto thread_end;
+ break; }
- // Input stream
- case WAIT_OBJECT_0 + S_INPUT: {
+ // Input stream
+ case WAIT_OBJECT_0 + S_INPUT: {
if (stream->captureClient == NULL)
break;
- if ((hr = ProcessInputBuffer(stream, processor)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
+ if ((hr = ProcessInputBuffer(stream, processor)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
- break; }
+ break; }
- // Output stream
- case WAIT_OBJECT_0 + S_OUTPUT: {
+ // Output stream
+ case WAIT_OBJECT_0 + S_OUTPUT: {
if (stream->renderClient == NULL)
break;
- if ((hr = ProcessOutputBuffer(stream, processor, stream->out.framesPerBuffer)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
+ if ((hr = ProcessOutputBuffer(stream, processor, stream->out.framesPerBuffer)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
- break; }
- }
- }
+ break; }
+ }
+ }
thread_end:
- // Process stop
- _StreamOnStop(stream);
+ // Process stop
+ _StreamOnStop(stream);
- // Release unmarshaled COM pointers
- FinishComPointers(stream, threadComInitialized);
+ // Release unmarshaled COM pointers
+ FinishComPointers(stream, threadComInitialized);
- // Restore system timer granularity
- SystemTimer_RestoreGranularity(&timer);
+ // Restore system timer granularity
+ SystemTimer_RestoreGranularity(&timer);
- // Notify: not running
- stream->running = FALSE;
+ // Notify: not running
+ stream->running = FALSE;
- // Notify: thread exited
- SetEvent(stream->hThreadExit);
+ // Notify: thread exited
+ SetEvent(stream->hThreadExit);
- // Notify: state
- NotifyStateChanged(stream, paWasapiStreamStateThreadStop, hr);
+ // Notify: state
+ NotifyStateChanged(stream, paWasapiStreamStateThreadStop, hr);
- return 0;
+ return 0;
thread_error:
- // Prevent deadlocking in Pa_StreamStart
- SetEvent(stream->hThreadStart);
+ // Prevent deadlocking in Pa_StreamStart
+ SetEvent(stream->hThreadStart);
- // Exit
- goto thread_end;
+ // Exit
+ goto thread_end;
}
// ------------------------------------------------------------------------------------------
static UINT32 GetSleepTime(PaWasapiStream *stream, UINT32 sleepTimeIn, UINT32 sleepTimeOut, UINT32 userFramesOut)
{
- UINT32 sleepTime;
+ UINT32 sleepTime;
- // According to the issue [https://github.com/PortAudio/portaudio/issues/303] glitches may occur when user frames
- // equal to 1/2 of the host buffer frames, therefore the emperical workaround for this problem is to lower
- // the sleep time by 2
- if (userFramesOut != 0)
- {
- UINT32 chunks = stream->out.framesPerHostCallback / userFramesOut;
- if (chunks <= 2)
- {
- sleepTimeOut /= 2;
- PRINT(("WASAPI: underrun workaround, sleep [%d] ms - 1/2 of the user buffer[%d] | host buffer[%d]\n", sleepTimeOut, userFramesOut, stream->out.framesPerHostCallback));
- }
- }
+ // According to the issue [https://github.com/PortAudio/portaudio/issues/303] glitches may occur when user frames
+ // equal to 1/2 of the host buffer frames, therefore the emperical workaround for this problem is to lower
+ // the sleep time by 2
+ if (userFramesOut != 0)
+ {
+ UINT32 chunks = stream->out.framesPerHostCallback / userFramesOut;
+ if (chunks <= 2)
+ {
+ sleepTimeOut /= 2;
+ PRINT(("WASAPI: underrun workaround, sleep [%d] ms - 1/2 of the user buffer[%d] | host buffer[%d]\n", sleepTimeOut, userFramesOut, stream->out.framesPerHostCallback));
+ }
+ }
- // Choose the smallest
- if ((sleepTimeIn != 0) && (sleepTimeOut != 0))
- sleepTime = min(sleepTimeIn, sleepTimeOut);
- else
- sleepTime = (sleepTimeIn ? sleepTimeIn : sleepTimeOut);
+ // Choose the smallest
+ if ((sleepTimeIn != 0) && (sleepTimeOut != 0))
+ sleepTime = min(sleepTimeIn, sleepTimeOut);
+ else
+ sleepTime = (sleepTimeIn ? sleepTimeIn : sleepTimeOut);
- return sleepTime;
+ return sleepTime;
}
// ------------------------------------------------------------------------------------------
static UINT32 ConfigureLoopSleepTimeAndScheduler(PaWasapiStream *stream, ThreadIdleScheduler *scheduler)
{
- UINT32 sleepTime, sleepTimeIn, sleepTimeOut;
- UINT32 userFramesIn = stream->in.framesPerHostCallback / WASAPI_PACKETS_PER_INPUT_BUFFER;
- UINT32 userFramesOut = stream->out.framesPerBuffer;
+ UINT32 sleepTime, sleepTimeIn, sleepTimeOut;
+ UINT32 userFramesIn = stream->in.framesPerHostCallback / WASAPI_PACKETS_PER_INPUT_BUFFER;
+ UINT32 userFramesOut = stream->out.framesPerBuffer;
- // Adjust polling time for non-paUtilFixedHostBufferSize, input stream is not adjustable as it is being
- // polled according its packet length
- if (stream->bufferMode != paUtilFixedHostBufferSize)
- {
- userFramesOut = (stream->bufferProcessor.framesPerUserBuffer ? stream->bufferProcessor.framesPerUserBuffer :
- stream->out.params.frames_per_buffer);
- }
+ // Adjust polling time for non-paUtilFixedHostBufferSize, input stream is not adjustable as it is being
+ // polled according its packet length
+ if (stream->bufferMode != paUtilFixedHostBufferSize)
+ {
+ userFramesOut = (stream->bufferProcessor.framesPerUserBuffer ? stream->bufferProcessor.framesPerUserBuffer :
+ stream->out.params.frames_per_buffer);
+ }
- // Calculate timeout for the next polling attempt
- sleepTimeIn = GetFramesSleepTime(userFramesIn, stream->in.wavex.Format.nSamplesPerSec);
- sleepTimeOut = GetFramesSleepTime(userFramesOut, stream->out.wavex.Format.nSamplesPerSec);
+ // Calculate timeout for the next polling attempt
+ sleepTimeIn = GetFramesSleepTime(userFramesIn, stream->in.wavex.Format.nSamplesPerSec);
+ sleepTimeOut = GetFramesSleepTime(userFramesOut, stream->out.wavex.Format.nSamplesPerSec);
- // WASAPI input packets tend to expire very easily, let's limit sleep time to 2 milliseconds
- // for all cases. Please propose better solution if any
- if (sleepTimeIn > 2)
- sleepTimeIn = 2;
+ // WASAPI input packets tend to expire very easily, let's limit sleep time to 2 milliseconds
+ // for all cases. Please propose better solution if any
+ if (sleepTimeIn > 2)
+ sleepTimeIn = 2;
- sleepTime = GetSleepTime(stream, sleepTimeIn, sleepTimeOut, userFramesOut);
+ sleepTime = GetSleepTime(stream, sleepTimeIn, sleepTimeOut, userFramesOut);
- // Make sure not 0, othervise use ThreadIdleScheduler to bounce between [0, 1] ms to avoid too busy loop
- if (sleepTime == 0)
- {
- sleepTimeIn = GetFramesSleepTimeMicroseconds(userFramesIn, stream->in.wavex.Format.nSamplesPerSec);
- sleepTimeOut = GetFramesSleepTimeMicroseconds(userFramesOut, stream->out.wavex.Format.nSamplesPerSec);
+ // Make sure not 0, othervise use ThreadIdleScheduler to bounce between [0, 1] ms to avoid too busy loop
+ if (sleepTime == 0)
+ {
+ sleepTimeIn = GetFramesSleepTimeMicroseconds(userFramesIn, stream->in.wavex.Format.nSamplesPerSec);
+ sleepTimeOut = GetFramesSleepTimeMicroseconds(userFramesOut, stream->out.wavex.Format.nSamplesPerSec);
- sleepTime = GetSleepTime(stream, sleepTimeIn, sleepTimeOut, userFramesOut);
+ sleepTime = GetSleepTime(stream, sleepTimeIn, sleepTimeOut, userFramesOut);
- // Setup thread sleep scheduler
- ThreadIdleScheduler_Setup(scheduler, 1, sleepTime/* microseconds here */);
- sleepTime = 0;
- }
+ // Setup thread sleep scheduler
+ ThreadIdleScheduler_Setup(scheduler, 1, sleepTime/* microseconds here */);
+ sleepTime = 0;
+ }
- return sleepTime;
+ return sleepTime;
}
// ------------------------------------------------------------------------------------------
static inline INT32 GetNextSleepTime(SystemTimer *timer, ThreadIdleScheduler *scheduler, LONGLONG startTime,
- UINT32 sleepTime)
+ UINT32 sleepTime)
{
- INT32 nextSleepTime;
+ INT32 nextSleepTime;
- // Get next sleep time
- if (sleepTime == 0)
- nextSleepTime = ThreadIdleScheduler_NextSleep(scheduler);
- else
- nextSleepTime = sleepTime;
+ // Get next sleep time
+ if (sleepTime == 0)
+ nextSleepTime = ThreadIdleScheduler_NextSleep(scheduler);
+ else
+ nextSleepTime = sleepTime;
- // Adjust next sleep time dynamically depending on how much time was spent in ProcessOutputBuffer/ProcessInputBuffer
- // therefore periodicity will not jitter or be increased for the amount of time spent in processing;
- // example when sleepTime is 10 ms where [] is polling time slot, {} processing time slot:
- //
- // [9],{2},[8],{1},[9],{1},[9],{3},[7],{2},[8],{3},[7],{2},[8],{2},[8],{3},[7],{2},[8],...
- //
- INT32 procTime = (INT32)(SystemTimer_GetTime(timer) - startTime);
- nextSleepTime -= procTime;
- if (nextSleepTime < 0)
- nextSleepTime = 0;
+ // Adjust next sleep time dynamically depending on how much time was spent in ProcessOutputBuffer/ProcessInputBuffer
+ // therefore periodicity will not jitter or be increased for the amount of time spent in processing;
+ // example when sleepTime is 10 ms where [] is polling time slot, {} processing time slot:
+ //
+ // [9],{2},[8],{1},[9],{1},[9],{3},[7],{2},[8],{3},[7],{2},[8],{2},[8],{3},[7],{2},[8],...
+ //
+ INT32 procTime = (INT32)(SystemTimer_GetTime(timer) - startTime);
+ nextSleepTime -= procTime;
+ if (nextSleepTime < 0)
+ nextSleepTime = 0;
#ifdef PA_WASAPI_LOG_TIME_SLOTS
- printf("{%d},", procTime);
+ printf("{%d},", procTime);
#endif
- return nextSleepTime;
+ return nextSleepTime;
}
// ------------------------------------------------------------------------------------------
PA_THREAD_FUNC ProcThreadPoll(void *param)
{
PaWasapiHostProcessor processor[S_COUNT];
- HRESULT hr;
+ HRESULT hr;
PaWasapiStream *stream = (PaWasapiStream *)param;
- PaWasapiHostProcessor defaultProcessor;
- INT32 i;
- ThreadIdleScheduler scheduler;
- SystemTimer timer;
- LONGLONG startTime;
- UINT32 sleepTime;
- INT32 nextSleepTime = 0; //! Do first loop without waiting as time could be spent when calling other APIs before ProcessXXXBuffer.
- BOOL threadComInitialized = FALSE;
+ PaWasapiHostProcessor defaultProcessor;
+ INT32 i;
+ ThreadIdleScheduler scheduler;
+ SystemTimer timer;
+ LONGLONG startTime;
+ UINT32 sleepTime;
+ INT32 nextSleepTime = 0; //! Do first loop without waiting as time could be spent when calling other APIs before ProcessXXXBuffer.
+ BOOL threadComInitialized = FALSE;
#ifdef PA_WASAPI_LOG_TIME_SLOTS
- LONGLONG startWaitTime;
+ LONGLONG startWaitTime;
#endif
- // Notify: state
- NotifyStateChanged(stream, paWasapiStreamStateThreadPrepare, ERROR_SUCCESS);
+ // Notify: state
+ NotifyStateChanged(stream, paWasapiStreamStateThreadPrepare, ERROR_SUCCESS);
- // Prepare COM pointers
- if (!PrepareComPointers(stream, &threadComInitialized))
- return (UINT32)paUnanticipatedHostError;
+ // Prepare COM pointers
+ if (!PrepareComPointers(stream, &threadComInitialized))
+ return (UINT32)paUnanticipatedHostError;
- // Request fine (1 ms) granularity of the system timer functions to guarantee correct logic around WaitForSingleObject
- SystemTimer_SetGranularity(&timer, 1);
+ // Request fine (1 ms) granularity of the system timer functions to guarantee correct logic around WaitForSingleObject
+ SystemTimer_SetGranularity(&timer, 1);
- // Claculate sleep time of the processing loop (inside WaitForSingleObject)
- sleepTime = ConfigureLoopSleepTimeAndScheduler(stream, &scheduler);
+ // Claculate sleep time of the processing loop (inside WaitForSingleObject)
+ sleepTime = ConfigureLoopSleepTimeAndScheduler(stream, &scheduler);
// Setup data processors
defaultProcessor.processor = WaspiHostProcessingLoop;
@@ -5964,373 +5964,373 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
processor[S_INPUT] = (stream->hostProcessOverrideInput.processor != NULL ? stream->hostProcessOverrideInput : defaultProcessor);
processor[S_OUTPUT] = (stream->hostProcessOverrideOutput.processor != NULL ? stream->hostProcessOverrideOutput : defaultProcessor);
- // Boost thread priority
- PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);
+ // Boost thread priority
+ PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);
- // Initialize event & start INPUT stream
- if (stream->in.clientProc)
- {
- if ((hr = IAudioClient_Start(stream->in.clientProc)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
- }
+ // Initialize event & start INPUT stream
+ if (stream->in.clientProc)
+ {
+ if ((hr = IAudioClient_Start(stream->in.clientProc)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
+ }
- // Initialize event & start OUTPUT stream
- if (stream->out.clientProc)
- {
- // Preload buffer (obligatory, othervise ->Start() will fail), avoid processing
- // when in full-duplex mode as it requires input processing as well
- if (!PA_WASAPI__IS_FULLDUPLEX(stream))
- {
- UINT32 frames = 0;
- if ((hr = _PollGetOutputFramesAvailable(stream, &frames)) == S_OK)
- {
- if (stream->bufferMode == paUtilFixedHostBufferSize)
- {
- // It is important to preload whole host buffer to avoid underruns/glitches when stream is started,
- // for more details see the discussion: https://github.com/PortAudio/portaudio/issues/303
- while (frames >= stream->out.framesPerBuffer)
- {
- if ((hr = ProcessOutputBuffer(stream, processor, stream->out.framesPerBuffer)) != S_OK)
- {
- LogHostError(hr); // not fatal, just log
- break;
- }
+ // Initialize event & start OUTPUT stream
+ if (stream->out.clientProc)
+ {
+ // Preload buffer (obligatory, othervise ->Start() will fail), avoid processing
+ // when in full-duplex mode as it requires input processing as well
+ if (!PA_WASAPI__IS_FULLDUPLEX(stream))
+ {
+ UINT32 frames = 0;
+ if ((hr = _PollGetOutputFramesAvailable(stream, &frames)) == S_OK)
+ {
+ if (stream->bufferMode == paUtilFixedHostBufferSize)
+ {
+ // It is important to preload whole host buffer to avoid underruns/glitches when stream is started,
+ // for more details see the discussion: https://github.com/PortAudio/portaudio/issues/303
+ while (frames >= stream->out.framesPerBuffer)
+ {
+ if ((hr = ProcessOutputBuffer(stream, processor, stream->out.framesPerBuffer)) != S_OK)
+ {
+ LogHostError(hr); // not fatal, just log
+ break;
+ }
- frames -= stream->out.framesPerBuffer;
- }
- }
- else
- {
- // Some devices may not start (will get stuck with 0 ready frames) if data not prefetched
- if (frames == 0)
- frames = stream->out.framesPerBuffer;
+ frames -= stream->out.framesPerBuffer;
+ }
+ }
+ else
+ {
+ // Some devices may not start (will get stuck with 0 ready frames) if data not prefetched
+ if (frames == 0)
+ frames = stream->out.framesPerBuffer;
- // USB DACs report large buffer in Exclusive mode and if it is filled fully will stuck in
- // non playing state, e.g. IAudioClient_GetCurrentPadding() will start reporting max buffer size
- // constantly, thus preload data size equal to the user buffer to allow process going
- if ((stream->out.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) && (frames >= (stream->out.framesPerBuffer * 2)))
- frames -= stream->out.framesPerBuffer;
+ // USB DACs report large buffer in Exclusive mode and if it is filled fully will stuck in
+ // non playing state, e.g. IAudioClient_GetCurrentPadding() will start reporting max buffer size
+ // constantly, thus preload data size equal to the user buffer to allow process going
+ if ((stream->out.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE) && (frames >= (stream->out.framesPerBuffer * 2)))
+ frames -= stream->out.framesPerBuffer;
- if ((hr = ProcessOutputBuffer(stream, processor, frames)) != S_OK)
- {
- LogHostError(hr); // not fatal, just log
- }
- }
- }
- else
- {
- LogHostError(hr); // not fatal, just log
- }
- }
+ if ((hr = ProcessOutputBuffer(stream, processor, frames)) != S_OK)
+ {
+ LogHostError(hr); // not fatal, just log
+ }
+ }
+ }
+ else
+ {
+ LogHostError(hr); // not fatal, just log
+ }
+ }
- // Start
- if ((hr = IAudioClient_Start(stream->out.clientProc)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
- }
+ // Start
+ if ((hr = IAudioClient_Start(stream->out.clientProc)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
+ }
- // Signal: stream running
- stream->running = TRUE;
+ // Signal: stream running
+ stream->running = TRUE;
- // Notify: thread started
- SetEvent(stream->hThreadStart);
+ // Notify: thread started
+ SetEvent(stream->hThreadStart);
- // Notify: state
- NotifyStateChanged(stream, paWasapiStreamStateThreadStart, ERROR_SUCCESS);
+ // Notify: state
+ NotifyStateChanged(stream, paWasapiStreamStateThreadStart, ERROR_SUCCESS);
#ifdef PA_WASAPI_LOG_TIME_SLOTS
- startWaitTime = SystemTimer_GetTime(&timer);
+ startWaitTime = SystemTimer_GetTime(&timer);
#endif
- if (!PA_WASAPI__IS_FULLDUPLEX(stream))
- {
- // Processing Loop
- while (WaitForSingleObject(stream->hCloseRequest, nextSleepTime) == WAIT_TIMEOUT)
- {
- startTime = SystemTimer_GetTime(&timer);
+ if (!PA_WASAPI__IS_FULLDUPLEX(stream))
+ {
+ // Processing Loop
+ while (WaitForSingleObject(stream->hCloseRequest, nextSleepTime) == WAIT_TIMEOUT)
+ {
+ startTime = SystemTimer_GetTime(&timer);
- #ifdef PA_WASAPI_LOG_TIME_SLOTS
- printf("[%d|%d],", nextSleepTime, (INT32)(startTime - startWaitTime));
- #endif
+ #ifdef PA_WASAPI_LOG_TIME_SLOTS
+ printf("[%d|%d],", nextSleepTime, (INT32)(startTime - startWaitTime));
+ #endif
- for (i = 0; i < S_COUNT; ++i)
- {
- // Process S_INPUT/S_OUTPUT
- switch (i)
- {
- // Input stream
- case S_INPUT: {
+ for (i = 0; i < S_COUNT; ++i)
+ {
+ // Process S_INPUT/S_OUTPUT
+ switch (i)
+ {
+ // Input stream
+ case S_INPUT: {
- if (stream->captureClient == NULL)
- break;
+ if (stream->captureClient == NULL)
+ break;
- if ((hr = ProcessInputBuffer(stream, processor)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
+ if ((hr = ProcessInputBuffer(stream, processor)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
- break; }
+ break; }
- // Output stream
- case S_OUTPUT: {
+ // Output stream
+ case S_OUTPUT: {
- UINT32 framesAvail;
+ UINT32 framesAvail;
- if (stream->renderClient == NULL)
- break;
+ if (stream->renderClient == NULL)
+ break;
- // Get available frames
- if ((hr = _PollGetOutputFramesAvailable(stream, &framesAvail)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
+ // Get available frames
+ if ((hr = _PollGetOutputFramesAvailable(stream, &framesAvail)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
- // Output data to the user callback
- if (stream->bufferMode == paUtilFixedHostBufferSize)
- {
- UINT32 framesProc = stream->out.framesPerBuffer;
+ // Output data to the user callback
+ if (stream->bufferMode == paUtilFixedHostBufferSize)
+ {
+ UINT32 framesProc = stream->out.framesPerBuffer;
- // If we got less frames avoid sleeping again as it might be the corner case and buffer
- // has sufficient number of frames now, in case 'out.framesPerBuffer' is 1/2 of the host
- // buffer sleeping again may cause underruns. Do short busy waiting (normally might take
- // 1-2 iterations)
- if (framesAvail < framesProc)
- {
- nextSleepTime = 0;
- continue;
- }
+ // If we got less frames avoid sleeping again as it might be the corner case and buffer
+ // has sufficient number of frames now, in case 'out.framesPerBuffer' is 1/2 of the host
+ // buffer sleeping again may cause underruns. Do short busy waiting (normally might take
+ // 1-2 iterations)
+ if (framesAvail < framesProc)
+ {
+ nextSleepTime = 0;
+ continue;
+ }
- while (framesAvail >= framesProc)
- {
- if ((hr = ProcessOutputBuffer(stream, processor, framesProc)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
+ while (framesAvail >= framesProc)
+ {
+ if ((hr = ProcessOutputBuffer(stream, processor, framesProc)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
- framesAvail -= framesProc;
- }
- }
- else
- if (framesAvail != 0)
- {
- if ((hr = ProcessOutputBuffer(stream, processor, framesAvail)) != S_OK)
- {
- LogHostError(hr);
- goto thread_error;
- }
- }
+ framesAvail -= framesProc;
+ }
+ }
+ else
+ if (framesAvail != 0)
+ {
+ if ((hr = ProcessOutputBuffer(stream, processor, framesAvail)) != S_OK)
+ {
+ LogHostError(hr);
+ goto thread_error;
+ }
+ }
- break; }
- }
- }
+ break; }
+ }
+ }
- // Get next sleep time
- nextSleepTime = GetNextSleepTime(&timer, &scheduler, startTime, sleepTime);
+ // Get next sleep time
+ nextSleepTime = GetNextSleepTime(&timer, &scheduler, startTime, sleepTime);
- #ifdef PA_WASAPI_LOG_TIME_SLOTS
- startWaitTime = SystemTimer_GetTime(&timer);
- #endif
- }
- }
- else
- {
- // Processing Loop (full-duplex)
- while (WaitForSingleObject(stream->hCloseRequest, nextSleepTime) == WAIT_TIMEOUT)
- {
- UINT32 i_frames = 0, i_processed = 0, o_frames = 0;
- BYTE *i_data = NULL, *o_data = NULL, *o_data_host = NULL;
- DWORD i_flags = 0;
-
- startTime = SystemTimer_GetTime(&timer);
+ #ifdef PA_WASAPI_LOG_TIME_SLOTS
+ startWaitTime = SystemTimer_GetTime(&timer);
+ #endif
+ }
+ }
+ else
+ {
+ // Processing Loop (full-duplex)
+ while (WaitForSingleObject(stream->hCloseRequest, nextSleepTime) == WAIT_TIMEOUT)
+ {
+ UINT32 i_frames = 0, i_processed = 0, o_frames = 0;
+ BYTE *i_data = NULL, *o_data = NULL, *o_data_host = NULL;
+ DWORD i_flags = 0;
+
+ startTime = SystemTimer_GetTime(&timer);
- #ifdef PA_WASAPI_LOG_TIME_SLOTS
- printf("[%d|%d],", nextSleepTime, (INT32)(startTime - startWaitTime));
- #endif
+ #ifdef PA_WASAPI_LOG_TIME_SLOTS
+ printf("[%d|%d],", nextSleepTime, (INT32)(startTime - startWaitTime));
+ #endif
- // get available frames
- if ((hr = _PollGetOutputFramesAvailable(stream, &o_frames)) != S_OK)
- {
- LogHostError(hr);
- break;
- }
+ // get available frames
+ if ((hr = _PollGetOutputFramesAvailable(stream, &o_frames)) != S_OK)
+ {
+ LogHostError(hr);
+ break;
+ }
- while (o_frames != 0)
- {
- // get host input buffer
- if ((hr = IAudioCaptureClient_GetBuffer(stream->captureClient, &i_data, &i_frames, &i_flags, NULL, NULL)) != S_OK)
- {
- if (hr == AUDCLNT_S_BUFFER_EMPTY)
- break; // no data in capture buffer
+ while (o_frames != 0)
+ {
+ // get host input buffer
+ if ((hr = IAudioCaptureClient_GetBuffer(stream->captureClient, &i_data, &i_frames, &i_flags, NULL, NULL)) != S_OK)
+ {
+ if (hr == AUDCLNT_S_BUFFER_EMPTY)
+ break; // no data in capture buffer
- LogHostError(hr);
- break;
- }
+ LogHostError(hr);
+ break;
+ }
- // process equal ammount of frames
- if (o_frames >= i_frames)
- {
- // process input ammount of frames
- UINT32 o_processed = i_frames;
+ // process equal ammount of frames
+ if (o_frames >= i_frames)
+ {
+ // process input ammount of frames
+ UINT32 o_processed = i_frames;
- // get host output buffer
- if ((hr = IAudioRenderClient_GetBuffer(stream->renderClient, o_processed, &o_data)) == S_OK)
- {
- // processed amount of i_frames
- i_processed = i_frames;
- o_data_host = o_data;
+ // get host output buffer
+ if ((hr = IAudioRenderClient_GetBuffer(stream->renderClient, o_processed, &o_data)) == S_OK)
+ {
+ // processed amount of i_frames
+ i_processed = i_frames;
+ o_data_host = o_data;
- // convert output mono
- if (stream->out.monoMixer)
- {
- UINT32 mono_frames_size = o_processed * (stream->out.wavex.Format.wBitsPerSample / 8);
- // expand buffer
- if (mono_frames_size > stream->out.monoBufferSize)
- {
- stream->out.monoBuffer = PaWasapi_ReallocateMemory(stream->out.monoBuffer, (stream->out.monoBufferSize = mono_frames_size));
- if (stream->out.monoBuffer == NULL)
- {
- // release input buffer
- IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);
- // release output buffer
- IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);
+ // convert output mono
+ if (stream->out.monoMixer)
+ {
+ UINT32 mono_frames_size = o_processed * (stream->out.wavex.Format.wBitsPerSample / 8);
+ // expand buffer
+ if (mono_frames_size > stream->out.monoBufferSize)
+ {
+ stream->out.monoBuffer = PaWasapi_ReallocateMemory(stream->out.monoBuffer, (stream->out.monoBufferSize = mono_frames_size));
+ if (stream->out.monoBuffer == NULL)
+ {
+ // release input buffer
+ IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);
+ // release output buffer
+ IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);
- LogPaError(paInsufficientMemory);
- goto thread_error;
- }
- }
+ LogPaError(paInsufficientMemory);
+ goto thread_error;
+ }
+ }
- // replace buffer pointer
- o_data = (BYTE *)stream->out.monoBuffer;
- }
+ // replace buffer pointer
+ o_data = (BYTE *)stream->out.monoBuffer;
+ }
- // convert input mono
- if (stream->in.monoMixer)
- {
- UINT32 mono_frames_size = i_processed * (stream->in.wavex.Format.wBitsPerSample / 8);
- // expand buffer
- if (mono_frames_size > stream->in.monoBufferSize)
- {
- stream->in.monoBuffer = PaWasapi_ReallocateMemory(stream->in.monoBuffer, (stream->in.monoBufferSize = mono_frames_size));
- if (stream->in.monoBuffer == NULL)
- {
- // release input buffer
- IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);
- // release output buffer
- IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);
+ // convert input mono
+ if (stream->in.monoMixer)
+ {
+ UINT32 mono_frames_size = i_processed * (stream->in.wavex.Format.wBitsPerSample / 8);
+ // expand buffer
+ if (mono_frames_size > stream->in.monoBufferSize)
+ {
+ stream->in.monoBuffer = PaWasapi_ReallocateMemory(stream->in.monoBuffer, (stream->in.monoBufferSize = mono_frames_size));
+ if (stream->in.monoBuffer == NULL)
+ {
+ // release input buffer
+ IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);
+ // release output buffer
+ IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);
- LogPaError(paInsufficientMemory);
- goto thread_error;
- }
- }
+ LogPaError(paInsufficientMemory);
+ goto thread_error;
+ }
+ }
- // mix 2 to 1 input channels
- stream->in.monoMixer(stream->in.monoBuffer, i_data, i_processed);
+ // mix 2 to 1 input channels
+ stream->in.monoMixer(stream->in.monoBuffer, i_data, i_processed);
- // replace buffer pointer
- i_data = (BYTE *)stream->in.monoBuffer;
- }
+ // replace buffer pointer
+ i_data = (BYTE *)stream->in.monoBuffer;
+ }
- // process
- processor[S_FULLDUPLEX].processor(i_data, i_processed, o_data, o_processed, processor[S_FULLDUPLEX].userData);
+ // process
+ processor[S_FULLDUPLEX].processor(i_data, i_processed, o_data, o_processed, processor[S_FULLDUPLEX].userData);
- // mix 1 to 2 output channels
- if (stream->out.monoBuffer)
- stream->out.monoMixer(o_data_host, stream->out.monoBuffer, o_processed);
+ // mix 1 to 2 output channels
+ if (stream->out.monoBuffer)
+ stream->out.monoMixer(o_data_host, stream->out.monoBuffer, o_processed);
- // release host output buffer
- if ((hr = IAudioRenderClient_ReleaseBuffer(stream->renderClient, o_processed, 0)) != S_OK)
- LogHostError(hr);
+ // release host output buffer
+ if ((hr = IAudioRenderClient_ReleaseBuffer(stream->renderClient, o_processed, 0)) != S_OK)
+ LogHostError(hr);
- o_frames -= o_processed;
- }
- else
- {
- if (stream->out.shareMode != AUDCLNT_SHAREMODE_SHARED)
- LogHostError(hr); // be silent in shared mode, try again next time
- }
- }
- else
- {
- i_processed = 0;
- goto fd_release_buffer_in;
- }
+ o_frames -= o_processed;
+ }
+ else
+ {
+ if (stream->out.shareMode != AUDCLNT_SHAREMODE_SHARED)
+ LogHostError(hr); // be silent in shared mode, try again next time
+ }
+ }
+ else
+ {
+ i_processed = 0;
+ goto fd_release_buffer_in;
+ }
fd_release_buffer_in:
- // release host input buffer
- if ((hr = IAudioCaptureClient_ReleaseBuffer(stream->captureClient, i_processed)) != S_OK)
- {
- LogHostError(hr);
- break;
- }
+ // release host input buffer
+ if ((hr = IAudioCaptureClient_ReleaseBuffer(stream->captureClient, i_processed)) != S_OK)
+ {
+ LogHostError(hr);
+ break;
+ }
- // break processing, input hasn't been accumulated yet
- if (i_processed == 0)
- break;
- }
+ // break processing, input hasn't been accumulated yet
+ if (i_processed == 0)
+ break;
+ }
- // Get next sleep time
- nextSleepTime = GetNextSleepTime(&timer, &scheduler, startTime, sleepTime);
+ // Get next sleep time
+ nextSleepTime = GetNextSleepTime(&timer, &scheduler, startTime, sleepTime);
- #ifdef PA_WASAPI_LOG_TIME_SLOTS
- startWaitTime = SystemTimer_GetTime(&timer);
- #endif
- }
- }
+ #ifdef PA_WASAPI_LOG_TIME_SLOTS
+ startWaitTime = SystemTimer_GetTime(&timer);
+ #endif
+ }
+ }
thread_end:
- // Process stop
- _StreamOnStop(stream);
+ // Process stop
+ _StreamOnStop(stream);
- // Release unmarshaled COM pointers
- FinishComPointers(stream, threadComInitialized);
+ // Release unmarshaled COM pointers
+ FinishComPointers(stream, threadComInitialized);
- // Restore system timer granularity
- SystemTimer_RestoreGranularity(&timer);
+ // Restore system timer granularity
+ SystemTimer_RestoreGranularity(&timer);
- // Notify: not running
- stream->running = FALSE;
+ // Notify: not running
+ stream->running = FALSE;
- // Notify: thread exited
- SetEvent(stream->hThreadExit);
+ // Notify: thread exited
+ SetEvent(stream->hThreadExit);
- // Notify: state
- NotifyStateChanged(stream, paWasapiStreamStateThreadStop, hr);
+ // Notify: state
+ NotifyStateChanged(stream, paWasapiStreamStateThreadStop, hr);
- return 0;
+ return 0;
thread_error:
- // Prevent deadlocking in Pa_StreamStart
- SetEvent(stream->hThreadStart);
+ // Prevent deadlocking in Pa_StreamStart
+ SetEvent(stream->hThreadStart);
- // Exit
- goto thread_end;
+ // Exit
+ goto thread_end;
}
// ------------------------------------------------------------------------------------------
void *PaWasapi_ReallocateMemory(void *prev, size_t size)
{
- void *ret = realloc(prev, size);
- if (ret == NULL)
- {
- PaWasapi_FreeMemory(prev);
- return NULL;
- }
- return ret;
+ void *ret = realloc(prev, size);
+ if (ret == NULL)
+ {
+ PaWasapi_FreeMemory(prev);
+ return NULL;
+ }
+ return ret;
}
// ------------------------------------------------------------------------------------------
void PaWasapi_FreeMemory(void *ptr)
{
- free(ptr);
+ free(ptr);
}
From 522f982158d2c7cb3d5ead593eed018821c10d4c Mon Sep 17 00:00:00 2001
From: dmitrykos
Date: Sat, 10 Oct 2020 00:42:20 +0300
Subject: [PATCH 018/157] wasapi: Refactored device list creation, if faulty
audio device is reported as active by WASAPI then it will not break device
list creation, silenced warnings when compiling for UWP platform.
---
src/hostapi/wasapi/pa_win_wasapi.c | 737 +++++++++++++++--------------
1 file changed, 386 insertions(+), 351 deletions(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index cdefe13..866d372 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -472,9 +472,6 @@ typedef struct
// this is the REAL number of devices, whether they are usefull to PA or not!
UINT32 deviceCount;
- WCHAR defaultRenderer[MAX_STR_LEN];
- WCHAR defaultCapturer[MAX_STR_LEN];
-
PaWasapiDeviceInfo *devInfo;
// is TRUE when WOW64 Vista/7 Workaround is needed
@@ -801,6 +798,9 @@ static BOOL SystemTimer_SetGranularity(SystemTimer *timer, UINT32 granularity)
timer->granularity = 0;
return FALSE;
}
+#else
+ (void)timer;
+ (void)granularity;
#endif
return TRUE;
@@ -817,6 +817,8 @@ static void SystemTimer_RestoreGranularity(SystemTimer *timer)
PRINT(("RestoreSystemTimer: timeEndPeriod(1) failed!\n"));
}
}
+#else
+ (void)timer;
#endif
}
@@ -829,6 +831,8 @@ static void SystemTimer_InitializeTimeGetter()
//! Get high-resolution time in milliseconds (using QPC by default).
static inline LONGLONG SystemTimer_GetTime(SystemTimer *timer)
{
+ (void)timer;
+
// QPC: https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
if (g_SystemTimerUseQpc)
{
@@ -1738,93 +1742,376 @@ static void NotifyStateChanged(PaWasapiStream *stream, UINT32 flags, HRESULT hr)
stream->fnStateHandler((PaStream *)stream, flags, hr, stream->pStateHandlerUserData);
}
+// ------------------------------------------------------------------------------------------
+static void FillBaseDeviceInfo(PaDeviceInfo *deviceInfo, PaHostApiIndex hostApiIndex)
+{
+ deviceInfo->structVersion = 2;
+ deviceInfo->hostApi = hostApiIndex;
+}
+
+// ------------------------------------------------------------------------------------------
+static PaError FillInactiveDeviceInfo(PaWasapiHostApiRepresentation *paWasapi, PaDeviceInfo *deviceInfo)
+{
+ if (deviceInfo->name == NULL)
+ deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, 1);
+
+ if (deviceInfo->name != NULL)
+ {
+ ((char *)deviceInfo->name)[0] = 0;
+ }
+ else
+ return paInsufficientMemory;
+
+ return paNoError;
+}
+
+// ------------------------------------------------------------------------------------------
+static PaError FillDeviceInfo(PaWasapiHostApiRepresentation *paWasapi, void *pEndPoints, INT32 index, const WCHAR *defaultRenderer,
+ const WCHAR *defaultCapturer, PaDeviceInfo *deviceInfo, PaWasapiDeviceInfo *wasapiDeviceInfo)
+{
+ HRESULT hr;
+ PaError result;
+ PaUtilHostApiRepresentation *hostApi = (PaUtilHostApiRepresentation *)paWasapi;
+
+#ifndef PA_WINRT
+ hr = IMMDeviceCollection_Item((IMMDeviceCollection *)pEndPoints, index, &wasapiDeviceInfo->device);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+
+ // getting ID
+ {
+ WCHAR *pszDeviceId;
+
+ hr = IMMDevice_GetId(wasapiDeviceInfo->device, &pszDeviceId);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+
+ wcsncpy(wasapiDeviceInfo->szDeviceID, pszDeviceId, MAX_STR_LEN - 1);
+ CoTaskMemFree(pszDeviceId);
+
+ if ((defaultCapturer != NULL) && (lstrcmpW(wasapiDeviceInfo->szDeviceID, defaultCapturer) == 0))
+ hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
+
+ if ((defaultRenderer != NULL) && (lstrcmpW(wasapiDeviceInfo->szDeviceID, defaultRenderer) == 0))
+ hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
+ }
+
+ hr = IMMDevice_GetState(wasapiDeviceInfo->device, &wasapiDeviceInfo->state);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+
+ if (wasapiDeviceInfo->state != DEVICE_STATE_ACTIVE)
+ {
+ PRINT(("WASAPI device: %d is not currently available (state:%d)\n", index, wasapiDeviceInfo->state));
+ }
+
+ // Get basic device info
+ {
+ IPropertyStore *pProperty;
+ IMMEndpoint *endpoint;
+ PROPVARIANT value;
+
+ hr = IMMDevice_OpenPropertyStore(wasapiDeviceInfo->device, STGM_READ, &pProperty);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+
+ // "Friendly" Name
+ {
+ PropVariantInit(&value);
+
+ hr = IPropertyStore_GetValue(pProperty, &PKEY_Device_FriendlyName, &value);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+
+ if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1)) == NULL)
+ {
+ result = paInsufficientMemory;
+ PropVariantClear(&value);
+ goto error;
+ }
+ if (value.pwszVal)
+ WideCharToMultiByte(CP_UTF8, 0, value.pwszVal, (int)wcslen(value.pwszVal), (char *)deviceInfo->name, MAX_STR_LEN - 1, 0, 0);
+ else
+ _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "baddev%d", index);
+
+ PropVariantClear(&value);
+
+ PA_DEBUG(("WASAPI:%d| name[%s]\n", index, deviceInfo->name));
+ }
+
+ // Default format
+ {
+ PropVariantInit(&value);
+
+ hr = IPropertyStore_GetValue(pProperty, &PKEY_AudioEngine_DeviceFormat, &value);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+
+ memcpy(&wasapiDeviceInfo->DefaultFormat, value.blob.pBlobData, min(sizeof(wasapiDeviceInfo->DefaultFormat), value.blob.cbSize));
+
+ PropVariantClear(&value);
+ }
+
+ // Form factor
+ {
+ PropVariantInit(&value);
+
+ hr = IPropertyStore_GetValue(pProperty, &PKEY_AudioEndpoint_FormFactor, &value);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+
+ // set
+ #if defined(DUMMYUNIONNAME) && defined(NONAMELESSUNION)
+ // avoid breaking strict-aliasing rules in such line: (EndpointFormFactor)(*((UINT *)(((WORD *)&value.wReserved3)+1)));
+ UINT v;
+ memcpy(&v, (((WORD *)&value.wReserved3) + 1), sizeof(v));
+ wasapiDeviceInfo->formFactor = (EndpointFormFactor)v;
+ #else
+ wasapiDeviceInfo->formFactor = (EndpointFormFactor)value.uintVal;
+ #endif
+
+ PA_DEBUG(("WASAPI:%d| form-factor[%d]\n", index, wasapiDeviceInfo->formFactor));
+
+ PropVariantClear(&value);
+ }
+
+ // Data flow (Renderer or Capture)
+ hr = IMMDevice_QueryInterface(wasapiDeviceInfo->device, &pa_IID_IMMEndpoint, (void **)&endpoint);
+ if (SUCCEEDED(hr))
+ {
+ hr = IMMEndpoint_GetDataFlow(endpoint, &wasapiDeviceInfo->flow);
+ SAFE_RELEASE(endpoint);
+ }
+
+ SAFE_RELEASE(pProperty);
+ }
+#else
+ (void)pEndPoints;
+ (void)defaultRenderer;
+ (void)defaultCapturer;
+#endif
+
+ // Getting a temporary IAudioClient for more fields
+ // we make sure NOT to call Initialize yet!
+ {
+ IAudioClient *tmpClient;
+ WAVEFORMATEX *mixFormat;
+
+ #ifdef PA_WINRT
+ // Set flow as ActivateAudioInterface depends on it and selects corresponding
+ // direction for the Audio Client
+ wasapiDeviceInfo->flow = (index == 0 ? eRender : eCapture);
+ #endif
+
+ // Create temp Audio Client instance to query additional details
+ hr = ActivateAudioInterface(wasapiDeviceInfo, NULL, &tmpClient);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+
+ // Get latency
+ hr = IAudioClient_GetDevicePeriod(tmpClient, &wasapiDeviceInfo->DefaultDevicePeriod, &wasapiDeviceInfo->MinimumDevicePeriod);
+ if (FAILED(hr))
+ {
+ PA_DEBUG(("WASAPI:%d| failed getting min/default periods by IAudioClient::GetDevicePeriod() with error[%08X], will use 30000/100000 hns\n", index, (UINT32)hr));
+
+ // assign WASAPI common values
+ wasapiDeviceInfo->DefaultDevicePeriod = 100000;
+ wasapiDeviceInfo->MinimumDevicePeriod = 30000;
+
+ // ignore error, let continue further without failing with paInternalError
+ hr = S_OK;
+ }
+
+ // Get mix format
+ hr = IAudioClient_GetMixFormat(tmpClient, &mixFormat);
+ if (SUCCEEDED(hr))
+ {
+ memcpy(&wasapiDeviceInfo->MixFormat, mixFormat, min(sizeof(wasapiDeviceInfo->MixFormat), (sizeof(*mixFormat) + mixFormat->cbSize)));
+ CoTaskMemFree(mixFormat);
+ }
+
+ // Register WINRT device
+ #ifdef PA_WINRT
+ if (SUCCEEDED(hr))
+ {
+ // Default device
+ if (index == 0)
+ hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
+ else
+ hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
+
+ // State
+ wasapiDeviceInfo->state = DEVICE_STATE_ACTIVE;
+
+ // Default format is always a mix format
+ wasapiDeviceInfo->DefaultFormat = wasapiDeviceInfo->MixFormat;
+
+ // Form-factor
+ wasapiDeviceInfo->formFactor = UnknownFormFactor;
+
+ // Name
+ if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1)) == NULL)
+ {
+ SAFE_RELEASE(tmpClient);
+ result = paInsufficientMemory;
+ goto error;
+ }
+ _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "WASAPI_%s:%d", (index == 0 ? "Output" : "Input"), index);
+ PA_DEBUG(("WASAPI:%d| name[%s]\n", index, deviceInfo->name));
+ }
+ #endif
+
+ // Release tmp client
+ SAFE_RELEASE(tmpClient);
+
+ if (hr != S_OK)
+ {
+ //davidv: this happened with my hardware, previously for that same device in DirectSound:
+ //Digital Output (Realtek AC'97 Audio)'s GUID: {0x38f2cf50,0x7b4c,0x4740,0x86,0xeb,0xd4,0x38,0x66,0xd8,0xc8, 0x9f}
+ //so something must be _really_ wrong with this device, TODO handle this better. We kind of need GetMixFormat
+ LogHostError(hr);
+ result = paInternalError;
+ goto error;
+ }
+ }
+
+ // Fill basic device data
+ deviceInfo->maxInputChannels = 0;
+ deviceInfo->maxOutputChannels = 0;
+ deviceInfo->defaultSampleRate = wasapiDeviceInfo->MixFormat.Format.nSamplesPerSec;
+ switch (wasapiDeviceInfo->flow)
+ {
+ case eRender: {
+ deviceInfo->maxOutputChannels = wasapiDeviceInfo->MixFormat.Format.nChannels;
+ deviceInfo->defaultHighOutputLatency = nano100ToSeconds(wasapiDeviceInfo->DefaultDevicePeriod);
+ deviceInfo->defaultLowOutputLatency = nano100ToSeconds(wasapiDeviceInfo->MinimumDevicePeriod);
+ PA_DEBUG(("WASAPI:%d| def.SR[%d] max.CH[%d] latency{hi[%f] lo[%f]}\n", index, (UINT32)deviceInfo->defaultSampleRate,
+ deviceInfo->maxOutputChannels, (float)deviceInfo->defaultHighOutputLatency, (float)deviceInfo->defaultLowOutputLatency));
+ break;}
+ case eCapture: {
+ deviceInfo->maxInputChannels = wasapiDeviceInfo->MixFormat.Format.nChannels;
+ deviceInfo->defaultHighInputLatency = nano100ToSeconds(wasapiDeviceInfo->DefaultDevicePeriod);
+ deviceInfo->defaultLowInputLatency = nano100ToSeconds(wasapiDeviceInfo->MinimumDevicePeriod);
+ PA_DEBUG(("WASAPI:%d| def.SR[%d] max.CH[%d] latency{hi[%f] lo[%f]}\n", index, (UINT32)deviceInfo->defaultSampleRate,
+ deviceInfo->maxInputChannels, (float)deviceInfo->defaultHighInputLatency, (float)deviceInfo->defaultLowInputLatency));
+ break; }
+ default:
+ PRINT(("WASAPI:%d| bad Data Flow!\n", index));
+ result = paInternalError;
+ goto error;
+ }
+
+ return paNoError;
+
+error:
+
+ PRINT(("WASAPI: failed filling device info for device index[%d] - error[%d|%s]\n", index, result, Pa_GetErrorText(result)));
+
+ return result;
+}
+
+// ------------------------------------------------------------------------------------------
+static PaDeviceInfo *AllocateDeviceListMemory(PaWasapiHostApiRepresentation *paWasapi)
+{
+ PaUtilHostApiRepresentation *hostApi = (PaUtilHostApiRepresentation *)paWasapi;
+ PaDeviceInfo *deviceInfoArray = NULL;
+
+ if ((paWasapi->devInfo = (PaWasapiDeviceInfo *)PaUtil_GroupAllocateMemory(paWasapi->allocations,
+ sizeof(PaWasapiDeviceInfo) * paWasapi->deviceCount)) == NULL)
+ {
+ return NULL;
+ }
+ memset(paWasapi->devInfo, 0, sizeof(PaWasapiDeviceInfo) * paWasapi->deviceCount);
+
+ if (paWasapi->deviceCount != 0)
+ {
+ UINT32 deviceCount = paWasapi->deviceCount;
+ #if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
+ if (deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT)
+ deviceCount = PA_WASAPI_MAX_CONST_DEVICE_COUNT;
+ #endif
+
+ if ((hostApi->deviceInfos = (PaDeviceInfo **)PaUtil_GroupAllocateMemory(paWasapi->allocations,
+ sizeof(PaDeviceInfo *) * deviceCount)) == NULL)
+ {
+ return NULL;
+ }
+ for (UINT32 i = 0; i < deviceCount; ++i)
+ hostApi->deviceInfos[i] = NULL;
+
+ // Allocate all device info structs in a contiguous block
+ if ((deviceInfoArray = (PaDeviceInfo *)PaUtil_GroupAllocateMemory(paWasapi->allocations,
+ sizeof(PaDeviceInfo) * deviceCount)) == NULL)
+ {
+ return NULL;
+ }
+ memset(deviceInfoArray, 0, sizeof(PaDeviceInfo) * deviceCount);
+ }
+
+ return deviceInfoArray;
+}
+
// ------------------------------------------------------------------------------------------
static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostApiIndex hostApiIndex)
{
PaUtilHostApiRepresentation *hostApi = (PaUtilHostApiRepresentation *)paWasapi;
PaError result = paNoError;
PaDeviceInfo *deviceInfoArray;
- HRESULT hr = S_OK;
UINT i;
+ WCHAR *defaultRenderer = NULL;
+ WCHAR *defaultCapturer = NULL;
#ifndef PA_WINRT
- IMMDeviceCollection* pEndPoints = NULL;
+ HRESULT hr;
+ IMMDeviceCollection *pEndPoints = NULL;
IMMDeviceEnumerator *pEnumerator = NULL;
-#endif
+#else
+ void *pEndPoints = NULL;
IAudioClient *tmpClient;
+#endif
// Make sure device list empty
if ((paWasapi->deviceCount != 0) || (hostApi->info.deviceCount != 0))
return paInternalError;
#ifndef PA_WINRT
- hr = CoCreateInstance(&pa_CLSID_IMMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER,
- &pa_IID_IMMDeviceEnumerator, (void **)&pEnumerator);
-
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
+ hr = CoCreateInstance(&pa_CLSID_IMMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER,
+ &pa_IID_IMMDeviceEnumerator, (void **)&pEnumerator);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- // getting default device ids in the eMultimedia "role"
+ // Get default render and capture devices
{
+ IMMDevice *device;
+
+ hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(pEnumerator, eRender, eMultimedia, &device);
+ if (hr != S_OK)
{
- IMMDevice *defaultRenderer = NULL;
- hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(pEnumerator, eRender, eMultimedia, &defaultRenderer);
- if (hr != S_OK)
+ if (hr != E_NOTFOUND)
{
- if (hr != E_NOTFOUND) {
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- }
- }
- else
- {
- WCHAR *pszDeviceId = NULL;
- hr = IMMDevice_GetId(defaultRenderer, &pszDeviceId);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- wcsncpy(paWasapi->defaultRenderer, pszDeviceId, MAX_STR_LEN-1);
- CoTaskMemFree(pszDeviceId);
- IMMDevice_Release(defaultRenderer);
}
}
-
+ else
{
- IMMDevice *defaultCapturer = NULL;
- hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(pEnumerator, eCapture, eMultimedia, &defaultCapturer);
- if (hr != S_OK)
+ hr = IMMDevice_GetId(device, &defaultRenderer);
+ IMMDevice_Release(device);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ }
+
+ hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(pEnumerator, eCapture, eMultimedia, &device);
+ if (hr != S_OK)
+ {
+ if (hr != E_NOTFOUND)
{
- if (hr != E_NOTFOUND) {
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- }
- }
- else
- {
- WCHAR *pszDeviceId = NULL;
- hr = IMMDevice_GetId(defaultCapturer, &pszDeviceId);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- wcsncpy(paWasapi->defaultCapturer, pszDeviceId, MAX_STR_LEN-1);
- CoTaskMemFree(pszDeviceId);
- IMMDevice_Release(defaultCapturer);
}
}
+ else
+ {
+ hr = IMMDevice_GetId(device, &defaultCapturer);
+ IMMDevice_Release(device);
+ IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ }
}
+ // Get all currently active devices
hr = IMMDeviceEnumerator_EnumAudioEndpoints(pEnumerator, eAll, DEVICE_STATE_ACTIVE, &pEndPoints);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
+ // Get device count
hr = IMMDeviceCollection_GetCount(pEndPoints, &paWasapi->deviceCount);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
-
#else
// Determine number of available devices by activating AudioClient for render and capture data flows
if (SUCCEEDED(ActivateAudioInterface_WINRT(eRender, GetAudioClientIID(), &tmpClient)))
@@ -1839,331 +2126,79 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
}
#endif
- paWasapi->devInfo = (PaWasapiDeviceInfo *)PaUtil_GroupAllocateMemory(
- paWasapi->allocations, sizeof(PaWasapiDeviceInfo) * paWasapi->deviceCount);
- if (paWasapi->devInfo == NULL)
+ // Allocate memory for the device list
+ if ((deviceInfoArray = AllocateDeviceListMemory(paWasapi)) == NULL)
{
result = paInsufficientMemory;
goto error;
}
- memset(paWasapi->devInfo, 0, sizeof(PaWasapiDeviceInfo) * paWasapi->deviceCount);
- if (paWasapi->deviceCount > 0)
+ // Fill WASAPI device info
+ for (i = 0; i < paWasapi->deviceCount; ++i)
{
- UINT32 deviceCount = paWasapi->deviceCount;
- #if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
- if (deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT)
- deviceCount = PA_WASAPI_MAX_CONST_DEVICE_COUNT;
- #endif
+ PaDeviceInfo *deviceInfo = &deviceInfoArray[i];
- hostApi->deviceInfos = (PaDeviceInfo **)PaUtil_GroupAllocateMemory(
- paWasapi->allocations, sizeof(PaDeviceInfo *) * deviceCount);
- if (hostApi->deviceInfos == NULL)
+ PA_DEBUG(("WASAPI: device idx: %02d\n", i));
+ PA_DEBUG(("WASAPI: ---------------\n"));
+
+ FillBaseDeviceInfo(deviceInfo, hostApiIndex);
+
+ if ((result = FillDeviceInfo(paWasapi, pEndPoints, i, defaultRenderer, defaultCapturer,
+ deviceInfo, &paWasapi->devInfo[i])) != paNoError)
{
- result = paInsufficientMemory;
- goto error;
+ // Faulty device is made inactive
+ if ((result = FillInactiveDeviceInfo(paWasapi, deviceInfo)) != paNoError)
+ goto error;
}
- /* allocate all device info structs in a contiguous block */
- deviceInfoArray = (PaDeviceInfo *)PaUtil_GroupAllocateMemory(
- paWasapi->allocations, sizeof(PaDeviceInfo) * deviceCount);
- if (deviceInfoArray == NULL)
+ hostApi->deviceInfos[i] = deviceInfo;
+ ++hostApi->info.deviceCount;
+ }
+
+ // Fill the remaining slots with inactive device info
+#if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
+ if (hostApi->info.deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT)
+ {
+ for (i = hostApi->info.deviceCount; i < PA_WASAPI_MAX_CONST_DEVICE_COUNT; ++i)
{
- result = paInsufficientMemory;
- goto error;
- }
- memset(deviceInfoArray, 0, sizeof(PaDeviceInfo) * deviceCount);
+ PaDeviceInfo *deviceInfo = &deviceInfoArray[i];
- for (i = 0; i < paWasapi->deviceCount; ++i)
- {
- PaDeviceInfo *deviceInfo = &deviceInfoArray[i];
- deviceInfo->structVersion = 2;
- deviceInfo->hostApi = hostApiIndex;
+ FillBaseDeviceInfo(deviceInfo, hostApiIndex);
- PA_DEBUG(("WASAPI: device idx: %02d\n", i));
- PA_DEBUG(("WASAPI: ---------------\n"));
-
- #ifndef PA_WINRT
- hr = IMMDeviceCollection_Item(pEndPoints, i, &paWasapi->devInfo[i].device);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
-
- // getting ID
- {
- WCHAR *pszDeviceId = NULL;
- hr = IMMDevice_GetId(paWasapi->devInfo[i].device, &pszDeviceId);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hr, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- wcsncpy(paWasapi->devInfo[i].szDeviceID, pszDeviceId, MAX_STR_LEN-1);
- CoTaskMemFree(pszDeviceId);
-
- if (lstrcmpW(paWasapi->devInfo[i].szDeviceID, paWasapi->defaultCapturer) == 0)
- {// we found the default input!
- hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
- }
- if (lstrcmpW(paWasapi->devInfo[i].szDeviceID, paWasapi->defaultRenderer) == 0)
- {// we found the default output!
- hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
- }
- }
-
- hr = IMMDevice_GetState(paWasapi->devInfo[i].device, &paWasapi->devInfo[i].state);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
-
- if (paWasapi->devInfo[i].state != DEVICE_STATE_ACTIVE)
- {
- PRINT(("WASAPI device: %d is not currently available (state:%d)\n", i, paWasapi->devInfo[i].state));
- }
-
- {
- IPropertyStore *pProperty;
- hr = IMMDevice_OpenPropertyStore(paWasapi->devInfo[i].device, STGM_READ, &pProperty);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
-
- // "Friendly" Name
- {
- PROPVARIANT value;
- PropVariantInit(&value);
- hr = IPropertyStore_GetValue(pProperty, &PKEY_Device_FriendlyName, &value);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1)) == NULL)
- {
- result = paInsufficientMemory;
- goto error;
- }
- if (value.pwszVal)
- WideCharToMultiByte(CP_UTF8, 0, value.pwszVal, (int)wcslen(value.pwszVal), (char *)deviceInfo->name, MAX_STR_LEN - 1, 0, 0);
- else
- _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "baddev%d", i);
- PropVariantClear(&value);
- PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
- }
-
- // Default format
- {
- PROPVARIANT value;
- PropVariantInit(&value);
- hr = IPropertyStore_GetValue(pProperty, &PKEY_AudioEngine_DeviceFormat, &value);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- memcpy(&paWasapi->devInfo[i].DefaultFormat, value.blob.pBlobData, min(sizeof(paWasapi->devInfo[i].DefaultFormat), value.blob.cbSize));
- // cleanup
- PropVariantClear(&value);
- }
-
- // Formfactor
- {
- PROPVARIANT value;
- PropVariantInit(&value);
- hr = IPropertyStore_GetValue(pProperty, &PKEY_AudioEndpoint_FormFactor, &value);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- // set
- #if defined(DUMMYUNIONNAME) && defined(NONAMELESSUNION)
- // avoid breaking strict-aliasing rules in such line: (EndpointFormFactor)(*((UINT *)(((WORD *)&value.wReserved3)+1)));
- UINT v;
- memcpy(&v, (((WORD *)&value.wReserved3)+1), sizeof(v));
- paWasapi->devInfo[i].formFactor = (EndpointFormFactor)v;
- #else
- paWasapi->devInfo[i].formFactor = (EndpointFormFactor)value.uintVal;
- #endif
- PA_DEBUG(("WASAPI:%d| form-factor[%d]\n", i, paWasapi->devInfo[i].formFactor));
- // cleanup
- PropVariantClear(&value);
- }
-
- SAFE_RELEASE(pProperty);
- }
-
- // Endpoint data
- {
- IMMEndpoint *endpoint = NULL;
- hr = IMMDevice_QueryInterface(paWasapi->devInfo[i].device, &pa_IID_IMMEndpoint, (void **)&endpoint);
- if (SUCCEEDED(hr))
- {
- hr = IMMEndpoint_GetDataFlow(endpoint, &paWasapi->devInfo[i].flow);
- SAFE_RELEASE(endpoint);
- }
- }
- #endif
-
- // Getting a temporary IAudioClient for more fields
- // we make sure NOT to call Initialize yet!
- {
- #ifdef PA_WINRT
- // Set flow as ActivateAudioInterface depends on it and selects corresponding
- // direction for the Audio Client
- paWasapi->devInfo[i].flow = (i == 0 ? eRender : eCapture);
- #endif
-
- // Create temp Audio Client instance to query additional details
- hr = ActivateAudioInterface(&paWasapi->devInfo[i], NULL, &tmpClient);
- // We need to set the result to a value otherwise we will return paNoError
- // [IF_FAILED_JUMP(hResult, error);]
- IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
-
- // Get latency
- hr = IAudioClient_GetDevicePeriod(tmpClient,
- &paWasapi->devInfo[i].DefaultDevicePeriod,
- &paWasapi->devInfo[i].MinimumDevicePeriod);
- if (FAILED(hr))
- {
- PA_DEBUG(("WASAPI:%d| failed getting min/default periods by IAudioClient::GetDevicePeriod() with error[%08X], will use 30000/100000 hns\n", i, (UINT32)hr));
-
- // assign WASAPI common values
- paWasapi->devInfo[i].DefaultDevicePeriod = 100000;
- paWasapi->devInfo[i].MinimumDevicePeriod = 30000;
-
- // ignore error, let continue further without failing with paInternalError
- hr = S_OK;
- }
-
- // Get mix format
- {
- WAVEFORMATEX *mixFormat;
-
- hr = IAudioClient_GetMixFormat(tmpClient, &mixFormat);
- if (SUCCEEDED(hr))
- {
- memcpy(&paWasapi->devInfo[i].MixFormat, mixFormat, min(sizeof(paWasapi->devInfo[i].MixFormat), (sizeof(*mixFormat) + mixFormat->cbSize)));
- CoTaskMemFree(mixFormat);
- }
- }
-
- // Register WINRT device
- #ifdef PA_WINRT
- if (SUCCEEDED(hr))
- {
- // Default device
- if (i == 0)
- hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
- else
- hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
-
- // State
- paWasapi->devInfo[i].state = DEVICE_STATE_ACTIVE;
-
- // Default format is always a mix format
- paWasapi->devInfo[i].DefaultFormat = paWasapi->devInfo[i].MixFormat;
-
- // Form-factor
- paWasapi->devInfo[i].formFactor = UnknownFormFactor;
-
- // Name
- if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1)) == NULL)
- {
- SAFE_RELEASE(tmpClient);
- result = paInsufficientMemory;
- goto error;
- }
- _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "WASAPI_%s:%d", (i == 0 ? "Output" : "Input"), i);
- PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
- }
- #endif
-
- // Release tmp client
- SAFE_RELEASE(tmpClient);
-
- if (hr != S_OK)
- {
- //davidv: this happened with my hardware, previously for that same device in DirectSound:
- //Digital Output (Realtek AC'97 Audio)'s GUID: {0x38f2cf50,0x7b4c,0x4740,0x86,0xeb,0xd4,0x38,0x66,0xd8,0xc8, 0x9f}
- //so something must be _really_ wrong with this device, TODO handle this better. We kind of need GetMixFormat
- LogHostError(hr);
- // We need to set the result to a value otherwise we will return paNoError
- result = paInternalError;
- goto error;
- }
- }
-
- // we can now fill in portaudio device data
- deviceInfo->maxInputChannels = 0;
- deviceInfo->maxOutputChannels = 0;
- deviceInfo->defaultSampleRate = paWasapi->devInfo[i].MixFormat.Format.nSamplesPerSec;
- switch (paWasapi->devInfo[i].flow)
- {
- case eRender: {
- deviceInfo->maxOutputChannels = paWasapi->devInfo[i].MixFormat.Format.nChannels;
- deviceInfo->defaultHighOutputLatency = nano100ToSeconds(paWasapi->devInfo[i].DefaultDevicePeriod);
- deviceInfo->defaultLowOutputLatency = nano100ToSeconds(paWasapi->devInfo[i].MinimumDevicePeriod);
- PA_DEBUG(("WASAPI:%d| def.SR[%d] max.CH[%d] latency{hi[%f] lo[%f]}\n", i, (UINT32)deviceInfo->defaultSampleRate,
- deviceInfo->maxOutputChannels, (float)deviceInfo->defaultHighOutputLatency, (float)deviceInfo->defaultLowOutputLatency));
- break;}
- case eCapture: {
- deviceInfo->maxInputChannels = paWasapi->devInfo[i].MixFormat.Format.nChannels;
- deviceInfo->defaultHighInputLatency = nano100ToSeconds(paWasapi->devInfo[i].DefaultDevicePeriod);
- deviceInfo->defaultLowInputLatency = nano100ToSeconds(paWasapi->devInfo[i].MinimumDevicePeriod);
- PA_DEBUG(("WASAPI:%d| def.SR[%d] max.CH[%d] latency{hi[%f] lo[%f]}\n", i, (UINT32)deviceInfo->defaultSampleRate,
- deviceInfo->maxInputChannels, (float)deviceInfo->defaultHighInputLatency, (float)deviceInfo->defaultLowInputLatency));
- break; }
- default:
- PRINT(("WASAPI:%d| bad Data Flow!\n", i));
- // We need to set the result to a value otherwise we will return paNoError
- result = paInternalError;
- //continue; // do not skip from list, allow to initialize
- break;
- }
+ if ((result = FillInactiveDeviceInfo(paWasapi, deviceInfo)) != paNoError)
+ goto error;
hostApi->deviceInfos[i] = deviceInfo;
++hostApi->info.deviceCount;
}
-
- #if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
- if (hostApi->info.deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT)
- {
- for (i = hostApi->info.deviceCount; i < PA_WASAPI_MAX_CONST_DEVICE_COUNT; ++i)
- {
- PaDeviceInfo *deviceInfo = &deviceInfoArray[i];
- deviceInfo->structVersion = 2;
- deviceInfo->hostApi = hostApiIndex;
-
- if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, 1)) == NULL)
- {
- result = paInsufficientMemory;
- goto error;
- }
- ((char *)deviceInfo->name)[0] = 0;
-
- hostApi->deviceInfos[i] = deviceInfo;
- ++hostApi->info.deviceCount;
- }
- }
- #endif
}
+#endif
+
+ // Clear any non-fatal errors
+ result = paNoError;
+
+ PRINT(("WASAPI: device list ok - found %d devices\n", paWasapi->deviceCount));
+
+done:
#ifndef PA_WINRT
+ CoTaskMemFree(defaultRenderer);
+ CoTaskMemFree(defaultCapturer);
SAFE_RELEASE(pEndPoints);
SAFE_RELEASE(pEnumerator);
#endif
- PRINT(("WASAPI: device list created ok\n"));
-
- return paNoError;
+ return result;
error:
-
- PRINT(("WASAPI: failed %s error[%d|%s]\n", __FUNCTION__, result, Pa_GetErrorText(result)));
-
-#ifndef PA_WINRT
- SAFE_RELEASE(pEndPoints);
- SAFE_RELEASE(pEnumerator);
-#endif
-
+
// Safety if error was not set so that we do not think initialize was a success
if (result == paNoError)
result = paInternalError;
- return result;
+ PRINT(("WASAPI: failed to create device list - error[%d|%s]\n", result, Pa_GetErrorText(result)));
+
+ goto done;
}
// ------------------------------------------------------------------------------------------
@@ -5637,7 +5672,7 @@ static void FinishComPointers(PaWasapiStream *stream, BOOL threadComInitialized)
PA_THREAD_FUNC ProcThreadEvent(void *param)
{
PaWasapiHostProcessor processor[S_COUNT];
- HRESULT hr;
+ HRESULT hr = S_OK;
DWORD dwResult;
PaWasapiStream *stream = (PaWasapiStream *)param;
PaWasapiHostProcessor defaultProcessor;
@@ -5931,7 +5966,7 @@ static inline INT32 GetNextSleepTime(SystemTimer *timer, ThreadIdleScheduler *sc
PA_THREAD_FUNC ProcThreadPoll(void *param)
{
PaWasapiHostProcessor processor[S_COUNT];
- HRESULT hr;
+ HRESULT hr = S_OK;
PaWasapiStream *stream = (PaWasapiStream *)param;
PaWasapiHostProcessor defaultProcessor;
INT32 i;
From 6bb858643b55834b12664401e9df7fe1899a20ef Mon Sep 17 00:00:00 2001
From: dmitrykos
Date: Thu, 26 Mar 2020 20:50:52 +0200
Subject: [PATCH 019/157] alsa: Introduce possibility to ignore all ALSA plugin
devices by setting the environment variable PA_ALSA_IGNORE_ALL_PLUGINS to
non-0. Fixed logic of guarding assertion in BuildDeviceList() when only one
or none PCM device is available (may occur if PA_ALSA_IGNORE_ALL_PLUGINS is
set to non-0 or when device has no any audio device available, including
plugin devices).
---
src/hostapi/alsa/pa_linux_alsa.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c
index 584cde8..c92f9aa 100644
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -1066,6 +1066,10 @@ static int IgnorePlugin( const char *pluginId )
static const char *ignoredPlugins[] = {"hw", "plughw", "plug", "dsnoop", "tee",
"file", "null", "shm", "cards", "rate_convert", NULL};
int i = 0;
+
+ if( getenv( "PA_ALSA_IGNORE_ALL_PLUGINS" ) && atoi( getenv( "PA_ALSA_IGNORE_ALL_PLUGINS") ) )
+ return 1;
+
while( ignoredPlugins[i] )
{
if( !strcmp( pluginId, ignoredPlugins[i] ) )
@@ -1327,6 +1331,8 @@ static PaError BuildDeviceList( PaAlsaHostApiRepresentation *alsaApi )
paInsufficientMemory );
snprintf( deviceName, len, "%s: %s (%s)", cardName, infoName, buf );
+ PA_DEBUG(( "%s: Found device [%d]: %s\n", __FUNCTION__, numDeviceNames, deviceName ));
+
++numDeviceNames;
if( !hwDevInfos || numDeviceNames > maxDeviceNames )
{
@@ -1450,7 +1456,7 @@ static PaError BuildDeviceList( PaAlsaHostApiRepresentation *alsaApi )
PA_ENSURE( FillInDevInfo( alsaApi, hwInfo, blocking, devInfo, &devIdx ) );
}
- assert( devIdx < numDeviceNames );
+ assert( devIdx <= numDeviceNames );
/* Now inspect 'dmix' and 'default' plugins */
for( i = 0; i < numDeviceNames; ++i )
{
From bd5b68a62b9ed4cca652b5c7875d93f0510dac04 Mon Sep 17 00:00:00 2001
From: Etienne Dechamps
Date: Sun, 18 Oct 2020 10:42:55 +0200
Subject: [PATCH 020/157] Ignore files generated by Visual Studio 2017/2019.
---
.gitignore | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/.gitignore b/.gitignore
index 892ddfc..8efca60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,9 @@ portaudio-2.0.pc
*.exe
*.out
*.app
+
+# Visual Studio 2017/2019 state folder
+.vs/
+
+# Visual Studio CMake build output folder
+out/
From 5bc01421c830f0785d5634acfc53ee0613bdb28e Mon Sep 17 00:00:00 2001
From: Etienne Dechamps
Date: Sun, 18 Oct 2020 11:09:40 +0200
Subject: [PATCH 021/157] Add a GitHub action for cross-compiling to MinGW via
CMake.
---
.github/workflows/c-cpp.yml | 13 +++++++++++++
i686-w64-mingw32.cmake | 17 +++++++++++++++++
2 files changed, 30 insertions(+)
create mode 100644 i686-w64-mingw32.cmake
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
index 10ecb69..ea0f17b 100644
--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -17,3 +17,16 @@ jobs:
run: ./configure
- name: make
run: make
+
+ build-cmake-mingw:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: apt
+ run: sudo apt-get install mingw-w64
+ - name: cmake
+ run: cmake -DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake .
+ - name: make
+ run: make
diff --git a/i686-w64-mingw32.cmake b/i686-w64-mingw32.cmake
new file mode 100644
index 0000000..c3331b6
--- /dev/null
+++ b/i686-w64-mingw32.cmake
@@ -0,0 +1,17 @@
+# CMake Toolchain file for cross-compiling PortAudio to i686-w64-mingw32
+# Inspired from: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/cross_compiling/Mingw
+# Example usage: $ cmake -DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake .
+# i686-w64-mingw32 needs to be installed for this to work. On Debian-based
+# distributions the package is typically named `mingw-w64`.
+
+SET(CMAKE_SYSTEM_NAME Windows)
+
+SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
+SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
+SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
+
+SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
From 58fe947b7fdb74a1010e2a3619ea2c7ff9c929dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?=
Date: Tue, 6 Oct 2020 23:07:15 +0200
Subject: [PATCH 022/157] Add support for enabling dynamic alsa loading in
CMakeLists.txt
It had been added to the source code a long time ago, but was not integrated to the
build system.
---
CMakeLists.txt | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4fbb3a8..0302ae8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -293,6 +293,7 @@ ELSE()
FIND_PACKAGE(ALSA)
IF(ALSA_FOUND)
OPTION(PA_USE_ALSA "Enable support for ALSA" ON)
+ OPTION(PA_ALSA_DYNAMIC "Enable loading ALSA through dlopen" OFF)
ELSE()
OPTION(PA_USE_ALSA "Enable support for ALSA" OFF)
ENDIF()
@@ -303,8 +304,14 @@ ELSE()
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_linux_alsa.h)
SET(PA_SOURCES ${PA_SOURCES} ${PA_ALSA_SOURCES})
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PA_USE_ALSA)
- SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ${ALSA_LIBRARIES})
- SET(PA_PKGCONFIG_LDFLAGS "${PA_PKGCONFIG_LDFLAGS} -lasound")
+ IF(PA_ALSA_DYNAMIC)
+ SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PA_ALSA_DYNAMIC)
+ SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ${CMAKE_DL_LIBS})
+ SET(PA_PKGCONFIG_LDFLAGS "${PA_PKGCONFIG_LDFLAGS} -l${CMAKE_DL_LIBS}")
+ ELSE()
+ SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ${ALSA_LIBRARIES})
+ SET(PA_PKGCONFIG_LDFLAGS "${PA_PKGCONFIG_LDFLAGS} -lasound")
+ ENDIF()
ENDIF()
ENDIF()
From e96c5dbdec277fa59a432894bae65342cfbd4cc6 Mon Sep 17 00:00:00 2001
From: Etienne Dechamps
Date: Sun, 18 Oct 2020 10:48:57 +0200
Subject: [PATCH 023/157] Add a GitHub action for building with CMake.
---
.github/workflows/c-cpp.yml | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
index ea0f17b..a9fb33f 100644
--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -18,6 +18,17 @@ jobs:
- name: make
run: make
+ build-cmake:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: cmake
+ run: cmake .
+ - name: make
+ run: make
+
build-cmake-mingw:
runs-on: ubuntu-latest
From 9d3e583ce50a075ff36d9050bf7ee9fcca88f6ca Mon Sep 17 00:00:00 2001
From: Etienne Dechamps
Date: Sun, 18 Oct 2020 13:06:03 +0200
Subject: [PATCH 024/157] Add a GitHub action for building with CMake on MSVC.
---
.github/workflows/c-cpp.yml | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
index a9fb33f..180b46b 100644
--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -29,6 +29,17 @@ jobs:
- name: make
run: make
+ build-cmake-msvc:
+
+ runs-on: windows-latest
+
+ steps:
+ - uses: actions/checkout@v1
+ - name: cmake
+ run: cmake .
+ - name: build
+ run: cmake --build .
+
build-cmake-mingw:
runs-on: ubuntu-latest
From b1a09028525629a5d7dc9bc4189264e729f47ed8 Mon Sep 17 00:00:00 2001
From: "Hool, Rory"
Date: Thu, 22 Oct 2020 13:53:56 -0400
Subject: [PATCH 025/157] Replace usage of deprecated component manager APIs on
10.6+
These APIs are deprecated in 10.8+ and are disabled on 11.0(10.16)+ https://developer.apple.com/documentation/coreservices/carbon_core/component_manager?language=objc
> "This application, or a library it uses, is using the deprecated Component Manager for hosting Audio Components. This is not supported when rebuilding against the 10.16 or later SDK. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h."
---
src/hostapi/coreaudio/pa_mac_core.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index 257e9de..a0eb6fd 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -1173,8 +1173,13 @@ static PaError OpenAndSetupOneAudioUnit(
const double sampleRate,
void *refCon )
{
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
+ AudioComponentDescription desc;
+ AudioComponent comp;
+#else
ComponentDescription desc;
Component comp;
+#endif
/*An Apple TN suggests using CAStreamBasicDescription, but that is C++*/
AudioStreamBasicDescription desiredFormat;
OSStatus result = noErr;
@@ -1245,7 +1250,11 @@ static PaError OpenAndSetupOneAudioUnit(
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
/* -- find the component -- */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
+ comp = AudioComponentFindNext( NULL, &desc );
+#else
comp = FindNextComponent( NULL, &desc );
+#endif
if( !comp )
{
DBUG( ( "AUHAL component not found." ) );
@@ -1254,7 +1263,11 @@ static PaError OpenAndSetupOneAudioUnit(
return paUnanticipatedHostError;
}
/* -- open it -- */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
+ result = AudioComponentInstanceNew( comp, audioUnit );
+#else
result = OpenAComponent( comp, audioUnit );
+#endif
if( result )
{
DBUG( ( "Failed to open AUHAL component." ) );
@@ -1607,7 +1620,12 @@ static PaError OpenAndSetupOneAudioUnit(
#undef ERR_WRAP
error:
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
+ AudioComponentInstanceDispose( *audioUnit );
+#else
CloseComponent( *audioUnit );
+#endif
*audioUnit = NULL;
if( result )
return PaMacCore_SetError( result, line, 1 );
@@ -2645,13 +2663,21 @@ static PaError CloseStream( PaStream* s )
}
if( stream->outputUnit && stream->outputUnit != stream->inputUnit ) {
AudioUnitUninitialize( stream->outputUnit );
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
+ AudioComponentInstanceDispose( stream->outputUnit );
+#else
CloseComponent( stream->outputUnit );
+#endif
}
stream->outputUnit = NULL;
if( stream->inputUnit )
{
AudioUnitUninitialize( stream->inputUnit );
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
+ AudioComponentInstanceDispose( stream->inputUnit );
+#else
CloseComponent( stream->inputUnit );
+#endif
stream->inputUnit = NULL;
}
if( stream->inputRingBuffer.buffer )
From a5fb8d94aa77c517022f9a6b112acb3cf61362dc Mon Sep 17 00:00:00 2001
From: dmitrykos
Date: Mon, 26 Oct 2020 16:40:25 +0200
Subject: [PATCH 026/157] wasapi: Support multiple devices in the device list
on Windows UWP/WinRT platform. All UWP/WinRT functions are now prefixed as
PaWasapiWinrt_ to be clearly visible, therefore
PaWasapi_SetDefaultInterfaceId() was renamed to
PaWasapiWinrt_SetDefaultDeviceId(). Expanded Important notes regarding
UWP/WinRT platform and how to make the fully-functional device list with the
corresponding pseudo-code example for easier understanding of the
functionality.
---
include/pa_win_wasapi.h | 128 ++++++++--
src/hostapi/wasapi/pa_win_wasapi.c | 377 ++++++++++++++++++++---------
2 files changed, 365 insertions(+), 140 deletions(-)
diff --git a/include/pa_win_wasapi.h b/include/pa_win_wasapi.h
index 9b827d1..e8b93b6 100644
--- a/include/pa_win_wasapi.h
+++ b/include/pa_win_wasapi.h
@@ -516,28 +516,6 @@ PaError PaWasapi_GetJackCount( PaDeviceIndex device, int *pJackCount );
PaError PaWasapi_GetJackDescription( PaDeviceIndex device, int jackIndex, PaWasapiJackDescription *pJackDescription );
-/** Set default interface Id.
-
- By default PA implementation will use DEVINTERFACE_AUDIO_RENDER and
- DEVINTERFACE_AUDIO_CAPTURE if device Id is not provided explicitly. These default Ids
- will not allow to use Exclusive mode on UWP platform and thus you must provide
- device Id explicitly via this API before calling Pa_OpenStream().
- Device Ids on UWP platform are obtainable via
- Windows::Media::Devices::MediaDevice::GetDefaultAudioRenderId() or
- Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId() API.
-
- @note UWP platform only.
-
- @param pId Interface Id, pointer to the 16-bit Unicode string (WCHAR). If NULL then device Id
- will be reset to the default, e.g. DEVINTERFACE_AUDIO_RENDER or DEVINTERFACE_AUDIO_CAPTURE.
- @param bOutput TRUE (1) for output (render), FALSE (0) for input (capture).
-
- @return Error code indicating success or failure. Will return paIncompatibleStreamHostApi if PA is not compiled
- for UWP platform. If Id is longer than 4096 characters paBufferTooBig will be returned.
-*/
-PaError PaWasapi_SetDefaultInterfaceId( unsigned short *pId, int bOutput );
-
-
/** Set stream state handler.
@param pStream Pointer to PaStream object.
@@ -549,6 +527,74 @@ PaError PaWasapi_SetDefaultInterfaceId( unsigned short *pId, int bOutput );
PaError PaWasapi_SetStreamStateHandler( PaStream *pStream, PaWasapiStreamStateCallback fnStateHandler, void *pUserData );
+/** Set default device Id.
+
+ By default implementation will use the DEVINTERFACE_AUDIO_RENDER and
+ DEVINTERFACE_AUDIO_CAPTURE Ids if device Id is not provided explicitly. These default Ids
+ will not allow to use Exclusive mode on UWP/WinRT platform and thus you must provide
+ device Id explicitly via this API before calling the Pa_OpenStream().
+
+ Device Ids on UWP platform are obtainable via:
+ Windows::Media::Devices::MediaDevice::GetDefaultAudioRenderId() or
+ Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId() API.
+
+ After the call completes, memory referenced by pointers can be freed, as implementation keeps its own copy.
+
+ Call this function before calling Pa_IsFormatSupported() when Exclusive mode is requested.
+
+ See an example in the IMPORTANT notes.
+
+ @note UWP/WinRT platform only.
+
+ @param pId Device Id, pointer to the 16-bit Unicode string (WCHAR). If NULL then device Id
+ will be reset to the default, e.g. DEVINTERFACE_AUDIO_RENDER or DEVINTERFACE_AUDIO_CAPTURE.
+ @param bOutput TRUE (1) for output (render), FALSE (0) for input (capture).
+
+ @return Error code indicating success or failure. Will return paIncompatibleStreamHostApi if library is not compiled
+ for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
+ be returned.
+*/
+PaError PaWasapiWinrt_SetDefaultDeviceId( const unsigned short *pId, int bOutput );
+
+
+/** Populate the device list.
+
+ By default the implementation will rely on DEVINTERFACE_AUDIO_RENDER and DEVINTERFACE_AUDIO_CAPTURE as
+ default devices. If device Id is provided by PaWasapiWinrt_SetDefaultDeviceId() then those
+ device Ids will be used as default and only devices for the device list.
+
+ By populating the device list you can provide an additional available audio devices of the system to PA
+ which are obtainable by:
+ Windows::Devices::Enumeration::DeviceInformation::FindAllAsync(selector) where selector is obtainable by
+ Windows::Media::Devices::MediaDevice::GetAudioRenderSelector() or
+ Windows::Media::Devices::MediaDevice::GetAudioCaptureSelector() API.
+
+ After the call completes, memory referenced by pointers can be freed, as implementation keeps its own copy.
+
+ You must call PaWasapi_UpdateDeviceList() to update the internal device list of the implementation after
+ calling this function.
+
+ See an example in the IMPORTANT notes.
+
+ @note UWP/WinRT platform only.
+
+ @param pId Array of device Ids, pointer to the array of pointers of 16-bit Unicode string (WCHAR). If NULL
+ and count is also 0 then device Ids will be reset to the default. Required.
+ @param pName Array of device Names, pointer to the array of pointers of 16-bit Unicode string (WCHAR). Optional.
+ @param pRole Array of device Roles, see PaWasapiDeviceRole and PaWasapi_GetDeviceRole() for more details. Optional.
+ @param count Number of devices, the number of array elements (pId, pName, pRole). Maximum count of devices
+ is limited by PA_WASAPI_DEVICE_MAX_COUNT.
+ @param bOutput TRUE (1) for output (render), FALSE (0) for input (capture).
+
+ @return Error code indicating success or failure. Will return paIncompatibleStreamHostApi if library is not compiled
+ for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
+ be returned. If Name is longer than PA_WASAPI_DEVICE_NAME_LEN characters paBufferTooBig will
+ be returned.
+*/
+PaError PaWasapiWinrt_PopulateDeviceList( const unsigned short **pId, const unsigned short **pName,
+ const PaWasapiDeviceRole *pRole, unsigned int count, int bOutput );
+
+
/*
IMPORTANT:
@@ -626,6 +672,44 @@ PaError PaWasapi_SetStreamStateHandler( PaStream *pStream, PaWasapiStreamStateCa
2) pXXX - pointer
3) fnXXX - pointer to function
4) structure members are never prefixed with a type distinguisher
+
+
+ UWP/WinRT:
+
+ This platform has number of limitations which do not allow to enumerate audio devices without
+ an additional external help. Enumeration is possible though from C++/CX, check the related API
+ Windows::Devices::Enumeration::DeviceInformation::FindAllAsync().
+
+ The main limitation is an absence of the device enumeration from inside the PA's implementation.
+ This problem can be solved by using the following functions:
+
+ PaWasapiWinrt_SetDefaultDeviceId() - to set default input/output device,
+ PaWasapiWinrt_PopulateDeviceList() - to populate device list with devices.
+
+ Here is an example of populating the device list which can also be updated dynamically depending on
+ whether device was removed from or added to the system:
+
+ ----------------
+
+ std::vector ids, names;
+ std::vector role;
+
+ ids.resize(count);
+ names.resize(count);
+ role.resize(count);
+
+ for (UINT32 i = 0; i < count; ++i)
+ {
+ ids[i] = (const UINT16 *)device_ids[i].c_str();
+ names[i] = (const UINT16 *)device_names[i].c_str();
+ role[i] = eRoleUnknownFormFactor;
+ }
+
+ PaWasapiWinrt_SetDefaultDeviceId((const UINT16 *)default_device_id.c_str(), !capture);
+ PaWasapiWinrt_PopulateDeviceList(ids.data(), names.data(), role.data(), count, !capture);
+ PaWasapi_UpdateDeviceList();
+
+ ----------------
*/
#ifdef __cplusplus
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index 866d372..c155f1f 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -309,10 +309,10 @@ PA_THREAD_FUNC ProcThreadPoll(void *param);
#define AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000
#endif
-#define MAX_STR_LEN 512
-
+#define PA_WASAPI_DEVICE_ID_LEN 256
+#define PA_WASAPI_DEVICE_NAME_LEN 128
#ifdef PA_WINRT
- #define PA_WASAPI_DEVICE_ID_LEN 4096
+ #define PA_WASAPI_DEVICE_MAX_COUNT 16
#endif
enum { S_INPUT = 0, S_OUTPUT = 1, S_COUNT = 2, S_FULLDUPLEX = 0 };
@@ -430,8 +430,8 @@ typedef struct PaWasapiDeviceInfo
IMMDevice *device;
#endif
- // from GetId
- WCHAR szDeviceID[MAX_STR_LEN];
+ // device Id
+ WCHAR deviceId[PA_WASAPI_DEVICE_ID_LEN];
// from GetState
DWORD state;
@@ -450,7 +450,7 @@ typedef struct PaWasapiDeviceInfo
// Fields filled from IMMEndpoint'sGetDataFlow
EDataFlow flow;
- // Formfactor
+ // Form-factor
EndpointFormFactor formFactor;
}
PaWasapiDeviceInfo;
@@ -623,10 +623,44 @@ static void *PaWasapi_ReallocateMemory(void *prev, size_t size);
static void PaWasapi_FreeMemory(void *ptr);
static PaSampleFormat WaveToPaFormat(const WAVEFORMATEXTENSIBLE *fmtext);
-// Local statics
+// WinRT (UWP) device list
#ifdef PA_WINRT
-static OLECHAR g_DefaultRenderId[PA_WASAPI_DEVICE_ID_LEN] = { 0 };
-static OLECHAR g_DefaultCaptureId[PA_WASAPI_DEVICE_ID_LEN] = { 0 };
+typedef struct PaWasapiWinrtDeviceInfo
+{
+ WCHAR id[PA_WASAPI_DEVICE_ID_LEN];
+ WCHAR name[PA_WASAPI_DEVICE_NAME_LEN];
+ EndpointFormFactor formFactor;
+}
+PaWasapiWinrtDeviceInfo;
+typedef struct PaWasapiWinrtDeviceListRole
+{
+ WCHAR defaultId[PA_WASAPI_DEVICE_ID_LEN];
+ PaWasapiWinrtDeviceInfo devices[PA_WASAPI_DEVICE_MAX_COUNT];
+ UINT32 deviceCount;
+}
+PaWasapiWinrtDeviceListRole;
+typedef struct PaWasapiWinrtDeviceList
+{
+ PaWasapiWinrtDeviceListRole render;
+ PaWasapiWinrtDeviceListRole capture;
+}
+PaWasapiWinrtDeviceList;
+static PaWasapiWinrtDeviceList g_DeviceListInfo = { 0 };
+#endif
+
+// WinRT (UWP) device list context
+#ifdef PA_WINRT
+typedef struct PaWasapiWinrtDeviceListContextEntry
+{
+ PaWasapiWinrtDeviceInfo *info;
+ EDataFlow flow;
+}
+PaWasapiWinrtDeviceListContextEntry;
+typedef struct PaWasapiWinrtDeviceListContext
+{
+ PaWasapiWinrtDeviceListContextEntry devices[PA_WASAPI_DEVICE_MAX_COUNT * 2];
+}
+PaWasapiWinrtDeviceListContext;
#endif
// ------------------------------------------------------------------------------------------
@@ -1593,65 +1627,72 @@ static HRESULT (STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_Acti
return hr;
}
-static IActivateAudioInterfaceCompletionHandler *CreateActivateAudioInterfaceCompletionHandler(const IID *iid, void **obj)
+static IActivateAudioInterfaceCompletionHandler *CreateActivateAudioInterfaceCompletionHandler(const IID *iid, void **client)
{
PaActivateAudioInterfaceCompletionHandler *handler = PaUtil_AllocateMemory(sizeof(PaActivateAudioInterfaceCompletionHandler));
- ZeroMemory(handler, sizeof(*handler));
+
+ memset(handler, 0, sizeof(*handler));
+
handler->parent.lpVtbl = PaUtil_AllocateMemory(sizeof(*handler->parent.lpVtbl));
handler->parent.lpVtbl->QueryInterface = &PaActivateAudioInterfaceCompletionHandler_QueryInterface;
handler->parent.lpVtbl->AddRef = &PaActivateAudioInterfaceCompletionHandler_AddRef;
handler->parent.lpVtbl->Release = &PaActivateAudioInterfaceCompletionHandler_Release;
handler->parent.lpVtbl->ActivateCompleted = &PaActivateAudioInterfaceCompletionHandler_ActivateCompleted;
- handler->refs = 1;
+ handler->refs = 1;
handler->in.iid = iid;
- handler->in.obj = obj;
+ handler->in.obj = client;
+
return (IActivateAudioInterfaceCompletionHandler *)handler;
}
#endif
// ------------------------------------------------------------------------------------------
#ifdef PA_WINRT
-static HRESULT ActivateAudioInterface_WINRT(EDataFlow flow, const IID *iid, void **obj)
+static HRESULT WinRT_GetDefaultDeviceId(WCHAR *deviceId, UINT32 deviceIdMax, EDataFlow flow)
{
-#define PA_WASAPI_DEVICE_PATH_LEN 64
-
- PaError result = paNoError;
- HRESULT hr = S_OK;
- IActivateAudioInterfaceAsyncOperation *asyncOp = NULL;
- IActivateAudioInterfaceCompletionHandler *handler = CreateActivateAudioInterfaceCompletionHandler(iid, obj);
- PaActivateAudioInterfaceCompletionHandler *handlerImpl = (PaActivateAudioInterfaceCompletionHandler *)handler;
- OLECHAR tmp[PA_WASAPI_DEVICE_PATH_LEN] = { 0 };
- OLECHAR *devicePath = tmp;
-
- // Get device path in form L"{DEVICE_GUID}"
switch (flow)
{
case eRender:
- if (g_DefaultRenderId[0] != 0)
- devicePath = g_DefaultRenderId;
+ if (g_DeviceListInfo.render.defaultId[0] != 0)
+ wcsncpy_s(deviceId, deviceIdMax, g_DeviceListInfo.render.defaultId, wcslen(g_DeviceListInfo.render.defaultId));
else
- StringFromGUID2(&DEVINTERFACE_AUDIO_RENDER, devicePath, PA_WASAPI_DEVICE_PATH_LEN - 1);
+ StringFromGUID2(&DEVINTERFACE_AUDIO_RENDER, deviceId, deviceIdMax);
break;
case eCapture:
- if (g_DefaultCaptureId[0] != 0)
- devicePath = g_DefaultCaptureId;
+ if (g_DeviceListInfo.capture.defaultId[0] != 0)
+ wcsncpy_s(deviceId, deviceIdMax, g_DeviceListInfo.capture.defaultId, wcslen(g_DeviceListInfo.capture.defaultId));
else
- StringFromGUID2(&DEVINTERFACE_AUDIO_CAPTURE, devicePath, PA_WASAPI_DEVICE_PATH_LEN - 1);
+ StringFromGUID2(&DEVINTERFACE_AUDIO_CAPTURE, deviceId, deviceIdMax);
break;
default:
return S_FALSE;
- }
+ }
+ return S_OK;
+}
+#endif
+
+// ------------------------------------------------------------------------------------------
+#ifdef PA_WINRT
+static HRESULT WinRT_ActivateAudioInterface(const WCHAR *deviceId, const IID *iid, void **client)
+{
+ PaError result = paNoError;
+ HRESULT hr = S_OK;
+ IActivateAudioInterfaceAsyncOperation *asyncOp = NULL;
+ IActivateAudioInterfaceCompletionHandler *handler = CreateActivateAudioInterfaceCompletionHandler(iid, client);
+ PaActivateAudioInterfaceCompletionHandler *handlerImpl = (PaActivateAudioInterfaceCompletionHandler *)handler;
+ UINT32 sleepToggle = 0;
+
// Async operation will call back to IActivateAudioInterfaceCompletionHandler::ActivateCompleted
// which must be an agile interface implementation
- hr = ActivateAudioInterfaceAsync(devicePath, iid, NULL, handler, &asyncOp);
+ hr = ActivateAudioInterfaceAsync(deviceId, iid, NULL, handler, &asyncOp);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
// Wait in busy loop for async operation to complete
// Use Interlocked API here to ensure that ->done variable is read every time through the loop
while (SUCCEEDED(hr) && !InterlockedOr(&handlerImpl->done, 0))
{
- Sleep(1);
+ Sleep(sleepToggle ^= 1);
}
hr = handlerImpl->out.hr;
@@ -1662,8 +1703,6 @@ error:
SAFE_RELEASE(handler);
return hr;
-
-#undef PA_WASAPI_DEVICE_PATH_LEN
}
#endif
@@ -1677,7 +1716,7 @@ static HRESULT ActivateAudioInterface(const PaWasapiDeviceInfo *deviceInfo, cons
if (FAILED(hr = IMMDevice_Activate(deviceInfo->device, GetAudioClientIID(), CLSCTX_ALL, NULL, (void **)client)))
return hr;
#else
- if (FAILED(hr = ActivateAudioInterface_WINRT(deviceInfo->flow, GetAudioClientIID(), (void **)client)))
+ if (FAILED(hr = WinRT_ActivateAudioInterface(deviceInfo->deviceId, GetAudioClientIID(), (void **)client)))
return hr;
#endif
@@ -1766,37 +1805,41 @@ static PaError FillInactiveDeviceInfo(PaWasapiHostApiRepresentation *paWasapi, P
}
// ------------------------------------------------------------------------------------------
-static PaError FillDeviceInfo(PaWasapiHostApiRepresentation *paWasapi, void *pEndPoints, INT32 index, const WCHAR *defaultRenderer,
- const WCHAR *defaultCapturer, PaDeviceInfo *deviceInfo, PaWasapiDeviceInfo *wasapiDeviceInfo)
+static PaError FillDeviceInfo(PaWasapiHostApiRepresentation *paWasapi, void *pEndPoints, INT32 index, const WCHAR *defaultRenderId,
+ const WCHAR *defaultCaptureId, PaDeviceInfo *deviceInfo, PaWasapiDeviceInfo *wasapiDeviceInfo
+#ifdef PA_WINRT
+ , PaWasapiWinrtDeviceListContext *deviceListContext
+#endif
+)
{
HRESULT hr;
PaError result;
PaUtilHostApiRepresentation *hostApi = (PaUtilHostApiRepresentation *)paWasapi;
+#ifdef PA_WINRT
+ PaWasapiWinrtDeviceListContextEntry *listEntry = &deviceListContext->devices[index];
+ (void)pEndPoints;
+ (void)defaultRenderId;
+ (void)defaultCaptureId;
+#endif
#ifndef PA_WINRT
hr = IMMDeviceCollection_Item((IMMDeviceCollection *)pEndPoints, index, &wasapiDeviceInfo->device);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- // getting ID
+ // Get device Id
{
- WCHAR *pszDeviceId;
+ WCHAR *deviceId;
- hr = IMMDevice_GetId(wasapiDeviceInfo->device, &pszDeviceId);
+ hr = IMMDevice_GetId(wasapiDeviceInfo->device, &deviceId);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- wcsncpy(wasapiDeviceInfo->szDeviceID, pszDeviceId, MAX_STR_LEN - 1);
- CoTaskMemFree(pszDeviceId);
-
- if ((defaultCapturer != NULL) && (lstrcmpW(wasapiDeviceInfo->szDeviceID, defaultCapturer) == 0))
- hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
-
- if ((defaultRenderer != NULL) && (lstrcmpW(wasapiDeviceInfo->szDeviceID, defaultRenderer) == 0))
- hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
+ wcsncpy(wasapiDeviceInfo->deviceId, deviceId, PA_WASAPI_DEVICE_ID_LEN - 1);
+ CoTaskMemFree(deviceId);
}
+ // Get state of the device
hr = IMMDevice_GetState(wasapiDeviceInfo->device, &wasapiDeviceInfo->state);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
-
if (wasapiDeviceInfo->state != DEVICE_STATE_ACTIVE)
{
PRINT(("WASAPI device: %d is not currently available (state:%d)\n", index, wasapiDeviceInfo->state));
@@ -1818,16 +1861,16 @@ static PaError FillDeviceInfo(PaWasapiHostApiRepresentation *paWasapi, void *pEn
hr = IPropertyStore_GetValue(pProperty, &PKEY_Device_FriendlyName, &value);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
- if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1)) == NULL)
+ if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, PA_WASAPI_DEVICE_NAME_LEN)) == NULL)
{
result = paInsufficientMemory;
PropVariantClear(&value);
goto error;
}
if (value.pwszVal)
- WideCharToMultiByte(CP_UTF8, 0, value.pwszVal, (int)wcslen(value.pwszVal), (char *)deviceInfo->name, MAX_STR_LEN - 1, 0, 0);
+ WideCharToMultiByte(CP_UTF8, 0, value.pwszVal, (INT32)wcslen(value.pwszVal), (char *)deviceInfo->name, PA_WASAPI_DEVICE_NAME_LEN - 1, 0, 0);
else
- _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "baddev%d", index);
+ _snprintf((char *)deviceInfo->name, PA_WASAPI_DEVICE_NAME_LEN - 1, "baddev%d", index);
PropVariantClear(&value);
@@ -1879,24 +1922,39 @@ static PaError FillDeviceInfo(PaWasapiHostApiRepresentation *paWasapi, void *pEn
SAFE_RELEASE(pProperty);
}
#else
- (void)pEndPoints;
- (void)defaultRenderer;
- (void)defaultCapturer;
+ // Set device Id
+ wcsncpy(wasapiDeviceInfo->deviceId, listEntry->info->id, PA_WASAPI_DEVICE_ID_LEN - 1);
+
+ // Set device name
+ if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, PA_WASAPI_DEVICE_NAME_LEN)) == NULL)
+ {
+ result = paInsufficientMemory;
+ goto error;
+ }
+ ((char *)deviceInfo->name)[0] = 0;
+ if (listEntry->info->name[0] != 0)
+ WideCharToMultiByte(CP_UTF8, 0, listEntry->info->name, (INT32)wcslen(listEntry->info->name), (char *)deviceInfo->name, PA_WASAPI_DEVICE_NAME_LEN - 1, 0, 0);
+ if (deviceInfo->name[0] == 0) // fallback if WideCharToMultiByte is failed, or listEntry is nameless
+ _snprintf((char *)deviceInfo->name, PA_WASAPI_DEVICE_NAME_LEN - 1, "WASAPI_%s:%d", (listEntry->flow == eRender ? "Output" : "Input"), index);
+
+ // Form-factor
+ wasapiDeviceInfo->formFactor = listEntry->info->formFactor;
+
+ // Set data flow
+ wasapiDeviceInfo->flow = listEntry->flow;
#endif
- // Getting a temporary IAudioClient for more fields
- // we make sure NOT to call Initialize yet!
+ // Set default Output/Input devices
+ if ((defaultRenderId != NULL) && (wcsncmp(wasapiDeviceInfo->deviceId, defaultRenderId, PA_WASAPI_DEVICE_NAME_LEN - 1) == 0))
+ hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
+ if ((defaultCaptureId != NULL) && (wcsncmp(wasapiDeviceInfo->deviceId, defaultCaptureId, PA_WASAPI_DEVICE_NAME_LEN - 1) == 0))
+ hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
+
+ // Get a temporary IAudioClient for more details
{
IAudioClient *tmpClient;
WAVEFORMATEX *mixFormat;
- #ifdef PA_WINRT
- // Set flow as ActivateAudioInterface depends on it and selects corresponding
- // direction for the Audio Client
- wasapiDeviceInfo->flow = (index == 0 ? eRender : eCapture);
- #endif
-
- // Create temp Audio Client instance to query additional details
hr = ActivateAudioInterface(wasapiDeviceInfo, NULL, &tmpClient);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
@@ -1926,30 +1984,11 @@ static PaError FillDeviceInfo(PaWasapiHostApiRepresentation *paWasapi, void *pEn
#ifdef PA_WINRT
if (SUCCEEDED(hr))
{
- // Default device
- if (index == 0)
- hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
- else
- hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
-
- // State
+ // Set state
wasapiDeviceInfo->state = DEVICE_STATE_ACTIVE;
- // Default format is always a mix format
+ // Default format (Shared mode) is always a mix format
wasapiDeviceInfo->DefaultFormat = wasapiDeviceInfo->MixFormat;
-
- // Form-factor
- wasapiDeviceInfo->formFactor = UnknownFormFactor;
-
- // Name
- if ((deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1)) == NULL)
- {
- SAFE_RELEASE(tmpClient);
- result = paInsufficientMemory;
- goto error;
- }
- _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "WASAPI_%s:%d", (index == 0 ? "Output" : "Input"), index);
- PA_DEBUG(("WASAPI:%d| name[%s]\n", index, deviceInfo->name));
}
#endif
@@ -2049,9 +2088,9 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
PaUtilHostApiRepresentation *hostApi = (PaUtilHostApiRepresentation *)paWasapi;
PaError result = paNoError;
PaDeviceInfo *deviceInfoArray;
- UINT i;
- WCHAR *defaultRenderer = NULL;
- WCHAR *defaultCapturer = NULL;
+ UINT32 i;
+ WCHAR *defaultRenderId = NULL;
+ WCHAR *defaultCaptureId = NULL;
#ifndef PA_WINRT
HRESULT hr;
IMMDeviceCollection *pEndPoints = NULL;
@@ -2059,6 +2098,9 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
#else
void *pEndPoints = NULL;
IAudioClient *tmpClient;
+ PaWasapiWinrtDeviceListContext deviceListContext = { 0 };
+ PaWasapiWinrtDeviceInfo defaultRender = { 0 };
+ PaWasapiWinrtDeviceInfo defaultCapture = { 0 };
#endif
// Make sure device list empty
@@ -2084,7 +2126,7 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
}
else
{
- hr = IMMDevice_GetId(device, &defaultRenderer);
+ hr = IMMDevice_GetId(device, &defaultRenderId);
IMMDevice_Release(device);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
}
@@ -2099,7 +2141,7 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
}
else
{
- hr = IMMDevice_GetId(device, &defaultCapturer);
+ hr = IMMDevice_GetId(device, &defaultCaptureId);
IMMDevice_Release(device);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
}
@@ -2113,16 +2155,52 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
hr = IMMDeviceCollection_GetCount(pEndPoints, &paWasapi->deviceCount);
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
#else
- // Determine number of available devices by activating AudioClient for render and capture data flows
- if (SUCCEEDED(ActivateAudioInterface_WINRT(eRender, GetAudioClientIID(), &tmpClient)))
+ WinRT_GetDefaultDeviceId(defaultRender.id, STATIC_ARRAY_SIZE(defaultRender.id) - 1, eRender);
+ defaultRenderId = defaultRender.id;
+
+ WinRT_GetDefaultDeviceId(defaultCapture.id, STATIC_ARRAY_SIZE(defaultCapture.id) - 1, eCapture);
+ defaultCaptureId = defaultCapture.id;
+
+ if (g_DeviceListInfo.render.deviceCount == 0)
{
- paWasapi->deviceCount++;
- SAFE_RELEASE(tmpClient);
+ if (SUCCEEDED(WinRT_ActivateAudioInterface(defaultRenderId, GetAudioClientIID(), &tmpClient)))
+ {
+ deviceListContext.devices[paWasapi->deviceCount].info = &defaultRender;
+ deviceListContext.devices[paWasapi->deviceCount].flow = eRender;
+ paWasapi->deviceCount++;
+
+ SAFE_RELEASE(tmpClient);
+ }
}
- if (SUCCEEDED(ActivateAudioInterface_WINRT(eCapture, GetAudioClientIID(), &tmpClient)))
+ else
{
- paWasapi->deviceCount++;
- SAFE_RELEASE(tmpClient);
+ for (i = 0; i < g_DeviceListInfo.render.deviceCount; ++i)
+ {
+ deviceListContext.devices[paWasapi->deviceCount].info = &g_DeviceListInfo.render.devices[i];
+ deviceListContext.devices[paWasapi->deviceCount].flow = eRender;
+ paWasapi->deviceCount++;
+ }
+ }
+
+ if (g_DeviceListInfo.capture.deviceCount == 0)
+ {
+ if (SUCCEEDED(WinRT_ActivateAudioInterface(defaultCaptureId, GetAudioClientIID(), &tmpClient)))
+ {
+ deviceListContext.devices[paWasapi->deviceCount].info = &defaultCapture;
+ deviceListContext.devices[paWasapi->deviceCount].flow = eCapture;
+ paWasapi->deviceCount++;
+
+ SAFE_RELEASE(tmpClient);
+ }
+ }
+ else
+ {
+ for (i = 0; i < g_DeviceListInfo.capture.deviceCount; ++i)
+ {
+ deviceListContext.devices[paWasapi->deviceCount].info = &g_DeviceListInfo.capture.devices[i];
+ deviceListContext.devices[paWasapi->deviceCount].flow = eCapture;
+ paWasapi->deviceCount++;
+ }
}
#endif
@@ -2143,8 +2221,12 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
FillBaseDeviceInfo(deviceInfo, hostApiIndex);
- if ((result = FillDeviceInfo(paWasapi, pEndPoints, i, defaultRenderer, defaultCapturer,
- deviceInfo, &paWasapi->devInfo[i])) != paNoError)
+ if ((result = FillDeviceInfo(paWasapi, pEndPoints, i, defaultRenderId, defaultCaptureId,
+ deviceInfo, &paWasapi->devInfo[i]
+ #ifdef PA_WINRT
+ , &deviceListContext
+ #endif
+ )) != paNoError)
{
// Faulty device is made inactive
if ((result = FillInactiveDeviceInfo(paWasapi, deviceInfo)) != paNoError)
@@ -2182,8 +2264,8 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
done:
#ifndef PA_WINRT
- CoTaskMemFree(defaultRenderer);
- CoTaskMemFree(defaultCapturer);
+ CoTaskMemFree(defaultRenderId);
+ CoTaskMemFree(defaultCaptureId);
SAFE_RELEASE(pEndPoints);
SAFE_RELEASE(pEnumerator);
#endif
@@ -5346,10 +5428,30 @@ PaError PaWasapi_GetAudioClient(PaStream *pStream, void **pAudioClient, int bOut
}
// ------------------------------------------------------------------------------------------
-PaError PaWasapi_SetDefaultInterfaceId( unsigned short *pId, int bOutput )
+#ifdef PA_WINRT
+static void CopyNameOrIdString(WCHAR *dst, const UINT32 dstMaxCount, const WCHAR *src)
+{
+ UINT32 i;
+
+ for (i = 0; i < dstMaxCount; ++i)
+ dst[i] = 0;
+
+ if (src != NULL)
+ {
+ for (i = 0; (src[i] != 0) && (i < dstMaxCount); ++i)
+ dst[i] = src[i];
+ }
+}
+#endif
+
+// ------------------------------------------------------------------------------------------
+PaError PaWasapiWinrt_SetDefaultDeviceId( const unsigned short *pId, int bOutput )
{
#ifdef PA_WINRT
- int i;
+ INT32 i;
+ PaWasapiWinrtDeviceListRole *role = (bOutput ? &g_DeviceListInfo.render : &g_DeviceListInfo.capture);
+
+ assert(STATIC_ARRAY_SIZE(role->defaultId) == PA_WASAPI_DEVICE_ID_LEN);
// Validate Id length
if (pId != NULL)
@@ -5362,27 +5464,66 @@ PaError PaWasapi_SetDefaultInterfaceId( unsigned short *pId, int bOutput )
}
// Set Id (or reset to all 0 if NULL is provided)
- if (bOutput)
+ CopyNameOrIdString(role->defaultId, STATIC_ARRAY_SIZE(role->defaultId), pId);
+
+ return paNoError;
+#else
+ return paIncompatibleStreamHostApi;
+#endif
+}
+
+// ------------------------------------------------------------------------------------------
+PaError PaWasapiWinrt_PopulateDeviceList( const unsigned short **pId, const unsigned short **pName,
+ const PaWasapiDeviceRole *pRole, unsigned int count, int bOutput )
+{
+#ifdef PA_WINRT
+ UINT32 i, j;
+ PaWasapiWinrtDeviceListRole *role = (bOutput ? &g_DeviceListInfo.render : &g_DeviceListInfo.capture);
+
+ memset(&role->devices, 0, sizeof(role->devices));
+ role->deviceCount = 0;
+
+ if (count == 0)
+ return paNoError;
+ else
+ if (count > PA_WASAPI_DEVICE_MAX_COUNT)
+ return paBufferTooBig;
+
+ // pName or pRole are optional
+ if (pId == NULL)
+ return paInsufficientMemory;
+
+ // Validate Id and Name lengths
+ for (i = 0; i < count; ++i)
{
- memset(g_DefaultRenderId, 0, sizeof(g_DefaultRenderId));
- if (pId != NULL)
+ const unsigned short *id = pId[i];
+ const unsigned short *name = pName[i];
+
+ for (j = 0; id[j] != 0; ++j)
{
- for (i = 0; (pId[i] != 0) && (i < STATIC_ARRAY_SIZE(g_DefaultRenderId)); ++i)
- g_DefaultRenderId[i] = pId[i];
+ if (j >= PA_WASAPI_DEVICE_ID_LEN)
+ return paBufferTooBig;
+ }
+
+ for (j = 0; name[j] != 0; ++j)
+ {
+ if (j >= PA_WASAPI_DEVICE_NAME_LEN)
+ return paBufferTooBig;
}
}
- else
+
+ // Set Id and Name (or reset to all 0 if NULL is provided)
+ for (i = 0; i < count; ++i)
{
- memset(g_DefaultCaptureId, 0, sizeof(g_DefaultCaptureId));
- if (pId != NULL)
- {
- for (i = 0; (pId[i] != 0) && (i < STATIC_ARRAY_SIZE(g_DefaultCaptureId)); ++i)
- g_DefaultCaptureId[i] = pId[i];
- }
+ CopyNameOrIdString(role->devices[i].id, STATIC_ARRAY_SIZE(role->devices[i].id), pId[i]);
+ CopyNameOrIdString(role->devices[i].name, STATIC_ARRAY_SIZE(role->devices[i].name), pName[i]);
+ role->devices[i].formFactor = (pRole != NULL ? (EndpointFormFactor)pRole[i] : UnknownFormFactor);
+
+ // Count device if it has at least the Id
+ role->deviceCount += (role->devices[i].id[0] != 0);
}
return paNoError;
-
#else
return paIncompatibleStreamHostApi;
#endif
From b3592b0749e40013adb5826325b09d38ced9f9c5 Mon Sep 17 00:00:00 2001
From: dmitrykos
Date: Mon, 26 Oct 2020 18:25:10 +0200
Subject: [PATCH 027/157] wasapi: Fixed compilation with MinGW (mingw32): gcc
version 6.3.0 (MinGW.org GCC-6.3.0-1), include /mingw-include folder
explicitly (when compiling with mingw-w64 the /mingw-include folder must not
be included).
---
.../wasapi/mingw-include/AudioSessionTypes.h | 58 +++
src/hostapi/wasapi/mingw-include/PropIdl.h | 19 +
src/hostapi/wasapi/mingw-include/ShTypes.h | 359 ++++++++++++++++++
.../wasapi/mingw-include/audioclient.h | 2 +-
.../functiondiscoverykeys_devpkey.h | 13 +
src/hostapi/wasapi/mingw-include/propkey.h | 13 +
src/hostapi/wasapi/mingw-include/sdkddkver.h | 220 +++++++++++
.../wasapi/mingw-include/winapifamily.h | 24 ++
src/hostapi/wasapi/pa_win_wasapi.c | 24 +-
9 files changed, 729 insertions(+), 3 deletions(-)
create mode 100644 src/hostapi/wasapi/mingw-include/AudioSessionTypes.h
create mode 100644 src/hostapi/wasapi/mingw-include/PropIdl.h
create mode 100644 src/hostapi/wasapi/mingw-include/ShTypes.h
create mode 100644 src/hostapi/wasapi/mingw-include/functiondiscoverykeys_devpkey.h
create mode 100644 src/hostapi/wasapi/mingw-include/propkey.h
create mode 100644 src/hostapi/wasapi/mingw-include/sdkddkver.h
create mode 100644 src/hostapi/wasapi/mingw-include/winapifamily.h
diff --git a/src/hostapi/wasapi/mingw-include/AudioSessionTypes.h b/src/hostapi/wasapi/mingw-include/AudioSessionTypes.h
new file mode 100644
index 0000000..91e7213
--- /dev/null
+++ b/src/hostapi/wasapi/mingw-include/AudioSessionTypes.h
@@ -0,0 +1,58 @@
+/**
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within this package.
+ */
+
+#include
+
+#ifndef __AUDIOSESSIONTYPES__
+#define __AUDIOSESSIONTYPES__
+
+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP)
+#if defined (__WIDL__)
+#define MIDL_SIZE_IS(x) [size_is (x)]
+#define MIDL_STRING [string]
+#define MIDL_ANYSIZE_ARRAY
+#else
+#define MIDL_SIZE_IS(x)
+#define MIDL_STRING
+#define MIDL_ANYSIZE_ARRAY ANYSIZE_ARRAY
+#endif
+
+typedef enum _AudioSessionState {
+ AudioSessionStateInactive = 0,
+ AudioSessionStateActive = 1,
+ AudioSessionStateExpired = 2
+} AudioSessionState;
+
+typedef enum _AUDCLNT_SHAREMODE {
+ AUDCLNT_SHAREMODE_SHARED,
+ AUDCLNT_SHAREMODE_EXCLUSIVE
+} AUDCLNT_SHAREMODE;
+
+typedef enum _AUDIO_STREAM_CATEGORY {
+ AudioCategory_Other = 0,
+ AudioCategory_ForegroundOnlyMedia,
+ AudioCategory_BackgroundCapableMedia,
+ AudioCategory_Communications,
+ AudioCategory_Alerts,
+ AudioCategory_SoundEffects,
+ AudioCategory_GameEffects,
+ AudioCategory_GameMedia,
+ AudioCategory_GameChat,
+ AudioCategory_Speech,
+ AudioCategory_Movie,
+ AudioCategory_Media
+} AUDIO_STREAM_CATEGORY;
+
+#define AUDCLNT_STREAMFLAGS_CROSSPROCESS 0x00010000
+#define AUDCLNT_STREAMFLAGS_LOOPBACK 0x00020000
+#define AUDCLNT_STREAMFLAGS_EVENTCALLBACK 0x00040000
+#define AUDCLNT_STREAMFLAGS_NOPERSIST 0x00080000
+#define AUDCLNT_STREAMFLAGS_RATEADJUST 0x00100000
+#define AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED 0x10000000
+#define AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE 0x20000000
+#define AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED 0x40000000
+
+#endif
+#endif
diff --git a/src/hostapi/wasapi/mingw-include/PropIdl.h b/src/hostapi/wasapi/mingw-include/PropIdl.h
new file mode 100644
index 0000000..84832d9
--- /dev/null
+++ b/src/hostapi/wasapi/mingw-include/PropIdl.h
@@ -0,0 +1,19 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the PortAudio library.
+ */
+#ifndef _INC_PROPIDL_PA
+#define _INC_PROPIDL_PA
+
+#ifndef COM_NO_WINDOWS_H
+#include "windows.h"
+#include "ole2.h"
+#endif
+
+typedef const PROPVARIANT *REFPROPVARIANT;
+
+#define PropVariantInit(VAR) memset((VAR), 0, sizeof(PROPVARIANT))
+WINOLEAPI PropVariantClear(PROPVARIANT *pvar);
+
+#endif /* _INC_PROPIDL_PA */
+
diff --git a/src/hostapi/wasapi/mingw-include/ShTypes.h b/src/hostapi/wasapi/mingw-include/ShTypes.h
new file mode 100644
index 0000000..cd11186
--- /dev/null
+++ b/src/hostapi/wasapi/mingw-include/ShTypes.h
@@ -0,0 +1,359 @@
+/*** Autogenerated by WIDL 4.5 from shtypes.idl - Do not edit ***/
+
+#ifdef _WIN32
+#ifndef __REQUIRED_RPCNDR_H_VERSION__
+#define __REQUIRED_RPCNDR_H_VERSION__ 475
+#endif
+#include
+#include
+#endif
+
+#ifndef COM_NO_WINDOWS_H
+#include
+#include
+#endif
+
+#ifndef __shtypes_h__
+#define __shtypes_h__
+
+/* Forward declarations */
+
+/* Headers for imported files */
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within this package.
+ */
+
+
+#ifndef DUMMYUNIONNAME
+#ifdef NONAMELESSUNION
+#define DUMMYUNIONNAME u
+#define DUMMYUNIONNAME2 u2
+#define DUMMYUNIONNAME3 u3
+#define DUMMYUNIONNAME4 u4
+#define DUMMYUNIONNAME5 u5
+#else
+#define DUMMYUNIONNAME
+#define DUMMYUNIONNAME2
+#define DUMMYUNIONNAME3
+#define DUMMYUNIONNAME4
+#define DUMMYUNIONNAME5
+#endif
+#endif
+
+#include
+typedef struct _SHITEMID {
+ USHORT cb;
+ BYTE abID[1];
+} SHITEMID;
+#include
+
+#if (defined(_X86_) && !defined(__x86_64))
+#undef __unaligned
+#define __unaligned
+#endif
+
+typedef SHITEMID *LPSHITEMID;
+typedef const SHITEMID *LPCSHITEMID;
+
+#include
+typedef struct _ITEMIDLIST {
+ SHITEMID mkid;
+} ITEMIDLIST;
+
+#if defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)
+ typedef struct _ITEMIDLIST_RELATIVE : ITEMIDLIST { } ITEMIDLIST_RELATIVE;
+ typedef struct _ITEMID_CHILD : ITEMIDLIST_RELATIVE { } ITEMID_CHILD;
+ typedef struct _ITEMIDLIST_ABSOLUTE : ITEMIDLIST_RELATIVE { } ITEMIDLIST_ABSOLUTE;
+#else
+typedef ITEMIDLIST ITEMIDLIST_RELATIVE;
+typedef ITEMIDLIST ITEMID_CHILD;
+typedef ITEMIDLIST ITEMIDLIST_ABSOLUTE;
+#endif
+#include
+
+typedef BYTE_BLOB *wirePIDL;
+typedef ITEMIDLIST *LPITEMIDLIST;
+typedef const ITEMIDLIST *LPCITEMIDLIST;
+#if defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)
+typedef ITEMIDLIST_ABSOLUTE *PIDLIST_ABSOLUTE;
+typedef const ITEMIDLIST_ABSOLUTE *PCIDLIST_ABSOLUTE;
+typedef const ITEMIDLIST_ABSOLUTE *PCUIDLIST_ABSOLUTE;
+typedef ITEMIDLIST_RELATIVE *PIDLIST_RELATIVE;
+typedef const ITEMIDLIST_RELATIVE *PCIDLIST_RELATIVE;
+typedef ITEMIDLIST_RELATIVE *PUIDLIST_RELATIVE;
+typedef const ITEMIDLIST_RELATIVE *PCUIDLIST_RELATIVE;
+typedef ITEMID_CHILD *PITEMID_CHILD;
+typedef const ITEMID_CHILD *PCITEMID_CHILD;
+typedef ITEMID_CHILD *PUITEMID_CHILD;
+typedef const ITEMID_CHILD *PCUITEMID_CHILD;
+typedef const PCUITEMID_CHILD *PCUITEMID_CHILD_ARRAY;
+typedef const PCUIDLIST_RELATIVE *PCUIDLIST_RELATIVE_ARRAY;
+typedef const PCIDLIST_ABSOLUTE *PCIDLIST_ABSOLUTE_ARRAY;
+typedef const PCUIDLIST_ABSOLUTE *PCUIDLIST_ABSOLUTE_ARRAY;
+#else
+#define PIDLIST_ABSOLUTE LPITEMIDLIST
+#define PCIDLIST_ABSOLUTE LPCITEMIDLIST
+#define PCUIDLIST_ABSOLUTE LPCITEMIDLIST
+#define PIDLIST_RELATIVE LPITEMIDLIST
+#define PCIDLIST_RELATIVE LPCITEMIDLIST
+#define PUIDLIST_RELATIVE LPITEMIDLIST
+#define PCUIDLIST_RELATIVE LPCITEMIDLIST
+#define PITEMID_CHILD LPITEMIDLIST
+#define PCITEMID_CHILD LPCITEMIDLIST
+#define PUITEMID_CHILD LPITEMIDLIST
+#define PCUITEMID_CHILD LPCITEMIDLIST
+#define PCUITEMID_CHILD_ARRAY LPCITEMIDLIST *
+#define PCUIDLIST_RELATIVE_ARRAY LPCITEMIDLIST *
+#define PCIDLIST_ABSOLUTE_ARRAY LPCITEMIDLIST *
+#define PCUIDLIST_ABSOLUTE_ARRAY LPCITEMIDLIST *
+#endif
+
+#if 0
+typedef struct _WIN32_FIND_DATAA {
+ DWORD dwFileAttributes;
+ FILETIME ftCreationTime;
+ FILETIME ftLastAccessTime;
+ FILETIME ftLastWriteTime;
+ DWORD nFileSizeHigh;
+ DWORD nFileSizeLow;
+ DWORD dwReserved0;
+ DWORD dwReserved1;
+ CHAR cFileName[260];
+ CHAR cAlternateFileName[14];
+} WIN32_FIND_DATAA;
+typedef struct _WIN32_FIND_DATAA *PWIN32_FIND_DATAA;
+typedef struct _WIN32_FIND_DATAA *LPWIN32_FIND_DATAA;
+
+typedef struct _WIN32_FIND_DATAW {
+ DWORD dwFileAttributes;
+ FILETIME ftCreationTime;
+ FILETIME ftLastAccessTime;
+ FILETIME ftLastWriteTime;
+ DWORD nFileSizeHigh;
+ DWORD nFileSizeLow;
+ DWORD dwReserved0;
+ DWORD dwReserved1;
+ WCHAR cFileName[260];
+ WCHAR cAlternateFileName[14];
+} WIN32_FIND_DATAW;
+typedef struct _WIN32_FIND_DATAW *PWIN32_FIND_DATAW;
+typedef struct _WIN32_FIND_DATAW *LPWIN32_FIND_DATAW;
+#endif
+
+typedef enum tagSTRRET_TYPE {
+ STRRET_WSTR = 0x0,
+ STRRET_OFFSET = 0x1,
+ STRRET_CSTR = 0x2
+} STRRET_TYPE;
+
+#include
+typedef struct _STRRET {
+ UINT uType;
+ __C89_NAMELESS union {
+ LPWSTR pOleStr;
+ UINT uOffset;
+ char cStr[260];
+ } __C89_NAMELESSUNIONNAME;
+} STRRET;
+#include
+
+typedef STRRET *LPSTRRET;
+
+#include
+typedef struct _SHELLDETAILS {
+ int fmt;
+ int cxChar;
+ STRRET str;
+} SHELLDETAILS;
+typedef struct _SHELLDETAILS *LPSHELLDETAILS;
+#include
+
+#if _WIN32_IE >= _WIN32_IE_IE60SP2
+typedef enum tagPERCEIVED {
+ PERCEIVED_TYPE_FIRST = -3,
+ PERCEIVED_TYPE_CUSTOM = -3,
+ PERCEIVED_TYPE_UNSPECIFIED = -2,
+ PERCEIVED_TYPE_FOLDER = -1,
+ PERCEIVED_TYPE_UNKNOWN = 0,
+ PERCEIVED_TYPE_TEXT = 1,
+ PERCEIVED_TYPE_IMAGE = 2,
+ PERCEIVED_TYPE_AUDIO = 3,
+ PERCEIVED_TYPE_VIDEO = 4,
+ PERCEIVED_TYPE_COMPRESSED = 5,
+ PERCEIVED_TYPE_DOCUMENT = 6,
+ PERCEIVED_TYPE_SYSTEM = 7,
+ PERCEIVED_TYPE_APPLICATION = 8,
+ PERCEIVED_TYPE_GAMEMEDIA = 9,
+ PERCEIVED_TYPE_CONTACTS = 10,
+ PERCEIVED_TYPE_LAST = 10
+} PERCEIVED;
+
+#define PERCEIVEDFLAG_UNDEFINED 0x0000
+#define PERCEIVEDFLAG_SOFTCODED 0x0001
+#define PERCEIVEDFLAG_HARDCODED 0x0002
+#define PERCEIVEDFLAG_NATIVESUPPORT 0x0004
+#define PERCEIVEDFLAG_GDIPLUS 0x0010
+#define PERCEIVEDFLAG_WMSDK 0x0020
+#define PERCEIVEDFLAG_ZIPFOLDER 0x0040
+
+typedef DWORD PERCEIVEDFLAG;
+#endif
+
+typedef struct _COMDLG_FILTERSPEC {
+ LPCWSTR pszName;
+ LPCWSTR pszSpec;
+} COMDLG_FILTERSPEC;
+
+typedef GUID KNOWNFOLDERID;
+
+#if 0
+typedef KNOWNFOLDERID *REFKNOWNFOLDERID;
+#endif
+
+#ifdef __cplusplus
+#define REFKNOWNFOLDERID const KNOWNFOLDERID &
+#else
+#define REFKNOWNFOLDERID const KNOWNFOLDERID * __MIDL_CONST
+#endif
+
+typedef DWORD KF_REDIRECT_FLAGS;
+
+typedef GUID FOLDERTYPEID;
+
+#if 0
+typedef FOLDERTYPEID *REFFOLDERTYPEID;
+#endif
+
+#ifdef __cplusplus
+#define REFFOLDERTYPEID const FOLDERTYPEID &
+#else
+#define REFFOLDERTYPEID const FOLDERTYPEID * __MIDL_CONST
+#endif
+
+typedef GUID TASKOWNERID;
+
+#if 0
+typedef TASKOWNERID *REFTASKOWNERID;
+#endif
+
+#ifdef __cplusplus
+#define REFTASKOWNERID const TASKOWNERID &
+#else
+#define REFTASKOWNERID const TASKOWNERID * __MIDL_CONST
+#endif
+
+typedef GUID ELEMENTID;
+
+#if 0
+typedef ELEMENTID *REFELEMENTID;
+#endif
+
+#ifdef __cplusplus
+#define REFELEMENTID const ELEMENTID &
+#else
+#define REFELEMENTID const ELEMENTID * __MIDL_CONST
+#endif
+
+#ifndef LF_FACESIZE
+typedef struct tagLOGFONTA {
+ LONG lfHeight;
+ LONG lfWidth;
+ LONG lfEscapement;
+ LONG lfOrientation;
+ LONG lfWeight;
+ BYTE lfItalic;
+ BYTE lfUnderline;
+ BYTE lfStrikeOut;
+ BYTE lfCharSet;
+ BYTE lfOutPrecision;
+ BYTE lfClipPrecision;
+ BYTE lfQuality;
+ BYTE lfPitchAndFamily;
+ CHAR lfFaceName[32];
+} LOGFONTA;
+
+typedef struct tagLOGFONTW {
+ LONG lfHeight;
+ LONG lfWidth;
+ LONG lfEscapement;
+ LONG lfOrientation;
+ LONG lfWeight;
+ BYTE lfItalic;
+ BYTE lfUnderline;
+ BYTE lfStrikeOut;
+ BYTE lfCharSet;
+ BYTE lfOutPrecision;
+ BYTE lfClipPrecision;
+ BYTE lfQuality;
+ BYTE lfPitchAndFamily;
+ WCHAR lfFaceName[32];
+} LOGFONTW;
+
+typedef LOGFONTA LOGFONT;
+#endif
+
+typedef enum tagSHCOLSTATE {
+ SHCOLSTATE_DEFAULT = 0x0,
+ SHCOLSTATE_TYPE_STR = 0x1,
+ SHCOLSTATE_TYPE_INT = 0x2,
+ SHCOLSTATE_TYPE_DATE = 0x3,
+ SHCOLSTATE_TYPEMASK = 0xf,
+ SHCOLSTATE_ONBYDEFAULT = 0x10,
+ SHCOLSTATE_SLOW = 0x20,
+ SHCOLSTATE_EXTENDED = 0x40,
+ SHCOLSTATE_SECONDARYUI = 0x80,
+ SHCOLSTATE_HIDDEN = 0x100,
+ SHCOLSTATE_PREFER_VARCMP = 0x200,
+ SHCOLSTATE_PREFER_FMTCMP = 0x400,
+ SHCOLSTATE_NOSORTBYFOLDERNESS = 0x800,
+ SHCOLSTATE_VIEWONLY = 0x10000,
+ SHCOLSTATE_BATCHREAD = 0x20000,
+ SHCOLSTATE_NO_GROUPBY = 0x40000,
+ SHCOLSTATE_FIXED_WIDTH = 0x1000,
+ SHCOLSTATE_NODPISCALE = 0x2000,
+ SHCOLSTATE_FIXED_RATIO = 0x4000,
+ SHCOLSTATE_DISPLAYMASK = 0xf000
+} SHCOLSTATE;
+
+typedef DWORD SHCOLSTATEF;
+typedef PROPERTYKEY SHCOLUMNID;
+typedef const SHCOLUMNID *LPCSHCOLUMNID;
+
+typedef enum DEVICE_SCALE_FACTOR {
+ DEVICE_SCALE_FACTOR_INVALID = 0,
+ SCALE_100_PERCENT = 100,
+ SCALE_120_PERCENT = 120,
+ SCALE_125_PERCENT = 125,
+ SCALE_140_PERCENT = 140,
+ SCALE_150_PERCENT = 150,
+ SCALE_160_PERCENT = 160,
+ SCALE_175_PERCENT = 175,
+ SCALE_180_PERCENT = 180,
+ SCALE_200_PERCENT = 200,
+ SCALE_225_PERCENT = 225,
+ SCALE_250_PERCENT = 250,
+ SCALE_300_PERCENT = 300,
+ SCALE_350_PERCENT = 350,
+ SCALE_400_PERCENT = 400,
+ SCALE_450_PERCENT = 450,
+ SCALE_500_PERCENT = 500
+} DEVICE_SCALE_FACTOR;
+/* Begin additional prototypes for all interfaces */
+
+
+/* End additional prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __shtypes_h__ */
diff --git a/src/hostapi/wasapi/mingw-include/audioclient.h b/src/hostapi/wasapi/mingw-include/audioclient.h
index bf77baf..60db0cd 100644
--- a/src/hostapi/wasapi/mingw-include/audioclient.h
+++ b/src/hostapi/wasapi/mingw-include/audioclient.h
@@ -19,7 +19,7 @@
/* verify that the version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
-#define __REQUIRED_RPCNDR_H_VERSION__ 500
+#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
/* verify that the version is high enough to compile this file*/
diff --git a/src/hostapi/wasapi/mingw-include/functiondiscoverykeys_devpkey.h b/src/hostapi/wasapi/mingw-include/functiondiscoverykeys_devpkey.h
new file mode 100644
index 0000000..d66cb97
--- /dev/null
+++ b/src/hostapi/wasapi/mingw-include/functiondiscoverykeys_devpkey.h
@@ -0,0 +1,13 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+#ifndef _INC_FUNCTIONDISCOVERYKEYS
+#define _INC_FUNCTIONDISCOVERYKEYS
+
+#include
+
+DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14);
+
+#endif /* _INC_FUNCTIONDISCOVERYKEYS */
diff --git a/src/hostapi/wasapi/mingw-include/propkey.h b/src/hostapi/wasapi/mingw-include/propkey.h
new file mode 100644
index 0000000..5b68236
--- /dev/null
+++ b/src/hostapi/wasapi/mingw-include/propkey.h
@@ -0,0 +1,13 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the PortAudio library.
+ */
+#ifndef _INC_PROPKEY_PA
+#define _INC_PROPKEY_PA
+
+#ifndef DEFINE_API_PKEY
+#define DEFINE_API_PKEY(name, managed_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \
+ DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid)
+#endif
+
+#endif /* _INC_PROPKEY_PA */
diff --git a/src/hostapi/wasapi/mingw-include/sdkddkver.h b/src/hostapi/wasapi/mingw-include/sdkddkver.h
new file mode 100644
index 0000000..44b5fb2
--- /dev/null
+++ b/src/hostapi/wasapi/mingw-include/sdkddkver.h
@@ -0,0 +1,220 @@
+/**
+ * sdkddkver.h: Version definitions for SDK and DDK. Originally
+ * from ReactOS PSDK/DDK, this file is in the public domain:
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef _INC_SDKDDKVER
+#define _INC_SDKDDKVER
+
+/* _WIN32_WINNT */
+#define _WIN32_WINNT_NT4 0x0400
+#define _WIN32_WINNT_WIN2K 0x0500
+#define _WIN32_WINNT_WINXP 0x0501
+#define _WIN32_WINNT_WS03 0x0502
+#define _WIN32_WINNT_WIN6 0x0600
+#define _WIN32_WINNT_VISTA 0x0600
+#define _WIN32_WINNT_WS08 0x0600
+#define _WIN32_WINNT_LONGHORN 0x0600
+#define _WIN32_WINNT_WIN7 0x0601
+#define _WIN32_WINNT_WIN8 0x0602
+#define _WIN32_WINNT_WINBLUE 0x0603
+#define _WIN32_WINNT_WINTHRESHOLD 0x0A00
+#define _WIN32_WINNT_WIN10 0x0A00
+
+/* _WIN32_IE */
+#define _WIN32_IE_IE20 0x0200
+#define _WIN32_IE_IE30 0x0300
+#define _WIN32_IE_IE302 0x0302
+#define _WIN32_IE_IE40 0x0400
+#define _WIN32_IE_IE401 0x0401
+#define _WIN32_IE_IE50 0x0500
+#define _WIN32_IE_IE501 0x0501
+#define _WIN32_IE_IE55 0x0550
+#define _WIN32_IE_IE60 0x0600
+#define _WIN32_IE_IE60SP1 0x0601
+#define _WIN32_IE_IE60SP2 0x0603
+#define _WIN32_IE_IE70 0x0700
+#define _WIN32_IE_IE80 0x0800
+#define _WIN32_IE_IE90 0x0900
+#define _WIN32_IE_IE100 0x0a00
+#define _WIN32_IE_IE110 0x0A00
+
+/* Mappings Between IE Version and Windows Version */
+#define _WIN32_IE_NT4 _WIN32_IE_IE20
+#define _WIN32_IE_NT4SP1 _WIN32_IE_IE20
+#define _WIN32_IE_NT4SP2 _WIN32_IE_IE20
+#define _WIN32_IE_NT4SP3 _WIN32_IE_IE302
+#define _WIN32_IE_NT4SP4 _WIN32_IE_IE401
+#define _WIN32_IE_NT4SP5 _WIN32_IE_IE401
+#define _WIN32_IE_NT4SP6 _WIN32_IE_IE50
+#define _WIN32_IE_WIN98 _WIN32_IE_IE401
+#define _WIN32_IE_WIN98SE _WIN32_IE_IE50
+#define _WIN32_IE_WINME _WIN32_IE_IE55
+#define _WIN32_IE_WIN2K _WIN32_IE_IE501
+#define _WIN32_IE_WIN2KSP1 _WIN32_IE_IE501
+#define _WIN32_IE_WIN2KSP2 _WIN32_IE_IE501
+#define _WIN32_IE_WIN2KSP3 _WIN32_IE_IE501
+#define _WIN32_IE_WIN2KSP4 _WIN32_IE_IE501
+#define _WIN32_IE_XP _WIN32_IE_IE60
+#define _WIN32_IE_XPSP1 _WIN32_IE_IE60SP1
+#define _WIN32_IE_XPSP2 _WIN32_IE_IE60SP2
+#define _WIN32_IE_WS03 0x0602
+#define _WIN32_IE_WS03SP1 _WIN32_IE_IE60SP2
+#define _WIN32_IE_WIN6 _WIN32_IE_IE70
+#define _WIN32_IE_LONGHORN _WIN32_IE_IE70
+#define _WIN32_IE_WIN7 _WIN32_IE_IE80
+#define _WIN32_IE_WIN8 _WIN32_IE_IE100
+#define _WIN32_IE_WINBLUE _WIN32_IE_IE100
+#define _WIN32_IE_WINTHRESHOLD _WIN32_IE_IE110
+#define _WIN32_IE_WIN10 _WIN32_IE_IE110
+
+/* NTDDI_VERSION */
+#ifndef NTDDI_WIN2K
+#define NTDDI_WIN2K 0x05000000
+#endif
+#ifndef NTDDI_WIN2KSP1
+#define NTDDI_WIN2KSP1 0x05000100
+#endif
+#ifndef NTDDI_WIN2KSP2
+#define NTDDI_WIN2KSP2 0x05000200
+#endif
+#ifndef NTDDI_WIN2KSP3
+#define NTDDI_WIN2KSP3 0x05000300
+#endif
+#ifndef NTDDI_WIN2KSP4
+#define NTDDI_WIN2KSP4 0x05000400
+#endif
+
+#ifndef NTDDI_WINXP
+#define NTDDI_WINXP 0x05010000
+#endif
+#ifndef NTDDI_WINXPSP1
+#define NTDDI_WINXPSP1 0x05010100
+#endif
+#ifndef NTDDI_WINXPSP2
+#define NTDDI_WINXPSP2 0x05010200
+#endif
+#ifndef NTDDI_WINXPSP3
+#define NTDDI_WINXPSP3 0x05010300
+#endif
+#ifndef NTDDI_WINXPSP4
+#define NTDDI_WINXPSP4 0x05010400
+#endif
+
+#define NTDDI_WS03 0x05020000
+#define NTDDI_WS03SP1 0x05020100
+#define NTDDI_WS03SP2 0x05020200
+#define NTDDI_WS03SP3 0x05020300
+#define NTDDI_WS03SP4 0x05020400
+
+#define NTDDI_WIN6 0x06000000
+#define NTDDI_WIN6SP1 0x06000100
+#define NTDDI_WIN6SP2 0x06000200
+#define NTDDI_WIN6SP3 0x06000300
+#define NTDDI_WIN6SP4 0x06000400
+
+#define NTDDI_VISTA NTDDI_WIN6
+#define NTDDI_VISTASP1 NTDDI_WIN6SP1
+#define NTDDI_VISTASP2 NTDDI_WIN6SP2
+#define NTDDI_VISTASP3 NTDDI_WIN6SP3
+#define NTDDI_VISTASP4 NTDDI_WIN6SP4
+#define NTDDI_LONGHORN NTDDI_VISTA
+
+#define NTDDI_WS08 NTDDI_WIN6SP1
+#define NTDDI_WS08SP2 NTDDI_WIN6SP2
+#define NTDDI_WS08SP3 NTDDI_WIN6SP3
+#define NTDDI_WS08SP4 NTDDI_WIN6SP4
+
+#define NTDDI_WIN7 0x06010000
+#define NTDDI_WIN8 0x06020000
+#define NTDDI_WINBLUE 0x06030000
+#define NTDDI_WINTHRESHOLD 0x0A000000
+#define NTDDI_WIN10 0x0A000000
+#define NTDDI_WIN10_TH2 0x0A000001
+#define NTDDI_WIN10_RS1 0x0A000002
+#define NTDDI_WIN10_RS2 0x0A000003
+#define NTDDI_WIN10_RS3 0x0A000004
+#define NTDDI_WIN10_RS4 0x0A000005
+#define NTDDI_WIN10_RS5 0x0A000006
+#define NTDDI_WIN10_19H1 0x0A000007
+#define NTDDI_WIN10_VB 0x0A000008
+#define NTDDI_WIN10_MN 0x0A000009
+#define NTDDI_WIN10_FE 0x0A00000A
+
+#define WDK_NTDDI_VERSION NTDDI_WIN10_FE
+
+/* Version Fields in NTDDI_VERSION */
+#define OSVERSION_MASK 0xFFFF0000U
+#define SPVERSION_MASK 0x0000FF00
+#define SUBVERSION_MASK 0x000000FF
+
+/* Macros to Extract Version Fields From NTDDI_VERSION */
+#define OSVER(Version) ((Version) & OSVERSION_MASK)
+#define SPVER(Version) (((Version) & SPVERSION_MASK) >> 8)
+#define SUBVER(Version) (((Version) & SUBVERSION_MASK))
+
+/* Macros to get the NTDDI for a given WIN32 */
+#define NTDDI_VERSION_FROM_WIN32_WINNT2(Version) Version##0000
+#define NTDDI_VERSION_FROM_WIN32_WINNT(Version) NTDDI_VERSION_FROM_WIN32_WINNT2(Version)
+
+/* Select Default WIN32_WINNT Value */
+#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
+#define _WIN32_WINNT _WIN32_WINNT_WS03
+#endif
+
+/* Choose NTDDI Version */
+#ifndef NTDDI_VERSION
+#ifdef _WIN32_WINNT
+#define NTDDI_VERSION NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT)
+#else
+#define NTDDI_VERSION NTDDI_WS03
+#endif
+#endif
+
+/* Choose WINVER Value */
+#ifndef WINVER
+#ifdef _WIN32_WINNT
+#define WINVER _WIN32_WINNT
+#else
+#define WINVER 0x0502
+#endif
+#endif
+
+/* Choose IE Version */
+#ifndef _WIN32_IE
+#ifdef _WIN32_WINNT
+#if (_WIN32_WINNT <= _WIN32_WINNT_NT4)
+#define _WIN32_IE _WIN32_IE_IE50
+#elif (_WIN32_WINNT <= _WIN32_WINNT_WIN2K)
+#define _WIN32_IE _WIN32_IE_IE501
+#elif (_WIN32_WINNT <= _WIN32_WINNT_WINXP)
+#define _WIN32_IE _WIN32_IE_IE60
+#elif (_WIN32_WINNT <= _WIN32_WINNT_WS03)
+#define _WIN32_IE _WIN32_IE_WS03
+#elif (_WIN32_WINNT <= _WIN32_WINNT_VISTA)
+#define _WIN32_IE _WIN32_IE_LONGHORN
+#elif (_WIN32_WINNT <= _WIN32_WINNT_WIN7)
+#define _WIN32_IE _WIN32_IE_WIN7
+#elif (_WIN32_WINNT <= _WIN32_WINNT_WIN8)
+#define _WIN32_IE _WIN32_IE_WIN8
+#else
+#define _WIN32_IE 0x0a00
+#endif
+#else
+#define _WIN32_IE 0x0700
+#endif
+#endif
+
+/* Make Sure NTDDI_VERSION and _WIN32_WINNT Match */
+#if ((OSVER(NTDDI_VERSION) == NTDDI_WIN2K) && (_WIN32_WINNT != _WIN32_WINNT_WIN2K)) || \
+ ((OSVER(NTDDI_VERSION) == NTDDI_WINXP) && (_WIN32_WINNT != _WIN32_WINNT_WINXP)) || \
+ ((OSVER(NTDDI_VERSION) == NTDDI_WS03) && (_WIN32_WINNT != _WIN32_WINNT_WS03)) || \
+ ((OSVER(NTDDI_VERSION) == NTDDI_WINXP) && (_WIN32_WINNT != _WIN32_WINNT_WINXP))
+#error NTDDI_VERSION and _WIN32_WINNT mismatch!
+#endif
+
+#endif /* _INC_SDKDDKVER */
diff --git a/src/hostapi/wasapi/mingw-include/winapifamily.h b/src/hostapi/wasapi/mingw-include/winapifamily.h
new file mode 100644
index 0000000..388d5f0
--- /dev/null
+++ b/src/hostapi/wasapi/mingw-include/winapifamily.h
@@ -0,0 +1,24 @@
+/**
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within this package.
+ */
+
+#ifndef _INC_WINAPIFAMILY
+#define _INC_WINAPIFAMILY
+
+#define WINAPI_PARTITION_DESKTOP 0x1
+#define WINAPI_PARTITION_APP 0x2
+
+#define WINAPI_FAMILY_APP WINAPI_PARTITION_APP
+#define WINAPI_FAMILY_DESKTOP_APP (WINAPI_PARTITION_DESKTOP \
+ | WINAPI_PARTITION_APP)
+
+/* WINAPI_FAMILY can be either desktop + App, or App. */
+#ifndef WINAPI_FAMILY
+#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
+#endif
+
+#define WINAPI_FAMILY_PARTITION(v) ((WINAPI_FAMILY & v) == v)
+#define WINAPI_FAMILY_ONE_PARTITION(vset, v) ((WINAPI_FAMILY & vset) == v)
+
+#endif
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index c155f1f..7e321f1 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -92,6 +92,9 @@
#include
#include
#endif
+#ifndef PA_WINRT
+ #include
+#endif
#include "pa_util.h"
#include "pa_allocation.h"
@@ -104,13 +107,25 @@
#include "pa_ringbuffer.h"
#include "pa_win_coinitialize.h"
-#if !defined(NTDDI_VERSION)
+#if !defined(NTDDI_VERSION) || (defined(__GNUC__) && (__GNUC__ <= 6) && !defined(__MINGW64__))
#undef WINVER
#undef _WIN32_WINNT
#define WINVER 0x0600 // VISTA
#define _WIN32_WINNT WINVER
+ #ifndef WINAPI
+ #define WINAPI __stdcall
+ #endif
+
+ #ifndef __unaligned
+ #define __unaligned
+ #endif
+
+ #ifndef __C89_NAMELESS
+ #define __C89_NAMELESS
+ #endif
+
#ifndef _AVRT_ //<< fix MinGW dummy compile by defining missing type: AVRT_PRIORITY
typedef enum _AVRT_PRIORITY
{
@@ -129,6 +144,8 @@
#define __LPCGUID_DEFINED__
typedef const GUID *LPCGUID;
#endif
+ typedef GUID IID;
+ typedef GUID CLSID;
#ifndef PROPERTYKEY_DEFINED
#define PROPERTYKEY_DEFINED
@@ -147,7 +164,6 @@
#ifdef WIN64
#include
- typedef LONG NTSTATUS;
#define FASTCALL
#include
#include
@@ -161,6 +177,10 @@
typedef LONGLONG REFERENCE_TIME;
#define NONAMELESSUNION
#endif
+
+ #ifndef NT_SUCCESS
+ typedef LONG NTSTATUS;
+ #endif
#ifndef WAVE_FORMAT_IEEE_FLOAT
#define WAVE_FORMAT_IEEE_FLOAT 0x0003 // 32-bit floating-point
From fd0d181261280f48180227fe42e1b3094f565555 Mon Sep 17 00:00:00 2001
From: Nemirtingas <9432037+Nemirtingas@users.noreply.github.com>
Date: Tue, 13 Oct 2020 09:56:09 +0200
Subject: [PATCH 028/157] Add the install interface.
---
CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0302ae8..5c5f748 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -372,7 +372,7 @@ IF(PA_BUILD_SHARED)
ADD_LIBRARY(portaudio SHARED ${PA_INCLUDES} ${PA_COMMON_INCLUDES} ${PA_SOURCES} ${PA_NON_UNICODE_SOURCES} ${PA_EXTRA_SHARED_SOURCES})
SET_PROPERTY(TARGET portaudio APPEND_STRING PROPERTY COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS})
TARGET_INCLUDE_DIRECTORIES(portaudio PRIVATE ${PA_PRIVATE_INCLUDE_PATHS})
- TARGET_INCLUDE_DIRECTORIES(portaudio PUBLIC "$")
+ TARGET_INCLUDE_DIRECTORIES(portaudio PUBLIC "$" "$")
TARGET_LINK_LIBRARIES(portaudio ${PA_LIBRARY_DEPENDENCIES})
ENDIF()
@@ -381,7 +381,7 @@ IF(PA_BUILD_STATIC)
ADD_LIBRARY(portaudio_static STATIC ${PA_INCLUDES} ${PA_COMMON_INCLUDES} ${PA_SOURCES} ${PA_NON_UNICODE_SOURCES})
SET_PROPERTY(TARGET portaudio_static APPEND_STRING PROPERTY COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS})
TARGET_INCLUDE_DIRECTORIES(portaudio_static PRIVATE ${PA_PRIVATE_INCLUDE_PATHS})
- TARGET_INCLUDE_DIRECTORIES(portaudio_static PUBLIC "$")
+ TARGET_INCLUDE_DIRECTORIES(portaudio_static PUBLIC "$" "$")
TARGET_LINK_LIBRARIES(portaudio_static ${PA_LIBRARY_DEPENDENCIES})
IF(NOT PA_LIBNAME_ADD_SUFFIX)
SET_PROPERTY(TARGET portaudio_static PROPERTY OUTPUT_NAME portaudio)
From ccc88607b60e7fad7be4fc26c7a0d47aeae3fe15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?=
Date: Thu, 12 Nov 2020 00:25:34 +0100
Subject: [PATCH 029/157] Don't crash if alsa_snd_pcm_poll_descriptors fails
---
src/hostapi/alsa/pa_linux_alsa.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c
index 5539d9d..48d77c1 100644
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -3642,8 +3642,11 @@ static PaError PaAlsaStreamComponent_BeginPolling( PaAlsaStreamComponent* self,
PaError result = paNoError;
int ret = alsa_snd_pcm_poll_descriptors( self->pcm, pfds, self->nfds );
(void)ret; /* Prevent unused variable warning if asserts are turned off */
- assert( ret == self->nfds );
-
+ /* If alsa returns anything else, like -EPIPE return*/
+ if( ret != self->nfds )
+ {
+ return paUnanticipatedHostError;
+ }
self->ready = 0;
return result;
@@ -3810,7 +3813,12 @@ static PaError PaAlsaStream_WaitForFrames( PaAlsaStream *self, unsigned long *fr
{
/* self->pfds is in effect an array of fds; if necessary, index past the capture fds */
playbackPfds = self->pfds + (pollCapture ? self->capture.nfds : 0);
- PA_ENSURE( PaAlsaStreamComponent_BeginPolling( &self->playback, playbackPfds ) );
+ int res = PaAlsaStreamComponent_BeginPolling( &self->playback, playbackPfds );
+ if( res != paNoError)
+ {
+ xrun = 1;
+ goto end;
+ }
totalFds += self->playback.nfds;
}
From 7e2a33c875c6b2b53a8925959496cc698765621f Mon Sep 17 00:00:00 2001
From: Colin McEwan
Date: Thu, 19 Nov 2020 02:22:22 +0000
Subject: [PATCH 030/157] Fix crashes on disconnected pins in wmdks topologies.
(#300)
* Fix crashes on disconnected pins in wmdks topologies.
* Fix potential assert on disconnected physical output pin in PinNew
---
src/hostapi/wdmks/pa_win_wdmks.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/hostapi/wdmks/pa_win_wdmks.c b/src/hostapi/wdmks/pa_win_wdmks.c
index 2403ed5..15ba438 100644
--- a/src/hostapi/wdmks/pa_win_wdmks.c
+++ b/src/hostapi/wdmks/pa_win_wdmks.c
@@ -1057,8 +1057,9 @@ static const KSTOPOLOGY_CONNECTION* FindStartConnectionFrom(ULONG startPin, PaWi
}
}
+ /* Some devices may report topologies that leave pins unconnected. This may be by design or driver installation
+ issues. Pass the error condition back to caller. */
PA_DEBUG(("FindStartConnectionFrom: returning NULL\n"));
- assert(FALSE);
return 0;
}
@@ -1077,8 +1078,8 @@ static const KSTOPOLOGY_CONNECTION* FindStartConnectionTo(ULONG startPin, PaWinW
}
}
+ /* Unconnected pin. Inform caller. */
PA_DEBUG(("FindStartConnectionTo: returning NULL\n"));
- assert(FALSE);
return 0;
}
@@ -1970,8 +1971,8 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
}
else
{
- /* Should never come here! */
- assert(FALSE);
+ /* Unconnected pin */
+ goto error;
}
}
}
From 4793ce4fbff3565d107ce306b632b664ff99276c Mon Sep 17 00:00:00 2001
From: Paul Boersma
Date: Thu, 26 Nov 2020 02:39:01 +0100
Subject: [PATCH 031/157] Add missing void argument, and include include
pa_jack.h in pa_jack.c (#347)
* Update pa_jack.c
include `pa_jack.h` in `pa_jack.c`, which provides prototypes for PaJack_SetClientName() and PaJack_GetClientName()
* Update pa_unix_util.h
PaUnixThreading_Initialize() is not a prototype in C, make it PaUnixThreading_Initialize(void)
* Update pa_unix_util.c
make PaUnixThreading_Initialize definition correspond to prototype
---
src/hostapi/jack/pa_jack.c | 2 ++
src/os/unix/pa_unix_util.c | 2 +-
src/os/unix/pa_unix_util.h | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/hostapi/jack/pa_jack.c b/src/hostapi/jack/pa_jack.c
index a800f8e..5ec55c6 100644
--- a/src/hostapi/jack/pa_jack.c
+++ b/src/hostapi/jack/pa_jack.c
@@ -71,6 +71,8 @@
#include "pa_ringbuffer.h"
#include "pa_debugprint.h"
+#include "pa_jack.h"
+
static pthread_t mainThread_;
static char *jackErr_ = NULL;
static const char* clientName_ = "PortAudio";
diff --git a/src/os/unix/pa_unix_util.c b/src/os/unix/pa_unix_util.c
index 17664ea..5472336 100644
--- a/src/os/unix/pa_unix_util.c
+++ b/src/os/unix/pa_unix_util.c
@@ -236,7 +236,7 @@ pthread_t paUnixMainThread = 0;
pthread_t paUnixMainThread = 0;
#endif
-PaError PaUnixThreading_Initialize()
+PaError PaUnixThreading_Initialize( void )
{
paUnixMainThread = pthread_self();
return paNoError;
diff --git a/src/os/unix/pa_unix_util.h b/src/os/unix/pa_unix_util.h
index d73c99c..c401f19 100644
--- a/src/os/unix/pa_unix_util.h
+++ b/src/os/unix/pa_unix_util.h
@@ -157,7 +157,7 @@ typedef struct
/** Initialize global threading state.
*/
-PaError PaUnixThreading_Initialize();
+PaError PaUnixThreading_Initialize( void );
/** Perish, passing on eventual error code.
*
From 521209c6335b3d835d77614e9015fe0ae0b46d9d Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 26 Nov 2020 13:46:05 +1100
Subject: [PATCH 032/157] pa_mac_core_utilities: add void to empty function
argument list (#355)
Insert "void" in the argument list to turn initializeXRunListenerList and destroyXRunListenerList declarations into valid prototypes. Also update the function definitions to match. Thanks to Paul Boersma.
---
src/hostapi/coreaudio/pa_mac_core_utilities.c | 4 ++--
src/hostapi/coreaudio/pa_mac_core_utilities.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.c b/src/hostapi/coreaudio/pa_mac_core_utilities.c
index 63e616f..f3563ee 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.c
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.c
@@ -641,13 +641,13 @@ OSStatus xrunCallback(
return 0;
}
-int initializeXRunListenerList()
+int initializeXRunListenerList( void )
{
xRunListSize = 0;
bzero( (void *) &firstXRunListNode, sizeof(firstXRunListNode) );
return pthread_mutex_init( &xrunMutex, NULL );
}
-int destroyXRunListenerList()
+int destroyXRunListenerList( void )
{
PaMacXRunListNode *node;
node = firstXRunListNode.next;
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.h b/src/hostapi/coreaudio/pa_mac_core_utilities.h
index 7c4afe5..fc65868 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.h
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.h
@@ -206,9 +206,9 @@ OSStatus xrunCallback(
void* inClientData ) ;
/** returns zero on success or a unix style error code. */
-int initializeXRunListenerList();
+int initializeXRunListenerList( void );
/** returns zero on success or a unix style error code. */
-int destroyXRunListenerList();
+int destroyXRunListenerList( void );
/**Returns the list, so that it can be passed to CorAudio.*/
void *addToXRunListenerList( void *stream );
From b37657be7081c8cd4dbb16f1f592082795dce776 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?=
Date: Fri, 27 Nov 2020 08:40:45 +0100
Subject: [PATCH 033/157] Remove superfluid void cast
---
src/hostapi/alsa/pa_linux_alsa.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c
index 48d77c1..0564351 100644
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -3641,7 +3641,6 @@ static PaError PaAlsaStreamComponent_BeginPolling( PaAlsaStreamComponent* self,
{
PaError result = paNoError;
int ret = alsa_snd_pcm_poll_descriptors( self->pcm, pfds, self->nfds );
- (void)ret; /* Prevent unused variable warning if asserts are turned off */
/* If alsa returns anything else, like -EPIPE return*/
if( ret != self->nfds )
{
From 5f35d35ad0f171dc0456d6806539df7bc67f8f1b Mon Sep 17 00:00:00 2001
From: Dmitry Kostjuchenko
Date: Tue, 8 Dec 2020 08:26:54 +0200
Subject: [PATCH 034/157] Fixed breaking strict-aliasing rules (if compiled
with GCC with -fstrict-aliasing) in PaWin_InitializeWaveFormatExtensible().
(#342)
---
src/os/win/pa_win_waveformat.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/os/win/pa_win_waveformat.c b/src/os/win/pa_win_waveformat.c
index bd5addd..5c6f29d 100644
--- a/src/os/win/pa_win_waveformat.c
+++ b/src/os/win/pa_win_waveformat.c
@@ -98,14 +98,15 @@ void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
waveFormatEx->wBitsPerSample = bytesPerSample * 8;
waveFormatEx->cbSize = 22;
- *((WORD*)&waveFormat->fields[PAWIN_INDEXOF_WVALIDBITSPERSAMPLE]) =
- waveFormatEx->wBitsPerSample;
+ memcpy(&waveFormat->fields[PAWIN_INDEXOF_WVALIDBITSPERSAMPLE],
+ &waveFormatEx->wBitsPerSample, sizeof(WORD));
+
+ memcpy(&waveFormat->fields[PAWIN_INDEXOF_DWCHANNELMASK],
+ &channelMask, sizeof(DWORD));
- *((DWORD*)&waveFormat->fields[PAWIN_INDEXOF_DWCHANNELMASK]) = channelMask;
-
guid = pawin_ksDataFormatSubtypeGuidBase;
guid.Data1 = (USHORT)waveFormatTag;
- *((GUID*)&waveFormat->fields[PAWIN_INDEXOF_SUBFORMAT]) = guid;
+ memcpy(&waveFormat->fields[PAWIN_INDEXOF_SUBFORMAT], &guid, sizeof(GUID));
}
PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels )
From e5279859cecd4d2e0bd68b6cfc07a5c40a73a5eb Mon Sep 17 00:00:00 2001
From: Nemirtingas <9432037+Nemirtingas@users.noreply.github.com>
Date: Tue, 8 Dec 2020 07:28:56 +0100
Subject: [PATCH 035/157] Fix GUID defines in pa_win_wdmks.c when compiling
with clang-cl (#327)
Fix GUID defines in pa_win_wdmks.c when compiling with clang-cl
Co-authored-by: Nemirtingas
---
src/hostapi/wdmks/pa_win_wdmks.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/hostapi/wdmks/pa_win_wdmks.c b/src/hostapi/wdmks/pa_win_wdmks.c
index 15ba438..add663b 100644
--- a/src/hostapi/wdmks/pa_win_wdmks.c
+++ b/src/hostapi/wdmks/pa_win_wdmks.c
@@ -163,9 +163,15 @@ Default is to use the pin category.
#define DYNAMIC_GUID(data) {data}
#define _NTRTL_ /* Turn off default definition of DEFINE_GUIDEX */
#undef DEFINE_GUID
-#define DEFINE_GUID(n,data) EXTERN_C const GUID n = {data}
-#define DEFINE_GUID_THUNK(n,data) DEFINE_GUID(n,data)
-#define DEFINE_GUIDEX(n) DEFINE_GUID_THUNK(n, STATIC_##n)
+#ifdef __clang__ /* clang-cl: avoid too many arguments error */
+ #define DEFINE_GUID(n, ...) EXTERN_C const GUID n = {__VA_ARGS__}
+ #define DEFINE_GUID_THUNK(n, ...) DEFINE_GUID(n, __VA_ARGS__)
+ #define DEFINE_GUIDEX(n) DEFINE_GUID_THUNK(n, STATIC_##n)
+#else
+ #define DEFINE_GUID(n, data) EXTERN_C const GUID n = {data}
+ #define DEFINE_GUID_THUNK(n, data) DEFINE_GUID(n, data)
+ #define DEFINE_GUIDEX(n) DEFINE_GUID_THUNK(n, STATIC_##n)
+#endif /* __clang__ */
#endif
#include
From f3924081ab5004deb86ed055d674bd018959b878 Mon Sep 17 00:00:00 2001
From: dmitrykos
Date: Fri, 11 Dec 2020 15:30:08 +0200
Subject: [PATCH 036/157] wasapi: Fixed underruns in the Exclusive mode on UWP
platform (or when timeBeginPeriod does not allow to set 1 ms granularity) by
assuming that system timer granularity on UWP equals to 10 msec, make sure
time to sleep provided by GetNextSleepTime is aligned to the granularity of
the system timer.
---
src/hostapi/wasapi/pa_win_wasapi.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index 7e321f1..216796e 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -825,7 +825,7 @@ static inline UINT32 ThreadIdleScheduler_NextSleep(ThreadIdleScheduler *sched)
// ------------------------------------------------------------------------------------------
typedef struct _SystemTimer
{
- UINT32 granularity;
+ INT32 granularity;
} SystemTimer;
static LARGE_INTEGER g_SystemTimerFrequency;
@@ -849,12 +849,15 @@ static BOOL SystemTimer_SetGranularity(SystemTimer *timer, UINT32 granularity)
{
PRINT(("SetSystemTimer: timeBeginPeriod(1) failed!\n"));
- timer->granularity = 0;
+ timer->granularity = 10;
return FALSE;
}
#else
- (void)timer;
(void)granularity;
+
+ // UWP does not support increase of the timer precision change and thus calling WaitForSingleObject with anything
+ // below 10 milliseconds will cause underruns for input and output stream.
+ timer->granularity = 10;
#endif
return TRUE;
@@ -6113,8 +6116,11 @@ static inline INT32 GetNextSleepTime(SystemTimer *timer, ThreadIdleScheduler *sc
//
INT32 procTime = (INT32)(SystemTimer_GetTime(timer) - startTime);
nextSleepTime -= procTime;
- if (nextSleepTime < 0)
+ if (nextSleepTime < timer->granularity)
nextSleepTime = 0;
+ else
+ if (timer->granularity > 1)
+ nextSleepTime = ALIGN_BWD(nextSleepTime, timer->granularity);
#ifdef PA_WASAPI_LOG_TIME_SLOTS
printf("{%d},", procTime);
From e1c3e59ee8bafe7e3e2e3b0c703b72c97649bcff Mon Sep 17 00:00:00 2001
From: luz paz
Date: Fri, 11 Dec 2020 07:37:23 -0500
Subject: [PATCH 037/157] Fix user-facing and non-user-facing typos
Found via `codespell v2.1.dev0`
---
README.md | 4 +--
aclocal.m4 | 4 +--
bindings/cpp/ChangeLog | 8 ++---
bindings/cpp/aclocal.m4 | 2 +-
bindings/cpp/build/gnu/config.guess | Bin 38293 -> 38292 bytes
bindings/cpp/example/devs.cxx | 8 ++---
bindings/cpp/example/sine.cxx | 8 ++---
.../portaudiocpp/AsioDeviceAdapter.hxx | 2 +-
bindings/cpp/include/portaudiocpp/Device.hxx | 2 +-
.../cpp/include/portaudiocpp/Exception.hxx | 2 +-
bindings/cpp/include/portaudiocpp/HostApi.hxx | 2 +-
.../cpp/include/portaudiocpp/PortAudioCpp.hxx | 2 +-
bindings/cpp/include/portaudiocpp/Stream.hxx | 2 +-
bindings/cpp/include/portaudiocpp/System.hxx | 2 +-
.../source/portaudiocpp/StreamParameters.cxx | 2 +-
.../jtests/com/portaudio/TestBasic.java | 6 ++--
build/msvc/readme.txt | 2 +-
doc/src/api_overview.dox | 2 +-
doc/src/tutorial/compile_cmake.dox | 2 +-
doc/src/tutorial/compile_linux.dox | 2 +-
doc/src/tutorial/start_stop_abort.dox | 2 +-
examples/pa_fuzz.c | 2 +-
examples/paex_mono_asio_channel_select.c | 2 +-
examples/paex_ocean_shore.c | 2 +-
examples/paex_pink.c | 2 +-
examples/paex_read_write_wire.c | 2 +-
examples/paex_record.c | 2 +-
examples/paex_record_file.c | 2 +-
examples/paex_saw.c | 2 +-
examples/paex_sine.c | 2 +-
examples/paex_sine_c++.cpp | 2 +-
examples/paex_wmme_ac3.c | 2 +-
examples/paex_wmme_surround.c | 2 +-
examples/paex_write_sine.c | 2 +-
examples/paex_write_sine_nonint.c | 2 +-
include/pa_asio.h | 4 +--
include/pa_mac_core.h | 8 ++---
include/pa_win_wasapi.h | 16 ++++-----
include/pa_win_wmme.h | 2 +-
ltmain.sh | 4 +--
pablio/test_rw.c | 2 +-
pablio/test_rw_echo.c | 2 +-
pablio/test_w_saw.c | 2 +-
pablio/test_w_saw8.c | 2 +-
qa/loopback/src/audio_analyzer.h | 2 +-
qa/loopback/src/paqa.c | 4 +--
qa/loopback/src/paqa_tools.c | 4 +--
src/common/pa_allocation.h | 2 +-
src/common/pa_converters.c | 2 +-
src/common/pa_converters.h | 6 ++--
src/common/pa_endianness.h | 6 ++--
src/common/pa_front.c | 8 ++---
src/common/pa_process.h | 18 +++++-----
src/common/pa_util.h | 6 ++--
src/hostapi/alsa/pa_linux_alsa.c | 12 +++----
src/hostapi/asio/pa_asio.cpp | 28 +++++++--------
src/hostapi/coreaudio/notes.txt | 2 +-
src/hostapi/coreaudio/pa_mac_core.c | 16 ++++-----
src/hostapi/coreaudio/pa_mac_core_blocking.c | 6 ++--
src/hostapi/coreaudio/pa_mac_core_utilities.c | 10 +++---
src/hostapi/coreaudio/pa_mac_core_utilities.h | 6 ++--
src/hostapi/dsound/pa_win_ds.c | 12 +++----
src/hostapi/dsound/pa_win_ds_dynlink.c | 2 +-
src/hostapi/dsound/pa_win_ds_dynlink.h | 2 +-
src/hostapi/oss/pa_unix_oss.c | 12 +++----
src/hostapi/skeleton/pa_hostapi_skeleton.c | 4 +--
src/hostapi/wasapi/mingw-include/ksproxy.h | 2 +-
src/hostapi/wasapi/pa_win_wasapi.c | 34 +++++++++---------
src/hostapi/wdmks/pa_win_wdmks.c | 4 +--
src/hostapi/wdmks/readme.txt | 2 +-
src/hostapi/wmme/pa_win_wmme.c | 12 +++----
src/os/unix/pa_unix_util.h | 4 +--
src/os/win/pa_win_waveformat.c | 4 +--
src/os/win/pa_win_wdmks_utils.h | 2 +-
src/os/win/pa_x86_plain_converters.c | 4 +--
test/pa_minlat.c | 2 +-
test/patest1.c | 4 +--
test/patest_buffer.c | 2 +-
test/patest_callbackstop.c | 2 +-
test/patest_clip.c | 2 +-
test/patest_dither.c | 2 +-
test/patest_dsound_low_level_latency_params.c | 2 +-
test/patest_dsound_surround.c | 2 +-
test/patest_hang.c | 2 +-
test/patest_in_overflow.c | 4 +--
test/patest_jack_wasapi.c | 4 +--
test/patest_latency.c | 2 +-
test/patest_leftright.c | 2 +-
test/patest_longsine.c | 2 +-
test/patest_many.c | 2 +-
test/patest_maxsines.c | 2 +-
test/patest_mono.c | 2 +-
test/patest_multi_sine.c | 2 +-
test/patest_out_underflow.c | 2 +-
test/patest_prime.c | 4 +--
test/patest_read_record.c | 2 +-
test/patest_sine8.c | 2 +-
test/patest_sine_channelmaps.c | 2 +-
test/patest_sine_formats.c | 2 +-
test/patest_sine_srate.c | 2 +-
test/patest_sine_time.c | 2 +-
test/patest_start_stop.c | 2 +-
test/patest_stop.c | 2 +-
test/patest_stop_playout.c | 2 +-
test/patest_suggested_vs_streaminfo_latency.c | 2 +-
test/patest_sync.c | 2 +-
test/patest_timing.c | 2 +-
test/patest_toomanysines.c | 2 +-
test/patest_two_rates.c | 2 +-
test/patest_underflow.c | 2 +-
test/patest_unplug.c | 2 +-
test/patest_wire.c | 2 +-
test/patest_wmme_find_best_latency_params.c | 4 +--
test/patest_wmme_low_level_latency_params.c | 2 +-
test/patest_write_stop.c | 2 +-
test/patest_write_stop_hang_illegal.c | 2 +-
116 files changed, 233 insertions(+), 233 deletions(-)
diff --git a/README.md b/README.md
index 74cfe6f..bf48975 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ Please feel free to join. See http://www.portaudio.com for details.
## Important Files and Folders:
include/portaudio.h = header file for PortAudio API. Specifies API.
- src/common/ = platform independant code, host independant
+ src/common/ = platform independent code, host independent
code for all implementations.
src/os = os specific (but host api neutral) code
src/hostapi = implementations for different host apis
@@ -58,5 +58,5 @@ Please feel free to join. See http://www.portaudio.com for details.
test/patest_record.c = record and playback some audio
test/patest_maxsines.c = how many sine waves can we play? Tests Pa_GetCPULoad().
test/patest_sine.c = output a sine wave in a simple PA app
- test/patest_sync.c = test syncronization of audio and video
+ test/patest_sync.c = test synchronization of audio and video
test/patest_wire.c = pass input to output, wire simulator
diff --git a/aclocal.m4 b/aclocal.m4
index 85326be..f6850af 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -649,7 +649,7 @@ configured by $[0], generated by m4_PACKAGE_STRING.
Copyright (C) 2011 Free Software Foundation, Inc.
This config.lt script is free software; the Free Software Foundation
-gives unlimited permision to copy, distribute and modify it."
+gives unlimited permission to copy, distribute and modify it."
while test $[#] != 0
do
@@ -8669,7 +8669,7 @@ fi[]dnl
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
#
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-# only at the first occurence in configure.ac, so if the first place
+# only at the first occurrence in configure.ac, so if the first place
# it's called might be skipped (such as if it is within an "if", you
# have to call PKG_CHECK_EXISTS manually
# --------------------------------------------------------------
diff --git a/bindings/cpp/ChangeLog b/bindings/cpp/ChangeLog
index 6b0b027..1e96618 100644
--- a/bindings/cpp/ChangeLog
+++ b/bindings/cpp/ChangeLog
@@ -12,7 +12,7 @@ PortAudioCpp v19 revision 15 (unknown release date):
mblaauw:
- Changed some exception handling code in HostApi's constructor.
- - Added accessors to PortAudio PaStream from PortAudioCpp Stream (their absense being pointed out
+ - Added accessors to PortAudio PaStream from PortAudioCpp Stream (their absence being pointed out
by Tom Jordan).
- Fixed a bug/typo in MemFunToCallbackInterfaceAdapter::init() thanks to Fredrik Viklund.
- Fixed issue with concrete Stream classes possibly throwing an exception and fixed documentation w.r.t. this.
@@ -37,14 +37,14 @@ PortAudioCpp v19 revision 13 03/10/19:
the std::exception base class's what() member function (which had throw(), i.e. no-throw guarantee).
- Changed the iterators so that they have a set of public typedefs instead of deriving the C++ standard
library std::iterator<> struct. G++ 2.95 doesn't support std::exception<> and composition-by-aggregation
- is prefered over composition-by-inheritance in this case.
+ is preferred over composition-by-inheritance in this case.
- Changed some minor things to avoid G++ warning messages.
mblaauw:
- Renamed this file (/WHATSNEW.txt) to /CHANGELOG.
- Renamed /PA_ISSUES.txt to /PA_ISSUES.
- Added /INSTALL file with some build info for GNU/Linux and VC6.
- - Added MSVC 6.0 projects for building PortAudioCpp as a staticly or dynamically linkable library.
+ - Added MSVC 6.0 projects for building PortAudioCpp as a statically or dynamically linkable library.
- Moved build files to /build/(gnu/ or vc6/).
- Moved Doxygen configuration files to /doc/ and output to /doc/api_reference/.
- Added a /doc/README with some info how to generate Doxygen documentation.
@@ -82,7 +82,7 @@ PortAudioCpp v19 revision 09 03/06/25:
mblaauw:
- Changed some things in SingleDirectionStreamParameters to ease it's usage.
- Placed all SingleDirectionStreamParameters stuff into a separate file.
- + Totally redid the callback stuff, now it's less ackward and supports C++ functions.
+ + Totally redid the callback stuff, now it's less awkward and supports C++ functions.
PortAudioCpp v19 revision 08 03/06/20:
diff --git a/bindings/cpp/aclocal.m4 b/bindings/cpp/aclocal.m4
index 68c908f..f5dec8f 100644
--- a/bindings/cpp/aclocal.m4
+++ b/bindings/cpp/aclocal.m4
@@ -657,7 +657,7 @@ configured by $[0], generated by m4_PACKAGE_STRING.
Copyright (C) 2011 Free Software Foundation, Inc.
This config.lt script is free software; the Free Software Foundation
-gives unlimited permision to copy, distribute and modify it."
+gives unlimited permission to copy, distribute and modify it."
while test $[#] != 0
do
diff --git a/bindings/cpp/build/gnu/config.guess b/bindings/cpp/build/gnu/config.guess
index 297e5c30f41b65e95341322c77994c4d1d447134..d5128acaf109e638a025c86cfdf17c453b4339c1 100644
GIT binary patch
delta 14
WcmbQbnrX^vrVY0QHs2Q5)dB!B00#O1
delta 14
WcmbQTnrZ54rVY0QHs2K3-2wnI_Xha@
diff --git a/bindings/cpp/example/devs.cxx b/bindings/cpp/example/devs.cxx
index 31a560f..5ef4cab 100644
--- a/bindings/cpp/example/devs.cxx
+++ b/bindings/cpp/example/devs.cxx
@@ -158,19 +158,19 @@ int main(int, char*[])
}
catch (const portaudio::PaException &e)
{
- std::cout << "A PortAudio error occured: " << e.paErrorText() << std::endl;
+ std::cout << "A PortAudio error occurred: " << e.paErrorText() << std::endl;
}
catch (const portaudio::PaCppException &e)
{
- std::cout << "A PortAudioCpp error occured: " << e.what() << std::endl;
+ std::cout << "A PortAudioCpp error occurred: " << e.what() << std::endl;
}
catch (const std::exception &e)
{
- std::cout << "A generic exception occured: " << e.what() << std::endl;
+ std::cout << "A generic exception occurred: " << e.what() << std::endl;
}
catch (...)
{
- std::cout << "An unknown exception occured." << std::endl;
+ std::cout << "An unknown exception occurred." << std::endl;
}
return 0;
diff --git a/bindings/cpp/example/sine.cxx b/bindings/cpp/example/sine.cxx
index 0676e3e..0c772e6 100644
--- a/bindings/cpp/example/sine.cxx
+++ b/bindings/cpp/example/sine.cxx
@@ -116,19 +116,19 @@ int main(int, char *[])
}
catch (const portaudio::PaException &e)
{
- std::cout << "A PortAudio error occured: " << e.paErrorText() << std::endl;
+ std::cout << "A PortAudio error occurred: " << e.paErrorText() << std::endl;
}
catch (const portaudio::PaCppException &e)
{
- std::cout << "A PortAudioCpp error occured: " << e.what() << std::endl;
+ std::cout << "A PortAudioCpp error occurred: " << e.what() << std::endl;
}
catch (const std::exception &e)
{
- std::cout << "A generic exception occured: " << e.what() << std::endl;
+ std::cout << "A generic exception occurred: " << e.what() << std::endl;
}
catch (...)
{
- std::cout << "An unknown exception occured." << std::endl;
+ std::cout << "An unknown exception occurred." << std::endl;
}
return 0;
diff --git a/bindings/cpp/include/portaudiocpp/AsioDeviceAdapter.hxx b/bindings/cpp/include/portaudiocpp/AsioDeviceAdapter.hxx
index 26957c4..59f6095 100644
--- a/bindings/cpp/include/portaudiocpp/AsioDeviceAdapter.hxx
+++ b/bindings/cpp/include/portaudiocpp/AsioDeviceAdapter.hxx
@@ -11,7 +11,7 @@ namespace portaudio
//////
/// @brief Adapts the given Device to an ASIO specific extension.
///
- /// Deleting the AsioDeviceAdapter does not affect the underlaying
+ /// Deleting the AsioDeviceAdapter does not affect the underlying
/// Device.
//////
class AsioDeviceAdapter
diff --git a/bindings/cpp/include/portaudiocpp/Device.hxx b/bindings/cpp/include/portaudiocpp/Device.hxx
index 3c6c3c0..0599582 100644
--- a/bindings/cpp/include/portaudiocpp/Device.hxx
+++ b/bindings/cpp/include/portaudiocpp/Device.hxx
@@ -41,7 +41,7 @@ namespace portaudio
{
public:
// query info: name, max in channels, max out channels,
- // default low/hight input/output latency, default sample rate
+ // default low/high input/output latency, default sample rate
PaDeviceIndex index() const;
const char *name() const;
int maxInputChannels() const;
diff --git a/bindings/cpp/include/portaudiocpp/Exception.hxx b/bindings/cpp/include/portaudiocpp/Exception.hxx
index f5249c9..02d36b2 100644
--- a/bindings/cpp/include/portaudiocpp/Exception.hxx
+++ b/bindings/cpp/include/portaudiocpp/Exception.hxx
@@ -36,7 +36,7 @@ namespace portaudio
/// other code.
///
/// To know what exceptions each function may throw, look up
- /// the errors that can occure in the PortAudio documentation
+ /// the errors that can occur in the PortAudio documentation
/// for the equivalent functions.
///
/// Some functions are likely to throw an exception (such as
diff --git a/bindings/cpp/include/portaudiocpp/HostApi.hxx b/bindings/cpp/include/portaudiocpp/HostApi.hxx
index ce397ca..113558c 100644
--- a/bindings/cpp/include/portaudiocpp/HostApi.hxx
+++ b/bindings/cpp/include/portaudiocpp/HostApi.hxx
@@ -28,7 +28,7 @@ namespace portaudio
/// A single System can support multiple HostApi's each one typically having
/// a set of Devices using that HostApi (usually driver type). All Devices in
/// the HostApi can be enumerated and the default input/output Device for this
- /// HostApi can be retreived.
+ /// HostApi can be retrieved.
//////
class HostApi
{
diff --git a/bindings/cpp/include/portaudiocpp/PortAudioCpp.hxx b/bindings/cpp/include/portaudiocpp/PortAudioCpp.hxx
index 96df96e..1165550 100644
--- a/bindings/cpp/include/portaudiocpp/PortAudioCpp.hxx
+++ b/bindings/cpp/include/portaudiocpp/PortAudioCpp.hxx
@@ -50,7 +50,7 @@
/// Other platforms should be easily supported as PortAudioCpp is platform-independent and (reasonably) C++ standard compliant.
///
///
-/// This documentation mainly provides information specific to PortAudioCpp. For a more complete explaination of all of the
+/// This documentation mainly provides information specific to PortAudioCpp. For a more complete explanation of all of the
/// concepts used, please consult the PortAudio documentation.
///
///
diff --git a/bindings/cpp/include/portaudiocpp/Stream.hxx b/bindings/cpp/include/portaudiocpp/Stream.hxx
index 1aed747..a731930 100644
--- a/bindings/cpp/include/portaudiocpp/Stream.hxx
+++ b/bindings/cpp/include/portaudiocpp/Stream.hxx
@@ -29,7 +29,7 @@ namespace portaudio
/// clients need to explicitly call close() to ensure the stream closed successfully.
///
/// The Stream object can be used to manipulate the Stream's state. Also, time-constant
- /// and time-varying information about the Stream can be retreived.
+ /// and time-varying information about the Stream can be retrieved.
//////
class Stream
{
diff --git a/bindings/cpp/include/portaudiocpp/System.hxx b/bindings/cpp/include/portaudiocpp/System.hxx
index d5ff9dd..a159dc3 100644
--- a/bindings/cpp/include/portaudiocpp/System.hxx
+++ b/bindings/cpp/include/portaudiocpp/System.hxx
@@ -26,7 +26,7 @@ namespace portaudio
/// @brief System singleton which represents the PortAudio system.
///
/// The System is used to initialize/terminate PortAudio and provide
- /// a single acccess point to the PortAudio System (instance()).
+ /// a single access point to the PortAudio System (instance()).
/// It can be used to iterate through all HostApi 's in the System as
/// well as all devices in the System. It also provides some utility
/// functionality of PortAudio.
diff --git a/bindings/cpp/source/portaudiocpp/StreamParameters.cxx b/bindings/cpp/source/portaudiocpp/StreamParameters.cxx
index 5b9e897..5857710 100644
--- a/bindings/cpp/source/portaudiocpp/StreamParameters.cxx
+++ b/bindings/cpp/source/portaudiocpp/StreamParameters.cxx
@@ -39,7 +39,7 @@ namespace portaudio
//////
/// Sets the requested sample rate. If this sample rate isn't supported by the hardware, the
/// Stream will fail to open. The real-life sample rate used might differ slightly due to
- /// imperfections in the sound card hardware; use Stream::sampleRate() to retreive the
+ /// imperfections in the sound card hardware; use Stream::sampleRate() to retrieve the
/// best known estimate for this value.
//////
void StreamParameters::setSampleRate(double sampleRate)
diff --git a/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java b/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java
index b05750d..43b8fa7 100644
--- a/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java
+++ b/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java
@@ -219,7 +219,7 @@ public class TestBasic extends TestCase
e.printStackTrace();
}
- assertTrue( "caught no expection", (caught != null) );
+ assertTrue( "caught no exception", (caught != null) );
assertTrue( "exception should say stream is stopped", caught
.getMessage().contains( "stopped" ) );
@@ -233,7 +233,7 @@ public class TestBasic extends TestCase
caught = e;
e.printStackTrace();
}
- assertTrue( "caught no expection", (caught != null) );
+ assertTrue( "caught no exception", (caught != null) );
assertTrue( "exception should say stream is stopped", caught
.getMessage().contains( "null" ) );
@@ -251,7 +251,7 @@ public class TestBasic extends TestCase
e.printStackTrace();
}
- assertTrue( "caught no expection", (caught != null) );
+ assertTrue( "caught no exception", (caught != null) );
assertTrue( "exception should say tried to", caught.getMessage()
.contains( "Tried to write short" ) );
diff --git a/build/msvc/readme.txt b/build/msvc/readme.txt
index 5fe5e28..07421ff 100644
--- a/build/msvc/readme.txt
+++ b/build/msvc/readme.txt
@@ -24,7 +24,7 @@ This DLL contains all 5 current Win32 PA APIS (MME/DS/ASIO/WASAPI/WDMKS)
Service pack 5:
Latest known URL:
http://msdn2.microsoft.com/en-us/vstudio/aa718363.aspx
- Yes there EXISTS a service pack 6 , but the processor pack (below) isnt compatible with it.
+ Yes there EXISTS a service pack 6 , but the processor pack (below) isn't compatible with it.
Processor Pack(only works with above SP5)
Latest known URL:
diff --git a/doc/src/api_overview.dox b/doc/src/api_overview.dox
index 98a0dbd..e5704ce 100644
--- a/doc/src/api_overview.dox
+++ b/doc/src/api_overview.dox
@@ -112,7 +112,7 @@ Many of the tests in the /tests directory of the PortAudio distribution implemen
@subsection read_write_io_method The Read/Write I/O Method
-As an alternative to the callback I/O method, PortAudio provides a synchronous read/write interface for acquiring and playing audio. This can be useful for applications that don't require the lowest possibly latency, or don't warrant the increased complexity of synchronising with an asynchronous callback funciton. This I/O method is also useful when calling PortAudio from programming languages that don't support asynchronous callbacks.
+As an alternative to the callback I/O method, PortAudio provides a synchronous read/write interface for acquiring and playing audio. This can be useful for applications that don't require the lowest possibly latency, or don't warrant the increased complexity of synchronising with an asynchronous callback function. This I/O method is also useful when calling PortAudio from programming languages that don't support asynchronous callbacks.
To open a Stream in read/write mode you pass a NULL stream callback function pointer to Pa_OpenStream().
diff --git a/doc/src/tutorial/compile_cmake.dox b/doc/src/tutorial/compile_cmake.dox
index ab2a239..8db400e 100644
--- a/doc/src/tutorial/compile_cmake.dox
+++ b/doc/src/tutorial/compile_cmake.dox
@@ -23,7 +23,7 @@ The "-G" option specifies the type of build metadata which will be generated. Yo
"make install" should install the same set of files that are installed using the usual configure script included with PortAudio along with a few extra files (similar to pkg-config metadata files) which make it easier for other CMake projects to use the installed libraries.
-On Windows, you can use CMake to generate Visual Studio project files which can be used to create the PortAudio libraries. The following serves as an example (and should be done from a directory outside the PortAudio tree) which will create Visual Studio 2015 project files targetting a 64-bit build:
+On Windows, you can use CMake to generate Visual Studio project files which can be used to create the PortAudio libraries. The following serves as an example (and should be done from a directory outside the PortAudio tree) which will create Visual Studio 2015 project files targeting a 64-bit build:
C:\PABUILD> cmake {portaudio path} -G "Visual Studio 14 2015 Win64"
diff --git a/doc/src/tutorial/compile_linux.dox b/doc/src/tutorial/compile_linux.dox
index e227d75..2c993ca 100644
--- a/doc/src/tutorial/compile_linux.dox
+++ b/doc/src/tutorial/compile_linux.dox
@@ -47,7 +47,7 @@ On some systems you may need to use:
cp /usr/local/lib/libportaudio.a /YOUR/PROJECT/DIR
@endcode
-You may also need to copy portaudio.h, located in the include/ directory of PortAudio into your project. Note that you will usually need to link with the approriate libraries that you used, such as ALSA and JACK, as well as with librt and libpthread. For example:
+You may also need to copy portaudio.h, located in the include/ directory of PortAudio into your project. Note that you will usually need to link with the appropriate libraries that you used, such as ALSA and JACK, as well as with librt and libpthread. For example:
@code
gcc main.c libportaudio.a -lrt -lm -lasound -ljack -pthread -o YOUR_BINARY
diff --git a/doc/src/tutorial/start_stop_abort.dox b/doc/src/tutorial/start_stop_abort.dox
index 6d4f777..0ddb460 100644
--- a/doc/src/tutorial/start_stop_abort.dox
+++ b/doc/src/tutorial/start_stop_abort.dox
@@ -10,7 +10,7 @@ PortAudio will not start playing back audio until you start the stream. After ca
if( err != paNoError ) goto error;
@endcode
-You can communicate with your callback routine through the data structure you passed in on the open call, or through global variables, or using other interprocess communication techniques, but please be aware that your callback function may be called at interrupt time when your foreground process is least expecting it. So avoid sharing complex data structures that are easily corrupted like double linked lists, and avoid using locks such as mutexs as this may cause your callback function to block and therefore drop audio. Such techniques may even cause deadlock on some platforms.
+You can communicate with your callback routine through the data structure you passed in on the open call, or through global variables, or using other interprocess communication techniques, but please be aware that your callback function may be called at interrupt time when your foreground process is least expecting it. So avoid sharing complex data structures that are easily corrupted like double linked lists, and avoid using locks such as mutexes as this may cause your callback function to block and therefore drop audio. Such techniques may even cause deadlock on some platforms.
PortAudio will continue to call your callback and process audio until you stop the stream. This can be done in one of several ways, but, before we do so, we'll want to see that some of our audio gets processed by sleeping for a few seconds. This is easy to do with Pa_Sleep(), which is used by many of the examples in the patests/ directory for exactly this purpose. Note that, for a variety of reasons, you can not rely on this function for accurate scheduling, so your stream may not run for exactly the same amount of time as you expect, but it's good enough for our example.
diff --git a/examples/pa_fuzz.c b/examples/pa_fuzz.c
index d5f99ec..337e06d 100644
--- a/examples/pa_fuzz.c
+++ b/examples/pa_fuzz.c
@@ -176,7 +176,7 @@ int main(void)
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return -1;
diff --git a/examples/paex_mono_asio_channel_select.c b/examples/paex_mono_asio_channel_select.c
index a141ac0..71b0198 100644
--- a/examples/paex_mono_asio_channel_select.c
+++ b/examples/paex_mono_asio_channel_select.c
@@ -160,7 +160,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/examples/paex_ocean_shore.c b/examples/paex_ocean_shore.c
index 7eb7f20..ae645d6 100644
--- a/examples/paex_ocean_shore.c
+++ b/examples/paex_ocean_shore.c
@@ -526,7 +526,7 @@ int main(void)
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return 0;
diff --git a/examples/paex_pink.c b/examples/paex_pink.c
index 3714ba7..cd84324 100644
--- a/examples/paex_pink.c
+++ b/examples/paex_pink.c
@@ -272,7 +272,7 @@ int main(void)
return 0;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return 0;
diff --git a/examples/paex_read_write_wire.c b/examples/paex_read_write_wire.c
index 4208a01..813c74d 100644
--- a/examples/paex_read_write_wire.c
+++ b/examples/paex_read_write_wire.c
@@ -197,7 +197,7 @@ error2:
Pa_CloseStream( stream );
}
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return -1;
diff --git a/examples/paex_record.c b/examples/paex_record.c
index 99226fc..4c9105c 100644
--- a/examples/paex_record.c
+++ b/examples/paex_record.c
@@ -344,7 +344,7 @@ done:
free( data.recordedSamples );
if( err != paNoError )
{
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
err = 1; /* Always return 0 or 1, but no other return codes. */
diff --git a/examples/paex_record_file.c b/examples/paex_record_file.c
index 1f1211f..1e1f473 100644
--- a/examples/paex_record_file.c
+++ b/examples/paex_record_file.c
@@ -448,7 +448,7 @@ done:
PaUtil_FreeMemory( data.ringBufferData );
if( err != paNoError )
{
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
err = 1; /* Always return 0 or 1, but no other return codes. */
diff --git a/examples/paex_saw.c b/examples/paex_saw.c
index 235f247..6f477b8 100644
--- a/examples/paex_saw.c
+++ b/examples/paex_saw.c
@@ -126,7 +126,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/examples/paex_sine.c b/examples/paex_sine.c
index bda290b..99fecf7 100644
--- a/examples/paex_sine.c
+++ b/examples/paex_sine.c
@@ -168,7 +168,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/examples/paex_sine_c++.cpp b/examples/paex_sine_c++.cpp
index 2859a57..64d7829 100644
--- a/examples/paex_sine_c++.cpp
+++ b/examples/paex_sine_c++.cpp
@@ -268,7 +268,7 @@ int main(void)
return paNoError;
error:
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", paInit.result() );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( paInit.result() ) );
return 1;
diff --git a/examples/paex_wmme_ac3.c b/examples/paex_wmme_ac3.c
index e59c571..ac9212a 100644
--- a/examples/paex_wmme_ac3.c
+++ b/examples/paex_wmme_ac3.c
@@ -213,7 +213,7 @@ error:
Pa_Terminate();
free( data.buffer );
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/examples/paex_wmme_surround.c b/examples/paex_wmme_surround.c
index ddab73d..dfccc99 100644
--- a/examples/paex_wmme_surround.c
+++ b/examples/paex_wmme_surround.c
@@ -203,7 +203,7 @@ int main(int argc, char* argv[])
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/examples/paex_write_sine.c b/examples/paex_write_sine.c
index f5ead3f..9021b94 100644
--- a/examples/paex_write_sine.c
+++ b/examples/paex_write_sine.c
@@ -151,7 +151,7 @@ int main(void)
return err;
error:
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
// Print more information about the error.
diff --git a/examples/paex_write_sine_nonint.c b/examples/paex_write_sine_nonint.c
index 3a038e1..bc266c0 100644
--- a/examples/paex_write_sine_nonint.c
+++ b/examples/paex_write_sine_nonint.c
@@ -160,7 +160,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/include/pa_asio.h b/include/pa_asio.h
index 9c606a9..e612aa3 100644
--- a/include/pa_asio.h
+++ b/include/pa_asio.h
@@ -52,7 +52,7 @@ extern "C"
#endif /* __cplusplus */
-/** Retrieve legal native buffer sizes for the specificed device, in sample frames.
+/** Retrieve legal native buffer sizes for the specified device, in sample frames.
@param device The global index of the device about which the query is being made.
@param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
@@ -112,7 +112,7 @@ PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex,
@param stream The stream to operate on.
@param sampleRate The new sample rate.
- Note that this function may fail if the stream is alredy running and the
+ Note that this function may fail if the stream is already running and the
ASIO driver does not support switching the sample rate of a running stream.
Returns paIncompatibleStreamHostApi if stream is not a paASIO stream.
diff --git a/include/pa_mac_core.h b/include/pa_mac_core.h
index 83e40a6..85ecc03 100644
--- a/include/pa_mac_core.h
+++ b/include/pa_mac_core.h
@@ -112,20 +112,20 @@ AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
* Returns a statically allocated string with the device's name
* for the given channel. NULL will be returned on failure.
*
- * This function's implemenation is not complete!
+ * This function's implementation is not complete!
*
* @param device The PortAudio device index.
* @param channel The channel number who's name is requested.
* @return a statically allocated string with the name of the device.
* Because this string is statically allocated, it must be
- * coppied if it is to be saved and used by the user after
+ * copied if it is to be saved and used by the user after
* another call to this function.
*
*/
const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input );
-/** Retrieve the range of legal native buffer sizes for the specificed device, in sample frames.
+/** Retrieve the range of legal native buffer sizes for the specified device, in sample frames.
@param device The global index of the PortAudio device about which the query is being made.
@param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
@@ -158,7 +158,7 @@ PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
* are supported by the device. */
#define paMacCoreFailIfConversionRequired (0x02)
-/** These flags set the SR conversion quality, if required. The wierd ordering
+/** These flags set the SR conversion quality, if required. The weird ordering
* allows Maximum Quality to be the default.*/
#define paMacCoreConversionQualityMin (0x0100)
#define paMacCoreConversionQualityMedium (0x0200)
diff --git a/include/pa_win_wasapi.h b/include/pa_win_wasapi.h
index e8b93b6..ab5d541 100644
--- a/include/pa_win_wasapi.h
+++ b/include/pa_win_wasapi.h
@@ -267,7 +267,7 @@ PaWasapiJackDescription;
/** Stream category.
Note:
- values are equal to WASAPI AUDIO_STREAM_CATEGORY enum
- - supported since Windows 8.0, noop on earler versions
+ - supported since Windows 8.0, noop on earlier versions
- values 1,2 are deprecated on Windows 10 and not included into enumeration
@version Available as of 19.6.0
@@ -291,7 +291,7 @@ PaWasapiStreamCategory;
/** Stream option.
Note:
- values are equal to WASAPI AUDCLNT_STREAMOPTIONS enum
- - supported since Windows 8.1, noop on earler versions
+ - supported since Windows 8.1, noop on earlier versions
@version Available as of 19.6.0
*/
@@ -380,7 +380,7 @@ PaError PaWasapi_UpdateDeviceList();
/** Get current audio format of the device assigned to the opened stream.
Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
- Use this function to reconfirm format if PA's processor is overriden and
+ Use this function to reconfirm format if PA's processor is overridden and
paWinWasapiRedirectHostProcessor flag is specified.
@param pStream Pointer to PaStream object.
@@ -388,7 +388,7 @@ PaError PaWasapi_UpdateDeviceList();
@param formatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
@param bOutput TRUE (1) for output stream, FALSE (0) for input stream.
- @return Non-negative value indicating the number of bytes copied into format decriptor
+ @return Non-negative value indicating the number of bytes copied into format descriptor
or, a PaErrorCode (which is always negative) if PortAudio is not initialized
or an error is encountered.
*/
@@ -404,7 +404,7 @@ int PaWasapi_GetDeviceCurrentFormat( PaStream *pStream, void *pFormat, unsigned
@param formatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
@param device Device index.
- @return Non-negative value indicating the number of bytes copied into format decriptor
+ @return Non-negative value indicating the number of bytes copied into format descriptor
or, a PaErrorCode (which is always negative) if PortAudio is not initialized
or an error is encountered.
*/
@@ -420,7 +420,7 @@ int PaWasapi_GetDeviceDefaultFormat( void *pFormat, unsigned int formatSize, PaD
@param formatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
@param device Device index.
- @return Non-negative value indicating the number of bytes copied into format decriptor
+ @return Non-negative value indicating the number of bytes copied into format descriptor
or, a PaErrorCode (which is always negative) if PortAudio is not initialized
or an error is encountered.
*/
@@ -468,7 +468,7 @@ PaError PaWasapi_ThreadPriorityRevert( void *pTask );
/** Get number of frames per host buffer.
It is max value of frames of WASAPI buffer which can be locked for operations.
- Use this method as helper to findout max values of inputFrames/outputFrames
+ Use this method as helper to find out max values of inputFrames/outputFrames
of PaWasapiHostProcessorCallback.
@param pStream Pointer to PaStream object.
@@ -624,7 +624,7 @@ PaError PaWasapiWinrt_PopulateDeviceList( const unsigned short **pId, const unsi
under Windows Vista x64 when application is WOW64(32-bit) and Event-Driven method simply
times out (event handle is never signalled on buffer completion). Please note, such WOW64 bug
does not exist in Vista x86 or Windows 7.
- Polling can be setup by speciying 'paWinWasapiPolling' flag. Our WASAPI implementation detects
+ Polling can be setup by specifying 'paWinWasapiPolling' flag. Our WASAPI implementation detects
WOW64 bug and sets 'paWinWasapiPolling' automatically.
Thread priority:
diff --git a/include/pa_win_wmme.h b/include/pa_win_wmme.h
index f84b68b..b80743c 100644
--- a/include/pa_win_wmme.h
+++ b/include/pa_win_wmme.h
@@ -109,7 +109,7 @@ typedef struct PaWinMmeStreamInfo{
If devices are specified here, the corresponding device parameter
to Pa_OpenStream() should be set to paUseHostApiSpecificDeviceSpecification,
otherwise an paInvalidDevice error will result.
- The total number of channels accross all specified devices
+ The total number of channels across all specified devices
must agree with the corresponding channelCount parameter to
Pa_OpenStream() otherwise a paInvalidChannelCount error will result.
*/
diff --git a/ltmain.sh b/ltmain.sh
index a356aca..d668a02 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -189,7 +189,7 @@ func_basename ()
# to NONDIR_REPLACEMENT.
# value returned in "$func_dirname_result"
# basename: Compute filename of FILE.
-# value retuned in "$func_basename_result"
+# value returned in "$func_basename_result"
# Implementation must be kept synchronized with func_dirname
# and func_basename. For efficiency, we do not delegate to
# those functions but instead duplicate the functionality here.
@@ -4394,7 +4394,7 @@ EOF
{
/* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
namespace, but it is not one of the ones we know about and
- have already dealt with, above (inluding dump-script), then
+ have already dealt with, above (including dump-script), then
report an error. Otherwise, targets might begin to believe
they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
namespace. The first time any user complains about this, we'll
diff --git a/pablio/test_rw.c b/pablio/test_rw.c
index 1388246..029240d 100644
--- a/pablio/test_rw.c
+++ b/pablio/test_rw.c
@@ -98,7 +98,7 @@ int main(void)
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return -1;
diff --git a/pablio/test_rw_echo.c b/pablio/test_rw_echo.c
index 470b4b0..431587c 100644
--- a/pablio/test_rw_echo.c
+++ b/pablio/test_rw_echo.c
@@ -122,7 +122,7 @@ int main(void)
return 0;
error:
- fprintf( stderr, "An error occured while using PortAudio\n" );
+ fprintf( stderr, "An error occurred while using PortAudio\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return -1;
diff --git a/pablio/test_w_saw.c b/pablio/test_w_saw.c
index 39efe9e..2303d20 100644
--- a/pablio/test_w_saw.c
+++ b/pablio/test_w_saw.c
@@ -107,7 +107,7 @@ int main(void)
return 0;
error:
- fprintf( stderr, "An error occured while using PABLIO\n" );
+ fprintf( stderr, "An error occurred while using PABLIO\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return -1;
diff --git a/pablio/test_w_saw8.c b/pablio/test_w_saw8.c
index b62c820..70686c1 100644
--- a/pablio/test_w_saw8.c
+++ b/pablio/test_w_saw8.c
@@ -105,7 +105,7 @@ int main(void)
return 0;
error:
- fprintf( stderr, "An error occured while using PABLIO\n" );
+ fprintf( stderr, "An error occurred while using PABLIO\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return -1;
diff --git a/qa/loopback/src/audio_analyzer.h b/qa/loopback/src/audio_analyzer.h
index 2a86798..c98acbb 100644
--- a/qa/loopback/src/audio_analyzer.h
+++ b/qa/loopback/src/audio_analyzer.h
@@ -130,7 +130,7 @@ void PaQa_SetupSineGenerator( PaQaSineGenerator *generator, double frequency, do
/*================= Recordings ===================================*/
/*================================================================*/
/**
- * Allocate memory for containg a mono audio signal. Set up recording for writing.
+ * Allocate memory for containing a mono audio signal. Set up recording for writing.
*/
int PaQa_InitializeRecording( PaQaRecording *recording, int maxSamples, int sampleRate );
diff --git a/qa/loopback/src/paqa.c b/qa/loopback/src/paqa.c
index cb7100d..ac8e841 100644
--- a/qa/loopback/src/paqa.c
+++ b/qa/loopback/src/paqa.c
@@ -891,7 +891,7 @@ static int PaQa_SingleLoopBackTest( UserOptions *userOptions, TestParameters *te
printf( "OK" );
}
- // Print the # errors so far to make it easier to see where the error occured.
+ // Print the # errors so far to make it easier to see where the error occurred.
printf( " - #errs = %d\n", g_testsFailed );
PaQa_TeardownLoopbackContext( &loopbackContext );
@@ -1304,7 +1304,7 @@ static int CheckLoopbackAndScan( UserOptions *userOptions,
/**
* Scan every combination of output to input device.
* If a loopback is found the analyse the combination.
- * The scan can be overriden using the -i and -o command line options.
+ * The scan can be overridden using the -i and -o command line options.
*/
static int ScanForLoopback(UserOptions *userOptions)
{
diff --git a/qa/loopback/src/paqa_tools.c b/qa/loopback/src/paqa_tools.c
index 97b5058..3f04ada 100644
--- a/qa/loopback/src/paqa_tools.c
+++ b/qa/loopback/src/paqa_tools.c
@@ -146,7 +146,7 @@ void PaQa_ConvertFromFloat( const float *input, int numSamples, PaSampleFormat o
for( i=0; iint16 -rb */
+ float samp = *src * const_1_div_32768_; /* FIXME: i'm concerned about this being asymmetrical with float->int16 -rb */
*dest = samp;
src += sourceStride;
diff --git a/src/common/pa_converters.h b/src/common/pa_converters.h
index 469f075..1a912eb 100644
--- a/src/common/pa_converters.h
+++ b/src/common/pa_converters.h
@@ -59,7 +59,7 @@ struct PaUtilTriangularDitherGenerator;
/** Choose an available sample format which is most appropriate for
representing the requested format. If the requested format is not available
- higher quality formats are considered before lower quality formates.
+ higher quality formats are considered before lower quality formats.
@param availableFormats A variable containing the logical OR of all available
formats.
@param format The desired format.
@@ -211,7 +211,7 @@ typedef struct{
PaUtil_SelectConverter() uses this table to lookup the appropriate
conversion functions. The fields of this structure are initialized
with default conversion functions. Fields may be NULL, indicating that
- no conversion function is available. User code may substitue optimised
+ no conversion function is available. User code may substitute optimised
conversion functions by assigning different function pointers to
these fields.
@@ -242,7 +242,7 @@ typedef struct{
/** A table of pointers to all required zeroer functions.
PaUtil_SelectZeroer() uses this table to lookup the appropriate
conversion functions. The fields of this structure are initialized
- with default conversion functions. User code may substitue optimised
+ with default conversion functions. User code may substitute optimised
conversion functions by assigning different function pointers to
these fields.
diff --git a/src/common/pa_endianness.h b/src/common/pa_endianness.h
index 9e8e059..7496651 100644
--- a/src/common/pa_endianness.h
+++ b/src/common/pa_endianness.h
@@ -54,7 +54,7 @@
example.
A PA_VALIDATE_ENDIANNESS macro is provided to compare the compile time
- and runtime endiannes and raise an assertion if they don't match.
+ and runtime endianness and raise an assertion if they don't match.
*/
@@ -65,7 +65,7 @@ extern "C"
/* If this is an apple, we need to do detect endianness this way */
#if defined(__APPLE__)
- /* we need to do some endian detection that is sensitive to harware arch */
+ /* we need to do some endian detection that is sensitive to hardware arch */
#if defined(__LITTLE_ENDIAN__)
#if !defined( PA_LITTLE_ENDIAN )
#define PA_LITTLE_ENDIAN
@@ -83,7 +83,7 @@ extern "C"
#endif
#else
/* this is not an apple, so first check the existing defines, and, failing that,
- detect well-known architechtures. */
+ detect well-known architectures. */
#if defined(PA_LITTLE_ENDIAN) || defined(PA_BIG_ENDIAN)
/* endianness define has been set externally, such as by autoconf */
diff --git a/src/common/pa_front.c b/src/common/pa_front.c
index 9d30f48..9a258eb 100644
--- a/src/common/pa_front.c
+++ b/src/common/pa_front.c
@@ -74,7 +74,7 @@
#include "pa_types.h"
#include "pa_hostapi.h"
#include "pa_stream.h"
-#include "pa_trace.h" /* still usefull?*/
+#include "pa_trace.h" /* still useful?*/
#include "pa_debugprint.h"
#ifndef PA_GIT_REVISION
@@ -805,7 +805,7 @@ static int SampleFormatIsValid( PaSampleFormat format )
}
/*
- NOTE: make sure this validation list is kept syncronised with the one in
+ NOTE: make sure this validation list is kept synchronised with the one in
pa_hostapi.h
ValidateOpenStreamParameters() checks that parameters to Pa_OpenStream()
@@ -884,7 +884,7 @@ static PaError ValidateOpenStreamParameters(
PaDeviceIndex *hostApiInputDevice,
PaDeviceIndex *hostApiOutputDevice )
{
- int inputHostApiIndex = -1, /* Surpress uninitialised var warnings: compiler does */
+ int inputHostApiIndex = -1, /* Suppress uninitialised var warnings: compiler does */
outputHostApiIndex = -1; /* not see that if inputParameters and outputParame- */
/* ters are both nonzero, these indices are set. */
@@ -1195,7 +1195,7 @@ PaError Pa_OpenStream( PaStream** stream,
}
/* Check for parameter errors.
- NOTE: make sure this validation list is kept syncronised with the one
+ NOTE: make sure this validation list is kept synchronised with the one
in pa_hostapi.h
*/
diff --git a/src/common/pa_process.h b/src/common/pa_process.h
index 37b91d7..803144a 100644
--- a/src/common/pa_process.h
+++ b/src/common/pa_process.h
@@ -78,7 +78,7 @@
When a stream is opened, the buffer processor should be initialized using
PaUtil_InitializeBufferProcessor. This function initializes internal state
- and allocates temporary buffers as neccesary according to the supplied
+ and allocates temporary buffers as necessary according to the supplied
configuration parameters. Some of the parameters correspond to those requested
by the user in their call to Pa_OpenStream(), others reflect the requirements
of the host API implementation - they indicate host buffer sizes, formats,
@@ -119,7 +119,7 @@
PaUtil_SetInterleavedInputChannels, PaUtil_SetNonInterleavedInputChannel.
Which function you call will depend on whether the host buffer(s) are
interleaved or not.
- - If the available host data is split accross two buffers (for example a
+ - If the available host data is split across two buffers (for example a
data range at the end of a circular buffer and another range at the
beginning of the circular buffer), also call
PaUtil_Set2ndInputFrameCount, PaUtil_Set2ndInputChannel,
@@ -134,7 +134,7 @@
PaUtil_SetInterleavedOutputChannels, PaUtil_SetNonInterleavedOutputChannel.
Which function you call will depend on whether the host buffer(s) are
interleaved or not.
- - If the available host output buffer space is split accross two buffers
+ - If the available host output buffer space is split across two buffers
(for example a data range at the end of a circular buffer and another
range at the beginning of the circular buffer), call
PaUtil_Set2ndOutputFrameCount, PaUtil_Set2ndOutputChannel,
@@ -237,7 +237,7 @@ typedef enum {
}PaUtilHostBufferSizeMode;
-/** @brief An auxilliary data structure used internally by the buffer processor
+/** @brief An auxiliary data structure used internally by the buffer processor
to represent host input and output buffers. */
typedef struct PaUtilChannelDescriptor{
void *data;
@@ -452,10 +452,10 @@ void PaUtil_SetInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
unsigned long frameCount );
-/** Indicate that no input is avalable. This function should be used when
+/** Indicate that no input is available. This function should be used when
priming the output of a full-duplex stream opened with the
paPrimeOutputBuffersUsingStreamCallback flag. Note that it is not necessary
- to call this or any othe PaUtil_Set*Input* functions for ouput-only streams.
+ to call this or any other PaUtil_Set*Input* functions for ouput-only streams.
@param bufferProcessor The buffer processor.
*/
@@ -648,11 +648,11 @@ void PaUtil_BeginBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
If the stream callback is called its result is stored in *callbackResult. If
the stream callback returns paComplete or paAbort, all output buffers will be
- full of valid data - some of which may be zeros to acount for data that
+ full of valid data - some of which may be zeros to account for data that
wasn't generated by the terminating callback.
@return The number of frames processed. This usually corresponds to the
- number of frames specified by the PaUtil_Set*FrameCount functions, exept in
+ number of frames specified by the PaUtil_Set*FrameCount functions, except in
the paUtilVariableHostBufferSizePartialUsageAllowed buffer size mode when a
smaller value may be returned.
*/
@@ -660,7 +660,7 @@ unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bufferProcessor
int *callbackResult );
-/** Determine whether any callback generated output remains in the bufffer
+/** Determine whether any callback generated output remains in the buffer
processor's internal buffers. This method may be used to determine when to
continue calling PaUtil_EndBufferProcessing() after the callback has returned
a callbackResult of paComplete.
diff --git a/src/common/pa_util.h b/src/common/pa_util.h
index ad5dac5..43ea894 100644
--- a/src/common/pa_util.h
+++ b/src/common/pa_util.h
@@ -65,7 +65,7 @@ struct PaUtilHostApiRepresentation;
host api specific extension functions which aren't passed a rep pointer
by pa_front.c.
- @param hostApi A pointer to a host API represenation pointer. Apon success
+ @param hostApi A pointer to a host API representation pointer. Upon success
this will receive the requested representation pointer.
@param type A valid host API type identifier.
@@ -79,7 +79,7 @@ PaError PaUtil_GetHostApiRepresentation( struct PaUtilHostApiRepresentation **ho
/** Convert a PortAudio device index into a host API specific device index.
- @param hostApiDevice Pointer to a device index, on success this will recieve the
+ @param hostApiDevice Pointer to a device index, on success this will receive the
converted device index value.
@param device The PortAudio device index to convert.
@param hostApi The host api which the index should be converted for.
@@ -121,7 +121,7 @@ void PaUtil_SetLastHostErrorInfo( PaHostApiTypeId hostApiType, long errorCode,
void *PaUtil_AllocateMemory( long size );
-/** Realease block if non-NULL. block may be NULL */
+/** Release block if non-NULL. block may be NULL */
void PaUtil_FreeMemory( void *block );
diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c
index 5539d9d..4dfdc75 100644
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -1962,7 +1962,7 @@ static PaError PaAlsaStreamComponent_InitialConfigure( PaAlsaStreamComponent *se
{
/* Configuration consists of setting all of ALSA's parameters.
* These parameters come in two flavors: hardware parameters
- * and software paramters. Hardware parameters will affect
+ * and software parameters. Hardware parameters will affect
* the way the device is initialized, software parameters
* affect the way ALSA interacts with me, the user-level client.
*/
@@ -1976,7 +1976,7 @@ static PaError PaAlsaStreamComponent_InitialConfigure( PaAlsaStreamComponent *se
/* self->framesPerPeriod = framesPerHostBuffer; */
- /* ... fill up the configuration space with all possibile
+ /* ... fill up the configuration space with all possible
* combinations of parameters this device will accept */
ENSURE_( alsa_snd_pcm_hw_params_any( pcm, hwParams ), paUnanticipatedHostError );
@@ -2161,7 +2161,7 @@ static PaError PaAlsaStream_Initialize( PaAlsaStream *self, PaAlsaHostApiReprese
self->framesPerUserBuffer = framesPerUserBuffer;
self->neverDropInput = streamFlags & paNeverDropInput;
- /* XXX: Ignore paPrimeOutputBuffersUsingStreamCallback untill buffer priming is fully supported in pa_process.c */
+ /* XXX: Ignore paPrimeOutputBuffersUsingStreamCallback until buffer priming is fully supported in pa_process.c */
/*
if( outParams & streamFlags & paPrimeOutputBuffersUsingStreamCallback )
self->primeBuffers = 1;
@@ -2389,7 +2389,7 @@ static PaError PaAlsaStreamComponent_DetermineFramesPerBuffer( PaAlsaStreamCompo
{
framesPerHostBuffer *= 2;
}
- /* One extra period is preferrable to one less (should be more robust) */
+ /* One extra period is preferable to one less (should be more robust) */
if( bufferSize / framesPerHostBuffer < numPeriods )
{
framesPerHostBuffer /= 2;
@@ -4186,7 +4186,7 @@ error:
* directly is obtained from ALSA, we then request as much directly accessible memory as possible within this amount
* from ALSA. The buffer memory is registered with the PA buffer processor and processing is carried out with
* PaUtil_EndBufferProcessing. Finally, the number of processed frames is reported to ALSA. The processing can
- * happen in several iterations untill we have consumed the known number of available frames (or an xrun is detected).
+ * happen in several iterations until we have consumed the known number of available frames (or an xrun is detected).
*/
static void *CallbackThreadFunc( void *userData )
{
@@ -4272,7 +4272,7 @@ static void *CallbackThreadFunc( void *userData )
/* There is still buffered output that needs to be processed */
}
- /* Wait for data to become available, this comes down to polling the ALSA file descriptors untill we have
+ /* Wait for data to become available, this comes down to polling the ALSA file descriptors until we have
* a number of available frames.
*/
PA_ENSURE( PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun ) );
diff --git a/src/hostapi/asio/pa_asio.cpp b/src/hostapi/asio/pa_asio.cpp
index f230d87..c9ca786 100644
--- a/src/hostapi/asio/pa_asio.cpp
+++ b/src/hostapi/asio/pa_asio.cpp
@@ -46,7 +46,7 @@
08-20-01 More conversion, PA_StreamTime, Pa_GetHostError : Stephane Letz
08-21-01 PaUInt8 bug correction, implementation of ASIOSTFloat32LSB and ASIOSTFloat32MSB native formats : Stephane Letz
08-24-01 MAX_INT32_FP hack, another Uint8 fix : Stephane and Phil
- 08-27-01 Implementation of hostBufferSize < userBufferSize case, better management of the ouput buffer when
+ 08-27-01 Implementation of hostBufferSize < userBufferSize case, better management of the output buffer when
the stream is stopped : Stephane Letz
08-28-01 Check the stream pointer for null in bufferSwitchTimeInfo, correct bug in bufferSwitchTimeInfo when
the stream is stopped : Stephane Letz
@@ -55,11 +55,11 @@
10-26-01 Management of hostBufferSize and userBufferSize of any size : Stephane Letz
10-27-01 Improve calculus of hostBufferSize to be multiple or divisor of userBufferSize if possible : Stephane and Phil
10-29-01 Change MAX_INT32_FP to (2147483520.0f) to prevent roundup to 0x80000000 : Phil Burk
- 10-31-01 Clear the ouput buffer and user buffers in PaHost_StartOutput, correct bug in GetFirstMultiple : Stephane Letz
+ 10-31-01 Clear the output buffer and user buffers in PaHost_StartOutput, correct bug in GetFirstMultiple : Stephane Letz
11-06-01 Rename functions : Stephane Letz
11-08-01 New Pa_ASIO_Adaptor_Init function to init Callback adpatation variables, cleanup of Pa_ASIO_Callback_Input: Stephane Letz
11-29-01 Break apart device loading to debug random failure in Pa_ASIO_QueryDeviceInfo ; Phil Burk
- 01-03-02 Desallocate all resources in PaHost_Term for cases where Pa_CloseStream is not called properly : Stephane Letz
+ 01-03-02 Deallocate all resources in PaHost_Term for cases where Pa_CloseStream is not called properly : Stephane Letz
02-01-02 Cleanup, test of multiple-stream opening : Stephane Letz
19-02-02 New Pa_ASIO_loadDriver that calls CoInitialize on each thread on Windows : Stephane Letz
09-04-02 Correct error code management in PaHost_Term, removes various compiler warning : Stephane Letz
@@ -69,7 +69,7 @@
12-06-02 Rehashed into new multi-api infrastructure, added support for all ASIO sample formats : Ross Bencina
18-06-02 Added pa_asio.h, PaAsio_GetAvailableLatencyValues() : Ross B.
21-06-02 Added SelectHostBufferSize() which selects host buffer size based on user latency parameters : Ross Bencina
- ** NOTE maintanance history is now stored in CVS **
+ ** NOTE maintenance history is now stored in CVS **
*/
/** @file
@@ -103,7 +103,7 @@
#include "pa_win_coinitialize.h"
-/* This version of pa_asio.cpp is currently only targetted at Win32,
+/* This version of pa_asio.cpp is currently only targeted at Win32,
It would require a few tweaks to work with pre-OS X Macintosh.
To make configuration easier, we define WIN32 here to make sure
that the ASIO SDK knows this is Win32.
@@ -2549,7 +2549,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
enough to store at least two complete data blocks.
1) Determine the amount of latency to be added to the
- prefered ASIO latency.
+ preferred ASIO latency.
2) Make sure we have at lest one additional latency frame.
3) Divide the number of frames by the desired block size to
get the number (rounded up to pure integer) of blocks to
@@ -2568,7 +2568,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
while( lBlockingBufferSize > (lBlockingBufferSizePow2<<=1) );
lBlockingBufferSize = lBlockingBufferSizePow2;
- /* Compute total intput latency in seconds */
+ /* Compute total input latency in seconds */
stream->streamRepresentation.streamInfo.inputLatency =
(double)( PaUtil_GetBufferProcessorInputLatencyFrames(&stream->bufferProcessor )
+ PaUtil_GetBufferProcessorInputLatencyFrames(&stream->blockingState->bufferProcessor)
@@ -2635,7 +2635,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
enough to store at least two complete data blocks.
1) Determine the amount of latency to be added to the
- prefered ASIO latency.
+ preferred ASIO latency.
2) Make sure we have at lest one additional latency frame.
3) Divide the number of frames by the desired block size to
get the number (rounded up to pure integer) of blocks to
@@ -2872,7 +2872,7 @@ static void bufferSwitch(long index, ASIOBool directProcess)
//TAKEN FROM THE ASIO SDK
// the actual processing callback.
- // Beware that this is normally in a seperate thread, hence be sure that
+ // Beware that this is normally in a separate thread, hence be sure that
// you take care about thread synchronization. This is omitted here for
// simplicity.
@@ -2904,7 +2904,7 @@ static void bufferSwitch(long index, ASIOBool directProcess)
static ASIOTime *bufferSwitchTimeInfo( ASIOTime *timeInfo, long index, ASIOBool directProcess )
{
// the actual processing callback.
- // Beware that this is normally in a seperate thread, hence be sure that
+ // Beware that this is normally in a separate thread, hence be sure that
// you take care about thread synchronization.
@@ -3269,7 +3269,7 @@ static long asioMessages(long selector, long value, void* message, double* opt)
break;
case kAsioSupportsTimeInfo:
- // informs the driver wether the asioCallbacks.bufferSwitchTimeInfo() callback
+ // informs the driver whether the asioCallbacks.bufferSwitchTimeInfo() callback
// is supported.
// For compatibility with ASIO 1.0 drivers the host application should always support
// the "old" bufferSwitch method, too.
@@ -3277,7 +3277,7 @@ static long asioMessages(long selector, long value, void* message, double* opt)
break;
case kAsioSupportsTimeCode:
- // informs the driver wether application is interested in time code info.
+ // informs the driver whether application is interested in time code info.
// If an application does not need to know about time code, the driver has less work
// to do.
ret = 0;
@@ -3423,7 +3423,7 @@ static PaError StopStream( PaStream *s )
blockingState->stopFlag = TRUE;
/* Wait until requested number of buffers has been freed. Time
- out after twice the blocking i/o ouput buffer could have
+ out after twice the blocking i/o output buffer could have
been consumed. */
DWORD timeout = (DWORD)( 2 * blockingState->writeRingBuffer.bufferSize * 1000
/ stream->streamRepresentation.streamInfo.sampleRate );
@@ -3762,7 +3762,7 @@ static PaError WriteStream( PaStream *s ,
unsigned int i; /* Just a counter. */
- /* Check if the stream ist still available ready to recieve new data. */
+ /* Check if the stream is still available ready to receive new data. */
if( blockingState->stopFlag || !stream->isActive )
{
PA_DEBUG(("Warning! Stream no longer available for writing in WriteStream()\n"));
diff --git a/src/hostapi/coreaudio/notes.txt b/src/hostapi/coreaudio/notes.txt
index 145afe1..4db0b0e 100644
--- a/src/hostapi/coreaudio/notes.txt
+++ b/src/hostapi/coreaudio/notes.txt
@@ -81,7 +81,7 @@ latency will be provided even if a large latency setting is selected.
- Latency: Latency settings are generally ignored. They may be used as a
hint for buffer size in paHostFramesPerBufferUnspecified, or the value may
be used in cases where additional buffering is needed, such as doing input and
-output on seperate devices. Latency settings are always automatically bound
+output on separate devices. Latency settings are always automatically bound
to "safe" values, however, so setting extreme values here should not be
an issue.
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index a0eb6fd..1766734 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -121,7 +121,7 @@ static bool ensureChannelNameSize( int size )
return true;
}
/*
- * Function declared in pa_mac_core.h. retrives channel names.
+ * Function declared in pa_mac_core.h. retrieves channel names.
*/
const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
{
@@ -1358,7 +1358,7 @@ static PaError OpenAndSetupOneAudioUnit(
/* set device format first, but only touch the device if the user asked */
if( inStreamParams ) {
/*The callback never calls back if we don't set the FPB */
- /*This seems wierd, because I would think setting anything on the device
+ /*This seems weird, because I would think setting anything on the device
would be disruptive.*/
paResult = setBestFramesPerBuffer( *audioDevice, FALSE,
requestedFramesPerBuffer,
@@ -1376,7 +1376,7 @@ static PaError OpenAndSetupOneAudioUnit(
}
if( outStreamParams && !inStreamParams ) {
/*The callback never calls back if we don't set the FPB */
- /*This seems wierd, because I would think setting anything on the device
+ /*This seems weird, because I would think setting anything on the device
would be disruptive.*/
paResult = setBestFramesPerBuffer( *audioDevice, TRUE,
requestedFramesPerBuffer,
@@ -1758,7 +1758,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
inputChannelCount = 0;
- inputSampleFormat = hostInputSampleFormat = paFloat32; /* Surpress 'uninitialised var' warnings. */
+ inputSampleFormat = hostInputSampleFormat = paFloat32; /* Suppress 'uninitialised var' warnings. */
}
if( outputParameters )
@@ -1788,7 +1788,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
outputChannelCount = 0;
- outputSampleFormat = hostOutputSampleFormat = paFloat32; /* Surpress 'uninitialized var' warnings. */
+ outputSampleFormat = hostOutputSampleFormat = paFloat32; /* Suppress 'uninitialized var' warnings. */
}
/* validate platform specific flags */
@@ -2182,8 +2182,8 @@ static OSStatus AudioIOProc( void *inRefCon,
/* -----------------------------------------------------------------*\
This output may be useful for debugging,
- But printing durring the callback is a bad enough idea that
- this is not enabled by enableing the usual debugging calls.
+ But printing during the callback is a bad enough idea that
+ this is not enabled by enabling the usual debugging calls.
\* -----------------------------------------------------------------*/
/*
static int renderCount = 0;
@@ -2622,7 +2622,7 @@ stop_stream:
static PaError CloseStream( PaStream* s )
{
/* This may be called from a failed OpenStream.
- Therefore, each piece of info is treated seperately. */
+ Therefore, each piece of info is treated separately. */
PaError result = paNoError;
PaMacCoreStream *stream = (PaMacCoreStream*)s;
diff --git a/src/hostapi/coreaudio/pa_mac_core_blocking.c b/src/hostapi/coreaudio/pa_mac_core_blocking.c
index 679c6ba..e99d55e 100644
--- a/src/hostapi/coreaudio/pa_mac_core_blocking.c
+++ b/src/hostapi/coreaudio/pa_mac_core_blocking.c
@@ -213,7 +213,7 @@ PaError blioSetIsInputEmpty( PaMacBlio *blio, bool isEmpty )
goto done;
/* we need to update the value. Here's what we do:
- * - Lock the mutex, so noone else can write.
+ * - Lock the mutex, so no one else can write.
* - update the value.
* - unlock.
* - broadcast to all listeners.
@@ -239,7 +239,7 @@ PaError blioSetIsOutputFull( PaMacBlio *blio, bool isFull )
goto done;
/* we need to update the value. Here's what we do:
- * - Lock the mutex, so noone else can write.
+ * - Lock the mutex, so no one else can write.
* - update the value.
* - unlock.
* - broadcast to all listeners.
@@ -334,7 +334,7 @@ PaError destroyBlioRingBuffers( PaMacBlio *blio )
}
/*
- * this is the BlioCallback function. It expects to recieve a PaMacBlio Object
+ * this is the BlioCallback function. It expects to receive a PaMacBlio Object
* pointer as userData.
*
*/
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.c b/src/hostapi/coreaudio/pa_mac_core_utilities.c
index f3563ee..c6d8605 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.c
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.c
@@ -168,7 +168,7 @@ PaError PaMacCore_SetError(OSStatus error, int line, int isError)
errorText = "Audio Unit: Format Not Supported";
result = paInternalError; break;
case kAudioUnitErr_Uninitialized:
- errorText = "Audio Unit: Unitialized";
+ errorText = "Audio Unit: Uninitialized";
result = paInternalError; break;
case kAudioUnitErr_InvalidScope:
errorText = "Audio Unit: Invalid Scope";
@@ -296,12 +296,12 @@ long computeRingBufferSize( const PaStreamParameters *inputParameters,
/*
- * Durring testing of core audio, I found that serious crashes could occur
+ * During testing of core audio, I found that serious crashes could occur
* if properties such as sample rate were changed multiple times in rapid
* succession. The function below could be used to with a condition variable.
* to prevent propertychanges from happening until the last property
* change is acknowledged. Instead, I implemented a busy-wait, which is simpler
- * to implement b/c in second round of testing (nov '09) property changes occured
+ * to implement b/c in second round of testing (nov '09) property changes occurred
* quickly and so there was no real way to test the condition variable implementation.
* therefore, this function is not used, but it is aluded to in commented code below,
* since it represents a theoretically better implementation.
@@ -505,7 +505,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
if( err )
return ERR( err );
- /* -- otherwise, something wierd happened: we didn't set the rate, and we got no errors. Just bail. */
+ /* -- otherwise, something weird happened: we didn't set the rate, and we got no errors. Just bail. */
return paInternalError;
}
@@ -516,7 +516,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
is available, it uses the smallest available size.
actualFramesPerBuffer will be set to the actual value on successful return.
OK to pass NULL to actualFramesPerBuffer.
- The logic is very simmilar too setBestSampleRate only failure here is
+ The logic is very similar too setBestSampleRate only failure here is
not usually catastrophic.
*/
PaError setBestFramesPerBuffer( const AudioDeviceID device,
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.h b/src/hostapi/coreaudio/pa_mac_core_utilities.h
index fc65868..e63b3cb 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.h
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.h
@@ -81,7 +81,7 @@
#define INPUT_ELEMENT (1)
#define OUTPUT_ELEMENT (0)
-/* Normal level of debugging: fine for most apps that don't mind the occational warning being printf'ed */
+/* Normal level of debugging: fine for most apps that don't mind the occasional warning being printf'ed */
/*
*/
#define MAC_CORE_DEBUG
@@ -91,7 +91,7 @@
# define DBUG(MSG)
#endif
-/* Verbose Debugging: useful for developement */
+/* Verbose Debugging: useful for development */
/*
#define MAC_CORE_VERBOSE_DEBUG
*/
@@ -183,7 +183,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
is available, it uses the smallest available size.
actualFramesPerBuffer will be set to the actual value on successful return.
OK to pass NULL to actualFramesPerBuffer.
- The logic is very simmilar too setBestSampleRate only failure here is
+ The logic is very similar too setBestSampleRate only failure here is
not usually catastrophic.
*/
PaError setBestFramesPerBuffer( const AudioDeviceID device,
diff --git a/src/hostapi/dsound/pa_win_ds.c b/src/hostapi/dsound/pa_win_ds.c
index 204004d..f3cb67f 100644
--- a/src/hostapi/dsound/pa_win_ds.c
+++ b/src/hostapi/dsound/pa_win_ds.c
@@ -58,7 +58,7 @@
/*
- Use the earliest version of DX required, no need to polute the namespace
+ Use the earliest version of DX required, no need to pollute the namespace
*/
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE
#define DIRECTSOUND_VERSION 0x0800
@@ -667,7 +667,7 @@ static GUID pawin_IID_IKsPropertySet =
property, and the other is using DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE.
I tried both methods and only the second worked. I found two postings on the
net from people who had the same problem with the first method, so I think the method used here is
- more common/likely to work. The probem is that IKsPropertySet_Get returns S_OK
+ more common/likely to work. The problem is that IKsPropertySet_Get returns S_OK
but the fields of the device description are not filled in.
The mechanism we use works by registering an enumeration callback which is called for
@@ -757,7 +757,7 @@ static double defaultSampleRateSearchOrder_[] =
/************************************************************************************
** Extract capabilities from an output device, and add it to the device info list
** if successful. This function assumes that there is enough room in the
-** device info list to accomodate all entries.
+** device info list to accommodate all entries.
**
** The device will not be added to the device list if any errors are encountered.
*/
@@ -1014,7 +1014,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
/************************************************************************************
** Extract capabilities from an input device, and add it to the device info list
** if successful. This function assumes that there is enough room in the
-** device info list to accomodate all entries.
+** device info list to accommodate all entries.
**
** The device will not be added to the device list if any errors are encountered.
*/
@@ -2255,7 +2255,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
/* create half duplex buffers. also used for full-duplex streams which didn't
succeed when using the full duplex API. that could happen because
- DX8 or greater isnt installed, the i/o devices aren't the same
+ DX8 or greater isn't installed, the i/o devices aren't the same
physical device. etc.
*/
@@ -2798,7 +2798,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
#else
- /* tick using WaitForSingleObject timout */
+ /* tick using WaitForSingleObject timeout */
while ( WaitForSingleObject( stream->processingCompleted, timerPeriodMs ) == WAIT_TIMEOUT )
{
TimerCallback( 0, 0, (DWORD_PTR)pArg, 0, 0 );
diff --git a/src/hostapi/dsound/pa_win_ds_dynlink.c b/src/hostapi/dsound/pa_win_ds_dynlink.c
index c4e3c4e..fdfc8bd 100644
--- a/src/hostapi/dsound/pa_win_ds_dynlink.c
+++ b/src/hostapi/dsound/pa_win_ds_dynlink.c
@@ -210,7 +210,7 @@ void PaWinDs_TerminateDSoundEntryPoints(void)
{
if( paWinDsDSoundEntryPoints.hInstance_ != NULL )
{
- /* ensure that we crash reliably if the entry points arent initialised */
+ /* ensure that we crash reliably if the entry points aren't initialised */
paWinDsDSoundEntryPoints.DirectSoundCreate = 0;
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = 0;
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = 0;
diff --git a/src/hostapi/dsound/pa_win_ds_dynlink.h b/src/hostapi/dsound/pa_win_ds_dynlink.h
index fd6d8fe..0fcf967 100644
--- a/src/hostapi/dsound/pa_win_ds_dynlink.h
+++ b/src/hostapi/dsound/pa_win_ds_dynlink.h
@@ -56,7 +56,7 @@
#endif
/*
- Use the earliest version of DX required, no need to polute the namespace
+ Use the earliest version of DX required, no need to pollute the namespace
*/
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE
#define DIRECTSOUND_VERSION 0x0800
diff --git a/src/hostapi/oss/pa_unix_oss.c b/src/hostapi/oss/pa_unix_oss.c
index 51e9630..9e18d6d 100644
--- a/src/hostapi/oss/pa_unix_oss.c
+++ b/src/hostapi/oss/pa_unix_oss.c
@@ -466,7 +466,7 @@ static PaError QueryDevice( char *deviceName, PaOSSHostApiRepresentation *ossApi
/* douglas:
we have to do this querying in a slightly different order. apparently
- some sound cards will give you different info based on their settins.
+ some sound cards will give you different info based on their settings.
e.g. a card might give you stereo at 22kHz but only mono at 44kHz.
the correct order for OSS is: format, channels, sample rate
*/
@@ -1335,7 +1335,7 @@ static PaError PaOssStream_WaitForFrames( PaOssStream *stream, unsigned long *fr
#ifdef PTHREAD_CANCELED
pthread_testcancel();
#else
- /* avoid indefinite waiting on thread not supporting cancelation */
+ /* avoid indefinite waiting on thread not supporting cancellation */
if( stream->callbackStop || stream->callbackAbort )
{
PA_DEBUG(( "Cancelling PaOssStream_WaitForFrames\n" ));
@@ -1369,7 +1369,7 @@ static PaError PaOssStream_WaitForFrames( PaOssStream *stream, unsigned long *fr
#ifdef PTHREAD_CANCELED
pthread_testcancel();
#else
- /* avoid indefinite waiting on thread not supporting cancelation */
+ /* avoid indefinite waiting on thread not supporting cancellation */
if( stream->callbackStop || stream->callbackAbort )
{
PA_DEBUG(( "Cancelling PaOssStream_WaitForFrames\n" ));
@@ -1640,7 +1640,7 @@ static void *PaOSS_AudioThreadProc( void *userData )
#ifdef PTHREAD_CANCELED
pthread_testcancel();
#else
- if( stream->callbackAbort ) /* avoid indefinite waiting on thread not supporting cancelation */
+ if( stream->callbackAbort ) /* avoid indefinite waiting on thread not supporting cancellation */
{
PA_DEBUG(( "Aborting callback thread\n" ));
break;
@@ -1681,7 +1681,7 @@ static void *PaOSS_AudioThreadProc( void *userData )
callbackResult = paComplete;
}
- if( stream->callbackAbort ) /* avoid indefinite waiting on thread not supporting cancelation */
+ if( stream->callbackAbort ) /* avoid indefinite waiting on thread not supporting cancellation */
{
PA_DEBUG(( "Aborting callback thread\n" ));
break;
@@ -1793,7 +1793,7 @@ static PaError CloseStream( PaStream* s )
*
* Aspect StreamState: After returning, the stream shall be in the Active state, implying that an eventual
* callback will be repeatedly called in a separate thread. If a separate thread is started this function
- * will block untill it has started processing audio, otherwise audio processing is started directly.
+ * will block until it has started processing audio, otherwise audio processing is started directly.
*/
static PaError StartStream( PaStream *s )
{
diff --git a/src/hostapi/skeleton/pa_hostapi_skeleton.c b/src/hostapi/skeleton/pa_hostapi_skeleton.c
index 6edc22c..cc31435 100644
--- a/src/hostapi/skeleton/pa_hostapi_skeleton.c
+++ b/src/hostapi/skeleton/pa_hostapi_skeleton.c
@@ -413,7 +413,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
inputChannelCount = 0;
- inputSampleFormat = hostInputSampleFormat = paInt16; /* Surpress 'uninitialised var' warnings. */
+ inputSampleFormat = hostInputSampleFormat = paInt16; /* Suppress 'uninitialised var' warnings. */
}
if( outputParameters )
@@ -442,7 +442,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
outputChannelCount = 0;
- outputSampleFormat = hostOutputSampleFormat = paInt16; /* Surpress 'uninitialized var' warnings. */
+ outputSampleFormat = hostOutputSampleFormat = paInt16; /* Suppress 'uninitialized var' warnings. */
}
/*
diff --git a/src/hostapi/wasapi/mingw-include/ksproxy.h b/src/hostapi/wasapi/mingw-include/ksproxy.h
index e6e049d..99de340 100644
--- a/src/hostapi/wasapi/mingw-include/ksproxy.h
+++ b/src/hostapi/wasapi/mingw-include/ksproxy.h
@@ -182,7 +182,7 @@ typedef KS_LogicalMemoryType *PKS_LogicalMemoryType;
typedef struct _PIPE_TERMINATION {
ULONG Flags;
ULONG OutsideFactors;
- ULONG Weigth;
+ ULONG Weight;
KS_FRAMING_RANGE PhysicalRange;
KS_FRAMING_RANGE_WEIGHTED OptimalRange;
KS_COMPRESSION Compression;
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index 216796e..86c08c2 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -310,7 +310,7 @@ typedef struct _pa_AudioClientProperties {
PA_THREAD_FUNC ProcThreadEvent(void *param);
PA_THREAD_FUNC ProcThreadPoll(void *param);
-// Error codes (availabe since Windows 7)
+// Error codes (available since Windows 7)
#ifndef AUDCLNT_E_BUFFER_ERROR
#define AUDCLNT_E_BUFFER_ERROR AUDCLNT_ERR(0x018)
#endif
@@ -321,7 +321,7 @@ PA_THREAD_FUNC ProcThreadPoll(void *param);
#define AUDCLNT_E_INVALID_DEVICE_PERIOD AUDCLNT_ERR(0x020)
#endif
-// Stream flags (availabe since Windows 7)
+// Stream flags (available since Windows 7)
#ifndef AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY
#define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000
#endif
@@ -489,7 +489,7 @@ typedef struct
PaWinUtilComInitializationResult comInitializationResult;
- // this is the REAL number of devices, whether they are usefull to PA or not!
+ // this is the REAL number of devices, whether they are useful to PA or not!
UINT32 deviceCount;
PaWasapiDeviceInfo *devInfo;
@@ -783,7 +783,7 @@ static PaError __LogPaError(PaError err, const char *func, const char *file, int
// ------------------------------------------------------------------------------------------
/*! \class ThreadSleepScheduler
Allows to emulate thread sleep of less than 1 millisecond under Windows. Scheduler
- calculates number of times the thread must run untill next sleep of 1 millisecond.
+ calculates number of times the thread must run until next sleep of 1 millisecond.
It does not make thread sleeping for real number of microseconds but rather controls
how many of imaginary microseconds the thread task can allow thread to sleep.
*/
@@ -3168,7 +3168,7 @@ static void _CalculateAlignedPeriod(PaWasapiSubStream *pSub, UINT32 *nFramesPerL
// Align frames to HD Audio packet size of 128 bytes for Exclusive mode only.
// Not aligning on Windows Vista will cause Event timeout, although Windows 7 will
// return AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED error to realign buffer. Aligning is necessary
- // for Exclusive mode only! when audio data is feeded directly to hardware.
+ // for Exclusive mode only! when audio data is fed directly to hardware.
if (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE)
{
(*nFramesPerLatency) = AlignFramesPerBuffer((*nFramesPerLatency),
@@ -3205,7 +3205,7 @@ static void _CalculatePeriodicity(PaWasapiSubStream *pSub, BOOL output, REFERENC
REFERENCE_TIME userPeriodicity;
// Align frames backwards, so device will likely make buffer read ready when we are ready
- // to read it (our sheduling will wait for amount of millisoconds of frames_per_buffer)
+ // to read it (our scheduling will wait for amount of millisoconds of frames_per_buffer)
alignedFrames = AlignFramesPerBuffer(pSub->params.frames_per_buffer,
pSub->wavex.Format.nSamplesPerSec, pSub->wavex.Format.nBlockAlign, ALIGN_BWD);
@@ -3562,7 +3562,7 @@ static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSu
_RecalculateBuffersCount(pSub, userFramesPerBuffer, MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec),
fullDuplex);
- // No error, client is succesfully created
+ // No error, client is successfully created
(*pa_error) = paNoError;
done:
@@ -3904,7 +3904,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
inputChannelCount = 0;
- inputSampleFormat = hostInputSampleFormat = paInt16; /* Surpress 'uninitialised var' warnings. */
+ inputSampleFormat = hostInputSampleFormat = paInt16; /* Suppress 'uninitialised var' warnings. */
}
// Try create device: Output
@@ -4007,7 +4007,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
outputChannelCount = 0;
- outputSampleFormat = hostOutputSampleFormat = paInt16; /* Surpress 'uninitialized var' warnings. */
+ outputSampleFormat = hostOutputSampleFormat = paInt16; /* Suppress 'uninitialized var' warnings. */
}
// log full-duplex
@@ -4065,7 +4065,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
// serious problem #2 - No, Not a problem, as framesPerHostCallback take into account
// sample size while it is not a problem for PA full-duplex, we must care of
- // preriod only!
+ // period only!
/*if (stream->out.framesPerHostCallback != stream->in.framesPerHostCallback)
{
PRINT(("WASAPI: OpenStream: framesPerHostCallback discrepancy\n"));
@@ -4636,7 +4636,7 @@ static PaError ReadStream( PaStream* s, void *_buffer, unsigned long frames )
((BYTE **)user_buffer)[i] = ((BYTE **)_buffer)[i];
}
- // Findout if there are tail frames, flush them all before reading hardware
+ // Find out if there are tail frames, flush them all before reading hardware
if ((available = PaUtil_GetRingBufferReadAvailable(stream->in.tailBuffer)) != 0)
{
ring_buffer_size_t buf1_size = 0, buf2_size = 0, read, desired;
@@ -4815,7 +4815,7 @@ static PaError WriteStream( PaStream* s, const void *_buffer, unsigned long fram
((const BYTE **)user_buffer)[i] = ((const BYTE **)_buffer)[i];
}
- // Blocking (potentially, untill 'frames' are consumed) loop
+ // Blocking (potentially, until 'frames' are consumed) loop
while (frames != 0)
{
// Check if blocking call must be interrupted
@@ -5694,7 +5694,7 @@ static HRESULT ProcessInputBuffer(PaWasapiStream *stream, PaWasapiHostProcessor
if (WaitForSingleObject(stream->hCloseRequest, 0) != WAIT_TIMEOUT)
break;
- // Findout if any frames available
+ // Find out if any frames available
frames = 0;
if ((hr = _PollGetInputFramesAvailable(stream, &frames)) != S_OK)
return hr;
@@ -6033,7 +6033,7 @@ static UINT32 GetSleepTime(PaWasapiStream *stream, UINT32 sleepTimeIn, UINT32 sl
UINT32 sleepTime;
// According to the issue [https://github.com/PortAudio/portaudio/issues/303] glitches may occur when user frames
- // equal to 1/2 of the host buffer frames, therefore the emperical workaround for this problem is to lower
+ // equal to 1/2 of the host buffer frames, therefore the empirical workaround for this problem is to lower
// the sleep time by 2
if (userFramesOut != 0)
{
@@ -6157,7 +6157,7 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
// Request fine (1 ms) granularity of the system timer functions to guarantee correct logic around WaitForSingleObject
SystemTimer_SetGranularity(&timer, 1);
- // Claculate sleep time of the processing loop (inside WaitForSingleObject)
+ // Calculate sleep time of the processing loop (inside WaitForSingleObject)
sleepTime = ConfigureLoopSleepTimeAndScheduler(stream, &scheduler);
// Setup data processors
@@ -6376,10 +6376,10 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
break;
}
- // process equal ammount of frames
+ // process equal amount of frames
if (o_frames >= i_frames)
{
- // process input ammount of frames
+ // process input amount of frames
UINT32 o_processed = i_frames;
// get host output buffer
diff --git a/src/hostapi/wdmks/pa_win_wdmks.c b/src/hostapi/wdmks/pa_win_wdmks.c
index add663b..f30ee95 100644
--- a/src/hostapi/wdmks/pa_win_wdmks.c
+++ b/src/hostapi/wdmks/pa_win_wdmks.c
@@ -4380,7 +4380,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
userInputChannels = 0;
- inputSampleFormat = hostInputSampleFormat = paInt16; /* Supress 'uninitialised var' warnings. */
+ inputSampleFormat = hostInputSampleFormat = paInt16; /* Suppress 'uninitialised var' warnings. */
}
if( outputParameters )
@@ -4415,7 +4415,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
userOutputChannels = 0;
- outputSampleFormat = hostOutputSampleFormat = paInt16; /* Supress 'uninitialized var' warnings. */
+ outputSampleFormat = hostOutputSampleFormat = paInt16; /* Suppress 'uninitialized var' warnings. */
}
/* validate platform specific flags */
diff --git a/src/hostapi/wdmks/readme.txt b/src/hostapi/wdmks/readme.txt
index c4c349c..611acc7 100644
--- a/src/hostapi/wdmks/readme.txt
+++ b/src/hostapi/wdmks/readme.txt
@@ -52,7 +52,7 @@ by the user, and can be limited in functionality or difficult to use.
This is where the PortAudio "WDM-KS" host implementation comes in.
It directly connects PortAudio to the same Kernel Streaming API which
-those ASIO bridges use. This avoids the mixing penatly of DirectX,
+those ASIO bridges use. This avoids the mixing penalty of DirectX,
giving at least as good latency as any ASIO driver, but it has the
advantage of working with ANY Windows audio hardware which is available
through the normal MME/DirectX routes without the user requiring
diff --git a/src/hostapi/wmme/pa_win_wmme.c b/src/hostapi/wmme/pa_win_wmme.c
index 422c867..8a07bab 100644
--- a/src/hostapi/wmme/pa_win_wmme.c
+++ b/src/hostapi/wmme/pa_win_wmme.c
@@ -58,7 +58,7 @@
RDB20020417 - stopped counting WAVE_MAPPER when there were no real devices
refactoring, renaming and fixed a few edge case bugs
RDB20020531 - converted to V19 framework
- ** NOTE maintanance history is now stored in CVS **
+ ** NOTE maintenance history is now stored in CVS **
*/
/** @file
@@ -192,7 +192,7 @@
/* When client suggestedLatency could result in many host buffers, we aim to have around 8,
based off Windows documentation that suggests that the kmixer uses 8 buffers. This choice
- is somewhat arbitrary here, since we havn't observed significant stability degredation
+ is somewhat arbitrary here, since we haven't observed significant stability degredation
with using either more, or less buffers.
*/
#define PA_MME_TARGET_HOST_BUFFER_COUNT_ 8
@@ -2563,7 +2563,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->primeStreamUsingCallback = ( (streamFlags&paPrimeOutputBuffersUsingStreamCallback) && streamCallback ) ? 1 : 0;
/* time to sleep when throttling due to >100% cpu usage.
- -a quater of a buffer's duration */
+ -a quarter of a buffer's duration */
stream->throttledSleepMsecs =
(unsigned long)(stream->bufferProcessor.framesPerHostBuffer *
stream->bufferProcessor.samplePeriod * .25 * 1000);
@@ -2886,7 +2886,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
if( waitResult == WAIT_FAILED )
{
result = paUnanticipatedHostError;
- /** @todo FIXME/REVIEW: can't return host error info from an asyncronous thread. see http://www.portaudio.com/trac/ticket/143 */
+ /** @todo FIXME/REVIEW: can't return host error info from an asynchronous thread. see http://www.portaudio.com/trac/ticket/143 */
done = 1;
}
else if( waitResult == WAIT_TIMEOUT )
@@ -3161,7 +3161,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
if( outputUnderflow && !done && !stream->stopProcessing )
{
/* Recover from underflow in the case where the
- underflow occured while processing the buffer
+ underflow occurred while processing the buffer
we just finished */
result = CatchUpOutputBuffers( stream );
@@ -3359,7 +3359,7 @@ static PaError StartStream( PaStream *s )
}
}
- /* we queue all channels of a single buffer frame (accross all
+ /* we queue all channels of a single buffer frame (across all
devices, because some multidevice multichannel drivers work
better this way */
for( j=0; joutput.deviceCount; ++j )
diff --git a/src/os/unix/pa_unix_util.h b/src/os/unix/pa_unix_util.h
index c401f19..2a62fe8 100644
--- a/src/os/unix/pa_unix_util.h
+++ b/src/os/unix/pa_unix_util.h
@@ -182,7 +182,7 @@ PaError PaUnixThreading_Initialize( void );
/** Spawn a thread.
*
* Intended for spawning the callback thread from the main thread. This function can even block (for a certain
- * time or indefinitely) untill notified by the callback thread (using PaUnixThread_NotifyParent), which can be
+ * time or indefinitely) until notified by the callback thread (using PaUnixThread_NotifyParent), which can be
* useful in order to make sure that callback has commenced before returning from Pa_StartStream.
* @param threadFunc: The function to be executed in the child thread.
* @param waitForChild: If not 0, wait for child thread to call PaUnixThread_NotifyParent. Less than 0 means
@@ -195,7 +195,7 @@ PaError PaUnixThread_New( PaUnixThread* self, void* (*threadFunc)( void* ), void
/** Terminate thread.
*
- * @param wait: If true, request that background thread stop and wait untill it does, else cancel it.
+ * @param wait: If true, request that background thread stop and wait until it does, else cancel it.
* @param exitResult: If non-null this will upon return contain the exit status of the thread.
*/
PaError PaUnixThread_Terminate( PaUnixThread* self, int wait, PaError* exitResult );
diff --git a/src/os/win/pa_win_waveformat.c b/src/os/win/pa_win_waveformat.c
index 5c6f29d..933cb78 100644
--- a/src/os/win/pa_win_waveformat.c
+++ b/src/os/win/pa_win_waveformat.c
@@ -134,7 +134,7 @@ PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels )
/* case 7: */
case 8:
/* RoBi: PAWIN_SPEAKER_7POINT1_SURROUND fits normal surround sound setups better than PAWIN_SPEAKER_7POINT1, f.i. NVidia HDMI Audio
- output is silent on channels 5&6 with NVidia drivers, and channel 7&8 with Micrsoft HD Audio driver using PAWIN_SPEAKER_7POINT1.
+ output is silent on channels 5&6 with NVidia drivers, and channel 7&8 with Microsoft HD Audio driver using PAWIN_SPEAKER_7POINT1.
With PAWIN_SPEAKER_7POINT1_SURROUND both setups work OK. */
return PAWIN_SPEAKER_7POINT1_SURROUND;
}
@@ -149,7 +149,7 @@ PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels )
/* Note that Alec Rogers proposed the following as an alternate method to
generate the default channel mask, however it doesn't seem to be an improvement
over the above, since some drivers will matrix outputs mapping to non-present
- speakers accross multiple physical speakers.
+ speakers across multiple physical speakers.
if(nChannels==1) {
pwfFormat->dwChannelMask = SPEAKER_FRONT_CENTER;
diff --git a/src/os/win/pa_win_wdmks_utils.h b/src/os/win/pa_win_wdmks_utils.h
index b8e923a..5a7a338 100644
--- a/src/os/win/pa_win_wdmks_utils.h
+++ b/src/os/win/pa_win_wdmks_utils.h
@@ -51,7 +51,7 @@ extern "C" {
specified device. Returns 0 if the query fails for any reason.
@param wcharDevicePath A system level PnP interface path, supplied as a WCHAR unicode string.
- Declard as void* to avoid introducing a dependency on wchar_t here.
+ Declared as void* to avoid introducing a dependency on wchar_t here.
@param isInput A flag specifying whether to query for input (non-zero) or output (zero) channels.
*/
diff --git a/src/os/win/pa_x86_plain_converters.c b/src/os/win/pa_x86_plain_converters.c
index ae43d28..44a6d67 100644
--- a/src/os/win/pa_x86_plain_converters.c
+++ b/src/os/win/pa_x86_plain_converters.c
@@ -55,7 +55,7 @@ TODO:
o- inline dither code
o- implement Dither only (no-clip) versions
o- implement int8 and uint8 versions
- o- test thouroughly
+ o- test thoroughly
o- the packed 24 bit functions could benefit from unrolling and avoiding
byte and word sized register access.
@@ -116,7 +116,7 @@ TODO:
/*
-EMT64/AMD64 uses different asm
- -VC2005 doesnt allow _WIN64 with inline assembly either!
+ -VC2005 doesn't allow _WIN64 with inline assembly either!
*/
void PaUtil_InitializeX86PlainConverters( void )
{
diff --git a/test/pa_minlat.c b/test/pa_minlat.c
index 0106cf3..a91f9e0 100644
--- a/test/pa_minlat.c
+++ b/test/pa_minlat.c
@@ -198,7 +198,7 @@ int main( int argc, char **argv )
return 0;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return 1;
diff --git a/test/patest1.c b/test/patest1.c
index a0fae47..2ad9c38 100644
--- a/test/patest1.c
+++ b/test/patest1.c
@@ -121,7 +121,7 @@ int main(int argc, char* argv[])
data.phase = 0;
data.sampsToGo = SAMPLE_RATE * 20; /* 20 seconds. */
- /* initialise portaudio subsytem */
+ /* initialise portaudio subsystem */
err = Pa_Initialize();
inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
@@ -179,7 +179,7 @@ done:
if( err != paNoError )
{
- fprintf( stderr, "An error occured while using portaudio\n" );
+ fprintf( stderr, "An error occurred while using portaudio\n" );
if( err == paUnanticipatedHostError )
{
fprintf( stderr, " unanticipated host error.\n");
diff --git a/test/patest_buffer.c b/test/patest_buffer.c
index 830b3ac..090b529 100644
--- a/test/patest_buffer.c
+++ b/test/patest_buffer.c
@@ -198,7 +198,7 @@ PaError TestOnce( int buffersize, PaDeviceIndex device )
return paNoError;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
fprintf( stderr, "Host Error message: %s\n", Pa_GetLastHostErrorInfo()->errorText );
diff --git a/test/patest_callbackstop.c b/test/patest_callbackstop.c
index bd6e829..aa7f7fd 100644
--- a/test/patest_callbackstop.c
+++ b/test/patest_callbackstop.c
@@ -245,7 +245,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_clip.c b/test/patest_clip.c
index e86d0ac..97ef211 100644
--- a/test/patest_clip.c
+++ b/test/patest_clip.c
@@ -135,7 +135,7 @@ int main(void)
return 0;
error:
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return 1;
diff --git a/test/patest_dither.c b/test/patest_dither.c
index e694c8b..5f471b1 100644
--- a/test/patest_dither.c
+++ b/test/patest_dither.c
@@ -179,7 +179,7 @@ int main(void)
done:
if (err)
{
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
err = 1; /* Though PlaySine() already called Pa_Terminate(), */
diff --git a/test/patest_dsound_low_level_latency_params.c b/test/patest_dsound_low_level_latency_params.c
index a1e7c7e..59734e2 100644
--- a/test/patest_dsound_low_level_latency_params.c
+++ b/test/patest_dsound_low_level_latency_params.c
@@ -179,7 +179,7 @@ int main(int argc, char* argv[])
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_dsound_surround.c b/test/patest_dsound_surround.c
index 3ffd151..e39bc91 100644
--- a/test/patest_dsound_surround.c
+++ b/test/patest_dsound_surround.c
@@ -197,7 +197,7 @@ int main(int argc, char* argv[])
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_hang.c b/test/patest_hang.c
index 6bda629..e317261 100644
--- a/test/patest_hang.c
+++ b/test/patest_hang.c
@@ -157,7 +157,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_in_overflow.c b/test/patest_in_overflow.c
index 1f2a837..5ce50d3 100644
--- a/test/patest_in_overflow.c
+++ b/test/patest_in_overflow.c
@@ -5,7 +5,7 @@
This test uses the same method to overload the stream as does
patest_out_underflow.c -- it generates sine waves until the cpu load
exceeds a certain level. However this test is only concerned with
- input and so doesn't ouput any sound.
+ input and so doesn't output any sound.
@author Ross Bencina
@author Phil Burk
@@ -229,7 +229,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_jack_wasapi.c b/test/patest_jack_wasapi.c
index f01297a..6175f88 100644
--- a/test/patest_jack_wasapi.c
+++ b/test/patest_jack_wasapi.c
@@ -305,7 +305,7 @@ int main(void)
int jackCount = 0;
int isInput = 0;
- printf("PortAudio Test: WASAPI Jack Configuratin");
+ printf("PortAudio Test: WASAPI Jack Configuration");
err = Pa_Initialize();
if( err != paNoError ) goto error;
@@ -336,7 +336,7 @@ int main(void)
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_latency.c b/test/patest_latency.c
index bbc6fe6..2078a04 100644
--- a/test/patest_latency.c
+++ b/test/patest_latency.c
@@ -186,7 +186,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_leftright.c b/test/patest_leftright.c
index 33ccf12..11ce463 100644
--- a/test/patest_leftright.c
+++ b/test/patest_leftright.c
@@ -178,7 +178,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_longsine.c b/test/patest_longsine.c
index 3eba0ce..e466ff3 100644
--- a/test/patest_longsine.c
+++ b/test/patest_longsine.c
@@ -144,7 +144,7 @@ int main(void)
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_many.c b/test/patest_many.c
index 083fdb4..b6bc314 100644
--- a/test/patest_many.c
+++ b/test/patest_many.c
@@ -203,7 +203,7 @@ PaError TestOnce( void )
return paNoError;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_maxsines.c b/test/patest_maxsines.c
index 49db8d2..672a492 100644
--- a/test/patest_maxsines.c
+++ b/test/patest_maxsines.c
@@ -209,7 +209,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_mono.c b/test/patest_mono.c
index 40c9d64..3af09f5 100644
--- a/test/patest_mono.c
+++ b/test/patest_mono.c
@@ -148,7 +148,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_multi_sine.c b/test/patest_multi_sine.c
index 2b11bfc..ad3db44 100644
--- a/test/patest_multi_sine.c
+++ b/test/patest_multi_sine.c
@@ -196,7 +196,7 @@ int main(void)
done:
if (err)
{
- fprintf(stderr, "An error occured while using the portaudio stream\n");
+ fprintf(stderr, "An error occurred while using the portaudio stream\n");
fprintf(stderr, "Error number: %d\n", err );
fprintf(stderr, "Error message: %s\n", Pa_GetErrorText(err));
}
diff --git a/test/patest_out_underflow.c b/test/patest_out_underflow.c
index dee90f8..86a35cb 100644
--- a/test/patest_out_underflow.c
+++ b/test/patest_out_underflow.c
@@ -244,7 +244,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_prime.c b/test/patest_prime.c
index 045757e..98acd60 100644
--- a/test/patest_prime.c
+++ b/test/patest_prime.c
@@ -92,7 +92,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
unsigned int i;
int result = paContinue;
- /* supress unused parameter warnings */
+ /* suppress unused parameter warnings */
(void) inputBuffer;
(void) timeInfo;
(void) statusFlags;
@@ -227,7 +227,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_read_record.c b/test/patest_read_record.c
index e8e5561..ae92ea2 100644
--- a/test/patest_read_record.c
+++ b/test/patest_read_record.c
@@ -236,7 +236,7 @@ int main(void)
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return -1;
diff --git a/test/patest_sine8.c b/test/patest_sine8.c
index c00319a..3688dd1 100644
--- a/test/patest_sine8.c
+++ b/test/patest_sine8.c
@@ -209,7 +209,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_sine_channelmaps.c b/test/patest_sine_channelmaps.c
index 3d0d4c0..83608b8 100644
--- a/test/patest_sine_channelmaps.c
+++ b/test/patest_sine_channelmaps.c
@@ -183,7 +183,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_sine_formats.c b/test/patest_sine_formats.c
index 5d01155..eb28334 100644
--- a/test/patest_sine_formats.c
+++ b/test/patest_sine_formats.c
@@ -196,7 +196,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_sine_srate.c b/test/patest_sine_srate.c
index 106a972..5fd07bd 100644
--- a/test/patest_sine_srate.c
+++ b/test/patest_sine_srate.c
@@ -175,7 +175,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_sine_time.c b/test/patest_sine_time.c
index 0d6a1da..1d4f551 100644
--- a/test/patest_sine_time.c
+++ b/test/patest_sine_time.c
@@ -212,7 +212,7 @@ int main(void)
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_start_stop.c b/test/patest_start_stop.c
index cf82b67..ec902cf 100644
--- a/test/patest_start_stop.c
+++ b/test/patest_start_stop.c
@@ -167,7 +167,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_stop.c b/test/patest_stop.c
index bc417cc..2ebd97a 100644
--- a/test/patest_stop.c
+++ b/test/patest_stop.c
@@ -317,7 +317,7 @@ int TestStopMode( paTestData *data )
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_stop_playout.c b/test/patest_stop_playout.c
index 9a451eb..17e09f3 100644
--- a/test/patest_stop_playout.c
+++ b/test/patest_stop_playout.c
@@ -471,7 +471,7 @@ int main(void)
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_suggested_vs_streaminfo_latency.c b/test/patest_suggested_vs_streaminfo_latency.c
index 0b7f21d..204e964 100644
--- a/test/patest_suggested_vs_streaminfo_latency.c
+++ b/test/patest_suggested_vs_streaminfo_latency.c
@@ -262,7 +262,7 @@ int main( int argc, const char* argv[] )
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_sync.c b/test/patest_sync.c
index a064be1..d3a8c0f 100644
--- a/test/patest_sync.c
+++ b/test/patest_sync.c
@@ -264,7 +264,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_timing.c b/test/patest_timing.c
index ed8a11a..659ec24 100644
--- a/test/patest_timing.c
+++ b/test/patest_timing.c
@@ -166,7 +166,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_toomanysines.c b/test/patest_toomanysines.c
index 4722f5e..072b022 100644
--- a/test/patest_toomanysines.c
+++ b/test/patest_toomanysines.c
@@ -193,7 +193,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_two_rates.c b/test/patest_two_rates.c
index 5a2b178..5148fe7 100644
--- a/test/patest_two_rates.c
+++ b/test/patest_two_rates.c
@@ -171,7 +171,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_underflow.c b/test/patest_underflow.c
index e1726a6..430de62 100644
--- a/test/patest_underflow.c
+++ b/test/patest_underflow.c
@@ -155,7 +155,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_unplug.c b/test/patest_unplug.c
index ba55b7d..e546921 100644
--- a/test/patest_unplug.c
+++ b/test/patest_unplug.c
@@ -235,7 +235,7 @@ int main(int argc, char **args)
return paNoError;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
fprintf( stderr, "Host Error message: %s\n", Pa_GetLastHostErrorInfo()->errorText );
diff --git a/test/patest_wire.c b/test/patest_wire.c
index ba3477b..a5f3ffc 100644
--- a/test/patest_wire.c
+++ b/test/patest_wire.c
@@ -246,7 +246,7 @@ done:
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
printf("Hit ENTER to quit.\n"); fflush(stdout);
diff --git a/test/patest_wmme_find_best_latency_params.c b/test/patest_wmme_find_best_latency_params.c
index 618b97e..0149f9e 100644
--- a/test/patest_wmme_find_best_latency_params.c
+++ b/test/patest_wmme_find_best_latency_params.c
@@ -62,7 +62,7 @@
#define CHANNEL_COUNT (2)
-/* seach parameters. we test all buffer counts in this range */
+/* search parameters. we test all buffer counts in this range */
#define MIN_WMME_BUFFER_COUNT (2)
#define MAX_WMME_BUFFER_COUNT (12)
@@ -510,7 +510,7 @@ int main(int argc, char* argv[])
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_wmme_low_level_latency_params.c b/test/patest_wmme_low_level_latency_params.c
index a28c88b..aa4d71e 100644
--- a/test/patest_wmme_low_level_latency_params.c
+++ b/test/patest_wmme_low_level_latency_params.c
@@ -184,7 +184,7 @@ int main(int argc, char* argv[])
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_write_stop.c b/test/patest_write_stop.c
index 243e774..ce5b597 100644
--- a/test/patest_write_stop.c
+++ b/test/patest_write_stop.c
@@ -158,7 +158,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
diff --git a/test/patest_write_stop_hang_illegal.c b/test/patest_write_stop_hang_illegal.c
index ed93425..5521c8d 100644
--- a/test/patest_write_stop_hang_illegal.c
+++ b/test/patest_write_stop_hang_illegal.c
@@ -161,7 +161,7 @@ int main(void)
return err;
error:
Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "An error occurred while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
From 0588b306c4791665a260096616607452b24b1430 Mon Sep 17 00:00:00 2001
From: luzpaz
Date: Sat, 12 Dec 2020 21:35:50 -0500
Subject: [PATCH 038/157] Revert typo
Co-authored-by: Phil Burk
---
src/hostapi/wasapi/mingw-include/ksproxy.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/hostapi/wasapi/mingw-include/ksproxy.h b/src/hostapi/wasapi/mingw-include/ksproxy.h
index 99de340..fcbc6b3 100644
--- a/src/hostapi/wasapi/mingw-include/ksproxy.h
+++ b/src/hostapi/wasapi/mingw-include/ksproxy.h
@@ -182,7 +182,7 @@ typedef KS_LogicalMemoryType *PKS_LogicalMemoryType;
typedef struct _PIPE_TERMINATION {
ULONG Flags;
ULONG OutsideFactors;
- ULONG Weight;
+ ULONG Weigth;
KS_FRAMING_RANGE PhysicalRange;
KS_FRAMING_RANGE_WEIGHTED OptimalRange;
KS_COMPRESSION Compression;
@@ -636,4 +636,3 @@ DECLARE_INTERFACE_(IKsTopology,IUnknown)
#endif
#endif /* __KSPROXY__ */
-
From 8f63b5180830ad3da103597305f4504fa4935148 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?=
Date: Mon, 14 Dec 2020 08:03:04 +0100
Subject: [PATCH 039/157] Don't crash for alsa_snd_pcm_poll_descriptors fail in
another case
---
src/hostapi/alsa/pa_linux_alsa.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c
index 0564351..22c30f1 100644
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -3805,14 +3805,19 @@ static PaError PaAlsaStream_WaitForFrames( PaAlsaStream *self, unsigned long *fr
if( pollCapture )
{
capturePfds = self->pfds;
- PA_ENSURE( PaAlsaStreamComponent_BeginPolling( &self->capture, capturePfds ) );
+ PaError res = PaAlsaStreamComponent_BeginPolling( &self->capture, capturePfds );
+ if( res != paNoError)
+ {
+ xrun = 1;
+ goto end;
+ }
totalFds += self->capture.nfds;
}
if( pollPlayback )
{
/* self->pfds is in effect an array of fds; if necessary, index past the capture fds */
playbackPfds = self->pfds + (pollCapture ? self->capture.nfds : 0);
- int res = PaAlsaStreamComponent_BeginPolling( &self->playback, playbackPfds );
+ PaError res = PaAlsaStreamComponent_BeginPolling( &self->playback, playbackPfds );
if( res != paNoError)
{
xrun = 1;
From 9ddb047ab1028add40e9499d2b1a5f1e78e70e6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?=
Date: Mon, 14 Dec 2020 08:21:34 +0100
Subject: [PATCH 040/157] Improve code style
---
src/hostapi/alsa/pa_linux_alsa.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c
index 22c30f1..12aee58 100644
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -3639,16 +3639,15 @@ error:
*/
static PaError PaAlsaStreamComponent_BeginPolling( PaAlsaStreamComponent* self, struct pollfd* pfds )
{
- PaError result = paNoError;
- int ret = alsa_snd_pcm_poll_descriptors( self->pcm, pfds, self->nfds );
- /* If alsa returns anything else, like -EPIPE return*/
- if( ret != self->nfds )
+ int nfds = alsa_snd_pcm_poll_descriptors( self->pcm, pfds, self->nfds );
+ /* If alsa returns anything else, like -EPIPE return */
+ if( nfds != self->nfds )
{
- return paUnanticipatedHostError;
+ return paUnanticipatedHostError;
}
self->ready = 0;
- return result;
+ return paNoError;
}
/** Examine results from poll().
From e5cb1a620fe2ab2b505ede66533850cd2f0c7f5f Mon Sep 17 00:00:00 2001
From: MichalPetryka <35800402+MichalPetryka@users.noreply.github.com>
Date: Tue, 15 Dec 2020 19:39:22 +0100
Subject: [PATCH 041/157] Update def files for #340
---
build/msvc/portaudio.def | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/build/msvc/portaudio.def b/build/msvc/portaudio.def
index c08243a..94d938b 100644
--- a/build/msvc/portaudio.def
+++ b/build/msvc/portaudio.def
@@ -52,5 +52,5 @@ PaWasapi_ThreadPriorityRevert @63
PaWasapi_GetFramesPerHostBuffer @64
PaWasapi_GetJackCount @65
PaWasapi_GetJackDescription @66
-PaWasapi_SetDefaultInterfaceId @67
-PaWasapi_SetStreamStateHandler @68
\ No newline at end of file
+PaWasapiWinrt_SetDefaultDeviceId @67
+PaWasapi_SetStreamStateHandler @68
From b900df6d9d810689c101061ddef31af400ba61b6 Mon Sep 17 00:00:00 2001
From: MichalPetryka <35800402+MichalPetryka@users.noreply.github.com>
Date: Thu, 17 Dec 2020 09:53:16 +0100
Subject: [PATCH 042/157] Add PaWasapiWinrt_PopulateDeviceList
---
build/msvc/portaudio.def | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/build/msvc/portaudio.def b/build/msvc/portaudio.def
index 94d938b..25a9376 100644
--- a/build/msvc/portaudio.def
+++ b/build/msvc/portaudio.def
@@ -52,5 +52,6 @@ PaWasapi_ThreadPriorityRevert @63
PaWasapi_GetFramesPerHostBuffer @64
PaWasapi_GetJackCount @65
PaWasapi_GetJackDescription @66
-PaWasapiWinrt_SetDefaultDeviceId @67
-PaWasapi_SetStreamStateHandler @68
+PaWasapi_SetStreamStateHandler @67
+PaWasapiWinrt_SetDefaultDeviceId @68
+PaWasapiWinrt_PopulateDeviceList @69
From 11a3e23917b22cd022f7cacaa5d7f5edf56edbd6 Mon Sep 17 00:00:00 2001
From: MichalPetryka <35800402+MichalPetryka@users.noreply.github.com>
Date: Thu, 17 Dec 2020 10:53:44 +0100
Subject: [PATCH 043/157] Update portaudio.def
---
build/msvc/portaudio.def | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/build/msvc/portaudio.def b/build/msvc/portaudio.def
index 25a9376..8f1738f 100644
--- a/build/msvc/portaudio.def
+++ b/build/msvc/portaudio.def
@@ -52,6 +52,6 @@ PaWasapi_ThreadPriorityRevert @63
PaWasapi_GetFramesPerHostBuffer @64
PaWasapi_GetJackCount @65
PaWasapi_GetJackDescription @66
-PaWasapi_SetStreamStateHandler @67
-PaWasapiWinrt_SetDefaultDeviceId @68
+PaWasapi_SetStreamStateHandler @68
+PaWasapiWinrt_SetDefaultDeviceId @67
PaWasapiWinrt_PopulateDeviceList @69
From 1c54d71e2ae8c3c99e939fd1dbb29db363d82da6 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Fri, 18 Dec 2020 11:48:08 +0200
Subject: [PATCH 044/157] use DWORD for thread id
---
src/os/win/pa_win_coinitialize.c | 2 +-
src/os/win/pa_win_coinitialize.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/os/win/pa_win_coinitialize.c b/src/os/win/pa_win_coinitialize.c
index c4c6dde..ace97f5 100644
--- a/src/os/win/pa_win_coinitialize.c
+++ b/src/os/win/pa_win_coinitialize.c
@@ -135,7 +135,7 @@ void PaWinUtil_CoUninitialize( PaHostApiTypeId hostApiType, PaWinUtilComInitiali
DWORD currentThreadId = GetCurrentThreadId();
if( comInitializationResult->initializingThreadId != currentThreadId )
{
- PA_DEBUG(("ERROR: failed PaWinUtil_CoUninitialize calling thread[%d] does not match initializing thread[%d]\n",
+ PA_DEBUG(("ERROR: failed PaWinUtil_CoUninitialize calling thread[%lu] does not match initializing thread[%lu]\n",
currentThreadId, comInitializationResult->initializingThreadId));
}
else
diff --git a/src/os/win/pa_win_coinitialize.h b/src/os/win/pa_win_coinitialize.h
index 687ab83..63fac7c 100644
--- a/src/os/win/pa_win_coinitialize.h
+++ b/src/os/win/pa_win_coinitialize.h
@@ -55,7 +55,7 @@ extern "C"
*/
typedef struct PaWinUtilComInitializationResult{
int state;
- int initializingThreadId;
+ DWORD initializingThreadId;
} PaWinUtilComInitializationResult;
From 7503d9f2393af401370d557dbf2be44d8cf6c139 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Fri, 18 Dec 2020 11:26:33 +0200
Subject: [PATCH 045/157] fix non latin1 character in pa_debugprint.c
---
src/common/pa_debugprint.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/common/pa_debugprint.c b/src/common/pa_debugprint.c
index f34d4bb..7e9e628 100644
--- a/src/common/pa_debugprint.c
+++ b/src/common/pa_debugprint.c
@@ -71,7 +71,7 @@ void PaUtil_SetDebugPrintFunction(PaUtilLogCallback cb)
}
/*
- If your platform doesn’t have vsnprintf, you are stuck with a
+ If your platform doesn't have vsnprintf, you are stuck with a
VERY dangerous alternative, vsprintf (with no n)
*/
#if _MSC_VER
From 609b998334139d60d1b6cd8fa0b1f772e2f78469 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Fri, 18 Dec 2020 18:32:45 +1100
Subject: [PATCH 046/157] Fix compiler warnings: 'type cast': conversion from
'int' to 'HWAVEIN' of greater size. See ticket #370
---
src/hostapi/wmme/pa_win_wmme.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/hostapi/wmme/pa_win_wmme.c b/src/hostapi/wmme/pa_win_wmme.c
index 8a07bab..b62693b 100644
--- a/src/hostapi/wmme/pa_win_wmme.c
+++ b/src/hostapi/wmme/pa_win_wmme.c
@@ -667,13 +667,16 @@ static void DetectDefaultSampleRate( PaWinMmeDeviceInfo *winMmeDeviceInfo, int w
#ifdef PAWIN_USE_WDMKS_DEVICE_INFO
-static int QueryWaveInKSFilterMaxChannels( int waveInDeviceId, int *maxChannels )
+static int QueryWaveInKSFilterMaxChannels( UINT waveInDeviceId, int *maxChannels )
{
void *devicePath;
DWORD devicePathSize;
int result = 0;
- if( waveInMessage((HWAVEIN)waveInDeviceId, DRV_QUERYDEVICEINTERFACESIZE,
+ /* pass UINT ID via punned HWAVEIN, as per DRV_QUERYDEVICEINTERFACESIZE documentation */
+ HWAVEIN hDeviceId = (HWAVEIN)((UINT_PTR)waveInDeviceId);
+
+ if( waveInMessage(hDeviceId, DRV_QUERYDEVICEINTERFACESIZE,
(DWORD_PTR)&devicePathSize, 0 ) != MMSYSERR_NOERROR )
return 0;
@@ -682,7 +685,7 @@ static int QueryWaveInKSFilterMaxChannels( int waveInDeviceId, int *maxChannels
return 0;
/* apparently DRV_QUERYDEVICEINTERFACE returns a unicode interface path, although this is undocumented */
- if( waveInMessage((HWAVEIN)waveInDeviceId, DRV_QUERYDEVICEINTERFACE,
+ if( waveInMessage(hDeviceId, DRV_QUERYDEVICEINTERFACE,
(DWORD_PTR)devicePath, devicePathSize ) == MMSYSERR_NOERROR )
{
int count = PaWin_WDMKS_QueryFilterMaximumChannelCount( devicePath, /* isInput= */ 1 );
@@ -797,13 +800,16 @@ error:
#ifdef PAWIN_USE_WDMKS_DEVICE_INFO
-static int QueryWaveOutKSFilterMaxChannels( int waveOutDeviceId, int *maxChannels )
+static int QueryWaveOutKSFilterMaxChannels( UINT waveOutDeviceId, int *maxChannels )
{
void *devicePath;
DWORD devicePathSize;
int result = 0;
- if( waveOutMessage((HWAVEOUT)waveOutDeviceId, DRV_QUERYDEVICEINTERFACESIZE,
+ /* pass UINT ID via punned HWAVEOUT, as per DRV_QUERYDEVICEINTERFACESIZE documentation */
+ HWAVEOUT hDeviceId = (HWAVEOUT)((UINT_PTR)waveOutDeviceId);
+
+ if( waveOutMessage(hDeviceId, DRV_QUERYDEVICEINTERFACESIZE,
(DWORD_PTR)&devicePathSize, 0 ) != MMSYSERR_NOERROR )
return 0;
@@ -812,7 +818,7 @@ static int QueryWaveOutKSFilterMaxChannels( int waveOutDeviceId, int *maxChannel
return 0;
/* apparently DRV_QUERYDEVICEINTERFACE returns a unicode interface path, although this is undocumented */
- if( waveOutMessage((HWAVEOUT)waveOutDeviceId, DRV_QUERYDEVICEINTERFACE,
+ if( waveOutMessage(hDeviceId, DRV_QUERYDEVICEINTERFACE,
(DWORD_PTR)devicePath, devicePathSize ) == MMSYSERR_NOERROR )
{
int count = PaWin_WDMKS_QueryFilterMaximumChannelCount( devicePath, /* isInput= */ 0 );
@@ -1017,11 +1023,11 @@ PaError PaWinMme_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
/* the following calls assume that if wave*Message fails the preferred device parameter won't be modified */
preferredDeviceStatusFlags = 0;
waveInPreferredDevice = -1;
- waveInMessage( (HWAVEIN)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveInPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags );
+ waveInMessage( (HWAVEIN)((UINT_PTR)WAVE_MAPPER), DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveInPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags );
preferredDeviceStatusFlags = 0;
waveOutPreferredDevice = -1;
- waveOutMessage( (HWAVEOUT)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveOutPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags );
+ waveOutMessage( (HWAVEOUT)((UINT_PTR)WAVE_MAPPER), DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveOutPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags );
maximumPossibleDeviceCount = 0;
From 4ce9f0d0a86667cf5c5b428356cdb8702f76888b Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Mon, 14 Dec 2020 19:20:43 +1100
Subject: [PATCH 047/157] fix issue #321 broken MSVC build. Always define
PaWasapi_UpdateDeviceList() even when it is a no-op because it is mentioned
in the .def file.
---
src/hostapi/wasapi/pa_win_wasapi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index 86c08c2..9bae24c 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -2498,12 +2498,14 @@ static PaError UpdateDeviceList()
}
// ------------------------------------------------------------------------------------------
-#if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
PaError PaWasapi_UpdateDeviceList()
{
+#if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
return UpdateDeviceList();
-}
+#else
+ return paNoError;
#endif
+}
// ------------------------------------------------------------------------------------------
int PaWasapi_GetDeviceCurrentFormat( PaStream *pStream, void *pFormat, unsigned int formatSize, int bOutput )
From 1a5c410f7f09042d2d7ce1509ec3cf0b6091c7f8 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Fri, 18 Dec 2020 17:53:42 +1100
Subject: [PATCH 048/157] return paInternalError from
PaWasapi_UpdateDeviceList() when it is disabled
---
src/hostapi/wasapi/pa_win_wasapi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index 9bae24c..d791b66 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -2503,7 +2503,7 @@ PaError PaWasapi_UpdateDeviceList()
#if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
return UpdateDeviceList();
#else
- return paNoError;
+ return paInternalError;
#endif
}
From 5f869e787e2127d9ddd640df9af7be610d03dd08 Mon Sep 17 00:00:00 2001
From: Phil Burk
Date: Sat, 19 Dec 2020 15:59:23 -0800
Subject: [PATCH 049/157] paqa_devs: test default device
Use sine wave instead of sawtooth because it is
easier to hear glitches.
Add some options:
-a - Test ALL devices, otherwise just the default devices.
-i - Test INPUT only.
-o - Test OUTPUT only.
---
qa/paqa_devs.c | 192 +++++++++++++++++++++++++++++++++++--------------
1 file changed, 137 insertions(+), 55 deletions(-)
diff --git a/qa/paqa_devs.c b/qa/paqa_devs.c
index 721b07f..fae9f25 100644
--- a/qa/paqa_devs.c
+++ b/qa/paqa_devs.c
@@ -1,13 +1,13 @@
/** @file paqa_devs.c
- @ingroup qa_src
+ @ingroup qa_src
@brief Self Testing Quality Assurance app for PortAudio
- Try to open each device and run through all the
- possible configurations. This test does not verify
+ Try to open the default devices and run through all the
+ possible configurations. This test does not verify
that the configuration works well. It just verifies
that it does not crash. It requires a human to listen to
- the outputs.
+ the sine wave outputs.
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
Pieter adapted to V19 API. Test now relies heavily on
Pa_IsFormatSupported(). Uses same 'standard' sample rates
@@ -52,14 +52,20 @@
*/
#include
+#include
+#include
#include
#include "portaudio.h"
#include "pa_trace.h"
/****************************************** Definitions ***********/
-#define MODE_INPUT (0)
-#define MODE_OUTPUT (1)
-#define MAX_TEST_CHANNELS 4
+#define MODE_INPUT (0)
+#define MODE_OUTPUT (1)
+#define MAX_TEST_CHANNELS (4)
+#define LOWEST_FREQUENCY (300.0)
+#define LOWEST_SAMPLE_RATE (8000.0)
+#define PHASE_INCREMENT (2.0 * M_PI * LOWEST_FREQUENCY / LOWEST_SAMPLE_RATE)
+#define SINE_AMPLITUDE (0.2)
typedef struct PaQaData
{
@@ -67,13 +73,13 @@ typedef struct PaQaData
int numChannels;
int bytesPerSample;
int mode;
- short sawPhase;
+ float phase;
PaSampleFormat format;
}
PaQaData;
/****************************************** Prototypes ***********/
-static void TestDevices( int mode );
+static void TestDevices( int mode, int allDevices );
static void TestFormats( int mode, PaDeviceIndex deviceID, double sampleRate,
int numChannels );
static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
@@ -107,6 +113,14 @@ static int gNumFailed = 0;
} \
} while(0)
+static float NextSineSample( PaQaData *data )
+{
+ float phase = data->phase + PHASE_INCREMENT;
+ if( phase > M_PI ) phase -= 2.0 * M_PI;
+ data->phase = phase;
+ return sinf(phase) * SINE_AMPLITUDE;
+}
+
/*******************************************************************/
/* This routine will be called by the PortAudio engine when audio is needed.
** It may be called at interrupt level on some machines so don't do anything
@@ -118,27 +132,26 @@ static int QaCallback( const void *inputBuffer, void *outputBuffer,
PaStreamCallbackFlags statusFlags,
void *userData )
{
- unsigned long i;
- short phase;
+ unsigned long frameIndex;
+ unsigned long channelIndex;
+ float sample;
PaQaData *data = (PaQaData *) userData;
(void) inputBuffer;
- /* Play simple sawtooth wave. */
+ /* Play simple sine wave. */
if( data->mode == MODE_OUTPUT )
{
- phase = data->sawPhase;
switch( data->format )
{
case paFloat32:
{
float *out = (float *) outputBuffer;
- for( i=0; inumChannels == 2 )
+ sample = NextSineSample( data );
+ for( channelIndex = 0; channelIndex < data->numChannels; channelIndex++ )
{
- *out++ = (float) (phase * (1.0 / 32768.0));
+ *out++ = sample;
}
}
}
@@ -147,13 +160,12 @@ static int QaCallback( const void *inputBuffer, void *outputBuffer,
case paInt32:
{
int *out = (int *) outputBuffer;
- for( i=0; inumChannels == 2 )
+ sample = NextSineSample( data );
+ for( channelIndex = 0; channelIndex < data->numChannels; channelIndex++ )
{
- *out++ = ((int) phase ) << 16;
+ *out++ = ((int)(sample * 0x00800000)) << 8;
}
}
}
@@ -162,13 +174,12 @@ static int QaCallback( const void *inputBuffer, void *outputBuffer,
case paInt16:
{
short *out = (short *) outputBuffer;
- for( i=0; inumChannels == 2 )
+ sample = NextSineSample( data );
+ for( channelIndex = 0; channelIndex < data->numChannels; channelIndex++ )
{
- *out++ = phase;
+ *out++ = (short)(sample * 32767);
}
}
}
@@ -178,14 +189,10 @@ static int QaCallback( const void *inputBuffer, void *outputBuffer,
{
unsigned char *out = (unsigned char *) outputBuffer;
unsigned long numBytes = framesPerBuffer * data->numChannels * data->bytesPerSample;
- for( i=0; isawPhase = phase;
}
/* Are we through yet? */
if( data->framesLeft > framesPerBuffer )
@@ -203,15 +210,78 @@ static int QaCallback( const void *inputBuffer, void *outputBuffer,
}
/*******************************************************************/
-int main(void);
-int main(void)
+static void usage( const char *name )
{
+ printf("%s [-a]\n", name);
+ printf(" -a - Test ALL devices, otherwise just the default devices.\n");
+ printf(" -i - Test INPUT only.\n");
+ printf(" -o - Test OUTPUT only.\n");
+ printf(" -? - Help\n");
+}
+
+/*******************************************************************/
+int main( int argc, char **argv );
+int main( int argc, char **argv )
+{
+ int i;
PaError result;
+ int allDevices = 0;
+ int testOutput = 1;
+ int testInput = 1;
+ char *executableName = argv[0];
+
+ /* Parse command line parameters. */
+ i = 1;
+ while( imaxInputChannels : pdi->maxOutputChannels);
+
+ if( mode == MODE_INPUT ) {
+ maxChannels = pdi->maxInputChannels;
+ isDefault = ( id == Pa_GetDefaultInputDevice());
+ } else {
+ maxChannels = pdi->maxOutputChannels;
+ isDefault = ( id == Pa_GetDefaultOutputDevice());
+ }
if( maxChannels > MAX_TEST_CHANNELS )
maxChannels = MAX_TEST_CHANNELS;
+
+ if (!allDevices && !isDefault) continue; // skip this device
for( jc=1; jc<=maxChannels; jc++ )
{
- printf("\n========================================================================\n");
+ printf("\n===========================================================\n");
printf(" Device = %s\n", pdi->name );
- printf("========================================================================\n");
+ printf("===========================================================\n");
/* Try each standard sample rate. */
for( i=0; standardSampleRates[i] > 0; i++ )
{
@@ -299,32 +378,35 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
inputParameters.device = deviceID;
inputParameters.channelCount = numChannels;
inputParameters.sampleFormat = format;
- inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency;
+ inputParameters.suggestedLatency =
+ Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency;
inputParameters.hostApiSpecificStreamInfo = NULL;
ipp = &inputParameters;
}
else
{
- ipp = NULL;
- }
-
+ ipp = NULL;
+ }
+
if( mode == MODE_OUTPUT )
{
outputParameters.device = deviceID;
outputParameters.channelCount = numChannels;
outputParameters.sampleFormat = format;
- outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
+ outputParameters.suggestedLatency =
+ Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
opp = &outputParameters;
}
else
{
- opp = NULL;
- }
-
+ opp = NULL;
+ }
+
if(paFormatIsSupported == Pa_IsFormatSupported( ipp, opp, sampleRate ))
{
- printf("------ TestAdvance: %s, device = %d, rate = %g, numChannels = %d, format = %lu -------\n",
+ printf("------ TestAdvance: %s, device = %d, rate = %g"
+ ", numChannels = %d, format = %lu -------\n",
( mode == MODE_INPUT ) ? "INPUT" : "OUTPUT",
deviceID, sampleRate, numChannels, (unsigned long)format);
EXPECT( ((result = Pa_OpenStream( &stream,
@@ -353,7 +435,7 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
oldStamp = Pa_GetStreamTime(stream);
Pa_Sleep(msec);
newStamp = Pa_GetStreamTime(stream);
- printf("oldStamp = %9.6f, newStamp = %9.6f\n", oldStamp, newStamp ); /**/
+ printf("oldStamp = %9.6f, newStamp = %9.6f\n", oldStamp, newStamp ); /**/
EXPECT( (oldStamp < newStamp) );
/* Check to make sure callback is decrementing framesLeft. */
oldFrames = myData.framesLeft;
From d68a78d30bc445b50ccbca505ddba45006e6c102 Mon Sep 17 00:00:00 2001
From: Phil Burk
Date: Sat, 26 Dec 2020 08:32:40 -0800
Subject: [PATCH 050/157] paqa_devs.c: remove some white space
---
qa/paqa_devs.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/qa/paqa_devs.c b/qa/paqa_devs.c
index fae9f25..87b074c 100644
--- a/qa/paqa_devs.c
+++ b/qa/paqa_devs.c
@@ -8,8 +8,8 @@
the sine wave outputs.
@author Phil Burk http://www.softsynth.com
-
- Pieter adapted to V19 API. Test now relies heavily on
+
+ Pieter adapted to V19 API. Test now relies heavily on
Pa_IsFormatSupported(). Uses same 'standard' sample rates
as in test pa_devs.c.
*/
@@ -41,13 +41,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -170,7 +170,7 @@ static int QaCallback( const void *inputBuffer, void *outputBuffer,
}
}
break;
-
+
case paInt16:
{
short *out = (short *) outputBuffer;
@@ -317,7 +317,7 @@ static void TestDevices( int mode, int allDevices )
maxChannels = MAX_TEST_CHANNELS;
if (!allDevices && !isDefault) continue; // skip this device
-
+
for( jc=1; jc<=maxChannels; jc++ )
{
printf("\n===========================================================\n");
@@ -352,7 +352,7 @@ static int TestAdvance( int mode, PaDeviceIndex deviceID, double sampleRate,
PaQaData myData;
#define FRAMES_PER_BUFFER (64)
const int kNumSeconds = 100;
-
+
/* Setup data for synthesis thread. */
myData.framesLeft = (unsigned long) (sampleRate * kNumSeconds);
myData.numChannels = numChannels;
From 63bbb63343876d997a4b3914d21e638f92172979 Mon Sep 17 00:00:00 2001
From: Phil Burk
Date: Sat, 26 Dec 2020 08:33:26 -0800
Subject: [PATCH 051/157] paqa_devs.c: improve file comment
---
qa/paqa_devs.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/qa/paqa_devs.c b/qa/paqa_devs.c
index 87b074c..a7d19a2 100644
--- a/qa/paqa_devs.c
+++ b/qa/paqa_devs.c
@@ -1,11 +1,12 @@
/** @file paqa_devs.c
@ingroup qa_src
@brief Self Testing Quality Assurance app for PortAudio
- Try to open the default devices and run through all the
- possible configurations. This test does not verify
- that the configuration works well. It just verifies
- that it does not crash. It requires a human to listen to
- the sine wave outputs.
+ Try to open devices and run through all possible configurations.
+ By default, open only the default devices. Command line options support
+ opening every device, or all input devices, or all output devices.
+ This test does not verify that the configuration works well.
+ It just verifies that it does not crash. It requires a human to
+ listen to the sine wave outputs.
@author Phil Burk http://www.softsynth.com
From a7bda88e6b628c4c9879cac2b4b4c68da3a1a6b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?=
Date: Mon, 21 Dec 2020 19:22:16 +0100
Subject: [PATCH 052/157] Fix a GCC warning due to unsigned substraction
Given
unsigned int reqRate, setRate, deviation;
then
setRate - reqRate
is also an unsigned int - the code works "by chance" as `abs` casts that to an int which overflows and is technically undefined behaviour, for instance for setRate = 44100 and reqRate = 48000.
Thus cast them to int when computing the absolute value to ensure no UB.
---
src/hostapi/alsa/pa_linux_alsa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c
index 462034c..be76c64 100644
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -3204,7 +3204,7 @@ static int SetApproximateSampleRate( snd_pcm_t *pcm, snd_pcm_hw_params_t *hwPara
ENSURE_( alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &setRate, NULL ), paUnanticipatedHostError );
/* The value actually set will be put in 'setRate' (may be way off); check the deviation as a proportion
* of the requested-rate with reference to the max-deviate-ratio (larger values allow less deviation) */
- deviation = abs( setRate - reqRate );
+ deviation = abs( (int)setRate - (int)reqRate );
if( deviation > 0 && deviation * RATE_MAX_DEVIATE_RATIO > reqRate )
result = paInvalidSampleRate;
From cdd1cf69fe3717651e4b066249d883efef6c7995 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Mon, 21 Dec 2020 17:25:42 +1100
Subject: [PATCH 053/157] Add new GitHub action to build PortAudio using the
MSVC project file. Fixes #368.
---
.github/workflows/MSBuild.yml | 96 +++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
create mode 100644 .github/workflows/MSBuild.yml
diff --git a/.github/workflows/MSBuild.yml b/.github/workflows/MSBuild.yml
new file mode 100644
index 0000000..b6f52b8
--- /dev/null
+++ b/.github/workflows/MSBuild.yml
@@ -0,0 +1,96 @@
+name: MSBuild
+
+on: [push]
+
+env:
+ # Path to the solution file relative to the root of the project.
+ SOLUTION_FILE_PATH: ./build/msvc/portaudio.sln
+ VCPROJ_FILE_PATH: ./build/msvc/portaudio.vcproj
+ VCXPROJ_FILE_PATH: ./build/msvc/portaudio.vcxproj
+ VCXPROJ_FILTERS_FILE_PATH: ./build/msvc/portaudio.vcxproj.filters
+ VCXPROJ_USER_FILE_PATH: ./build/msvc/portaudio.vcxproj.user
+ DEF_FILE_PATH: ./build/msvc/portaudio.def
+
+jobs:
+ build:
+ runs-on: windows-latest
+ strategy:
+ matrix:
+ BUILD_CONFIGURATION: [Release]
+ BUILD_PLATFORM: [Win32, x64]
+
+ steps:
+ - name: Add MSBuild to PATH
+ uses: microsoft/setup-msbuild@v1
+
+ - uses: actions/checkout@v2
+
+ - name: Upgrade Solution
+ # We maintain our vcproj file in an old format to maintain backwards compatibility
+ # This step upgrades the project to the latest version of MSVC
+ # see https://docs.microsoft.com/en-us/visualstudio/ide/reference/upgrade-devenv-exe?view=vs-2019
+ # pipe to file to ensure that it terminates https://stackoverflow.com/questions/48896010/occasionally-occurring-msbuild-error-msb3428/48918105#48918105
+ # discussion of using vswhere.exe here: https://stackoverflow.com/questions/65287456/how-to-upgrade-a-visual-studio-project-from-within-a-github-action/65311868#65311868
+ run: |
+ $devenv = & vswhere.exe '-property' productPath
+ Write-Output "$devenv"
+ & $devenv "${{env.VCPROJ_FILE_PATH}}" /Upgrade /NoSplash | Out-Null
+ Write-Output "devenv launched"
+ while (!(Test-Path "${{env.VCXPROJ_FILE_PATH}}")) { Start-Sleep -Seconds 10 }
+ Write-Output "vcxproj found"
+ while (!(Test-Path "${{env.VCXPROJ_FILTERS_FILE_PATH}}")) { Start-Sleep -Seconds 10 }
+ Write-Output "vcxproj.filters found"
+ Start-Sleep -Seconds 10
+ Write-Output "done."
+
+ - name: Remove ASIO Files
+ # Process the project files to remove ASIO-related sources and includes (since we can not access the ASIO SDK in a public build)
+ run: |
+ # Process .vcxproj file: remove source files
+ $xdoc = new-object System.Xml.XmlDocument
+ $vcxprojFile = resolve-path("${{env.VCXPROJ_FILE_PATH}}")
+ $xdoc.load($vcxprojFile)
+ $namespace = New-Object -TypeName "Xml.XmlNamespaceManager" -ArgumentList $xdoc.NameTable
+ $namespace.AddNamespace("vs", $xdoc.DocumentElement.NamespaceURI)
+ $nodes = $xdoc.SelectNodes("//vs:ClCompile[contains(@Include, '..\src\hostapi\asio')]", $namespace)
+ Write-Output "deleting ASIO related compilation nodes from .vcxproj:"
+ Write-Output $nodes
+ ForEach($node in $nodes) {
+ $parent = $node.ParentNode
+ $parent.RemoveChild($node)
+ }
+ # Enable DirectSound host API
+ $nodes = $xdoc.SelectNodes("//vs:PreprocessorDefinitions[contains(., 'PA_USE_DS=0')]", $namespace)
+ ForEach($node in $nodes) {
+ $text = $node.InnerText
+ $node.InnerText = $text -replace 'PA_USE_DS=0', 'PA_USE_DS=1'
+ }
+ $xdoc.save($vcxprojFile)
+ # Process .vcxproj.filters file: remove source files and includes
+ $vcxprojFiltersFile = resolve-path("${{env.VCXPROJ_FILTERS_FILE_PATH}}")
+ $xdoc.load($vcxprojFiltersFile)
+ $namespace = New-Object -TypeName "Xml.XmlNamespaceManager" -ArgumentList $xdoc.NameTable
+ $namespace.AddNamespace("vs", $xdoc.DocumentElement.NamespaceURI)
+ $nodes = $xdoc.SelectNodes("//vs:ClCompile[contains(@Include, '..\src\hostapi\asio')]", $namespace)
+ Write-Output "deleting ASIO related compilation nodes from .vcxproj.filters:"
+ Write-Output $nodes
+ ForEach($node in $nodes) {
+ $parent = $node.ParentNode
+ $parent.RemoveChild($node)
+ }
+ $nodes = $xdoc.SelectNodes("//vs:ClInclude[contains(@Include, 'pa_asio.h')]", $namespace)
+ Write-Output "deleting ASIO related include nodes from .vcxproj.filters:"
+ Write-Output $nodes
+ ForEach($node in $nodes) {
+ $parent = $node.ParentNode
+ $parent.RemoveChild($node)
+ }
+ $xdoc.save($vcxprojFiltersFile)
+ # Process .def file: remove PaAsio_ symbols
+ Set-Content -Path "${{env.DEF_FILE_PATH}}" -Value (Get-Content -Path "${{env.DEF_FILE_PATH}}" | Select-String -Pattern 'PaAsio_' -NotMatch)
+
+ - name: Build
+ working-directory: ${{env.GITHUB_WORKSPACE}}
+ # Add additional options to the MSBuild command line here (like platform or verbosity level).
+ # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
+ run: msbuild /m /p:Configuration=${{matrix.BUILD_CONFIGURATION}} /p:Platform=${{matrix.BUILD_PLATFORM}} ${{env.VCXPROJ_FILE_PATH}}
From fb9b6463ebbff946047840dfcc643c86a6fe5518 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Mon, 21 Dec 2020 17:31:34 +1100
Subject: [PATCH 054/157] Rename build steps for clarity.
---
.github/workflows/MSBuild.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/MSBuild.yml b/.github/workflows/MSBuild.yml
index b6f52b8..4a78bec 100644
--- a/.github/workflows/MSBuild.yml
+++ b/.github/workflows/MSBuild.yml
@@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v2
- - name: Upgrade Solution
+ - name: Upgrade VC Project File
# We maintain our vcproj file in an old format to maintain backwards compatibility
# This step upgrades the project to the latest version of MSVC
# see https://docs.microsoft.com/en-us/visualstudio/ide/reference/upgrade-devenv-exe?view=vs-2019
@@ -43,7 +43,7 @@ jobs:
Start-Sleep -Seconds 10
Write-Output "done."
- - name: Remove ASIO Files
+ - name: Remove ASIO Files and Enable PA_USE_DS=1
# Process the project files to remove ASIO-related sources and includes (since we can not access the ASIO SDK in a public build)
run: |
# Process .vcxproj file: remove source files
From 6a676d3ecb9a493750b18387d56e586305f5749e Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Tue, 22 Dec 2020 18:57:23 +1100
Subject: [PATCH 055/157] wdmks: Reset packet->Header.OptionsFlags = 0 for each
packet. Fixes issue with Focusrite Scarlett 2i4 (1st Gen). Fixes #310
---
src/hostapi/wdmks/pa_win_wdmks.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/hostapi/wdmks/pa_win_wdmks.c b/src/hostapi/wdmks/pa_win_wdmks.c
index f30ee95..21f944d 100644
--- a/src/hostapi/wdmks/pa_win_wdmks.c
+++ b/src/hostapi/wdmks/pa_win_wdmks.c
@@ -6548,6 +6548,7 @@ static PaError PaPinCaptureSubmitHandler_WaveCyclic(PaProcessThreadInfo* pInfo,
assert(packet != 0);
PA_HP_TRACE((pInfo->stream->hLog, "Capture submit: %u", eventIndex));
packet->Header.DataUsed = 0; /* Reset for reuse */
+ packet->Header.OptionsFlags = 0; /* Reset for reuse. Required for e.g. Focusrite Scarlett 2i4 (1st Gen) see #310 */
ResetEvent(packet->Signal.hEvent);
result = PinRead(pInfo->stream->capture.pPin->handle, packet);
++pInfo->pending;
From 7ffe61ea26bcc6822ce647e58e9b7f8504703b36 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Mon, 21 Dec 2020 18:11:12 +1100
Subject: [PATCH 056/157] Fix uninitialized variable warnings. Improved
solution for PR #377
---
src/hostapi/wdmks/pa_win_wdmks.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/hostapi/wdmks/pa_win_wdmks.c b/src/hostapi/wdmks/pa_win_wdmks.c
index 21f944d..7224e13 100644
--- a/src/hostapi/wdmks/pa_win_wdmks.c
+++ b/src/hostapi/wdmks/pa_win_wdmks.c
@@ -4380,7 +4380,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
userInputChannels = 0;
- inputSampleFormat = hostInputSampleFormat = paInt16; /* Suppress 'uninitialised var' warnings. */
+ inputSampleFormat = paInt16; /* Suppress 'uninitialised var' warnings. */
}
if( outputParameters )
@@ -4415,7 +4415,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
userOutputChannels = 0;
- outputSampleFormat = hostOutputSampleFormat = paInt16; /* Suppress 'uninitialized var' warnings. */
+ outputSampleFormat = paInt16; /* Suppress 'uninitialized var' warnings. */
}
/* validate platform specific flags */
@@ -4600,6 +4600,8 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
}
else
{
+ hostInputSampleFormat = (PaSampleFormat)0; /* Avoid uninitialized variable warning */
+
stream->capture.pPin = NULL;
stream->capture.bytesPerFrame = 0;
}
@@ -4724,6 +4726,8 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
}
else
{
+ hostOutputSampleFormat = (PaSampleFormat)0; /* Avoid uninitialized variable warning */
+
stream->render.pPin = NULL;
stream->render.bytesPerFrame = 0;
}
From 17b895bb8f4c103d88bde3defd5124cbb164db6e Mon Sep 17 00:00:00 2001
From: petris
Date: Tue, 22 Dec 2020 18:30:19 +0100
Subject: [PATCH 057/157] Fix ANSI in MME and DSound
---
src/hostapi/dsound/pa_win_ds.c | 11 ------
src/hostapi/wmme/pa_win_wmme.c | 70 ++++++++++------------------------
2 files changed, 21 insertions(+), 60 deletions(-)
diff --git a/src/hostapi/dsound/pa_win_ds.c b/src/hostapi/dsound/pa_win_ds.c
index f3cb67f..f2dcf90 100644
--- a/src/hostapi/dsound/pa_win_ds.c
+++ b/src/hostapi/dsound/pa_win_ds.c
@@ -408,16 +408,6 @@ static char *DuplicateDeviceNameString( PaUtilAllocationGroup *allocations, cons
if( src != NULL )
{
-#if !defined(_UNICODE) && !defined(UNICODE)
- size_t len = WideCharToMultiByte(CP_ACP, 0, src, -1, NULL, 0, NULL, NULL);
-
- result = (char*)PaUtil_GroupAllocateMemory( allocations, (long)(len + 1) );
- if( result ) {
- if (WideCharToMultiByte(CP_ACP, 0, src, -1, result, (int)len, NULL, NULL) == 0) {
- result = 0;
- }
- }
-#else
size_t len = WideCharToMultiByte(CP_UTF8, 0, src, -1, NULL, 0, NULL, NULL);
result = (char*)PaUtil_GroupAllocateMemory( allocations, (long)(len + 1) );
@@ -426,7 +416,6 @@ static char *DuplicateDeviceNameString( PaUtilAllocationGroup *allocations, cons
result = 0;
}
}
-#endif
}
else
{
diff --git a/src/hostapi/wmme/pa_win_wmme.c b/src/hostapi/wmme/pa_win_wmme.c
index b62693b..bf48be5 100644
--- a/src/hostapi/wmme/pa_win_wmme.c
+++ b/src/hostapi/wmme/pa_win_wmme.c
@@ -204,12 +204,9 @@ static const char constOutputMapperSuffix_[] = " - Output";
/********************************************************************/
-/* Copy null-terminated TCHAR string to explicit char string using UTF8 encoding */
-static char *CopyTCharStringToUtf8CString(char *destination, size_t destLengthBytes, const TCHAR *source)
+/* Copy null-terminated WCHAR string to explicit char string using UTF8 encoding */
+static char *CopyWCharStringToUtf8CString(char *destination, size_t destLengthBytes, const WCHAR *source)
{
-#if !defined(_UNICODE) && !defined(UNICODE)
- return strcpy(destination, source);
-#else
/* The cbMultiByte parameter ["destLengthBytes" below] is:
"""
Size, in bytes, of the buffer indicated by lpMultiByteStr ["destination" below].
@@ -237,18 +234,13 @@ static char *CopyTCharStringToUtf8CString(char *destination, size_t destLengthBy
if (WideCharToMultiByte(CP_UTF8, 0, source, -1, destination, /*cbMultiByte=*/intDestLengthBytes, NULL, NULL) == 0)
return NULL;
return destination;
-#endif
}
/* returns required length (in bytes) of destination buffer when
- converting TCHAR string to UTF8 bytes, not including the terminating null. */
-static size_t TCharStringLen(const TCHAR *str)
+ converting WCHAR string to UTF8 bytes, not including the terminating null. */
+static size_t WCharStringLen(const WCHAR *str)
{
-#if !defined(_UNICODE) && !defined(UNICODE)
- return strlen(str);
-#else
- return WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);
-#endif
+ return WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);
}
/********************************************************************/
@@ -298,14 +290,12 @@ static signed long GetStreamWriteAvailable( PaStream* stream );
/* macros for setting last host error information */
-#ifdef UNICODE
-
#define PA_MME_SET_LAST_WAVEIN_ERROR( mmresult ) \
{ \
wchar_t mmeErrorTextWide[ MAXERRORLENGTH ]; \
char mmeErrorText[ MAXERRORLENGTH ]; \
- waveInGetErrorText( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
- WideCharToMultiByte( CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR,\
+ waveInGetErrorTextW( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
+ WideCharToMultiByte( CP_UTF8, WC_COMPOSITECHECK | WC_DEFAULTCHAR,\
mmeErrorTextWide, -1, mmeErrorText, MAXERRORLENGTH, NULL, NULL ); \
PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
}
@@ -314,29 +304,11 @@ static signed long GetStreamWriteAvailable( PaStream* stream );
{ \
wchar_t mmeErrorTextWide[ MAXERRORLENGTH ]; \
char mmeErrorText[ MAXERRORLENGTH ]; \
- waveOutGetErrorText( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
- WideCharToMultiByte( CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR,\
+ waveOutGetErrorTextW( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
+ WideCharToMultiByte( CP_UTF8, WC_COMPOSITECHECK | WC_DEFAULTCHAR,\
mmeErrorTextWide, -1, mmeErrorText, MAXERRORLENGTH, NULL, NULL ); \
PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
}
-
-#else /* !UNICODE */
-
-#define PA_MME_SET_LAST_WAVEIN_ERROR( mmresult ) \
- { \
- char mmeErrorText[ MAXERRORLENGTH ]; \
- waveInGetErrorText( mmresult, mmeErrorText, MAXERRORLENGTH ); \
- PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
- }
-
-#define PA_MME_SET_LAST_WAVEOUT_ERROR( mmresult ) \
- { \
- char mmeErrorText[ MAXERRORLENGTH ]; \
- waveOutGetErrorText( mmresult, mmeErrorText, MAXERRORLENGTH ); \
- PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
- }
-
-#endif /* UNICODE */
static void PaMme_SetLastSystemError( DWORD errorCode )
@@ -709,13 +681,13 @@ static PaError InitializeInputDeviceInfo( PaWinMmeHostApiRepresentation *winMmeH
PaError result = paNoError;
char *deviceName; /* non-const ptr */
MMRESULT mmresult;
- WAVEINCAPS wic;
+ WAVEINCAPSW wic;
PaDeviceInfo *deviceInfo = &winMmeDeviceInfo->inheritedDeviceInfo;
size_t len;
*success = 0;
- mmresult = waveInGetDevCaps( winMmeInputDeviceId, &wic, sizeof( WAVEINCAPS ) );
+ mmresult = waveInGetDevCapsW( winMmeInputDeviceId, &wic, sizeof( WAVEINCAPSW ) );
if( mmresult == MMSYSERR_NOMEM )
{
result = paInsufficientMemory;
@@ -735,7 +707,7 @@ static PaError InitializeInputDeviceInfo( PaWinMmeHostApiRepresentation *winMmeH
so we are limited to displaying only the first 31 characters of the device name. */
if( winMmeInputDeviceId == WAVE_MAPPER )
{
- len = TCharStringLen( wic.szPname ) + 1 + sizeof(constInputMapperSuffix_);
+ len = WCharStringLen( wic.szPname ) + 1 + sizeof(constInputMapperSuffix_);
/* Append I/O suffix to WAVE_MAPPER device. */
deviceName = (char*)PaUtil_GroupAllocateMemory(
winMmeHostApi->allocations,
@@ -745,12 +717,12 @@ static PaError InitializeInputDeviceInfo( PaWinMmeHostApiRepresentation *winMmeH
result = paInsufficientMemory;
goto error;
}
- CopyTCharStringToUtf8CString( deviceName, len, wic.szPname );
+ CopyWCharStringToUtf8CString( deviceName, len, wic.szPname );
strcat( deviceName, constInputMapperSuffix_ );
}
else
{
- len = TCharStringLen( wic.szPname ) + 1;
+ len = WCharStringLen( wic.szPname ) + 1;
deviceName = (char*)PaUtil_GroupAllocateMemory(
winMmeHostApi->allocations,
(long)len );
@@ -759,7 +731,7 @@ static PaError InitializeInputDeviceInfo( PaWinMmeHostApiRepresentation *winMmeH
result = paInsufficientMemory;
goto error;
}
- CopyTCharStringToUtf8CString( deviceName, len, wic.szPname );
+ CopyWCharStringToUtf8CString( deviceName, len, wic.szPname );
}
deviceInfo->name = deviceName;
@@ -842,7 +814,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
PaError result = paNoError;
char *deviceName; /* non-const ptr */
MMRESULT mmresult;
- WAVEOUTCAPS woc;
+ WAVEOUTCAPSW woc;
PaDeviceInfo *deviceInfo = &winMmeDeviceInfo->inheritedDeviceInfo;
size_t len;
#ifdef PAWIN_USE_WDMKS_DEVICE_INFO
@@ -851,7 +823,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
*success = 0;
- mmresult = waveOutGetDevCaps( winMmeOutputDeviceId, &woc, sizeof( WAVEOUTCAPS ) );
+ mmresult = waveOutGetDevCapsW( winMmeOutputDeviceId, &woc, sizeof( WAVEOUTCAPSW ) );
if( mmresult == MMSYSERR_NOMEM )
{
result = paInsufficientMemory;
@@ -872,7 +844,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
if( winMmeOutputDeviceId == WAVE_MAPPER )
{
/* Append I/O suffix to WAVE_MAPPER device. */
- len = TCharStringLen( woc.szPname ) + 1 + sizeof(constOutputMapperSuffix_);
+ len = WCharStringLen( woc.szPname ) + 1 + sizeof(constOutputMapperSuffix_);
deviceName = (char*)PaUtil_GroupAllocateMemory(
winMmeHostApi->allocations,
(long)len );
@@ -881,12 +853,12 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
result = paInsufficientMemory;
goto error;
}
- CopyTCharStringToUtf8CString( deviceName, len, woc.szPname );
+ CopyWCharStringToUtf8CString( deviceName, len, woc.szPname );
strcat( deviceName, constOutputMapperSuffix_ );
}
else
{
- len = TCharStringLen( woc.szPname ) + 1;
+ len = WCharStringLen( woc.szPname ) + 1;
deviceName = (char*)PaUtil_GroupAllocateMemory(
winMmeHostApi->allocations,
(long)len );
@@ -895,7 +867,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
result = paInsufficientMemory;
goto error;
}
- CopyTCharStringToUtf8CString( deviceName, len, woc.szPname );
+ CopyWCharStringToUtf8CString( deviceName, len, woc.szPname );
}
deviceInfo->name = deviceName;
From 6f90db9612f80c9dd781969959820cb1610b8184 Mon Sep 17 00:00:00 2001
From: MichalPetryka <35800402+MichalPetryka@users.noreply.github.com>
Date: Tue, 22 Dec 2020 21:00:53 +0100
Subject: [PATCH 058/157] Update pa_win_wmme.c
---
src/hostapi/wmme/pa_win_wmme.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/hostapi/wmme/pa_win_wmme.c b/src/hostapi/wmme/pa_win_wmme.c
index bf48be5..020cfc0 100644
--- a/src/hostapi/wmme/pa_win_wmme.c
+++ b/src/hostapi/wmme/pa_win_wmme.c
@@ -295,7 +295,7 @@ static signed long GetStreamWriteAvailable( PaStream* stream );
wchar_t mmeErrorTextWide[ MAXERRORLENGTH ]; \
char mmeErrorText[ MAXERRORLENGTH ]; \
waveInGetErrorTextW( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
- WideCharToMultiByte( CP_UTF8, WC_COMPOSITECHECK | WC_DEFAULTCHAR,\
+ WideCharToMultiByte( CP_UTF8, 0, \
mmeErrorTextWide, -1, mmeErrorText, MAXERRORLENGTH, NULL, NULL ); \
PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
}
@@ -305,7 +305,7 @@ static signed long GetStreamWriteAvailable( PaStream* stream );
wchar_t mmeErrorTextWide[ MAXERRORLENGTH ]; \
char mmeErrorText[ MAXERRORLENGTH ]; \
waveOutGetErrorTextW( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
- WideCharToMultiByte( CP_UTF8, WC_COMPOSITECHECK | WC_DEFAULTCHAR,\
+ WideCharToMultiByte( CP_UTF8, 0, \
mmeErrorTextWide, -1, mmeErrorText, MAXERRORLENGTH, NULL, NULL ); \
PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
}
From f4a9023400f5a0e7b86c616e217ea2579a56e3ba Mon Sep 17 00:00:00 2001
From: MichalPetryka <35800402+MichalPetryka@users.noreply.github.com>
Date: Wed, 23 Dec 2020 13:06:48 +0100
Subject: [PATCH 059/157] Align slashes
---
src/hostapi/wmme/pa_win_wmme.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/hostapi/wmme/pa_win_wmme.c b/src/hostapi/wmme/pa_win_wmme.c
index 020cfc0..d5337b8 100644
--- a/src/hostapi/wmme/pa_win_wmme.c
+++ b/src/hostapi/wmme/pa_win_wmme.c
@@ -290,24 +290,24 @@ static signed long GetStreamWriteAvailable( PaStream* stream );
/* macros for setting last host error information */
-#define PA_MME_SET_LAST_WAVEIN_ERROR( mmresult ) \
- { \
- wchar_t mmeErrorTextWide[ MAXERRORLENGTH ]; \
- char mmeErrorText[ MAXERRORLENGTH ]; \
- waveInGetErrorTextW( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
- WideCharToMultiByte( CP_UTF8, 0, \
- mmeErrorTextWide, -1, mmeErrorText, MAXERRORLENGTH, NULL, NULL ); \
- PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
+#define PA_MME_SET_LAST_WAVEIN_ERROR( mmresult ) \
+ { \
+ wchar_t mmeErrorTextWide[ MAXERRORLENGTH ]; \
+ char mmeErrorText[ MAXERRORLENGTH ]; \
+ waveInGetErrorTextW( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
+ WideCharToMultiByte( CP_UTF8, 0, mmeErrorTextWide, -1, \
+ mmeErrorText, MAXERRORLENGTH, NULL, NULL ); \
+ PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
}
-#define PA_MME_SET_LAST_WAVEOUT_ERROR( mmresult ) \
- { \
- wchar_t mmeErrorTextWide[ MAXERRORLENGTH ]; \
- char mmeErrorText[ MAXERRORLENGTH ]; \
- waveOutGetErrorTextW( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
- WideCharToMultiByte( CP_UTF8, 0, \
- mmeErrorTextWide, -1, mmeErrorText, MAXERRORLENGTH, NULL, NULL ); \
- PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
+#define PA_MME_SET_LAST_WAVEOUT_ERROR( mmresult ) \
+ { \
+ wchar_t mmeErrorTextWide[ MAXERRORLENGTH ]; \
+ char mmeErrorText[ MAXERRORLENGTH ]; \
+ waveOutGetErrorTextW( mmresult, mmeErrorTextWide, MAXERRORLENGTH ); \
+ WideCharToMultiByte( CP_UTF8, 0, mmeErrorTextWide, -1, \
+ mmeErrorText, MAXERRORLENGTH, NULL, NULL ); \
+ PaUtil_SetLastHostErrorInfo( paMME, mmresult, mmeErrorText ); \
}
From 2d8c7eb0f72931e9ef7847db298ce8a15f40c5a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Damstedt=20Rasmussen?=
Date: Tue, 29 Dec 2020 07:31:58 +0100
Subject: [PATCH 060/157] Report thread running so Pa_StartStream can return
prior to PaStreamCallback
StartStream() calls WaitForSingleObject(stream->hThreadStart, 60*1000)
but it will not be able to return until X number of PaStreamCallback
have been performed by ProcessOutputBuffer().
The above behaviour will cause a deadlock if the user supplied
PaStreamCallback tries to access a shared lock currently held by the
function calling Pa_StartStream().
Also it's a bit weird that you start receiving PaStreamCallbacks
before Pa_StartStream() is able to complete.
---
src/hostapi/wasapi/pa_win_wasapi.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index d791b66..1914550 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -5890,6 +5890,12 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
goto thread_error;
}
+ // Signal: stream running
+ stream->running = TRUE;
+
+ // Notify: thread started
+ SetEvent(stream->hThreadStart);
+
// Initialize event & start INPUT stream
if (stream->in.clientProc)
{
@@ -5940,12 +5946,6 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
}
- // Signal: stream running
- stream->running = TRUE;
-
- // Notify: thread started
- SetEvent(stream->hThreadStart);
-
// Notify: state
NotifyStateChanged(stream, paWasapiStreamStateThreadStart, ERROR_SUCCESS);
@@ -6171,6 +6171,12 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
// Boost thread priority
PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);
+ // Signal: stream running
+ stream->running = TRUE;
+
+ // Notify: thread started
+ SetEvent(stream->hThreadStart);
+
// Initialize event & start INPUT stream
if (stream->in.clientProc)
{
@@ -6238,12 +6244,6 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
}
}
- // Signal: stream running
- stream->running = TRUE;
-
- // Notify: thread started
- SetEvent(stream->hThreadStart);
-
// Notify: state
NotifyStateChanged(stream, paWasapiStreamStateThreadStart, ERROR_SUCCESS);
From 159b415af0325ec385cae167727964c45285702b Mon Sep 17 00:00:00 2001
From: John Melas
Date: Fri, 18 Dec 2020 16:53:35 +0200
Subject: [PATCH 061/157] fix signed/unsigned mismatch warning
---
src/hostapi/wasapi/pa_win_wasapi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index d791b66..7eec93e 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -841,8 +841,8 @@ static BOOL SystemTimer_SetGranularity(SystemTimer *timer, UINT32 granularity)
if (timeGetDevCaps(&caps, sizeof(caps)) == MMSYSERR_NOERROR)
{
- if (timer->granularity < caps.wPeriodMin)
- timer->granularity = caps.wPeriodMin;
+ if (timer->granularity < (INT32)caps.wPeriodMin)
+ timer->granularity = (INT32)caps.wPeriodMin;
}
if (timeBeginPeriod(timer->granularity) != TIMERR_NOERROR)
From 5b75613f065dd948365d8263ffd75764c8752f95 Mon Sep 17 00:00:00 2001
From: Etienne Dechamps
Date: Fri, 1 Jan 2021 15:35:13 +0000
Subject: [PATCH 062/157] Add missing PaWasapi_GetDeviceMixFormat cmake DLL
export
This omission made it impossible to use PaWasapi_GetDeviceMixFormat()
from a PortAudio DLL built using CMake.
---
cmake_support/template_portaudio.def | 1 +
1 file changed, 1 insertion(+)
diff --git a/cmake_support/template_portaudio.def b/cmake_support/template_portaudio.def
index d05da59..8044d43 100644
--- a/cmake_support/template_portaudio.def
+++ b/cmake_support/template_portaudio.def
@@ -51,3 +51,4 @@ PaUtil_SetDebugPrintFunction @55
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetFramesPerHostBuffer @60
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackDescription @61
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackCount @62
+@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceMixFormat @63
From 3532e567847b69131cf66fd8b7165e9064969fd9 Mon Sep 17 00:00:00 2001
From: Blue Cat Audio
Date: Thu, 7 Jan 2021 12:24:41 +0100
Subject: [PATCH 063/157] Fix: WASAPI should not fail with error if no device
found
---
src/hostapi/wasapi/pa_win_wasapi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/hostapi/wasapi/pa_win_wasapi.c b/src/hostapi/wasapi/pa_win_wasapi.c
index 39a09db..9273cb6 100644
--- a/src/hostapi/wasapi/pa_win_wasapi.c
+++ b/src/hostapi/wasapi/pa_win_wasapi.c
@@ -2110,7 +2110,7 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
{
PaUtilHostApiRepresentation *hostApi = (PaUtilHostApiRepresentation *)paWasapi;
PaError result = paNoError;
- PaDeviceInfo *deviceInfoArray;
+ PaDeviceInfo *deviceInfoArray = NULL;
UINT32 i;
WCHAR *defaultRenderId = NULL;
WCHAR *defaultCaptureId = NULL;
@@ -2228,7 +2228,7 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
#endif
// Allocate memory for the device list
- if ((deviceInfoArray = AllocateDeviceListMemory(paWasapi)) == NULL)
+ if ((paWasapi->deviceCount != 0) && ((deviceInfoArray = AllocateDeviceListMemory(paWasapi)) == NULL))
{
result = paInsufficientMemory;
goto error;
@@ -2262,7 +2262,7 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
// Fill the remaining slots with inactive device info
#if defined(PA_WASAPI_MAX_CONST_DEVICE_COUNT) && (PA_WASAPI_MAX_CONST_DEVICE_COUNT > 0)
- if (hostApi->info.deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT)
+ if ((hostApi->info.deviceCount != 0) && (hostApi->info.deviceCount < PA_WASAPI_MAX_CONST_DEVICE_COUNT))
{
for (i = hostApi->info.deviceCount; i < PA_WASAPI_MAX_CONST_DEVICE_COUNT; ++i)
{
From 0377f169b7b365318c0edfcac16430e05eb3d7df Mon Sep 17 00:00:00 2001
From: Be
Date: Wed, 13 Jan 2021 06:12:54 -0600
Subject: [PATCH 064/157] remove index.html
This file does not belong in a code repository.
---
index.html | 105 -----------------------------------------------------
1 file changed, 105 deletions(-)
delete mode 100644 index.html
diff --git a/index.html b/index.html
deleted file mode 100644
index 55f9ed6..0000000
--- a/index.html
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
-
-
-
-
-
- PortAudio Implementations for DirectSound
-
-
-
-
-
-
-
-
-PortAudio - Portable Audio Library
- |
-
-
-
-PortAudio is a cross platform, open-source, audio
-I/O library proposed by Ross Bencina to the music-dsp
-mailing list. It lets you write simple audio programs in 'C' that will
-compile and run on Windows, Macintosh, Unix, BeOS. PortAudio is
-intended to promote the exchange of audio synthesis software between developers
-on different platforms.
-
For complete information on PortAudio and to download the latest releases,
-please visit "http://www.portaudio.com".
-
-
-
-
-
-
-
-
-
-Contacts and E-Mail List
-
-
--
-If you are using or implementing PortAudio then please join the PortAudio
-mail list .
-
--
-If you find bugs in one of these implementations, or have suggestions,
-please e-mail them to Phil Burk.
-
--
-If you make improvements to the library, please send them to us so we can
-incorporate the improvements.
-
-
-
-License
-
-
-|
-
-PortAudio Portable Real-Time Audio Library
- Copyright © 1999-2006 Ross Bencina and Phil Burk
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following conditions:
-
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND ON INFRINGEMENT.
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
-OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
-THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-
-The text above constitutes the entire PortAudio license; however,
-the PortAudio community also makes the following non-binding requests:
-
-
-Any person wishing to distribute modifications to the Software is
-requested to send the modifications to the original developer so that
-they can be incorporated into the canonical version. It is also
-requested that these non-binding requests be included along with the
-license above.
-
-
- |
-
-
-
-
-
-
From 91debabf3f0697c1ebda2dd1afc051d9acc6ab79 Mon Sep 17 00:00:00 2001
From: Be
Date: Wed, 13 Jan 2021 05:16:58 -0600
Subject: [PATCH 065/157] remove unused and undocumented fixdir.bat &
fixfile.bat
---
fixdir.bat | 19 -------------------
fixfile.bat | 7 -------
2 files changed, 26 deletions(-)
delete mode 100755 fixdir.bat
delete mode 100755 fixfile.bat
diff --git a/fixdir.bat b/fixdir.bat
deleted file mode 100755
index 92d6c74..0000000
--- a/fixdir.bat
+++ /dev/null
@@ -1,19 +0,0 @@
-rem Use Astyle to fix style in 'C' files
-cd %1%
-
-fixlines -p *.c
-fixlines -p *.cpp
-fixlines -p *.cc
-
-astyle --style=ansi -c -o --convert-tabs --indent-preprocessor *.c
-astyle --style=ansi -c -o --convert-tabs --indent-preprocessor *.cpp
-astyle --style=ansi -c -o --convert-tabs --indent-preprocessor *.cc
-del *.orig
-@rem convert line terminators to Unix style LFs
-fixlines -u *.c
-fixlines -u *.cpp
-fixlines -u *.cc
-fixlines -u *.h
-del *.bak
-
-cd ..\
diff --git a/fixfile.bat b/fixfile.bat
deleted file mode 100755
index 48f6fbc..0000000
--- a/fixfile.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-rem Use Astyle to fix style in a file
-fixlines -p %1%
-astyle --style=ansi -c -o --convert-tabs --indent-preprocessor %1%
-del %1%.orig
-@rem convert line terminators to Unix style LFs
-fixlines -u %1%
-del %1%.bak
From f13ab77c46eeafa4c1b206912fd215467cf255c4 Mon Sep 17 00:00:00 2001
From: Ed Maste
Date: Tue, 19 Jan 2021 16:09:01 -0500
Subject: [PATCH 066/157] OSS: include both /dev/dsp and /dev/dsp0
On FreeBSD /dev/dsp is the default device but may not be /dev/dsp0.
PortAudio in the FreeBSD ports collection initially had a patch to
replace the default device with /dev/dsp (for example, with three
devices and /dev/dsp1 as the default we'd have /dev/dsp0, /dev/dsp,
/dev/dsp2). This caused some trouble (the first device is no longer
default) and was later replaced with this change, leaving /dev/dsp
as the first entry, and just adding each /dev/dsp%d that exists.
FreeBSD bugs 208968 and 236118.
---
src/hostapi/oss/pa_unix_oss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/hostapi/oss/pa_unix_oss.c b/src/hostapi/oss/pa_unix_oss.c
index 9e18d6d..4ca3788 100644
--- a/src/hostapi/oss/pa_unix_oss.c
+++ b/src/hostapi/oss/pa_unix_oss.c
@@ -535,13 +535,13 @@ static PaError BuildDeviceList( PaOSSHostApiRepresentation *ossApi )
* add it to a linked list.
* A: Set an arbitrary of 100 devices, should probably be a smarter way. */
- for( i = 0; i < 100; i++ )
+ for( i = -1; i < 100; i++ )
{
char deviceName[32];
PaDeviceInfo *deviceInfo;
int testResult;
- if( i == 0 )
+ if( i == -1 )
snprintf(deviceName, sizeof (deviceName), "%s", DEVICE_NAME_BASE);
else
snprintf(deviceName, sizeof (deviceName), "%s%d", DEVICE_NAME_BASE, i);
From fc2a24d3945ccf1a3905750b2ab59ce22f21cb1f Mon Sep 17 00:00:00 2001
From: Ed Maste
Date: Tue, 19 Jan 2021 15:00:09 -0500
Subject: [PATCH 067/157] OSS: correct test for unsupported formats
Previously GetAvailableFormats returned paSampleFormatNotSupported if
AFMT_S16_NE was not supported, regardless of the supported state of any
other formats. Instead, return paSampleFormatNotSupported if no
supported formats are found.
---
src/hostapi/oss/pa_unix_oss.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hostapi/oss/pa_unix_oss.c b/src/hostapi/oss/pa_unix_oss.c
index 4ca3788..83ab558 100644
--- a/src/hostapi/oss/pa_unix_oss.c
+++ b/src/hostapi/oss/pa_unix_oss.c
@@ -961,7 +961,7 @@ static PaError GetAvailableFormats( PaOssStreamComponent *component, PaSampleFor
frmts |= paInt8;
if( mask & AFMT_S16_NE )
frmts |= paInt16;
- else
+ if( frmts == 0 )
result = paSampleFormatNotSupported;
*availableFormats = frmts;
From afc6591519f6c0a21e9d3f55c76b5f2e491bb8e9 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Thu, 26 Nov 2020 13:23:36 +0200
Subject: [PATCH 068/157] fix logging warnings
---
src/hostapi/coreaudio/pa_mac_core.c | 16 ++++++++--------
src/hostapi/coreaudio/pa_mac_core_utilities.c | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index 1766734..4f66f8c 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -373,7 +373,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
{
int i;
for( i=0; idevCount; ++i )
- printf( "Device %d\t: %ld\n", i, auhalHostApi->devIds[i] );
+ printf( "Device %d\t: %ld\n", i, (long)auhalHostApi->devIds[i] );
}
#endif
@@ -420,8 +420,8 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
}
}
- VDBUG( ( "Default in : %ld\n", auhalHostApi->defaultIn ) );
- VDBUG( ( "Default out: %ld\n", auhalHostApi->defaultOut ) );
+ VDBUG( ( "Default in : %ld\n", (long)auhalHostApi->defaultIn ) );
+ VDBUG( ( "Default out: %ld\n", (long)auhalHostApi->defaultOut ) );
return paNoError;
}
@@ -1606,15 +1606,15 @@ static PaError OpenAndSetupOneAudioUnit(
if( inStreamParams && outStreamParams )
{
- VDBUG( ("Opened device %ld for input and output.\n", *audioDevice ) );
+ VDBUG( ("Opened device %ld for input and output.\n", (long)*audioDevice ) );
}
else if( inStreamParams )
{
- VDBUG( ("Opened device %ld for input.\n", *audioDevice ) );
+ VDBUG( ("Opened device %ld for input.\n", (long)*audioDevice ) );
}
else if( outStreamParams )
{
- VDBUG( ("Opened device %ld for output.\n", *audioDevice ) );
+ VDBUG( ("Opened device %ld for output.\n", (long)*audioDevice ) );
}
return paNoError;
#undef ERR_WRAP
@@ -1676,7 +1676,7 @@ static UInt32 CalculateOptimalBufferSize( PaMacAUHAL *auhalHostApi,
}else{
VDBUG( ("Block Size unspecified. Based on Latency, the user wants a Block Size near: %ld.\n",
- resultBufferSizeFrames ) );
+ (long)resultBufferSizeFrames ) );
}
// Clip to the capabilities of the device.
@@ -1691,7 +1691,7 @@ static UInt32 CalculateOptimalBufferSize( PaMacAUHAL *auhalHostApi,
ClipToDeviceBufferSize( auhalHostApi->devIds[outputParameters->device],
false, resultBufferSizeFrames, &resultBufferSizeFrames );
}
- VDBUG(("After querying hardware, setting block size to %ld.\n", resultBufferSizeFrames));
+ VDBUG(("After querying hardware, setting block size to %ld.\n", (long)resultBufferSizeFrames));
return resultBufferSizeFrames;
}
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.c b/src/hostapi/coreaudio/pa_mac_core_utilities.c
index c6d8605..73c7f8c 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.c
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.c
@@ -428,7 +428,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
int i=0;
Float64 max = -1; /*the maximum rate available*/
Float64 best = -1; /*the lowest sample rate still greater than desired rate*/
- VDBUG(("Setting sample rate for device %ld to %g.\n",device,(float)desiredSrate));
+ VDBUG(("Setting sample rate for device %ld to %g.\n",(long)device,(float)desiredSrate));
/* -- try setting the sample rate -- */
srate = 0;
From 98ea697d33ad8d21d2fd7a720a565d73c9855635 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Thu, 26 Nov 2020 14:28:17 +0200
Subject: [PATCH 069/157] new hal
---
src/hostapi/coreaudio/pa_mac_core.c | 241 +++++++++++++-----
src/hostapi/coreaudio/pa_mac_core_utilities.c | 212 +++++++++++++--
src/hostapi/coreaudio/pa_mac_core_utilities.h | 75 +++++-
3 files changed, 448 insertions(+), 80 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index 4f66f8c..155c6ba 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -138,7 +138,7 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
/* First try with CFString */
UInt32 size = sizeof(nameRef);
- error = AudioDeviceGetProperty( hostApiDevice,
+ error = pa_AudioDeviceGetProperty( hostApiDevice,
channelIndex + 1,
input,
kAudioDevicePropertyChannelNameCFString,
@@ -148,18 +148,17 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
{
/* try the C String */
size = 0;
- error = AudioDeviceGetPropertyInfo( hostApiDevice,
+ error = pa_AudioDeviceGetPropertySize( hostApiDevice,
channelIndex + 1,
input,
kAudioDevicePropertyChannelName,
- &size,
- NULL);
+ &size);
if( !error )
{
if( !ensureChannelNameSize( size ) )
return NULL;
-
- error = AudioDeviceGetProperty( hostApiDevice,
+
+ error = pa_AudioDeviceGetProperty( hostApiDevice,
channelIndex + 1,
input,
kAudioDevicePropertyChannelName,
@@ -223,8 +222,8 @@ PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
Boolean isInput = 0;
if( macCoreHostApi->inheritedHostApiRep.deviceInfos[hostApiDeviceIndex]->maxOutputChannels == 0 )
isInput = 1;
-
- result = WARNING(AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
+
+ result = WARNING(pa_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
*minBufferSizeFrames = audioRange.mMinimum;
*maxBufferSizeFrames = audioRange.mMaximum;
@@ -353,9 +352,8 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
auhalHostApi->devIds = NULL;
/* -- figure out how many devices there are -- */
- AudioHardwareGetPropertyInfo( kAudioHardwarePropertyDevices,
- &propsize,
- NULL );
+ pa_AudioHardwareGetPropertySize( kAudioHardwarePropertyDevices,
+ &propsize);
auhalHostApi->devCount = propsize / sizeof( AudioDeviceID );
VDBUG( ( "Found %ld device(s).\n", auhalHostApi->devCount ) );
@@ -366,7 +364,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
propsize );
if( !auhalHostApi->devIds )
return paInsufficientMemory;
- AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
+ pa_AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
&propsize,
auhalHostApi->devIds );
#ifdef MAC_CORE_VERBOSE_DEBUG
@@ -385,7 +383,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
/* I am not sure how these calls to AudioHardwareGetProperty()
could fail, but in case they do, we use the first available
device as the default. */
- if( 0 != AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
+ if( 0 != pa_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
&size,
&auhalHostApi->defaultIn) ) {
int i;
@@ -401,8 +399,8 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
break;
}
}
- }
- if( 0 != AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
+ }
+ if( 0 != pa_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
&size,
&auhalHostApi->defaultOut) ) {
int i;
@@ -437,7 +435,7 @@ static PaError ClipToDeviceBufferSize( AudioDeviceID macCoreDeviceId,
UInt32 resultSize = desiredSize;
AudioValueRange audioRange;
UInt32 propSize = sizeof( audioRange );
- PaError err = WARNING(AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
+ PaError err = WARNING(pa_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
resultSize = MAX( resultSize, audioRange.mMinimum );
resultSize = MIN( resultSize, audioRange.mMaximum );
*allowedSize = resultSize;
@@ -487,7 +485,7 @@ static void DumpDeviceProperties( AudioDeviceID macCoreDeviceId,
printf("Stream #%d = %d---------------------- \n", i, streamIDs[i] );
propSize = sizeof(UInt32);
- err = WARNING(AudioStreamGetProperty(streamIDs[i], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
+ err = WARNING(p_AudioStreamGetProperty(streamIDs[i], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
printf(" kAudioStreamPropertyLatency: err = %d, propSize = %d, value = %d\n", err, propSize, streamLatency );
}
}
@@ -517,20 +515,20 @@ static PaError CalculateFixedDeviceLatency( AudioDeviceID macCoreDeviceId, int i
// To get stream latency we have to get a streamID from the device.
// We are only going to look at the first stream so only fetch one stream.
propSize = sizeof(streamIDs);
- err = WARNING(AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreams, &propSize, &streamIDs[0]));
+ err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreams, &propSize, &streamIDs[0]));
if( err != paNoError ) goto error;
if( propSize == sizeof(AudioStreamID) )
{
propSize = sizeof(UInt32);
- err = WARNING(AudioStreamGetProperty(streamIDs[0], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
+ err = WARNING(pa_AudioStreamGetProperty(streamIDs[0], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
}
propSize = sizeof(UInt32);
- err = WARNING(AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertySafetyOffset, &propSize, &safetyOffset));
+ err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertySafetyOffset, &propSize, &safetyOffset));
if( err != paNoError ) goto error;
propSize = sizeof(UInt32);
- err = WARNING(AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyLatency, &propSize, &deviceLatency));
+ err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyLatency, &propSize, &deviceLatency));
if( err != paNoError ) goto error;
*fixedLatencyPtr = deviceLatency + streamLatency + safetyOffset;
@@ -560,7 +558,7 @@ static PaError CalculateDefaultDeviceLatencies( AudioDeviceID macCoreDeviceId,
// For high latency use the default device buffer size.
propSize = sizeof(UInt32);
- err = WARNING(AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSize, &propSize, &bufferFrames));
+ err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSize, &propSize, &bufferFrames));
if( err != paNoError ) goto error;
*lowLatencyFramesPtr = fixedLatency + clippedMinBufferSize;
@@ -589,14 +587,14 @@ static PaError GetChannelInfo( PaMacAUHAL *auhalHostApi,
/* Get the number of channels from the stream configuration.
Fail if we can't get this. */
- err = ERR(AudioDeviceGetPropertyInfo(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize, NULL));
+ err = ERR(pa_AudioDeviceGetPropertySize(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize));
if (err)
return err;
buflist = PaUtil_AllocateMemory(propSize);
if( !buflist )
return paInsufficientMemory;
- err = ERR(AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize, buflist));
+ err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize, buflist));
if (err)
goto error;
@@ -664,18 +662,18 @@ static PaError InitializeDeviceInfo( PaMacAUHAL *auhalHostApi,
/* Get the device name using CFString */
propSize = sizeof(nameRef);
- err = ERR(AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceNameCFString, &propSize, &nameRef));
+ err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceNameCFString, &propSize, &nameRef));
if (err)
{
/* Get the device name using c string. Fail if we can't get it. */
- err = ERR(AudioDeviceGetPropertyInfo(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize, NULL));
+ err = ERR(pa_AudioDeviceGetPropertySize(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize));
if (err)
return err;
name = PaUtil_GroupAllocateMemory(auhalHostApi->allocations,propSize+1);
if ( !name )
return paInsufficientMemory;
- err = ERR(AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize, name));
+ err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize, name));
if (err)
return err;
}
@@ -696,7 +694,7 @@ static PaError InitializeDeviceInfo( PaMacAUHAL *auhalHostApi,
/* Try to get the default sample rate. Don't fail if we can't get this. */
propSize = sizeof(Float64);
- err = ERR(AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyNominalSampleRate, &propSize, &sampleRate));
+ err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyNominalSampleRate, &propSize, &sampleRate));
if (err)
deviceInfo->defaultSampleRate = 0.0;
else
@@ -1045,7 +1043,7 @@ static OSStatus UpdateSampleRateFromDeviceProperty( PaMacCoreStream *stream, Aud
Float64 sampleRate = 0.0;
UInt32 propSize = sizeof(Float64);
- OSStatus osErr = AudioDeviceGetProperty( deviceID, 0, isInput, sampleRatePropertyID, &propSize, &sampleRate);
+ OSStatus osErr = pa_AudioDeviceGetProperty( deviceID, 0, isInput, sampleRatePropertyID, &propSize, &sampleRate);
if( (osErr == noErr) && (sampleRate > 1000.0) ) /* avoid divide by zero if there's an error */
{
deviceProperties->sampleRate = sampleRate;
@@ -1054,6 +1052,23 @@ static OSStatus UpdateSampleRateFromDeviceProperty( PaMacCoreStream *stream, Aud
return osErr;
}
+#if PA_NEW_HAL
+static OSStatus AudioDevicePropertyActualSampleRateListenerProc(AudioObjectID inDevice, UInt32 inNumberAddresses, const AudioObjectPropertyAddress * inAddresses, void * inClientData)
+{
+ PaMacCoreStream * stream = (PaMacCoreStream *) inClientData;
+ bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput;
+
+ // Make sure the callback is operating on a stream that is still valid!
+ assert(stream->streamRepresentation.magic == PA_STREAM_MAGIC);
+
+ OSStatus osErr = UpdateSampleRateFromDeviceProperty(stream, inDevice, isInput, kAudioDevicePropertyActualSampleRate);
+ if (osErr == noErr)
+ {
+ UpdateTimeStampOffsets(stream);
+ }
+ return osErr;
+}
+#else
static OSStatus AudioDevicePropertyActualSampleRateListenerProc( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput, AudioDevicePropertyID inPropertyID, void *inClientData )
{
PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
@@ -1068,13 +1083,13 @@ static OSStatus AudioDevicePropertyActualSampleRateListenerProc( AudioDeviceID i
}
return osErr;
}
-
+#endif
/* ================================================================================= */
static OSStatus QueryUInt32DeviceProperty( AudioDeviceID deviceID, Boolean isInput, AudioDevicePropertyID propertyID, UInt32 *outValue )
{
UInt32 propertyValue = 0;
UInt32 propertySize = sizeof(UInt32);
- OSStatus osErr = AudioDeviceGetProperty( deviceID, 0, isInput, propertyID, &propertySize, &propertyValue);
+ OSStatus osErr = pa_AudioDeviceGetProperty( deviceID, 0, isInput, propertyID, &propertySize, &propertyValue);
if( osErr == noErr )
{
*outValue = propertyValue;
@@ -1082,6 +1097,44 @@ static OSStatus QueryUInt32DeviceProperty( AudioDeviceID deviceID, Boolean isInp
return osErr;
}
+#if PA_NEW_HAL
+static OSStatus AudioDevicePropertyGenericListenerProc(AudioObjectID inDevice, UInt32 inNumberAddresses, const AudioObjectPropertyAddress * inAddresses, void * inClientData)
+{
+ OSStatus osErr = noErr;
+ PaMacCoreStream * stream = (PaMacCoreStream *) inClientData;
+ bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput;
+ AudioDevicePropertyID inPropertyID = inAddresses->mSelector;
+
+ // Make sure the callback is operating on a stream that is still valid!
+ assert(stream->streamRepresentation.magic == PA_STREAM_MAGIC);
+
+ PaMacCoreDeviceProperties * deviceProperties = isInput ? &stream->inputProperties : &stream->outputProperties;
+ UInt32 * valuePtr = NULL;
+ switch (inPropertyID)
+ {
+ case kAudioDevicePropertySafetyOffset:
+ valuePtr = &deviceProperties->safetyOffset;
+ break;
+
+ case kAudioDevicePropertyLatency:
+ valuePtr = &deviceProperties->deviceLatency;
+ break;
+
+ case kAudioDevicePropertyBufferFrameSize:
+ valuePtr = &deviceProperties->bufferFrameSize;
+ break;
+ }
+ if (valuePtr != NULL)
+ {
+ osErr = QueryUInt32DeviceProperty(inDevice, isInput, inPropertyID, valuePtr);
+ if (osErr == noErr)
+ {
+ UpdateTimeStampOffsets(stream);
+ }
+ }
+ return osErr;
+}
+#else
static OSStatus AudioDevicePropertyGenericListenerProc( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput, AudioDevicePropertyID inPropertyID, void *inClientData )
{
OSStatus osErr = noErr;
@@ -1116,6 +1169,7 @@ static OSStatus AudioDevicePropertyGenericListenerProc( AudioDeviceID inDevice,
}
return osErr;
}
+#endif
/* ================================================================================= */
/*
@@ -1131,31 +1185,31 @@ static OSStatus SetupDevicePropertyListeners( PaMacCoreStream *stream, AudioDevi
kAudioDevicePropertyBufferFrameSize, &deviceProperties->bufferFrameSize )) != noErr ) return osErr;
if( (osErr = QueryUInt32DeviceProperty( deviceID, isInput,
kAudioDevicePropertySafetyOffset, &deviceProperties->safetyOffset )) != noErr ) return osErr;
-
- AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
+
+ pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
AudioDevicePropertyActualSampleRateListenerProc, stream );
-
- AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioStreamPropertyLatency,
- AudioDevicePropertyGenericListenerProc, stream );
- AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
- AudioDevicePropertyGenericListenerProc, stream );
- AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
- AudioDevicePropertyGenericListenerProc, stream );
-
+
+ pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioStreamPropertyLatency,
+ AudioDevicePropertyGenericListenerProc, stream );
+ pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
+ AudioDevicePropertyGenericListenerProc, stream );
+ pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
+ AudioDevicePropertyGenericListenerProc, stream );
+
return osErr;
}
static void CleanupDevicePropertyListeners( PaMacCoreStream *stream, AudioDeviceID deviceID, Boolean isInput )
-{
- AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
- AudioDevicePropertyActualSampleRateListenerProc );
-
- AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyLatency,
- AudioDevicePropertyGenericListenerProc );
- AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
- AudioDevicePropertyGenericListenerProc );
- AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
- AudioDevicePropertyGenericListenerProc );
+{
+ pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
+ AudioDevicePropertyActualSampleRateListenerProc, stream );
+
+ pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyLatency,
+ AudioDevicePropertyGenericListenerProc, stream );
+ pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
+ AudioDevicePropertyGenericListenerProc, stream );
+ pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
+ AudioDevicePropertyGenericListenerProc, stream );
}
/* ================================================================================= */
@@ -1329,7 +1383,7 @@ static PaError OpenAndSetupOneAudioUnit(
sizeof(AudioDeviceID) ) );
}
/* -- add listener for dropouts -- */
- result = AudioDeviceAddPropertyListener( *audioDevice,
+ result = pa_AudioDeviceAddPropertyListener( *audioDevice,
0,
outStreamParams ? false : true,
kAudioDeviceProcessorOverload,
@@ -2128,9 +2182,43 @@ PaTime GetStreamTime( PaStream *s )
#define RING_BUFFER_EMPTY (1000)
-static OSStatus ringBufferIOProc( AudioConverterRef inAudioConverter,
- UInt32*ioDataSize,
- void** outData,
+#if PA_NEW_HAL
+static OSStatus ringBufferIOProc(
+ AudioConverterRef inAudioConverter,
+ UInt32* ioNumberDataPackets,
+ AudioBufferList* ioData,
+ AudioStreamPacketDescription** outDataPacketDescription,
+ void* inUserData)
+{
+ UInt32 * ioDataSize = &ioData->mBuffers[0].mDataByteSize;
+ void ** outData = &ioData->mBuffers[0].mData;
+
+ void *dummyData;
+ ring_buffer_size_t dummySize;
+ PaUtilRingBuffer *rb = (PaUtilRingBuffer *) inUserData;
+
+ VVDBUG(("ringBufferIOProc()\n"));
+
+ if( PaUtil_GetRingBufferReadAvailable( rb ) == 0 ) {
+ *outData = NULL;
+ *ioDataSize = 0;
+ return RING_BUFFER_EMPTY;
+ }
+ assert(sizeof(UInt32) == sizeof(ring_buffer_size_t));
+ assert( ( (*ioDataSize) / rb->elementSizeBytes ) * rb->elementSizeBytes == (*ioDataSize) ) ;
+ (*ioDataSize) /= rb->elementSizeBytes ;
+ PaUtil_GetRingBufferReadRegions( rb, *ioDataSize,
+ outData, (ring_buffer_size_t *)ioDataSize,
+ &dummyData, &dummySize );
+ assert( *ioDataSize );
+ PaUtil_AdvanceRingBufferReadIndex( rb, *ioDataSize );
+ (*ioDataSize) *= rb->elementSizeBytes ;
+ return noErr;
+}
+#else
+static OSStatus ringBufferIOProc( AudioConverterRef inAudioConverter,
+ UInt32*ioDataSize,
+ void** outData,
void*inUserData )
{
void *dummyData;
@@ -2156,6 +2244,7 @@ static OSStatus ringBufferIOProc( AudioConverterRef inAudioConverter,
return noErr;
}
+#endif
/*
* Called by the AudioUnit API to process audio from the sound card.
@@ -2377,12 +2466,27 @@ static OSStatus AudioIOProc( void *inRefCon,
UInt32 size;
float data[ inChan * frames ];
size = sizeof( data );
- err = AudioConverterFillBuffer(
+#if PA_NEW_HAL
+ AudioBufferList bufferList;
+ bufferList.mNumberBuffers = 1;
+ bufferList.mBuffers[0].mNumberChannels = inChan;
+ bufferList.mBuffers[0].mDataByteSize = size;
+ bufferList.mBuffers[0].mData = data;
+ err = AudioConverterFillComplexBuffer(
+ stream->inputSRConverter,
+ ringBufferIOProc,
+ &stream->inputRingBuffer,
+ &size,
+ &bufferList,
+ NULL);
+#else
+ err = AudioConverterFillBuffer(
stream->inputSRConverter,
ringBufferIOProc,
&stream->inputRingBuffer,
&size,
(void *)&data );
+#endif
if( err == RING_BUFFER_EMPTY )
{ /* the ring buffer callback underflowed */
err = 0;
@@ -2562,12 +2666,27 @@ static OSStatus AudioIOProc( void *inRefCon,
long f;
size = sizeof( data );
- err = AudioConverterFillBuffer(
+#if PA_NEW_HAL
+ AudioBufferList bufferList;
+ bufferList.mNumberBuffers = 1;
+ bufferList.mBuffers[0].mNumberChannels = chan;
+ bufferList.mBuffers[0].mDataByteSize = size;
+ bufferList.mBuffers[0].mData = data;
+ err = AudioConverterFillComplexBuffer(
+ stream->inputSRConverter,
+ ringBufferIOProc,
+ &stream->inputRingBuffer,
+ &size,
+ &bufferList,
+ NULL);
+#else
+ err = AudioConverterFillBuffer(
stream->inputSRConverter,
ringBufferIOProc,
&stream->inputRingBuffer,
&size,
(void *)data );
+#endif
if( err != RING_BUFFER_EMPTY )
ERR( err );
if( err != noErr && err != RING_BUFFER_EMPTY )
@@ -2646,20 +2765,20 @@ static PaError CloseStream( PaStream* s )
if( stream->outputUnit ) {
int count = removeFromXRunListenerList( stream );
if( count == 0 )
- AudioDeviceRemovePropertyListener( stream->outputDevice,
+ pa_AudioDeviceRemovePropertyListener( stream->outputDevice,
0,
false,
kAudioDeviceProcessorOverload,
- xrunCallback );
+ xrunCallback, NULL ); //todo: do we need to pass actual node?
}
if( stream->inputUnit && stream->outputUnit != stream->inputUnit ) {
int count = removeFromXRunListenerList( stream );
if( count == 0 )
- AudioDeviceRemovePropertyListener( stream->inputDevice,
+ pa_AudioDeviceRemovePropertyListener( stream->inputDevice,
0,
true,
kAudioDeviceProcessorOverload,
- xrunCallback );
+ xrunCallback, NULL ); //todo: do we need to pass actual node?
}
if( stream->outputUnit && stream->outputUnit != stream->inputUnit ) {
AudioUnitUninitialize( stream->outputUnit );
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.c b/src/hostapi/coreaudio/pa_mac_core_utilities.c
index 73c7f8c..4563a93 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.c
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.c
@@ -63,6 +63,131 @@
#include
#include
+OSStatus pa_AudioHardwareGetProperty(
+ AudioHardwarePropertyID inPropertyID,
+ UInt32* ioPropertyDataSize,
+ void* outPropertyData)
+{
+#if PA_NEW_HAL
+ AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+ return AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
+#else
+ macErr = AudioHardwareGetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
+#endif
+}
+
+OSStatus pa_AudioHardwareGetPropertySize(
+ AudioHardwarePropertyID inPropertyID,
+ UInt32* outSize)
+{
+#if PA_NEW_HAL
+ AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+ return AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &address, 0, NULL, outSize);
+#else
+ macErr = AudioHardwareGetPropertyInfo(inPropertyID, outSize, NULL);
+#endif
+}
+
+OSStatus pa_AudioDeviceGetProperty(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ UInt32* ioPropertyDataSize,
+ void* outPropertyData)
+{
+#if PA_NEW_HAL
+ AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+ AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
+ return AudioObjectGetPropertyData(inDevice, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
+#else
+ macErr = AudioDeviceGetProperty(inDevice, inChannel, isInput, inPropertyID, ioPropertyDataSize, outPropertyData);
+#endif
+}
+
+OSStatus pa_AudioDeviceSetProperty(
+ AudioDeviceID inDevice,
+ const AudioTimeStamp* inWhen,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ UInt32 inPropertyDataSize,
+ const void* inPropertyData)
+{
+#if PA_NEW_HAL
+ AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+ AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
+ return AudioObjectSetPropertyData(inDevice, &address, 0, NULL, inPropertyDataSize, inPropertyData);
+#else
+ return AudioDeviceSetProperty(inDevice, inWhen, inChannel, isInput, inPropertyID, inPropertyDataSize, inPropertyData);
+#endif
+}
+
+OSStatus pa_AudioDeviceGetPropertySize(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ UInt32* outSize)
+{
+#if PA_NEW_HAL
+ AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+ AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
+ return AudioObjectGetPropertyDataSize(inDevice, &address, 0, NULL, outSize);
+#else
+ return AudioDeviceGetPropertyInfo(inDevice, inChannel, isInput, inPropertyID, outSize, NULL);
+#endif
+}
+
+OSStatus pa_AudioDeviceAddPropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ pa_AudioDevicePropertyListenerProc inProc,
+ void* inClientData)
+{
+#if PA_NEW_HAL
+ AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+ AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
+ return AudioObjectAddPropertyListener(inDevice, &address, inProc, inClientData);
+#else
+ return AudioDeviceAddPropertyListener(inDevice, inChannel, isInput, inPropertyID, inProc, inClientData);
+#endif
+}
+
+OSStatus pa_AudioDeviceRemovePropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ pa_AudioDevicePropertyListenerProc inProc,
+ void* inClientData)
+{
+#if PA_NEW_HAL
+ AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+ AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
+ return AudioObjectRemovePropertyListener(inDevice, &address, inProc, inClientData);
+#else
+ return AudioDeviceRemovePropertyListener(inDevice, inChannel, isInput, inPropertyID, inProc);
+#endif
+}
+
+OSStatus pa_AudioStreamGetProperty(
+ AudioStreamID inStream,
+ UInt32 inChannel,
+ AudioDevicePropertyID inPropertyID,
+ UInt32* ioPropertyDataSize,
+ void* outPropertyData)
+{
+#if PA_NEW_HAL
+ AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+ return AudioObjectGetPropertyData(inStream, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
+#else
+ return AudioStreamGetProperty(inStream, inChannel, inPropertyID, ioPropertyDataSize, outPropertyData);
+#endif
+}
+
PaError PaMacCore_SetUnixError( int err, int line )
{
PaError ret;
@@ -149,12 +274,14 @@ PaError PaMacCore_SetError(OSStatus error, int line, int isError)
case kAudioUnitErr_TooManyFramesToProcess:
errorText = "Audio Unit: Too Many Frames";
result = paInternalError; break;
+#if ! PA_NEW_HAL
case kAudioUnitErr_IllegalInstrument:
errorText = "Audio Unit: Illegal Instrument";
result = paInternalError; break;
case kAudioUnitErr_InstrumentTypeNotFound:
errorText = "Audio Unit: Instrument Type Not Found";
result = paInternalError; break;
+#endif
case kAudioUnitErr_InvalidFile:
errorText = "Audio Unit: Invalid File";
result = paInternalError; break;
@@ -307,6 +434,17 @@ long computeRingBufferSize( const PaStreamParameters *inputParameters,
* since it represents a theoretically better implementation.
*/
+#if PA_NEW_HAL
+OSStatus propertyProc(
+ AudioObjectID inObjectID,
+ UInt32 inNumberAddresses,
+ const AudioObjectPropertyAddress* inAddresses,
+ void* inClientData)
+{
+ // this is where we would set the condition variable
+ return noErr;
+}
+#else
OSStatus propertyProc(
AudioDeviceID inDevice,
UInt32 inChannel,
@@ -317,6 +455,7 @@ OSStatus propertyProc(
// this is where we would set the condition variable
return noErr;
}
+#endif
/* sets the value of the given property and waits for the change to
be acknowledged, and returns the final value, which is not guaranteed
@@ -340,8 +479,8 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
UInt32 outPropertyDataSize = inPropertyDataSize;
/* First, see if it already has that value. If so, return. */
- macErr = AudioDeviceGetProperty( inDevice, inChannel,
- isInput, inPropertyID,
+ macErr = pa_AudioDeviceGetProperty( inDevice, inChannel,
+ isInput, inPropertyID,
&outPropertyDataSize, outPropertyData );
if( macErr ) {
memset( outPropertyData, 0, inPropertyDataSize );
@@ -357,7 +496,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
/* If we were using a cond variable, we'd do something useful here,
but for now, this is just to make 10.6 happy. */
- macErr = AudioDeviceAddPropertyListener( inDevice, inChannel, isInput,
+ macErr = pa_AudioDeviceAddPropertyListener( inDevice, inChannel, isInput,
inPropertyID, propertyProc,
NULL );
if( macErr )
@@ -365,7 +504,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
goto failMac;
/* set property */
- macErr = AudioDeviceSetProperty( inDevice, NULL, inChannel,
+ macErr = pa_AudioDeviceSetProperty( inDevice, NULL, inChannel,
isInput, inPropertyID,
inPropertyDataSize, inPropertyData );
if( macErr )
@@ -380,8 +519,8 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
memcpy( &tv2, &tv1, sizeof( struct timeval ) );
while( tv2.tv_sec - tv1.tv_sec < 30 ) {
/* now read the property back out */
- macErr = AudioDeviceGetProperty( inDevice, inChannel,
- isInput, inPropertyID,
+ macErr = pa_AudioDeviceGetProperty( inDevice, inChannel,
+ isInput, inPropertyID,
&outPropertyDataSize, outPropertyData );
if( macErr ) {
memset( outPropertyData, 0, inPropertyDataSize );
@@ -389,7 +528,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
}
/* and compare... */
if( 0==memcmp( outPropertyData, inPropertyData, outPropertyDataSize ) ) {
- AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc );
+ pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL);
return paNoError;
}
/* No match yet, so let's sleep and try again. */
@@ -397,12 +536,12 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
gettimeofday( &tv2, NULL );
}
DBUG( ("Timeout waiting for device setting.\n" ) );
-
- AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc );
+
+ pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
return paNoError;
failMac:
- AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc );
+ pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
return ERR( macErr );
}
@@ -448,15 +587,15 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
return paInvalidSampleRate;
/* -- generate a list of available sample rates -- */
- err = AudioDeviceGetPropertyInfo( device, 0, isInput,
+ err = pa_AudioDeviceGetPropertySize( device, 0, isInput,
kAudioDevicePropertyAvailableNominalSampleRates,
- &propsize, NULL );
+ &propsize );
if( err )
return ERR( err );
ranges = (AudioValueRange *)calloc( 1, propsize );
if( !ranges )
return paInsufficientMemory;
- err = AudioDeviceGetProperty( device, 0, isInput,
+ err = pa_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyAvailableNominalSampleRates,
&propsize, ranges );
if( err )
@@ -536,10 +675,10 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
}
/* -- try and set exact FPB -- */
- err = AudioDeviceSetProperty( device, NULL, 0, isInput,
+ err = pa_AudioDeviceSetProperty( device, NULL, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
propsize, &requestedFramesPerBuffer);
- err = AudioDeviceGetProperty( device, 0, isInput,
+ err = pa_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
&propsize, actualFramesPerBuffer);
if( err )
@@ -554,7 +693,7 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
// Clip requested value against legal range for the device.
propsize = sizeof(AudioValueRange);
- err = AudioDeviceGetProperty( device, 0, isInput,
+ err = pa_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSizeRange,
&propsize, &range );
if( err )
@@ -572,11 +711,11 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
/* --- set the buffer size (ignore errors) -- */
propsize = sizeof( UInt32 );
- err = AudioDeviceSetProperty( device, NULL, 0, isInput,
+ err = pa_AudioDeviceSetProperty( device, NULL, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
propsize, &requestedFramesPerBuffer );
/* --- read the property to check that it was set -- */
- err = AudioDeviceGetProperty( device, 0, isInput,
+ err = pa_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
&propsize, actualFramesPerBuffer );
@@ -605,6 +744,42 @@ static PaMacXRunListNode firstXRunListNode;
static int xRunListSize;
static pthread_mutex_t xrunMutex;
+#if PA_NEW_HAL
+OSStatus xrunCallback(
+ AudioObjectID inDevice,
+ UInt32 inNumberAddresses,
+ const AudioObjectPropertyAddress* inAddresses,
+ void * inClientData)
+{
+ PaMacXRunListNode *node = (PaMacXRunListNode *) inClientData;
+ bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput;
+
+ int ret = pthread_mutex_trylock( &xrunMutex ) ;
+
+ if( ret == 0 ) {
+ node = node->next ; //skip the first node
+
+ for( ; node; node=node->next ) {
+ PaMacCoreStream *stream = node->stream;
+
+ if( stream->state != ACTIVE )
+ continue; //if the stream isn't active, we don't care if the device is dropping
+
+ if( isInput ) {
+ if( stream->inputDevice == inDevice )
+ OSAtomicOr32( paInputOverflow, &stream->xrunFlags );
+ } else {
+ if( stream->outputDevice == inDevice )
+ OSAtomicOr32( paOutputUnderflow, &stream->xrunFlags );
+ }
+ }
+
+ pthread_mutex_unlock( &xrunMutex );
+ }
+
+ return 0;
+}
+#else
OSStatus xrunCallback(
AudioDeviceID inDevice,
UInt32 inChannel,
@@ -640,6 +815,7 @@ OSStatus xrunCallback(
return 0;
}
+#endif
int initializeXRunListenerList( void )
{
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.h b/src/hostapi/coreaudio/pa_mac_core_utilities.h
index e63b3cb..e6e0c6e 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.h
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.h
@@ -111,9 +111,66 @@
# define VVDBUG(MSG)
#endif
+#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
+#define PA_NEW_HAL 1
+#else
+#define PA_NEW_HAL 0
+#endif
+#if PA_NEW_HAL
+typedef AudioObjectPropertyListenerProc pa_AudioDevicePropertyListenerProc;
+#else
+typedef AudioDevicePropertyListenerProc pa_AudioDevicePropertyListenerProc;
+#endif
-
+OSStatus pa_AudioHardwareGetProperty(
+ AudioHardwarePropertyID inPropertyID,
+ UInt32* ioPropertyDataSize,
+ void* outPropertyData);
+OSStatus pa_AudioHardwareGetPropertySize(
+ AudioHardwarePropertyID inPropertyID,
+ UInt32* outSize);
+OSStatus pa_AudioDeviceGetProperty(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ UInt32* ioPropertyDataSize,
+ void* outPropertyData);
+OSStatus pa_AudioDeviceSetProperty(
+ AudioDeviceID inDevice,
+ const AudioTimeStamp* inWhen,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ UInt32 inPropertyDataSize,
+ const void* inPropertyData);
+OSStatus pa_AudioDeviceGetPropertySize(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ UInt32* outSize);
+OSStatus pa_AudioDeviceAddPropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ pa_AudioDevicePropertyListenerProc inProc,
+ void* inClientData);
+OSStatus pa_AudioDeviceRemovePropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ pa_AudioDevicePropertyListenerProc inProc,
+ void* inClientData);
+OSStatus pa_AudioStreamGetProperty(
+ AudioStreamID inStream,
+ UInt32 inChannel,
+ AudioDevicePropertyID inPropertyID,
+ UInt32* ioPropertyDataSize,
+ void* outPropertyData);
#define UNIX_ERR(err) PaMacCore_SetUnixError( err, __LINE__ )
@@ -143,12 +200,20 @@ long computeRingBufferSize( const PaStreamParameters *inputParameters,
long outputFramesPerBuffer,
double sampleRate );
+#if PA_NEW_HAL
+OSStatus propertyProc(
+ AudioObjectID inObjectID,
+ UInt32 inNumberAddresses,
+ const AudioObjectPropertyAddress* inAddresses,
+ void* inClientData);
+#else
OSStatus propertyProc(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData );
+#endif
/* sets the value of the given property and waits for the change to
be acknowledged, and returns the final value, which is not guaranteed
@@ -198,12 +263,20 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
*
*********************/
+#if PA_NEW_HAL
+OSStatus xrunCallback(
+ AudioObjectID inObjectID,
+ UInt32 inNumberAddresses,
+ const AudioObjectPropertyAddress* inAddresses,
+ void * inClientData );
+#else
OSStatus xrunCallback(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData ) ;
+#endif
/** returns zero on success or a unix style error code. */
int initializeXRunListenerList( void );
From 992e84387fddc202dd8d3940c8cfc8584c064660 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Fri, 27 Nov 2020 09:05:47 +0200
Subject: [PATCH 070/157] fix compile error
---
src/hostapi/coreaudio/pa_mac_core_utilities.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.c b/src/hostapi/coreaudio/pa_mac_core_utilities.c
index 4563a93..2e85907 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.c
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.c
@@ -72,7 +72,7 @@ OSStatus pa_AudioHardwareGetProperty(
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
- macErr = AudioHardwareGetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
+ return AudioHardwareGetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
#endif
}
@@ -84,7 +84,7 @@ OSStatus pa_AudioHardwareGetPropertySize(
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &address, 0, NULL, outSize);
#else
- macErr = AudioHardwareGetPropertyInfo(inPropertyID, outSize, NULL);
+ return AudioHardwareGetPropertyInfo(inPropertyID, outSize, NULL);
#endif
}
@@ -101,7 +101,7 @@ OSStatus pa_AudioDeviceGetProperty(
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectGetPropertyData(inDevice, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
- macErr = AudioDeviceGetProperty(inDevice, inChannel, isInput, inPropertyID, ioPropertyDataSize, outPropertyData);
+ return AudioDeviceGetProperty(inDevice, inChannel, isInput, inPropertyID, ioPropertyDataSize, outPropertyData);
#endif
}
From f4ca4385995edc83ff59404332342d918b540d77 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Fri, 27 Nov 2020 09:09:00 +0200
Subject: [PATCH 071/157] formatting and #ifdef comment
---
src/hostapi/coreaudio/pa_mac_core.c | 11 +++++-----
src/hostapi/coreaudio/pa_mac_core_utilities.c | 20 +++++++++----------
src/hostapi/coreaudio/pa_mac_core_utilities.h | 13 +++++++++---
3 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index 155c6ba..21bd788 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -1083,7 +1083,8 @@ static OSStatus AudioDevicePropertyActualSampleRateListenerProc( AudioDeviceID i
}
return osErr;
}
-#endif
+#endif /* PA_NEW_HAL */
+
/* ================================================================================= */
static OSStatus QueryUInt32DeviceProperty( AudioDeviceID deviceID, Boolean isInput, AudioDevicePropertyID propertyID, UInt32 *outValue )
{
@@ -1169,7 +1170,7 @@ static OSStatus AudioDevicePropertyGenericListenerProc( AudioDeviceID inDevice,
}
return osErr;
}
-#endif
+#endif /* PA_NEW_HAL */
/* ================================================================================= */
/*
@@ -2244,7 +2245,7 @@ static OSStatus ringBufferIOProc( AudioConverterRef inAudioConverter,
return noErr;
}
-#endif
+#endif /* PA_NEW_HAL */
/*
* Called by the AudioUnit API to process audio from the sound card.
@@ -2486,7 +2487,7 @@ static OSStatus AudioIOProc( void *inRefCon,
&stream->inputRingBuffer,
&size,
(void *)&data );
-#endif
+#endif /* PA_NEW_HAL */
if( err == RING_BUFFER_EMPTY )
{ /* the ring buffer callback underflowed */
err = 0;
@@ -2686,7 +2687,7 @@ static OSStatus AudioIOProc( void *inRefCon,
&stream->inputRingBuffer,
&size,
(void *)data );
-#endif
+#endif /* PA_NEW_HAL */
if( err != RING_BUFFER_EMPTY )
ERR( err );
if( err != noErr && err != RING_BUFFER_EMPTY )
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.c b/src/hostapi/coreaudio/pa_mac_core_utilities.c
index 2e85907..711d5ca 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.c
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.c
@@ -73,7 +73,7 @@ OSStatus pa_AudioHardwareGetProperty(
return AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
return AudioHardwareGetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
-#endif
+#endif /* PA_NEW_HAL */
}
OSStatus pa_AudioHardwareGetPropertySize(
@@ -85,7 +85,7 @@ OSStatus pa_AudioHardwareGetPropertySize(
return AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &address, 0, NULL, outSize);
#else
return AudioHardwareGetPropertyInfo(inPropertyID, outSize, NULL);
-#endif
+#endif /* PA_NEW_HAL */
}
OSStatus pa_AudioDeviceGetProperty(
@@ -102,7 +102,7 @@ OSStatus pa_AudioDeviceGetProperty(
return AudioObjectGetPropertyData(inDevice, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
return AudioDeviceGetProperty(inDevice, inChannel, isInput, inPropertyID, ioPropertyDataSize, outPropertyData);
-#endif
+#endif /* PA_NEW_HAL */
}
OSStatus pa_AudioDeviceSetProperty(
@@ -120,7 +120,7 @@ OSStatus pa_AudioDeviceSetProperty(
return AudioObjectSetPropertyData(inDevice, &address, 0, NULL, inPropertyDataSize, inPropertyData);
#else
return AudioDeviceSetProperty(inDevice, inWhen, inChannel, isInput, inPropertyID, inPropertyDataSize, inPropertyData);
-#endif
+#endif /* PA_NEW_HAL */
}
OSStatus pa_AudioDeviceGetPropertySize(
@@ -136,7 +136,7 @@ OSStatus pa_AudioDeviceGetPropertySize(
return AudioObjectGetPropertyDataSize(inDevice, &address, 0, NULL, outSize);
#else
return AudioDeviceGetPropertyInfo(inDevice, inChannel, isInput, inPropertyID, outSize, NULL);
-#endif
+#endif /* PA_NEW_HAL */
}
OSStatus pa_AudioDeviceAddPropertyListener(
@@ -153,7 +153,7 @@ OSStatus pa_AudioDeviceAddPropertyListener(
return AudioObjectAddPropertyListener(inDevice, &address, inProc, inClientData);
#else
return AudioDeviceAddPropertyListener(inDevice, inChannel, isInput, inPropertyID, inProc, inClientData);
-#endif
+#endif /* PA_NEW_HAL */
}
OSStatus pa_AudioDeviceRemovePropertyListener(
@@ -170,7 +170,7 @@ OSStatus pa_AudioDeviceRemovePropertyListener(
return AudioObjectRemovePropertyListener(inDevice, &address, inProc, inClientData);
#else
return AudioDeviceRemovePropertyListener(inDevice, inChannel, isInput, inPropertyID, inProc);
-#endif
+#endif /* PA_NEW_HAL */
}
OSStatus pa_AudioStreamGetProperty(
@@ -185,7 +185,7 @@ OSStatus pa_AudioStreamGetProperty(
return AudioObjectGetPropertyData(inStream, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
#else
return AudioStreamGetProperty(inStream, inChannel, inPropertyID, ioPropertyDataSize, outPropertyData);
-#endif
+#endif /* PA_NEW_HAL */
}
PaError PaMacCore_SetUnixError( int err, int line )
@@ -455,7 +455,7 @@ OSStatus propertyProc(
// this is where we would set the condition variable
return noErr;
}
-#endif
+#endif /* PA_NEW_HAL */
/* sets the value of the given property and waits for the change to
be acknowledged, and returns the final value, which is not guaranteed
@@ -815,7 +815,7 @@ OSStatus xrunCallback(
return 0;
}
-#endif
+#endif /* PA_NEW_HAL */
int initializeXRunListenerList( void )
{
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.h b/src/hostapi/coreaudio/pa_mac_core_utilities.h
index e6e0c6e..8888a36 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.h
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.h
@@ -121,15 +121,17 @@
typedef AudioObjectPropertyListenerProc pa_AudioDevicePropertyListenerProc;
#else
typedef AudioDevicePropertyListenerProc pa_AudioDevicePropertyListenerProc;
-#endif
+#endif /* PA_NEW_HAL */
OSStatus pa_AudioHardwareGetProperty(
AudioHardwarePropertyID inPropertyID,
UInt32* ioPropertyDataSize,
void* outPropertyData);
+
OSStatus pa_AudioHardwareGetPropertySize(
AudioHardwarePropertyID inPropertyID,
UInt32* outSize);
+
OSStatus pa_AudioDeviceGetProperty(
AudioDeviceID inDevice,
UInt32 inChannel,
@@ -137,6 +139,7 @@ OSStatus pa_AudioDeviceGetProperty(
AudioDevicePropertyID inPropertyID,
UInt32* ioPropertyDataSize,
void* outPropertyData);
+
OSStatus pa_AudioDeviceSetProperty(
AudioDeviceID inDevice,
const AudioTimeStamp* inWhen,
@@ -145,12 +148,14 @@ OSStatus pa_AudioDeviceSetProperty(
AudioDevicePropertyID inPropertyID,
UInt32 inPropertyDataSize,
const void* inPropertyData);
+
OSStatus pa_AudioDeviceGetPropertySize(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
UInt32* outSize);
+
OSStatus pa_AudioDeviceAddPropertyListener(
AudioDeviceID inDevice,
UInt32 inChannel,
@@ -158,6 +163,7 @@ OSStatus pa_AudioDeviceAddPropertyListener(
AudioDevicePropertyID inPropertyID,
pa_AudioDevicePropertyListenerProc inProc,
void* inClientData);
+
OSStatus pa_AudioDeviceRemovePropertyListener(
AudioDeviceID inDevice,
UInt32 inChannel,
@@ -165,6 +171,7 @@ OSStatus pa_AudioDeviceRemovePropertyListener(
AudioDevicePropertyID inPropertyID,
pa_AudioDevicePropertyListenerProc inProc,
void* inClientData);
+
OSStatus pa_AudioStreamGetProperty(
AudioStreamID inStream,
UInt32 inChannel,
@@ -213,7 +220,7 @@ OSStatus propertyProc(
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData );
-#endif
+#endif /* PA_NEW_HAL */
/* sets the value of the given property and waits for the change to
be acknowledged, and returns the final value, which is not guaranteed
@@ -276,7 +283,7 @@ OSStatus xrunCallback(
Boolean isInput,
AudioDevicePropertyID inPropertyID,
void* inClientData ) ;
-#endif
+#endif /* PA_NEW_HAL */
/** returns zero on success or a unix style error code. */
int initializeXRunListenerList( void );
From 1d3a239fd081263721e9c3997b8e007f7a1c4127 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Wed, 16 Dec 2020 12:45:30 +0200
Subject: [PATCH 072/157] remove support for OS X 10.4, rename functions pa_ ->
PaMacCore_
---
src/hostapi/coreaudio/pa_mac_core.c | 201 +++++-------------
src/hostapi/coreaudio/pa_mac_core_utilities.c | 158 +++-----------
src/hostapi/coreaudio/pa_mac_core_utilities.h | 70 ++----
3 files changed, 103 insertions(+), 326 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index 21bd788..24883a8 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -138,7 +138,7 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
/* First try with CFString */
UInt32 size = sizeof(nameRef);
- error = pa_AudioDeviceGetProperty( hostApiDevice,
+ error = PaMacCore_AudioDeviceGetProperty( hostApiDevice,
channelIndex + 1,
input,
kAudioDevicePropertyChannelNameCFString,
@@ -148,7 +148,7 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
{
/* try the C String */
size = 0;
- error = pa_AudioDeviceGetPropertySize( hostApiDevice,
+ error = PaMacCore_AudioDeviceGetPropertySize( hostApiDevice,
channelIndex + 1,
input,
kAudioDevicePropertyChannelName,
@@ -158,7 +158,7 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
if( !ensureChannelNameSize( size ) )
return NULL;
- error = pa_AudioDeviceGetProperty( hostApiDevice,
+ error = PaMacCore_AudioDeviceGetProperty( hostApiDevice,
channelIndex + 1,
input,
kAudioDevicePropertyChannelName,
@@ -223,7 +223,7 @@ PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
if( macCoreHostApi->inheritedHostApiRep.deviceInfos[hostApiDeviceIndex]->maxOutputChannels == 0 )
isInput = 1;
- result = WARNING(pa_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
+ result = WARNING(PaMacCore_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
*minBufferSizeFrames = audioRange.mMinimum;
*maxBufferSizeFrames = audioRange.mMaximum;
@@ -352,7 +352,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
auhalHostApi->devIds = NULL;
/* -- figure out how many devices there are -- */
- pa_AudioHardwareGetPropertySize( kAudioHardwarePropertyDevices,
+ PaMacCore_AudioHardwareGetPropertySize( kAudioHardwarePropertyDevices,
&propsize);
auhalHostApi->devCount = propsize / sizeof( AudioDeviceID );
@@ -364,7 +364,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
propsize );
if( !auhalHostApi->devIds )
return paInsufficientMemory;
- pa_AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
+ PaMacCore_AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
&propsize,
auhalHostApi->devIds );
#ifdef MAC_CORE_VERBOSE_DEBUG
@@ -383,7 +383,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
/* I am not sure how these calls to AudioHardwareGetProperty()
could fail, but in case they do, we use the first available
device as the default. */
- if( 0 != pa_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
+ if( 0 != PaMacCore_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
&size,
&auhalHostApi->defaultIn) ) {
int i;
@@ -400,7 +400,7 @@ static PaError gatherDeviceInfo(PaMacAUHAL *auhalHostApi)
}
}
}
- if( 0 != pa_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
+ if( 0 != PaMacCore_AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
&size,
&auhalHostApi->defaultOut) ) {
int i;
@@ -435,7 +435,7 @@ static PaError ClipToDeviceBufferSize( AudioDeviceID macCoreDeviceId,
UInt32 resultSize = desiredSize;
AudioValueRange audioRange;
UInt32 propSize = sizeof( audioRange );
- PaError err = WARNING(pa_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
+ PaError err = WARNING(PaMacCore_AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
resultSize = MAX( resultSize, audioRange.mMinimum );
resultSize = MIN( resultSize, audioRange.mMaximum );
*allowedSize = resultSize;
@@ -485,7 +485,7 @@ static void DumpDeviceProperties( AudioDeviceID macCoreDeviceId,
printf("Stream #%d = %d---------------------- \n", i, streamIDs[i] );
propSize = sizeof(UInt32);
- err = WARNING(p_AudioStreamGetProperty(streamIDs[i], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
+ err = WARNING(PaMacCore_AudioStreamGetProperty(streamIDs[i], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
printf(" kAudioStreamPropertyLatency: err = %d, propSize = %d, value = %d\n", err, propSize, streamLatency );
}
}
@@ -515,20 +515,20 @@ static PaError CalculateFixedDeviceLatency( AudioDeviceID macCoreDeviceId, int i
// To get stream latency we have to get a streamID from the device.
// We are only going to look at the first stream so only fetch one stream.
propSize = sizeof(streamIDs);
- err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreams, &propSize, &streamIDs[0]));
+ err = WARNING(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreams, &propSize, &streamIDs[0]));
if( err != paNoError ) goto error;
if( propSize == sizeof(AudioStreamID) )
{
propSize = sizeof(UInt32);
- err = WARNING(pa_AudioStreamGetProperty(streamIDs[0], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
+ err = WARNING(PaMacCore_AudioStreamGetProperty(streamIDs[0], 0, kAudioStreamPropertyLatency, &propSize, &streamLatency));
}
propSize = sizeof(UInt32);
- err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertySafetyOffset, &propSize, &safetyOffset));
+ err = WARNING(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertySafetyOffset, &propSize, &safetyOffset));
if( err != paNoError ) goto error;
propSize = sizeof(UInt32);
- err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyLatency, &propSize, &deviceLatency));
+ err = WARNING(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyLatency, &propSize, &deviceLatency));
if( err != paNoError ) goto error;
*fixedLatencyPtr = deviceLatency + streamLatency + safetyOffset;
@@ -558,7 +558,7 @@ static PaError CalculateDefaultDeviceLatencies( AudioDeviceID macCoreDeviceId,
// For high latency use the default device buffer size.
propSize = sizeof(UInt32);
- err = WARNING(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSize, &propSize, &bufferFrames));
+ err = WARNING(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSize, &propSize, &bufferFrames));
if( err != paNoError ) goto error;
*lowLatencyFramesPtr = fixedLatency + clippedMinBufferSize;
@@ -587,14 +587,14 @@ static PaError GetChannelInfo( PaMacAUHAL *auhalHostApi,
/* Get the number of channels from the stream configuration.
Fail if we can't get this. */
- err = ERR(pa_AudioDeviceGetPropertySize(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize));
+ err = ERR(PaMacCore_AudioDeviceGetPropertySize(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize));
if (err)
return err;
buflist = PaUtil_AllocateMemory(propSize);
if( !buflist )
return paInsufficientMemory;
- err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize, buflist));
+ err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, isInput, kAudioDevicePropertyStreamConfiguration, &propSize, buflist));
if (err)
goto error;
@@ -662,18 +662,18 @@ static PaError InitializeDeviceInfo( PaMacAUHAL *auhalHostApi,
/* Get the device name using CFString */
propSize = sizeof(nameRef);
- err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceNameCFString, &propSize, &nameRef));
+ err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceNameCFString, &propSize, &nameRef));
if (err)
{
/* Get the device name using c string. Fail if we can't get it. */
- err = ERR(pa_AudioDeviceGetPropertySize(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize));
+ err = ERR(PaMacCore_AudioDeviceGetPropertySize(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize));
if (err)
return err;
name = PaUtil_GroupAllocateMemory(auhalHostApi->allocations,propSize+1);
if ( !name )
return paInsufficientMemory;
- err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize, name));
+ err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyDeviceName, &propSize, name));
if (err)
return err;
}
@@ -694,7 +694,7 @@ static PaError InitializeDeviceInfo( PaMacAUHAL *auhalHostApi,
/* Try to get the default sample rate. Don't fail if we can't get this. */
propSize = sizeof(Float64);
- err = ERR(pa_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyNominalSampleRate, &propSize, &sampleRate));
+ err = ERR(PaMacCore_AudioDeviceGetProperty(macCoreDeviceId, 0, 0, kAudioDevicePropertyNominalSampleRate, &propSize, &sampleRate));
if (err)
deviceInfo->defaultSampleRate = 0.0;
else
@@ -1043,7 +1043,7 @@ static OSStatus UpdateSampleRateFromDeviceProperty( PaMacCoreStream *stream, Aud
Float64 sampleRate = 0.0;
UInt32 propSize = sizeof(Float64);
- OSStatus osErr = pa_AudioDeviceGetProperty( deviceID, 0, isInput, sampleRatePropertyID, &propSize, &sampleRate);
+ OSStatus osErr = PaMacCore_AudioDeviceGetProperty( deviceID, 0, isInput, sampleRatePropertyID, &propSize, &sampleRate);
if( (osErr == noErr) && (sampleRate > 1000.0) ) /* avoid divide by zero if there's an error */
{
deviceProperties->sampleRate = sampleRate;
@@ -1052,45 +1052,28 @@ static OSStatus UpdateSampleRateFromDeviceProperty( PaMacCoreStream *stream, Aud
return osErr;
}
-#if PA_NEW_HAL
static OSStatus AudioDevicePropertyActualSampleRateListenerProc(AudioObjectID inDevice, UInt32 inNumberAddresses, const AudioObjectPropertyAddress * inAddresses, void * inClientData)
{
- PaMacCoreStream * stream = (PaMacCoreStream *) inClientData;
+ PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput;
- // Make sure the callback is operating on a stream that is still valid!
- assert(stream->streamRepresentation.magic == PA_STREAM_MAGIC);
-
- OSStatus osErr = UpdateSampleRateFromDeviceProperty(stream, inDevice, isInput, kAudioDevicePropertyActualSampleRate);
- if (osErr == noErr)
- {
- UpdateTimeStampOffsets(stream);
- }
- return osErr;
-}
-#else
-static OSStatus AudioDevicePropertyActualSampleRateListenerProc( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput, AudioDevicePropertyID inPropertyID, void *inClientData )
-{
- PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
-
// Make sure the callback is operating on a stream that is still valid!
assert( stream->streamRepresentation.magic == PA_STREAM_MAGIC );
- OSStatus osErr = UpdateSampleRateFromDeviceProperty( stream, inDevice, isInput, kAudioDevicePropertyActualSampleRate );
+ OSStatus osErr = UpdateSampleRateFromDeviceProperty( stream, inDevice, isInput, kAudioDevicePropertyActualSampleRate );
if( osErr == noErr )
{
UpdateTimeStampOffsets( stream );
}
return osErr;
}
-#endif /* PA_NEW_HAL */
/* ================================================================================= */
static OSStatus QueryUInt32DeviceProperty( AudioDeviceID deviceID, Boolean isInput, AudioDevicePropertyID propertyID, UInt32 *outValue )
{
UInt32 propertyValue = 0;
UInt32 propertySize = sizeof(UInt32);
- OSStatus osErr = pa_AudioDeviceGetProperty( deviceID, 0, isInput, propertyID, &propertySize, &propertyValue);
+ OSStatus osErr = PaMacCore_AudioDeviceGetProperty( deviceID, 0, isInput, propertyID, &propertySize, &propertyValue);
if( osErr == noErr )
{
*outValue = propertyValue;
@@ -1098,49 +1081,13 @@ static OSStatus QueryUInt32DeviceProperty( AudioDeviceID deviceID, Boolean isInp
return osErr;
}
-#if PA_NEW_HAL
static OSStatus AudioDevicePropertyGenericListenerProc(AudioObjectID inDevice, UInt32 inNumberAddresses, const AudioObjectPropertyAddress * inAddresses, void * inClientData)
{
OSStatus osErr = noErr;
- PaMacCoreStream * stream = (PaMacCoreStream *) inClientData;
+ PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput;
AudioDevicePropertyID inPropertyID = inAddresses->mSelector;
- // Make sure the callback is operating on a stream that is still valid!
- assert(stream->streamRepresentation.magic == PA_STREAM_MAGIC);
-
- PaMacCoreDeviceProperties * deviceProperties = isInput ? &stream->inputProperties : &stream->outputProperties;
- UInt32 * valuePtr = NULL;
- switch (inPropertyID)
- {
- case kAudioDevicePropertySafetyOffset:
- valuePtr = &deviceProperties->safetyOffset;
- break;
-
- case kAudioDevicePropertyLatency:
- valuePtr = &deviceProperties->deviceLatency;
- break;
-
- case kAudioDevicePropertyBufferFrameSize:
- valuePtr = &deviceProperties->bufferFrameSize;
- break;
- }
- if (valuePtr != NULL)
- {
- osErr = QueryUInt32DeviceProperty(inDevice, isInput, inPropertyID, valuePtr);
- if (osErr == noErr)
- {
- UpdateTimeStampOffsets(stream);
- }
- }
- return osErr;
-}
-#else
-static OSStatus AudioDevicePropertyGenericListenerProc( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput, AudioDevicePropertyID inPropertyID, void *inClientData )
-{
- OSStatus osErr = noErr;
- PaMacCoreStream *stream = (PaMacCoreStream*)inClientData;
-
// Make sure the callback is operating on a stream that is still valid!
assert( stream->streamRepresentation.magic == PA_STREAM_MAGIC );
@@ -1170,7 +1117,6 @@ static OSStatus AudioDevicePropertyGenericListenerProc( AudioDeviceID inDevice,
}
return osErr;
}
-#endif /* PA_NEW_HAL */
/* ================================================================================= */
/*
@@ -1187,14 +1133,14 @@ static OSStatus SetupDevicePropertyListeners( PaMacCoreStream *stream, AudioDevi
if( (osErr = QueryUInt32DeviceProperty( deviceID, isInput,
kAudioDevicePropertySafetyOffset, &deviceProperties->safetyOffset )) != noErr ) return osErr;
- pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
+ PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
AudioDevicePropertyActualSampleRateListenerProc, stream );
- pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioStreamPropertyLatency,
+ PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioStreamPropertyLatency,
AudioDevicePropertyGenericListenerProc, stream );
- pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
+ PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
AudioDevicePropertyGenericListenerProc, stream );
- pa_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
+ PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
AudioDevicePropertyGenericListenerProc, stream );
return osErr;
@@ -1202,14 +1148,14 @@ static OSStatus SetupDevicePropertyListeners( PaMacCoreStream *stream, AudioDevi
static void CleanupDevicePropertyListeners( PaMacCoreStream *stream, AudioDeviceID deviceID, Boolean isInput )
{
- pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
+ PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
AudioDevicePropertyActualSampleRateListenerProc, stream );
- pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyLatency,
+ PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyLatency,
AudioDevicePropertyGenericListenerProc, stream );
- pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
+ PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
AudioDevicePropertyGenericListenerProc, stream );
- pa_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
+ PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
AudioDevicePropertyGenericListenerProc, stream );
}
@@ -1384,7 +1330,7 @@ static PaError OpenAndSetupOneAudioUnit(
sizeof(AudioDeviceID) ) );
}
/* -- add listener for dropouts -- */
- result = pa_AudioDeviceAddPropertyListener( *audioDevice,
+ result = PaMacCore_AudioDeviceAddPropertyListener( *audioDevice,
0,
outStreamParams ? false : true,
kAudioDeviceProcessorOverload,
@@ -2183,7 +2129,6 @@ PaTime GetStreamTime( PaStream *s )
#define RING_BUFFER_EMPTY (1000)
-#if PA_NEW_HAL
static OSStatus ringBufferIOProc(
AudioConverterRef inAudioConverter,
UInt32* ioNumberDataPackets,
@@ -2200,34 +2145,6 @@ static OSStatus ringBufferIOProc(
VVDBUG(("ringBufferIOProc()\n"));
- if( PaUtil_GetRingBufferReadAvailable( rb ) == 0 ) {
- *outData = NULL;
- *ioDataSize = 0;
- return RING_BUFFER_EMPTY;
- }
- assert(sizeof(UInt32) == sizeof(ring_buffer_size_t));
- assert( ( (*ioDataSize) / rb->elementSizeBytes ) * rb->elementSizeBytes == (*ioDataSize) ) ;
- (*ioDataSize) /= rb->elementSizeBytes ;
- PaUtil_GetRingBufferReadRegions( rb, *ioDataSize,
- outData, (ring_buffer_size_t *)ioDataSize,
- &dummyData, &dummySize );
- assert( *ioDataSize );
- PaUtil_AdvanceRingBufferReadIndex( rb, *ioDataSize );
- (*ioDataSize) *= rb->elementSizeBytes ;
- return noErr;
-}
-#else
-static OSStatus ringBufferIOProc( AudioConverterRef inAudioConverter,
- UInt32*ioDataSize,
- void** outData,
- void*inUserData )
-{
- void *dummyData;
- ring_buffer_size_t dummySize;
- PaUtilRingBuffer *rb = (PaUtilRingBuffer *) inUserData;
-
- VVDBUG(("ringBufferIOProc()\n"));
-
if( PaUtil_GetRingBufferReadAvailable( rb ) == 0 ) {
*outData = NULL;
*ioDataSize = 0;
@@ -2245,7 +2162,6 @@ static OSStatus ringBufferIOProc( AudioConverterRef inAudioConverter,
return noErr;
}
-#endif /* PA_NEW_HAL */
/*
* Called by the AudioUnit API to process audio from the sound card.
@@ -2467,7 +2383,6 @@ static OSStatus AudioIOProc( void *inRefCon,
UInt32 size;
float data[ inChan * frames ];
size = sizeof( data );
-#if PA_NEW_HAL
AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mNumberChannels = inChan;
@@ -2480,14 +2395,6 @@ static OSStatus AudioIOProc( void *inRefCon,
&size,
&bufferList,
NULL);
-#else
- err = AudioConverterFillBuffer(
- stream->inputSRConverter,
- ringBufferIOProc,
- &stream->inputRingBuffer,
- &size,
- (void *)&data );
-#endif /* PA_NEW_HAL */
if( err == RING_BUFFER_EMPTY )
{ /* the ring buffer callback underflowed */
err = 0;
@@ -2667,27 +2574,18 @@ static OSStatus AudioIOProc( void *inRefCon,
long f;
size = sizeof( data );
-#if PA_NEW_HAL
- AudioBufferList bufferList;
- bufferList.mNumberBuffers = 1;
- bufferList.mBuffers[0].mNumberChannels = chan;
- bufferList.mBuffers[0].mDataByteSize = size;
- bufferList.mBuffers[0].mData = data;
- err = AudioConverterFillComplexBuffer(
- stream->inputSRConverter,
- ringBufferIOProc,
- &stream->inputRingBuffer,
- &size,
- &bufferList,
- NULL);
-#else
- err = AudioConverterFillBuffer(
- stream->inputSRConverter,
- ringBufferIOProc,
- &stream->inputRingBuffer,
- &size,
- (void *)data );
-#endif /* PA_NEW_HAL */
+ AudioBufferList bufferList;
+ bufferList.mNumberBuffers = 1;
+ bufferList.mBuffers[0].mNumberChannels = chan;
+ bufferList.mBuffers[0].mDataByteSize = size;
+ bufferList.mBuffers[0].mData = data;
+ err = AudioConverterFillComplexBuffer(
+ stream->inputSRConverter,
+ ringBufferIOProc,
+ &stream->inputRingBuffer,
+ &size,
+ &bufferList,
+ NULL);
if( err != RING_BUFFER_EMPTY )
ERR( err );
if( err != noErr && err != RING_BUFFER_EMPTY )
@@ -2695,7 +2593,6 @@ static OSStatus AudioIOProc( void *inRefCon,
goto stop_stream;
}
-
f = size / ( chan * sizeof(float) );
PaUtil_SetInputFrameCount( &(stream->bufferProcessor), f );
if( f )
@@ -2766,7 +2663,7 @@ static PaError CloseStream( PaStream* s )
if( stream->outputUnit ) {
int count = removeFromXRunListenerList( stream );
if( count == 0 )
- pa_AudioDeviceRemovePropertyListener( stream->outputDevice,
+ PaMacCore_AudioDeviceRemovePropertyListener( stream->outputDevice,
0,
false,
kAudioDeviceProcessorOverload,
@@ -2775,7 +2672,7 @@ static PaError CloseStream( PaStream* s )
if( stream->inputUnit && stream->outputUnit != stream->inputUnit ) {
int count = removeFromXRunListenerList( stream );
if( count == 0 )
- pa_AudioDeviceRemovePropertyListener( stream->inputDevice,
+ PaMacCore_AudioDeviceRemovePropertyListener( stream->inputDevice,
0,
true,
kAudioDeviceProcessorOverload,
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.c b/src/hostapi/coreaudio/pa_mac_core_utilities.c
index 711d5ca..5d93706 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.c
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.c
@@ -63,32 +63,24 @@
#include
#include
-OSStatus pa_AudioHardwareGetProperty(
+OSStatus PaMacCore_AudioHardwareGetProperty(
AudioHardwarePropertyID inPropertyID,
UInt32* ioPropertyDataSize,
void* outPropertyData)
{
-#if PA_NEW_HAL
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
-#else
- return AudioHardwareGetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
-#endif /* PA_NEW_HAL */
}
-OSStatus pa_AudioHardwareGetPropertySize(
+OSStatus PaMacCore_AudioHardwareGetPropertySize(
AudioHardwarePropertyID inPropertyID,
UInt32* outSize)
{
-#if PA_NEW_HAL
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &address, 0, NULL, outSize);
-#else
- return AudioHardwareGetPropertyInfo(inPropertyID, outSize, NULL);
-#endif /* PA_NEW_HAL */
}
-OSStatus pa_AudioDeviceGetProperty(
+OSStatus PaMacCore_AudioDeviceGetProperty(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
@@ -96,16 +88,12 @@ OSStatus pa_AudioDeviceGetProperty(
UInt32* ioPropertyDataSize,
void* outPropertyData)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectGetPropertyData(inDevice, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
-#else
- return AudioDeviceGetProperty(inDevice, inChannel, isInput, inPropertyID, ioPropertyDataSize, outPropertyData);
-#endif /* PA_NEW_HAL */
}
-OSStatus pa_AudioDeviceSetProperty(
+OSStatus PaMacCore_AudioDeviceSetProperty(
AudioDeviceID inDevice,
const AudioTimeStamp* inWhen,
UInt32 inChannel,
@@ -114,78 +102,58 @@ OSStatus pa_AudioDeviceSetProperty(
UInt32 inPropertyDataSize,
const void* inPropertyData)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectSetPropertyData(inDevice, &address, 0, NULL, inPropertyDataSize, inPropertyData);
-#else
- return AudioDeviceSetProperty(inDevice, inWhen, inChannel, isInput, inPropertyID, inPropertyDataSize, inPropertyData);
-#endif /* PA_NEW_HAL */
}
-OSStatus pa_AudioDeviceGetPropertySize(
+OSStatus PaMacCore_AudioDeviceGetPropertySize(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
UInt32* outSize)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectGetPropertyDataSize(inDevice, &address, 0, NULL, outSize);
-#else
- return AudioDeviceGetPropertyInfo(inDevice, inChannel, isInput, inPropertyID, outSize, NULL);
-#endif /* PA_NEW_HAL */
}
-OSStatus pa_AudioDeviceAddPropertyListener(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- pa_AudioDevicePropertyListenerProc inProc,
- void* inClientData)
+OSStatus PaMacCore_AudioDeviceAddPropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ AudioObjectPropertyListenerProc inProc,
+ void* inClientData)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectAddPropertyListener(inDevice, &address, inProc, inClientData);
-#else
- return AudioDeviceAddPropertyListener(inDevice, inChannel, isInput, inPropertyID, inProc, inClientData);
-#endif /* PA_NEW_HAL */
}
-OSStatus pa_AudioDeviceRemovePropertyListener(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- pa_AudioDevicePropertyListenerProc inProc,
- void* inClientData)
+OSStatus PaMacCore_AudioDeviceRemovePropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ AudioObjectPropertyListenerProc inProc,
+ void* inClientData)
{
-#if PA_NEW_HAL
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
return AudioObjectRemovePropertyListener(inDevice, &address, inProc, inClientData);
-#else
- return AudioDeviceRemovePropertyListener(inDevice, inChannel, isInput, inPropertyID, inProc);
-#endif /* PA_NEW_HAL */
}
-OSStatus pa_AudioStreamGetProperty(
+OSStatus PaMacCore_AudioStreamGetProperty(
AudioStreamID inStream,
UInt32 inChannel,
AudioDevicePropertyID inPropertyID,
UInt32* ioPropertyDataSize,
void* outPropertyData)
{
-#if PA_NEW_HAL
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
return AudioObjectGetPropertyData(inStream, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
-#else
- return AudioStreamGetProperty(inStream, inChannel, inPropertyID, ioPropertyDataSize, outPropertyData);
-#endif /* PA_NEW_HAL */
}
PaError PaMacCore_SetUnixError( int err, int line )
@@ -274,14 +242,6 @@ PaError PaMacCore_SetError(OSStatus error, int line, int isError)
case kAudioUnitErr_TooManyFramesToProcess:
errorText = "Audio Unit: Too Many Frames";
result = paInternalError; break;
-#if ! PA_NEW_HAL
- case kAudioUnitErr_IllegalInstrument:
- errorText = "Audio Unit: Illegal Instrument";
- result = paInternalError; break;
- case kAudioUnitErr_InstrumentTypeNotFound:
- errorText = "Audio Unit: Instrument Type Not Found";
- result = paInternalError; break;
-#endif
case kAudioUnitErr_InvalidFile:
errorText = "Audio Unit: Invalid File";
result = paInternalError; break;
@@ -434,7 +394,6 @@ long computeRingBufferSize( const PaStreamParameters *inputParameters,
* since it represents a theoretically better implementation.
*/
-#if PA_NEW_HAL
OSStatus propertyProc(
AudioObjectID inObjectID,
UInt32 inNumberAddresses,
@@ -444,18 +403,6 @@ OSStatus propertyProc(
// this is where we would set the condition variable
return noErr;
}
-#else
-OSStatus propertyProc(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- void* inClientData )
-{
- // this is where we would set the condition variable
- return noErr;
-}
-#endif /* PA_NEW_HAL */
/* sets the value of the given property and waits for the change to
be acknowledged, and returns the final value, which is not guaranteed
@@ -479,7 +426,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
UInt32 outPropertyDataSize = inPropertyDataSize;
/* First, see if it already has that value. If so, return. */
- macErr = pa_AudioDeviceGetProperty( inDevice, inChannel,
+ macErr = PaMacCore_AudioDeviceGetProperty( inDevice, inChannel,
isInput, inPropertyID,
&outPropertyDataSize, outPropertyData );
if( macErr ) {
@@ -496,7 +443,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
/* If we were using a cond variable, we'd do something useful here,
but for now, this is just to make 10.6 happy. */
- macErr = pa_AudioDeviceAddPropertyListener( inDevice, inChannel, isInput,
+ macErr = PaMacCore_AudioDeviceAddPropertyListener( inDevice, inChannel, isInput,
inPropertyID, propertyProc,
NULL );
if( macErr )
@@ -504,7 +451,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
goto failMac;
/* set property */
- macErr = pa_AudioDeviceSetProperty( inDevice, NULL, inChannel,
+ macErr = PaMacCore_AudioDeviceSetProperty( inDevice, NULL, inChannel,
isInput, inPropertyID,
inPropertyDataSize, inPropertyData );
if( macErr )
@@ -519,7 +466,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
memcpy( &tv2, &tv1, sizeof( struct timeval ) );
while( tv2.tv_sec - tv1.tv_sec < 30 ) {
/* now read the property back out */
- macErr = pa_AudioDeviceGetProperty( inDevice, inChannel,
+ macErr = PaMacCore_AudioDeviceGetProperty( inDevice, inChannel,
isInput, inPropertyID,
&outPropertyDataSize, outPropertyData );
if( macErr ) {
@@ -528,7 +475,7 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
}
/* and compare... */
if( 0==memcmp( outPropertyData, inPropertyData, outPropertyDataSize ) ) {
- pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL);
+ PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL);
return paNoError;
}
/* No match yet, so let's sleep and try again. */
@@ -537,11 +484,11 @@ PaError AudioDeviceSetPropertyNowAndWaitForChange(
}
DBUG( ("Timeout waiting for device setting.\n" ) );
- pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
+ PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
return paNoError;
failMac:
- pa_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
+ PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
return ERR( macErr );
}
@@ -587,7 +534,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
return paInvalidSampleRate;
/* -- generate a list of available sample rates -- */
- err = pa_AudioDeviceGetPropertySize( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetPropertySize( device, 0, isInput,
kAudioDevicePropertyAvailableNominalSampleRates,
&propsize );
if( err )
@@ -595,7 +542,7 @@ PaError setBestSampleRateForDevice( const AudioDeviceID device,
ranges = (AudioValueRange *)calloc( 1, propsize );
if( !ranges )
return paInsufficientMemory;
- err = pa_AudioDeviceGetProperty( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyAvailableNominalSampleRates,
&propsize, ranges );
if( err )
@@ -675,10 +622,10 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
}
/* -- try and set exact FPB -- */
- err = pa_AudioDeviceSetProperty( device, NULL, 0, isInput,
+ err = PaMacCore_AudioDeviceSetProperty( device, NULL, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
propsize, &requestedFramesPerBuffer);
- err = pa_AudioDeviceGetProperty( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
&propsize, actualFramesPerBuffer);
if( err )
@@ -693,7 +640,7 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
// Clip requested value against legal range for the device.
propsize = sizeof(AudioValueRange);
- err = pa_AudioDeviceGetProperty( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSizeRange,
&propsize, &range );
if( err )
@@ -711,11 +658,11 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
/* --- set the buffer size (ignore errors) -- */
propsize = sizeof( UInt32 );
- err = pa_AudioDeviceSetProperty( device, NULL, 0, isInput,
+ err = PaMacCore_AudioDeviceSetProperty( device, NULL, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
propsize, &requestedFramesPerBuffer );
/* --- read the property to check that it was set -- */
- err = pa_AudioDeviceGetProperty( device, 0, isInput,
+ err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
kAudioDevicePropertyBufferFrameSize,
&propsize, actualFramesPerBuffer );
@@ -744,7 +691,6 @@ static PaMacXRunListNode firstXRunListNode;
static int xRunListSize;
static pthread_mutex_t xrunMutex;
-#if PA_NEW_HAL
OSStatus xrunCallback(
AudioObjectID inDevice,
UInt32 inNumberAddresses,
@@ -756,41 +702,6 @@ OSStatus xrunCallback(
int ret = pthread_mutex_trylock( &xrunMutex ) ;
- if( ret == 0 ) {
- node = node->next ; //skip the first node
-
- for( ; node; node=node->next ) {
- PaMacCoreStream *stream = node->stream;
-
- if( stream->state != ACTIVE )
- continue; //if the stream isn't active, we don't care if the device is dropping
-
- if( isInput ) {
- if( stream->inputDevice == inDevice )
- OSAtomicOr32( paInputOverflow, &stream->xrunFlags );
- } else {
- if( stream->outputDevice == inDevice )
- OSAtomicOr32( paOutputUnderflow, &stream->xrunFlags );
- }
- }
-
- pthread_mutex_unlock( &xrunMutex );
- }
-
- return 0;
-}
-#else
-OSStatus xrunCallback(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- void* inClientData)
-{
- PaMacXRunListNode *node = (PaMacXRunListNode *) inClientData;
-
- int ret = pthread_mutex_trylock( &xrunMutex ) ;
-
if( ret == 0 ) {
node = node->next ; //skip the first node
@@ -815,7 +726,6 @@ OSStatus xrunCallback(
return 0;
}
-#endif /* PA_NEW_HAL */
int initializeXRunListenerList( void )
{
diff --git a/src/hostapi/coreaudio/pa_mac_core_utilities.h b/src/hostapi/coreaudio/pa_mac_core_utilities.h
index 8888a36..091ee65 100644
--- a/src/hostapi/coreaudio/pa_mac_core_utilities.h
+++ b/src/hostapi/coreaudio/pa_mac_core_utilities.h
@@ -111,28 +111,16 @@
# define VVDBUG(MSG)
#endif
-#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
-#define PA_NEW_HAL 1
-#else
-#define PA_NEW_HAL 0
-#endif
-
-#if PA_NEW_HAL
-typedef AudioObjectPropertyListenerProc pa_AudioDevicePropertyListenerProc;
-#else
-typedef AudioDevicePropertyListenerProc pa_AudioDevicePropertyListenerProc;
-#endif /* PA_NEW_HAL */
-
-OSStatus pa_AudioHardwareGetProperty(
+OSStatus PaMacCore_AudioHardwareGetProperty(
AudioHardwarePropertyID inPropertyID,
UInt32* ioPropertyDataSize,
void* outPropertyData);
-OSStatus pa_AudioHardwareGetPropertySize(
+OSStatus PaMacCore_AudioHardwareGetPropertySize(
AudioHardwarePropertyID inPropertyID,
UInt32* outSize);
-OSStatus pa_AudioDeviceGetProperty(
+OSStatus PaMacCore_AudioDeviceGetProperty(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
@@ -140,7 +128,7 @@ OSStatus pa_AudioDeviceGetProperty(
UInt32* ioPropertyDataSize,
void* outPropertyData);
-OSStatus pa_AudioDeviceSetProperty(
+OSStatus PaMacCore_AudioDeviceSetProperty(
AudioDeviceID inDevice,
const AudioTimeStamp* inWhen,
UInt32 inChannel,
@@ -149,30 +137,30 @@ OSStatus pa_AudioDeviceSetProperty(
UInt32 inPropertyDataSize,
const void* inPropertyData);
-OSStatus pa_AudioDeviceGetPropertySize(
+OSStatus PaMacCore_AudioDeviceGetPropertySize(
AudioDeviceID inDevice,
UInt32 inChannel,
Boolean isInput,
AudioDevicePropertyID inPropertyID,
UInt32* outSize);
-OSStatus pa_AudioDeviceAddPropertyListener(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- pa_AudioDevicePropertyListenerProc inProc,
- void* inClientData);
+OSStatus PaMacCore_AudioDeviceAddPropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ AudioObjectPropertyListenerProc inProc,
+ void* inClientData);
-OSStatus pa_AudioDeviceRemovePropertyListener(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- pa_AudioDevicePropertyListenerProc inProc,
- void* inClientData);
+OSStatus PaMacCore_AudioDeviceRemovePropertyListener(
+ AudioDeviceID inDevice,
+ UInt32 inChannel,
+ Boolean isInput,
+ AudioDevicePropertyID inPropertyID,
+ AudioObjectPropertyListenerProc inProc,
+ void* inClientData);
-OSStatus pa_AudioStreamGetProperty(
+OSStatus PaMacCore_AudioStreamGetProperty(
AudioStreamID inStream,
UInt32 inChannel,
AudioDevicePropertyID inPropertyID,
@@ -207,20 +195,11 @@ long computeRingBufferSize( const PaStreamParameters *inputParameters,
long outputFramesPerBuffer,
double sampleRate );
-#if PA_NEW_HAL
OSStatus propertyProc(
AudioObjectID inObjectID,
UInt32 inNumberAddresses,
const AudioObjectPropertyAddress* inAddresses,
void* inClientData);
-#else
-OSStatus propertyProc(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- void* inClientData );
-#endif /* PA_NEW_HAL */
/* sets the value of the given property and waits for the change to
be acknowledged, and returns the final value, which is not guaranteed
@@ -270,20 +249,11 @@ PaError setBestFramesPerBuffer( const AudioDeviceID device,
*
*********************/
-#if PA_NEW_HAL
OSStatus xrunCallback(
AudioObjectID inObjectID,
UInt32 inNumberAddresses,
const AudioObjectPropertyAddress* inAddresses,
void * inClientData );
-#else
-OSStatus xrunCallback(
- AudioDeviceID inDevice,
- UInt32 inChannel,
- Boolean isInput,
- AudioDevicePropertyID inPropertyID,
- void* inClientData ) ;
-#endif /* PA_NEW_HAL */
/** returns zero on success or a unix style error code. */
int initializeXRunListenerList( void );
From 61c402f941b7948cf3b497897b8181d1ebc3cbce Mon Sep 17 00:00:00 2001
From: John Melas
Date: Sun, 20 Dec 2020 14:35:24 +0200
Subject: [PATCH 073/157] fix ringBufferIOProc
---
src/hostapi/coreaudio/pa_mac_core.c | 40 +++++++++++++++++------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index 24883a8..e6cb4db 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -2136,29 +2136,35 @@ static OSStatus ringBufferIOProc(
AudioStreamPacketDescription** outDataPacketDescription,
void* inUserData)
{
- UInt32 * ioDataSize = &ioData->mBuffers[0].mDataByteSize;
- void ** outData = &ioData->mBuffers[0].mData;
-
- void *dummyData;
- ring_buffer_size_t dummySize;
- PaUtilRingBuffer *rb = (PaUtilRingBuffer *) inUserData;
-
VVDBUG(("ringBufferIOProc()\n"));
+ PaUtilRingBuffer *rb = (PaUtilRingBuffer *) inUserData;
+
if( PaUtil_GetRingBufferReadAvailable( rb ) == 0 ) {
- *outData = NULL;
- *ioDataSize = 0;
+ ioData->mBuffers[0].mData = NULL;
+ ioData->mBuffers[0].mDataByteSize = 0;
+ *ioNumberDataPackets = 0;
+ VVDBUG(("Ring buffer empty!\n"));
return RING_BUFFER_EMPTY;
}
- assert(sizeof(UInt32) == sizeof(ring_buffer_size_t));
- assert( ( (*ioDataSize) / rb->elementSizeBytes ) * rb->elementSizeBytes == (*ioDataSize) ) ;
- (*ioDataSize) /= rb->elementSizeBytes ;
- PaUtil_GetRingBufferReadRegions( rb, *ioDataSize,
- outData, (ring_buffer_size_t *)ioDataSize,
+
+ UInt32 packetSize = sizeof(float) * ioData->mBuffers[0].mNumberChannels;
+ UInt32 dataSize = *ioNumberDataPackets * packetSize;
+ assert(dataSize % rb->elementSizeBytes == 0);
+ UInt32 rbElements = dataSize / rb->elementSizeBytes;
+ ring_buffer_size_t rbElementsRead = rbElements;
+ void *dummyData;
+ ring_buffer_size_t dummySize;
+ PaUtil_GetRingBufferReadRegions( rb, rbElements,
+ &ioData->mBuffers[0].mData, &rbElementsRead,
&dummyData, &dummySize );
- assert( *ioDataSize );
- PaUtil_AdvanceRingBufferReadIndex( rb, *ioDataSize );
- (*ioDataSize) *= rb->elementSizeBytes ;
+ assert(rbElementsRead > 0);
+ VVDBUG(("RingBuffer read elements %u of %u\n", rbElementsRead, rbElements));
+ PaUtil_AdvanceRingBufferReadIndex( rb, rbElementsRead );
+
+ UInt32 bytesRead = rbElementsRead * rb->elementSizeBytes;
+ ioData->mBuffers[0].mDataByteSize = bytesRead;
+ *ioNumberDataPackets = bytesRead / packetSize;
return noErr;
}
From ac76dea010a73fa7af4e1b228572a64aa1c34a15 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Sun, 20 Dec 2020 20:00:44 +0200
Subject: [PATCH 074/157] pass input size in AudioConverterFillComplexBuffer as
number of packets
---
src/hostapi/coreaudio/pa_mac_core.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index e6cb4db..4c14a42 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -2386,24 +2386,24 @@ static OSStatus AudioIOProc( void *inRefCon,
if( stream->inputSRConverter )
{
OSStatus err;
- UInt32 size;
float data[ inChan * frames ];
- size = sizeof( data );
AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mNumberChannels = inChan;
- bufferList.mBuffers[0].mDataByteSize = size;
+ bufferList.mBuffers[0].mDataByteSize = sizeof( data );
bufferList.mBuffers[0].mData = data;
+ UInt32 packets = frames;
err = AudioConverterFillComplexBuffer(
stream->inputSRConverter,
ringBufferIOProc,
&stream->inputRingBuffer,
- &size,
+ &packets,
&bufferList,
NULL);
if( err == RING_BUFFER_EMPTY )
{ /* the ring buffer callback underflowed */
err = 0;
+ UInt32 size = packets * bytesPerFrame;
bzero( ((char *)data) + size, sizeof(data)-size );
/* The ring buffer can underflow normally when the stream is stopping.
* So only report an error if the stream is active. */
@@ -2576,20 +2576,17 @@ static OSStatus AudioIOProc( void *inRefCon,
OSStatus err;
do
{ /* Run the buffer processor until we are out of data. */
- UInt32 size;
- long f;
-
- size = sizeof( data );
AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mNumberChannels = chan;
- bufferList.mBuffers[0].mDataByteSize = size;
+ bufferList.mBuffers[0].mDataByteSize = sizeof( data );
bufferList.mBuffers[0].mData = data;
+ UInt32 packets = inNumberFrames;
err = AudioConverterFillComplexBuffer(
stream->inputSRConverter,
ringBufferIOProc,
&stream->inputRingBuffer,
- &size,
+ &packets,
&bufferList,
NULL);
if( err != RING_BUFFER_EMPTY )
@@ -2599,9 +2596,8 @@ static OSStatus AudioIOProc( void *inRefCon,
goto stop_stream;
}
- f = size / ( chan * sizeof(float) );
- PaUtil_SetInputFrameCount( &(stream->bufferProcessor), f );
- if( f )
+ PaUtil_SetInputFrameCount( &(stream->bufferProcessor), packets );
+ if( packets > 0 )
{
PaUtil_BeginBufferProcessing( &(stream->bufferProcessor),
&timeInfo,
From 9a1fa587737533b7281fa052a7c4f9589948d644 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Tue, 29 Dec 2020 16:48:04 +0200
Subject: [PATCH 075/157] remove todo comments
---
src/hostapi/coreaudio/pa_mac_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index 4c14a42..08f938c 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -2669,7 +2669,7 @@ static PaError CloseStream( PaStream* s )
0,
false,
kAudioDeviceProcessorOverload,
- xrunCallback, NULL ); //todo: do we need to pass actual node?
+ xrunCallback, NULL ); //no need to pass actual node
}
if( stream->inputUnit && stream->outputUnit != stream->inputUnit ) {
int count = removeFromXRunListenerList( stream );
@@ -2678,7 +2678,7 @@ static PaError CloseStream( PaStream* s )
0,
true,
kAudioDeviceProcessorOverload,
- xrunCallback, NULL ); //todo: do we need to pass actual node?
+ xrunCallback, NULL ); //no need to pass actual node
}
if( stream->outputUnit && stream->outputUnit != stream->inputUnit ) {
AudioUnitUninitialize( stream->outputUnit );
From 51e075d3dcc0a5bb8b869d720af980c903f86258 Mon Sep 17 00:00:00 2001
From: John Melas
Date: Tue, 29 Dec 2020 16:51:28 +0200
Subject: [PATCH 076/157] alignment fixes
---
src/hostapi/coreaudio/pa_mac_core.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c
index 08f938c..310422c 100644
--- a/src/hostapi/coreaudio/pa_mac_core.c
+++ b/src/hostapi/coreaudio/pa_mac_core.c
@@ -1137,11 +1137,11 @@ static OSStatus SetupDevicePropertyListeners( PaMacCoreStream *stream, AudioDevi
AudioDevicePropertyActualSampleRateListenerProc, stream );
PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioStreamPropertyLatency,
- AudioDevicePropertyGenericListenerProc, stream );
+ AudioDevicePropertyGenericListenerProc, stream );
PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
- AudioDevicePropertyGenericListenerProc, stream );
+ AudioDevicePropertyGenericListenerProc, stream );
PaMacCore_AudioDeviceAddPropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
- AudioDevicePropertyGenericListenerProc, stream );
+ AudioDevicePropertyGenericListenerProc, stream );
return osErr;
}
@@ -1149,14 +1149,14 @@ static OSStatus SetupDevicePropertyListeners( PaMacCoreStream *stream, AudioDevi
static void CleanupDevicePropertyListeners( PaMacCoreStream *stream, AudioDeviceID deviceID, Boolean isInput )
{
PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyActualSampleRate,
- AudioDevicePropertyActualSampleRateListenerProc, stream );
+ AudioDevicePropertyActualSampleRateListenerProc, stream );
PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyLatency,
- AudioDevicePropertyGenericListenerProc, stream );
+ AudioDevicePropertyGenericListenerProc, stream );
PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertyBufferFrameSize,
- AudioDevicePropertyGenericListenerProc, stream );
+ AudioDevicePropertyGenericListenerProc, stream );
PaMacCore_AudioDeviceRemovePropertyListener( deviceID, 0, isInput, kAudioDevicePropertySafetyOffset,
- AudioDevicePropertyGenericListenerProc, stream );
+ AudioDevicePropertyGenericListenerProc, stream );
}
/* ================================================================================= */
From c441223dfac41f0bb04bf360e3adcb48351c5d2e Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 21 Jan 2021 14:19:22 +1100
Subject: [PATCH 077/157] Clean up whitespace in include/ in preparation for
.editorconfig. (#415)
* Clean up whitespace in include/ in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF.
---
include/pa_asio.h | 18 ++--
include/pa_jack.h | 6 +-
include/pa_linux_alsa.h | 6 +-
include/pa_mac_core.h | 18 ++--
include/pa_win_ds.h | 14 ++--
include/pa_win_wasapi.h | 24 +++---
include/pa_win_waveformat.h | 162 ++++++++++++++++++------------------
include/pa_win_wdmks.h | 8 +-
include/pa_win_wmme.h | 16 ++--
include/portaudio.h | 122 +++++++++++++--------------
10 files changed, 197 insertions(+), 197 deletions(-)
diff --git a/include/pa_asio.h b/include/pa_asio.h
index e612aa3..27cbd3b 100644
--- a/include/pa_asio.h
+++ b/include/pa_asio.h
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -68,7 +68,7 @@ extern "C"
#define that maps PaAsio_GetAvailableLatencyValues to this function for backwards compatibility.
*/
PaError PaAsio_GetAvailableBufferSizes( PaDeviceIndex device,
- long *minBufferSizeFrames, long *maxBufferSizeFrames, long *preferredBufferSizeFrames, long *granularity );
+ long *minBufferSizeFrames, long *maxBufferSizeFrames, long *preferredBufferSizeFrames, long *granularity );
/** Backwards compatibility alias for PaAsio_GetAvailableBufferSizes
@@ -97,7 +97,7 @@ PaError PaAsio_ShowControlPanel( PaDeviceIndex device, void* systemSpecific );
PaError PaAsio_GetInputChannelName( PaDeviceIndex device, int channelIndex,
const char** channelName );
-
+
/** Retrieve a pointer to a string containing the name of the specified
input channel. The string is valid until Pa_Terminate is called.
@@ -108,11 +108,11 @@ PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex,
/** Set the sample rate of an open paASIO stream.
-
- @param stream The stream to operate on.
- @param sampleRate The new sample rate.
- Note that this function may fail if the stream is already running and the
+ @param stream The stream to operate on.
+ @param sampleRate The new sample rate.
+
+ Note that this function may fail if the stream is already running and the
ASIO driver does not support switching the sample rate of a running stream.
Returns paIncompatibleStreamHostApi if stream is not a paASIO stream.
diff --git a/include/pa_jack.h b/include/pa_jack.h
index 99ef833..750d116 100644
--- a/include/pa_jack.h
+++ b/include/pa_jack.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
diff --git a/include/pa_linux_alsa.h b/include/pa_linux_alsa.h
index 7ac6736..c940615 100644
--- a/include/pa_linux_alsa.h
+++ b/include/pa_linux_alsa.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
diff --git a/include/pa_mac_core.h b/include/pa_mac_core.h
index 85ecc03..beb5396 100644
--- a/include/pa_mac_core.h
+++ b/include/pa_mac_core.h
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -66,8 +66,8 @@ typedef struct
PaHostApiTypeId hostApiType; /**host API for which this data is intended */
unsigned long version; /**structure version */
unsigned long flags; /** flags to modify behaviour */
- SInt32 const * channelMap; /** Channel map for HAL channel mapping , if not needed, use NULL;*/
- unsigned long channelMapSize; /** Channel map size for HAL channel mapping , if not needed, use 0;*/
+ SInt32 const * channelMap; /** Channel map for HAL channel mapping , if not needed, use NULL;*/
+ unsigned long channelMapSize; /** Channel map size for HAL channel mapping , if not needed, use 0;*/
} PaMacCoreStreamInfo;
/**
@@ -98,7 +98,7 @@ void PaMacCore_SetupChannelMap( PaMacCoreStreamInfo *data, const SInt32 * const
* @return A valid AudioDeviceID, or NULL if an error occurred.
*/
AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s );
-
+
/**
* Retrieve the AudioDeviceID of the output device assigned to an open stream
*
@@ -124,13 +124,13 @@ AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
*/
const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input );
-
+
/** Retrieve the range of legal native buffer sizes for the specified device, in sample frames.
-
+
@param device The global index of the PortAudio device about which the query is being made.
@param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
@param maxBufferSizeFrames A pointer to the location which will receive the maximum buffer size value.
-
+
@see kAudioDevicePropertyBufferFrameSizeRange in the CoreAudio SDK.
*/
PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
diff --git a/include/pa_win_ds.h b/include/pa_win_ds.h
index 5d38641..8081abd 100644
--- a/include/pa_win_ds.h
+++ b/include/pa_win_ds.h
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -63,11 +63,11 @@ typedef struct PaWinDirectSoundStreamInfo{
unsigned long flags; /**< enable other features of this struct */
- /**
+ /**
low-level latency setting support
Sets the size of the DirectSound host buffer.
When flags contains the paWinDirectSoundUseLowLevelLatencyParameters
- this size will be used instead of interpreting the generic latency
+ this size will be used instead of interpreting the generic latency
parameters to Pa_OpenStream(). If the flag is not set this value is ignored.
If the stream is a full duplex stream the implementation requires that
@@ -77,7 +77,7 @@ typedef struct PaWinDirectSoundStreamInfo{
/**
support for WAVEFORMATEXTENSIBLE channel masks. If flags contains
- paWinDirectSoundUseChannelMask this allows you to specify which speakers
+ paWinDirectSoundUseChannelMask this allows you to specify which speakers
to address in a multichannel stream. Constants for channelMask
are specified in pa_win_waveformat.h
@@ -92,4 +92,4 @@ typedef struct PaWinDirectSoundStreamInfo{
}
#endif /* __cplusplus */
-#endif /* PA_WIN_DS_H */
+#endif /* PA_WIN_DS_H */
diff --git a/include/pa_win_wasapi.h b/include/pa_win_wasapi.h
index ab5d541..e7cb421 100644
--- a/include/pa_win_wasapi.h
+++ b/include/pa_win_wasapi.h
@@ -551,7 +551,7 @@ PaError PaWasapi_SetStreamStateHandler( PaStream *pStream, PaWasapiStreamStateCa
@param bOutput TRUE (1) for output (render), FALSE (0) for input (capture).
@return Error code indicating success or failure. Will return paIncompatibleStreamHostApi if library is not compiled
- for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
+ for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
be returned.
*/
PaError PaWasapiWinrt_SetDefaultDeviceId( const unsigned short *pId, int bOutput );
@@ -559,11 +559,11 @@ PaError PaWasapiWinrt_SetDefaultDeviceId( const unsigned short *pId, int bOutput
/** Populate the device list.
- By default the implementation will rely on DEVINTERFACE_AUDIO_RENDER and DEVINTERFACE_AUDIO_CAPTURE as
- default devices. If device Id is provided by PaWasapiWinrt_SetDefaultDeviceId() then those
+ By default the implementation will rely on DEVINTERFACE_AUDIO_RENDER and DEVINTERFACE_AUDIO_CAPTURE as
+ default devices. If device Id is provided by PaWasapiWinrt_SetDefaultDeviceId() then those
device Ids will be used as default and only devices for the device list.
- By populating the device list you can provide an additional available audio devices of the system to PA
+ By populating the device list you can provide an additional available audio devices of the system to PA
which are obtainable by:
Windows::Devices::Enumeration::DeviceInformation::FindAllAsync(selector) where selector is obtainable by
Windows::Media::Devices::MediaDevice::GetAudioRenderSelector() or
@@ -571,14 +571,14 @@ PaError PaWasapiWinrt_SetDefaultDeviceId( const unsigned short *pId, int bOutput
After the call completes, memory referenced by pointers can be freed, as implementation keeps its own copy.
- You must call PaWasapi_UpdateDeviceList() to update the internal device list of the implementation after
+ You must call PaWasapi_UpdateDeviceList() to update the internal device list of the implementation after
calling this function.
See an example in the IMPORTANT notes.
@note UWP/WinRT platform only.
- @param pId Array of device Ids, pointer to the array of pointers of 16-bit Unicode string (WCHAR). If NULL
+ @param pId Array of device Ids, pointer to the array of pointers of 16-bit Unicode string (WCHAR). If NULL
and count is also 0 then device Ids will be reset to the default. Required.
@param pName Array of device Names, pointer to the array of pointers of 16-bit Unicode string (WCHAR). Optional.
@param pRole Array of device Roles, see PaWasapiDeviceRole and PaWasapi_GetDeviceRole() for more details. Optional.
@@ -587,11 +587,11 @@ PaError PaWasapiWinrt_SetDefaultDeviceId( const unsigned short *pId, int bOutput
@param bOutput TRUE (1) for output (render), FALSE (0) for input (capture).
@return Error code indicating success or failure. Will return paIncompatibleStreamHostApi if library is not compiled
- for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
- be returned. If Name is longer than PA_WASAPI_DEVICE_NAME_LEN characters paBufferTooBig will
+ for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
+ be returned. If Name is longer than PA_WASAPI_DEVICE_NAME_LEN characters paBufferTooBig will
be returned.
*/
-PaError PaWasapiWinrt_PopulateDeviceList( const unsigned short **pId, const unsigned short **pName,
+PaError PaWasapiWinrt_PopulateDeviceList( const unsigned short **pId, const unsigned short **pName,
const PaWasapiDeviceRole *pRole, unsigned int count, int bOutput );
@@ -676,11 +676,11 @@ PaError PaWasapiWinrt_PopulateDeviceList( const unsigned short **pId, const unsi
UWP/WinRT:
- This platform has number of limitations which do not allow to enumerate audio devices without
+ This platform has number of limitations which do not allow to enumerate audio devices without
an additional external help. Enumeration is possible though from C++/CX, check the related API
Windows::Devices::Enumeration::DeviceInformation::FindAllAsync().
- The main limitation is an absence of the device enumeration from inside the PA's implementation.
+ The main limitation is an absence of the device enumeration from inside the PA's implementation.
This problem can be solved by using the following functions:
PaWasapiWinrt_SetDefaultDeviceId() - to set default input/output device,
@@ -706,7 +706,7 @@ PaError PaWasapiWinrt_PopulateDeviceList( const unsigned short **pId, const unsi
}
PaWasapiWinrt_SetDefaultDeviceId((const UINT16 *)default_device_id.c_str(), !capture);
- PaWasapiWinrt_PopulateDeviceList(ids.data(), names.data(), role.data(), count, !capture);
+ PaWasapiWinrt_PopulateDeviceList(ids.data(), names.data(), role.data(), count, !capture);
PaWasapi_UpdateDeviceList();
----------------
diff --git a/include/pa_win_waveformat.h b/include/pa_win_waveformat.h
index 2c00267..251562d 100644
--- a/include/pa_win_waveformat.h
+++ b/include/pa_win_waveformat.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -49,87 +49,87 @@ extern "C" {
#endif
/*
- The following #defines for speaker channel masks are the same
- as those in ksmedia.h, except with PAWIN_ prepended, KSAUDIO_ removed
- in some cases, and casts to PaWinWaveFormatChannelMask added.
+ The following #defines for speaker channel masks are the same
+ as those in ksmedia.h, except with PAWIN_ prepended, KSAUDIO_ removed
+ in some cases, and casts to PaWinWaveFormatChannelMask added.
*/
typedef unsigned long PaWinWaveFormatChannelMask;
/* Speaker Positions: */
-#define PAWIN_SPEAKER_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1)
-#define PAWIN_SPEAKER_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x2)
-#define PAWIN_SPEAKER_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x4)
-#define PAWIN_SPEAKER_LOW_FREQUENCY ((PaWinWaveFormatChannelMask)0x8)
-#define PAWIN_SPEAKER_BACK_LEFT ((PaWinWaveFormatChannelMask)0x10)
-#define PAWIN_SPEAKER_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20)
-#define PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER ((PaWinWaveFormatChannelMask)0x40)
-#define PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER ((PaWinWaveFormatChannelMask)0x80)
-#define PAWIN_SPEAKER_BACK_CENTER ((PaWinWaveFormatChannelMask)0x100)
-#define PAWIN_SPEAKER_SIDE_LEFT ((PaWinWaveFormatChannelMask)0x200)
-#define PAWIN_SPEAKER_SIDE_RIGHT ((PaWinWaveFormatChannelMask)0x400)
-#define PAWIN_SPEAKER_TOP_CENTER ((PaWinWaveFormatChannelMask)0x800)
-#define PAWIN_SPEAKER_TOP_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1000)
-#define PAWIN_SPEAKER_TOP_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x2000)
-#define PAWIN_SPEAKER_TOP_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x4000)
-#define PAWIN_SPEAKER_TOP_BACK_LEFT ((PaWinWaveFormatChannelMask)0x8000)
-#define PAWIN_SPEAKER_TOP_BACK_CENTER ((PaWinWaveFormatChannelMask)0x10000)
-#define PAWIN_SPEAKER_TOP_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20000)
+#define PAWIN_SPEAKER_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1)
+#define PAWIN_SPEAKER_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x2)
+#define PAWIN_SPEAKER_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x4)
+#define PAWIN_SPEAKER_LOW_FREQUENCY ((PaWinWaveFormatChannelMask)0x8)
+#define PAWIN_SPEAKER_BACK_LEFT ((PaWinWaveFormatChannelMask)0x10)
+#define PAWIN_SPEAKER_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20)
+#define PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER ((PaWinWaveFormatChannelMask)0x40)
+#define PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER ((PaWinWaveFormatChannelMask)0x80)
+#define PAWIN_SPEAKER_BACK_CENTER ((PaWinWaveFormatChannelMask)0x100)
+#define PAWIN_SPEAKER_SIDE_LEFT ((PaWinWaveFormatChannelMask)0x200)
+#define PAWIN_SPEAKER_SIDE_RIGHT ((PaWinWaveFormatChannelMask)0x400)
+#define PAWIN_SPEAKER_TOP_CENTER ((PaWinWaveFormatChannelMask)0x800)
+#define PAWIN_SPEAKER_TOP_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1000)
+#define PAWIN_SPEAKER_TOP_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x2000)
+#define PAWIN_SPEAKER_TOP_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x4000)
+#define PAWIN_SPEAKER_TOP_BACK_LEFT ((PaWinWaveFormatChannelMask)0x8000)
+#define PAWIN_SPEAKER_TOP_BACK_CENTER ((PaWinWaveFormatChannelMask)0x10000)
+#define PAWIN_SPEAKER_TOP_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20000)
/* Bit mask locations reserved for future use */
-#define PAWIN_SPEAKER_RESERVED ((PaWinWaveFormatChannelMask)0x7FFC0000)
+#define PAWIN_SPEAKER_RESERVED ((PaWinWaveFormatChannelMask)0x7FFC0000)
/* Used to specify that any possible permutation of speaker configurations */
-#define PAWIN_SPEAKER_ALL ((PaWinWaveFormatChannelMask)0x80000000)
+#define PAWIN_SPEAKER_ALL ((PaWinWaveFormatChannelMask)0x80000000)
/* DirectSound Speaker Config */
-#define PAWIN_SPEAKER_DIRECTOUT 0
-#define PAWIN_SPEAKER_MONO (PAWIN_SPEAKER_FRONT_CENTER)
-#define PAWIN_SPEAKER_STEREO (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT)
-#define PAWIN_SPEAKER_QUAD (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
- PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
-#define PAWIN_SPEAKER_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
- PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_BACK_CENTER)
-#define PAWIN_SPEAKER_5POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
- PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
- PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
-#define PAWIN_SPEAKER_7POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
- PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
- PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
- PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER | PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER)
-#define PAWIN_SPEAKER_5POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
- PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
- PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
-#define PAWIN_SPEAKER_7POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
- PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
- PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
- PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
+#define PAWIN_SPEAKER_DIRECTOUT 0
+#define PAWIN_SPEAKER_MONO (PAWIN_SPEAKER_FRONT_CENTER)
+#define PAWIN_SPEAKER_STEREO (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT)
+#define PAWIN_SPEAKER_QUAD (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
+ PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
+#define PAWIN_SPEAKER_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
+ PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_BACK_CENTER)
+#define PAWIN_SPEAKER_5POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
+ PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
+ PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
+#define PAWIN_SPEAKER_7POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
+ PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
+ PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
+ PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER | PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER)
+#define PAWIN_SPEAKER_5POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
+ PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
+ PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
+#define PAWIN_SPEAKER_7POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
+ PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
+ PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
+ PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
/*
According to the Microsoft documentation:
The following are obsolete 5.1 and 7.1 settings (they lack side speakers). Note this means
that the default 5.1 and 7.1 settings (KSAUDIO_SPEAKER_5POINT1 and KSAUDIO_SPEAKER_7POINT1 are
similarly obsolete but are unchanged for compatibility reasons).
*/
-#define PAWIN_SPEAKER_5POINT1_BACK PAWIN_SPEAKER_5POINT1
-#define PAWIN_SPEAKER_7POINT1_WIDE PAWIN_SPEAKER_7POINT1
+#define PAWIN_SPEAKER_5POINT1_BACK PAWIN_SPEAKER_5POINT1
+#define PAWIN_SPEAKER_7POINT1_WIDE PAWIN_SPEAKER_7POINT1
/* DVD Speaker Positions */
-#define PAWIN_SPEAKER_GROUND_FRONT_LEFT PAWIN_SPEAKER_FRONT_LEFT
-#define PAWIN_SPEAKER_GROUND_FRONT_CENTER PAWIN_SPEAKER_FRONT_CENTER
-#define PAWIN_SPEAKER_GROUND_FRONT_RIGHT PAWIN_SPEAKER_FRONT_RIGHT
-#define PAWIN_SPEAKER_GROUND_REAR_LEFT PAWIN_SPEAKER_BACK_LEFT
-#define PAWIN_SPEAKER_GROUND_REAR_RIGHT PAWIN_SPEAKER_BACK_RIGHT
-#define PAWIN_SPEAKER_TOP_MIDDLE PAWIN_SPEAKER_TOP_CENTER
-#define PAWIN_SPEAKER_SUPER_WOOFER PAWIN_SPEAKER_LOW_FREQUENCY
+#define PAWIN_SPEAKER_GROUND_FRONT_LEFT PAWIN_SPEAKER_FRONT_LEFT
+#define PAWIN_SPEAKER_GROUND_FRONT_CENTER PAWIN_SPEAKER_FRONT_CENTER
+#define PAWIN_SPEAKER_GROUND_FRONT_RIGHT PAWIN_SPEAKER_FRONT_RIGHT
+#define PAWIN_SPEAKER_GROUND_REAR_LEFT PAWIN_SPEAKER_BACK_LEFT
+#define PAWIN_SPEAKER_GROUND_REAR_RIGHT PAWIN_SPEAKER_BACK_RIGHT
+#define PAWIN_SPEAKER_TOP_MIDDLE PAWIN_SPEAKER_TOP_CENTER
+#define PAWIN_SPEAKER_SUPER_WOOFER PAWIN_SPEAKER_LOW_FREQUENCY
/*
- PaWinWaveFormat is defined here to provide compatibility with
- compilation environments which don't have headers defining
- WAVEFORMATEXTENSIBLE (e.g. older versions of MSVC, Borland C++ etc.
+ PaWinWaveFormat is defined here to provide compatibility with
+ compilation environments which don't have headers defining
+ WAVEFORMATEXTENSIBLE (e.g. older versions of MSVC, Borland C++ etc.
- The fields for WAVEFORMATEX and WAVEFORMATEXTENSIBLE are declared as an
- unsigned char array here to avoid clients who include this file having
+ The fields for WAVEFORMATEX and WAVEFORMATEXTENSIBLE are declared as an
+ unsigned char array here to avoid clients who include this file having
a dependency on windows.h and mmsystem.h, and also to to avoid having
to write separate packing pragmas for each compiler.
*/
@@ -138,24 +138,24 @@ typedef unsigned long PaWinWaveFormatChannelMask;
typedef struct{
unsigned char fields[ PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE ];
- unsigned long extraLongForAlignment; /* ensure that compiler aligns struct to DWORD */
+ unsigned long extraLongForAlignment; /* ensure that compiler aligns struct to DWORD */
} PaWinWaveFormat;
/*
WAVEFORMATEXTENSIBLE fields:
-
+
union {
- WORD wValidBitsPerSample;
- WORD wSamplesPerBlock;
- WORD wReserved;
+ WORD wValidBitsPerSample;
+ WORD wSamplesPerBlock;
+ WORD wReserved;
} Samples;
- DWORD dwChannelMask;
+ DWORD dwChannelMask;
GUID SubFormat;
*/
-#define PAWIN_INDEXOF_WVALIDBITSPERSAMPLE (PAWIN_SIZEOF_WAVEFORMATEX+0)
-#define PAWIN_INDEXOF_DWCHANNELMASK (PAWIN_SIZEOF_WAVEFORMATEX+2)
-#define PAWIN_INDEXOF_SUBFORMAT (PAWIN_SIZEOF_WAVEFORMATEX+6)
+#define PAWIN_INDEXOF_WVALIDBITSPERSAMPLE (PAWIN_SIZEOF_WAVEFORMATEX+0)
+#define PAWIN_INDEXOF_DWCHANNELMASK (PAWIN_SIZEOF_WAVEFORMATEX+2)
+#define PAWIN_INDEXOF_SUBFORMAT (PAWIN_SIZEOF_WAVEFORMATEX+6)
/*
@@ -163,10 +163,10 @@ typedef struct{
PaWin_InitializeWaveFormatExtensible functions below. These must match
the standard Windows WAVE_FORMAT_* values.
*/
-#define PAWIN_WAVE_FORMAT_PCM (1)
-#define PAWIN_WAVE_FORMAT_IEEE_FLOAT (3)
-#define PAWIN_WAVE_FORMAT_DOLBY_AC3_SPDIF (0x0092)
-#define PAWIN_WAVE_FORMAT_WMA_SPDIF (0x0164)
+#define PAWIN_WAVE_FORMAT_PCM (1)
+#define PAWIN_WAVE_FORMAT_IEEE_FLOAT (3)
+#define PAWIN_WAVE_FORMAT_DOLBY_AC3_SPDIF (0x0092)
+#define PAWIN_WAVE_FORMAT_WMA_SPDIF (0x0164)
/*
@@ -176,16 +176,16 @@ typedef struct{
int PaWin_SampleFormatToLinearWaveFormatTag( PaSampleFormat sampleFormat );
/*
- Use the following two functions to initialize the waveformat structure.
+ Use the following two functions to initialize the waveformat structure.
*/
-void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat,
- int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate );
+void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat,
+ int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate );
-void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
- int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate,
- PaWinWaveFormatChannelMask channelMask );
+void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
+ int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate,
+ PaWinWaveFormatChannelMask channelMask );
/* Map a channel count to a speaker channel mask */
@@ -196,4 +196,4 @@ PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels );
}
#endif /* __cplusplus */
-#endif /* PA_WIN_WAVEFORMAT_H */
\ No newline at end of file
+#endif /* PA_WIN_WAVEFORMAT_H */
diff --git a/include/pa_win_wdmks.h b/include/pa_win_wdmks.h
index 3592962..bc2f689 100644
--- a/include/pa_win_wdmks.h
+++ b/include/pa_win_wdmks.h
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -134,4 +134,4 @@ extern "C"
}
#endif /* __cplusplus */
-#endif /* PA_WIN_DS_H */
+#endif /* PA_WIN_DS_H */
diff --git a/include/pa_win_wmme.h b/include/pa_win_wmme.h
index b80743c..814022b 100644
--- a/include/pa_win_wmme.h
+++ b/include/pa_win_wmme.h
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -52,7 +52,7 @@ extern "C"
#endif /* __cplusplus */
-/* The following are flags which can be set in
+/* The following are flags which can be set in
PaWinMmeStreamInfo's flags field.
*/
@@ -100,7 +100,7 @@ typedef struct PaWinMmeStreamInfo{
Pa_OpenStream().
*/
unsigned long framesPerBuffer;
- unsigned long bufferCount; /* formerly numBuffers */
+ unsigned long bufferCount; /* formerly numBuffers */
/* multiple devices per direction support
If flags contains the PaWinMmeUseMultipleDevices flag,
@@ -118,7 +118,7 @@ typedef struct PaWinMmeStreamInfo{
/*
support for WAVEFORMATEXTENSIBLE channel masks. If flags contains
- paWinMmeUseChannelMask this allows you to specify which speakers
+ paWinMmeUseChannelMask this allows you to specify which speakers
to address in a multichannel stream. Constants for channelMask
are specified in pa_win_waveformat.h
@@ -155,7 +155,7 @@ HWAVEIN PaWinMME_GetStreamInputHandle( PaStream* stream, int handleIndex );
/** Retrieve the number of wave out handles used by a PortAudio WinMME stream.
Returns zero if the stream is input only.
-
+
@return A non-negative value indicating the number of wave out handles
or, a PaErrorCode (which are always negative) if PortAudio is not initialized
or an error is encountered.
@@ -182,4 +182,4 @@ HWAVEOUT PaWinMME_GetStreamOutputHandle( PaStream* stream, int handleIndex );
}
#endif /* __cplusplus */
-#endif /* PA_WIN_WMME_H */
+#endif /* PA_WIN_WMME_H */
diff --git a/include/portaudio.h b/include/portaudio.h
index 738080d..0c5b6a4 100644
--- a/include/portaudio.h
+++ b/include/portaudio.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -100,7 +100,7 @@ typedef struct PaVersionInfo {
/** Version as a string, for example "PortAudio V19.5.0-devel, revision 1952M" */
const char *versionText;
} PaVersionInfo;
-
+
/** Retrieve version information for the currently running PortAudio build.
@return A pointer to an immutable PaVersionInfo structure.
@@ -167,9 +167,9 @@ const char *Pa_GetErrorText( PaError errorCode );
and Pa_GetErrorText(), this function MUST be called before using any other
PortAudio API functions.
- If Pa_Initialize() is called multiple times, each successful
- call must be matched with a corresponding call to Pa_Terminate().
- Pairs of calls to Pa_Initialize()/Pa_Terminate() may overlap, and are not
+ If Pa_Initialize() is called multiple times, each successful
+ call must be matched with a corresponding call to Pa_Terminate().
+ Pairs of calls to Pa_Initialize()/Pa_Terminate() may overlap, and are not
required to be fully nested.
Note that if Pa_Initialize() returns an error code, Pa_Terminate() should
@@ -196,7 +196,7 @@ PaError Pa_Initialize( void );
@return paNoError if successful, otherwise an error code indicating the cause
of failure.
-
+
@see Pa_Initialize
*/
PaError Pa_Terminate( void );
@@ -320,7 +320,7 @@ typedef struct PaHostApiInfo
if no default output device is available.
*/
PaDeviceIndex defaultOutputDevice;
-
+
} PaHostApiInfo;
@@ -349,7 +349,7 @@ const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );
@return A valid PaHostApiIndex ranging from 0 to (Pa_GetHostApiCount()-1) or,
a PaErrorCode (which are always negative) if PortAudio is not initialized
or an error is encountered.
-
+
The paHostApiNotFound error code indicates that the host API specified by the
type parameter is not available.
@@ -376,7 +376,7 @@ PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );
A paInvalidDevice error code indicates that the hostApiDeviceIndex parameter
is out of range.
-
+
@see PaHostApiInfo
*/
PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,
@@ -449,12 +449,12 @@ PaDeviceIndex Pa_GetDefaultInputDevice( void );
PaDeviceIndex Pa_GetDefaultOutputDevice( void );
-/** The type used to represent monotonic time in seconds. PaTime is
- used for the fields of the PaStreamCallbackTimeInfo argument to the
+/** The type used to represent monotonic time in seconds. PaTime is
+ used for the fields of the PaStreamCallbackTimeInfo argument to the
PaStreamCallback and as the result of Pa_GetStreamTime().
PaTime values have unspecified origin.
-
+
@see PaStreamCallback, PaStreamCallbackTimeInfo, Pa_GetStreamTime
*/
typedef double PaTime;
@@ -472,7 +472,7 @@ typedef double PaTime;
paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
- The paNonInterleaved flag indicates that audio data is passed as an array
+ The paNonInterleaved flag indicates that audio data is passed as an array
of pointers to separate buffers, one buffer for each channel. Usually,
when this flag is not used, audio data is passed as a single buffer with
all channels interleaved.
@@ -502,7 +502,7 @@ typedef struct PaDeviceInfo
int structVersion; /* this is struct version 2 */
const char *name;
PaHostApiIndex hostApi; /**< note this is a host API index, not a type id*/
-
+
int maxInputChannels;
int maxOutputChannels;
@@ -544,7 +544,7 @@ typedef struct PaStreamParameters
This field must not be set to paNoDevice.
*/
PaDeviceIndex device;
-
+
/** The number of channels of sound to be delivered to the
stream callback or accessed by Pa_ReadStream() or Pa_WriteStream().
It can range from 1 to the value of maxInputChannels in the
@@ -619,9 +619,9 @@ PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
A single PaStream can provide multiple channels of real-time
streaming audio input and output to a client application. A stream
provides access to audio hardware represented by one or more
- PaDevices. Depending on the underlying Host API, it may be possible
- to open multiple streams using the same device, however this behavior
- is implementation defined. Portable applications should assume that
+ PaDevices. Depending on the underlying Host API, it may be possible
+ to open multiple streams using the same device, however this behavior
+ is implementation defined. Portable applications should assume that
a PaDevice may be simultaneously used by at most one PaStream.
Pointers to PaStream objects are passed between PortAudio functions that
@@ -679,7 +679,7 @@ typedef unsigned long PaStreamFlags;
/** Call the stream callback to fill initial output buffers, rather than the
default behavior of priming the buffers with zeros (silence). This flag has
no effect for input-only and blocking read/write streams.
-
+
@see PaStreamFlags
*/
#define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
@@ -693,7 +693,7 @@ typedef unsigned long PaStreamFlags;
Timing information for the buffers passed to the stream callback.
Time values are expressed in seconds and are synchronised with the time base used by Pa_GetStreamTime() for the associated stream.
-
+
@see PaStreamCallback, Pa_GetStreamTime
*/
typedef struct PaStreamCallbackTimeInfo{
@@ -764,41 +764,41 @@ typedef enum PaStreamCallbackResult
active PortAudio stream.
When a stream is running, PortAudio calls the stream callback periodically.
- The callback function is responsible for processing buffers of audio samples
+ The callback function is responsible for processing buffers of audio samples
passed via the input and output parameters.
The PortAudio stream callback runs at very high or real-time priority.
- It is required to consistently meet its time deadlines. Do not allocate
- memory, access the file system, call library functions or call other functions
+ It is required to consistently meet its time deadlines. Do not allocate
+ memory, access the file system, call library functions or call other functions
from the stream callback that may block or take an unpredictable amount of
time to complete.
In order for a stream to maintain glitch-free operation the callback
must consume and return audio data faster than it is recorded and/or
- played. PortAudio anticipates that each callback invocation may execute for
- a duration approaching the duration of frameCount audio frames at the stream
+ played. PortAudio anticipates that each callback invocation may execute for
+ a duration approaching the duration of frameCount audio frames at the stream
sample rate. It is reasonable to expect to be able to utilise 70% or more of
- the available CPU time in the PortAudio callback. However, due to buffer size
- adaption and other factors, not all host APIs are able to guarantee audio
- stability under heavy CPU load with arbitrary fixed callback buffer sizes.
- When high callback CPU utilisation is required the most robust behavior
- can be achieved by using paFramesPerBufferUnspecified as the
+ the available CPU time in the PortAudio callback. However, due to buffer size
+ adaption and other factors, not all host APIs are able to guarantee audio
+ stability under heavy CPU load with arbitrary fixed callback buffer sizes.
+ When high callback CPU utilisation is required the most robust behavior
+ can be achieved by using paFramesPerBufferUnspecified as the
Pa_OpenStream() framesPerBuffer parameter.
-
+
@param input and @param output are either arrays of interleaved samples or;
- if non-interleaved samples were requested using the paNonInterleaved sample
- format flag, an array of buffer pointers, one non-interleaved buffer for
+ if non-interleaved samples were requested using the paNonInterleaved sample
+ format flag, an array of buffer pointers, one non-interleaved buffer for
each channel.
The format, packing and number of channels used by the buffers are
determined by parameters to Pa_OpenStream().
-
+
@param frameCount The number of sample frames to be processed by
the stream callback.
@param timeInfo Timestamps indicating the ADC capture time of the first sample
in the input buffer, the DAC output time of the first sample in the output buffer
- and the time the callback was invoked.
+ and the time the callback was invoked.
See PaStreamCallbackTimeInfo and Pa_GetStreamTime()
@param statusFlags Flags indicating whether input and/or output buffers
@@ -836,10 +836,10 @@ typedef int PaStreamCallback(
/** Opens a stream for either input, output or both.
-
+
@param stream The address of a PaStream pointer which will receive
a pointer to the newly opened stream.
-
+
@param inputParameters A structure that describes the input parameters used by
the opened stream. See PaStreamParameters for a description of these parameters.
inputParameters must be NULL for output-only streams.
@@ -847,10 +847,10 @@ typedef int PaStreamCallback(
@param outputParameters A structure that describes the output parameters used by
the opened stream. See PaStreamParameters for a description of these parameters.
outputParameters must be NULL for input-only streams.
-
+
@param sampleRate The desired sampleRate. For full-duplex streams it is the
sample rate for both input and output
-
+
@param framesPerBuffer The number of frames passed to the stream callback
function, or the preferred block granularity for a blocking read/write stream.
The special value paFramesPerBufferUnspecified (0) may be used to request that
@@ -862,11 +862,11 @@ typedef int PaStreamCallback(
will be kept to the theoretical minimum however, it is strongly recommended
that a non-zero framesPerBuffer value only be used when your algorithm
requires a fixed number of frames per stream callback.
-
+
@param streamFlags Flags which modify the behavior of the streaming process.
This parameter may contain a combination of flags ORed together. Some flags may
only be relevant to certain buffer formats.
-
+
@param streamCallback A pointer to a client supplied function that is responsible
for processing and filling input and output buffers. If this parameter is NULL
the stream will be opened in 'blocking read/write' mode. In blocking mode,
@@ -879,7 +879,7 @@ typedef int PaStreamCallback(
function. It could for example, contain a pointer to instance data necessary
for processing the audio buffers. This parameter is ignored if streamCallback
is NULL.
-
+
@return
Upon success Pa_OpenStream() returns paNoError and places a pointer to a
valid PaStream in the stream argument. The stream is inactive (stopped).
@@ -904,7 +904,7 @@ PaError Pa_OpenStream( PaStream** stream,
@param stream The address of a PaStream pointer which will receive
a pointer to the newly opened stream.
-
+
@param numInputChannels The number of channels of sound that will be supplied
to the stream callback or returned by Pa_ReadStream. It can range from 1 to
the value of maxInputChannels in the PaDeviceInfo record for the default input
@@ -919,7 +919,7 @@ PaError Pa_OpenStream( PaStream** stream,
provided to the callback or passed to and from Pa_ReadStream and Pa_WriteStream.
sampleFormat may be any of the formats described by the PaSampleFormat
enumeration.
-
+
@param sampleRate Same as Pa_OpenStream parameter of the same name.
@param framesPerBuffer Same as Pa_OpenStream parameter of the same name.
@param streamCallback Same as Pa_OpenStream parameter of the same name.
@@ -945,7 +945,7 @@ PaError Pa_OpenDefaultStream( PaStream** stream,
PaError Pa_CloseStream( PaStream *stream );
-/** Functions of type PaStreamFinishedCallback are implemented by PortAudio
+/** Functions of type PaStreamFinishedCallback are implemented by PortAudio
clients. They can be registered with a stream using the Pa_SetStreamFinishedCallback
function. Once registered they are called when the stream becomes inactive
(ie once a call to Pa_StopStream() will not block).
@@ -954,7 +954,7 @@ PaError Pa_CloseStream( PaStream *stream );
output, if the stream callback returns paComplete, or Pa_StopStream() is called,
the stream finished callback will not be called until all generated sample data
has been played.
-
+
@param userData The userData parameter supplied to Pa_OpenStream()
@see Pa_SetStreamFinishedCallback
@@ -962,12 +962,12 @@ PaError Pa_CloseStream( PaStream *stream );
typedef void PaStreamFinishedCallback( void *userData );
-/** Register a stream finished callback function which will be called when the
- stream becomes inactive. See the description of PaStreamFinishedCallback for
+/** Register a stream finished callback function which will be called when the
+ stream becomes inactive. See the description of PaStreamFinishedCallback for
further details about when the callback will be called.
@param stream a pointer to a PaStream that is in the stopped state - if the
- stream is not stopped, the stream's finished callback will remain unchanged
+ stream is not stopped, the stream's finished callback will remain unchanged
and an error code will be returned.
@param streamFinishedCallback a pointer to a function with the same signature
@@ -980,7 +980,7 @@ typedef void PaStreamFinishedCallback( void *userData );
@see PaStreamFinishedCallback
*/
-PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
+PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
/** Commences audio processing.
@@ -1065,7 +1065,7 @@ typedef struct PaStreamInfo
parameter passed to Pa_OpenStream().
*/
double sampleRate;
-
+
} PaStreamInfo;
@@ -1087,15 +1087,15 @@ const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
/** Returns the current time in seconds for a stream according to the same clock used
to generate callback PaStreamCallbackTimeInfo timestamps. The time values are
- monotonically increasing and have unspecified origin.
-
+ monotonically increasing and have unspecified origin.
+
Pa_GetStreamTime returns valid time values for the entire life of the stream,
from when the stream is opened until it is closed. Starting and stopping the stream
does not affect the passage of time returned by Pa_GetStreamTime.
- This time may be used for synchronizing other events to the audio stream, for
+ This time may be used for synchronizing other events to the audio stream, for
example synchronizing audio to MIDI.
-
+
@return The stream's current time in seconds, or 0 if an error occurred.
@see PaTime, PaStreamCallback, PaStreamCallbackTimeInfo
@@ -1110,7 +1110,7 @@ PaTime Pa_GetStreamTime( PaStream *stream );
This function may be called from the stream callback function or the
application.
-
+
@return
A floating point value, typically between 0.0 and 1.0, where 1.0 indicates
that the stream callback is consuming the maximum number of CPU cycles possible
@@ -1127,12 +1127,12 @@ double Pa_GetStreamCpuLoad( PaStream* stream );
system to supply the data.
@param stream A pointer to an open stream previously created with Pa_OpenStream.
-
+
@param buffer A pointer to a buffer of sample frames. The buffer contains
samples in the format specified by the inputParameters->sampleFormat field
used to open the stream, and the number of channels specified by
inputParameters->numChannels. If non-interleaved samples were requested using
- the paNonInterleaved sample format flag, buffer is a pointer to the first element
+ the paNonInterleaved sample format flag, buffer is a pointer to the first element
of an array of buffer pointers, one non-interleaved buffer for each channel.
@param frames The number of frames to be read into buffer. This parameter
@@ -1158,7 +1158,7 @@ PaError Pa_ReadStream( PaStream* stream,
samples in the format specified by the outputParameters->sampleFormat field
used to open the stream, and the number of channels specified by
outputParameters->numChannels. If non-interleaved samples were requested using
- the paNonInterleaved sample format flag, buffer is a pointer to the first element
+ the paNonInterleaved sample format flag, buffer is a pointer to the first element
of an array of buffer pointers, one non-interleaved buffer for each channel.
@param frames The number of frames to be written from buffer. This parameter
From 20a971df57b55e621665adff6c97dbeeb8bc4c42 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 21 Jan 2021 21:58:54 +1100
Subject: [PATCH 078/157] Clean up whitespace in src/hostapi/{asihpi, jack,
oss, skeleton} in preparation for .editorconfig. (#414)
* Clean up whitespace in src/hostapi/{asihpi, jack, oss, skeleton} in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF.
* Additional formatting cleanups.
---
src/hostapi/asihpi/pa_linux_asihpi.c | 44 ++++----
src/hostapi/jack/pa_jack.c | 16 +--
src/hostapi/oss/pa_unix_oss.c | 123 ++++++++++-----------
src/hostapi/oss/recplay.c | 2 +-
src/hostapi/skeleton/pa_hostapi_skeleton.c | 60 +++++-----
5 files changed, 122 insertions(+), 123 deletions(-)
diff --git a/src/hostapi/asihpi/pa_linux_asihpi.c b/src/hostapi/asihpi/pa_linux_asihpi.c
index f5a5290..79eb1d7 100644
--- a/src/hostapi/asihpi/pa_linux_asihpi.c
+++ b/src/hostapi/asihpi/pa_linux_asihpi.c
@@ -199,27 +199,27 @@
/* If HPI error occurred */ \
if( UNLIKELY( hpiError ) ) \
{ \
- char szError[256]; \
- HPI_GetErrorText( hpiError, szError ); \
- PA_DEBUG(( "HPI error %d occurred: %s\n", hpiError, szError )); \
- /* This message will always be displayed, even if debug info is disabled */ \
+ char szError[256]; \
+ HPI_GetErrorText( hpiError, szError ); \
+ PA_DEBUG(( "HPI error %d occurred: %s\n", hpiError, szError )); \
+ /* This message will always be displayed, even if debug info is disabled */ \
PA_DEBUG(( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZE( __LINE__ ) "\n" )); \
if( (paError) == paUnanticipatedHostError ) \
- { \
- PA_DEBUG(( "Host error description: %s\n", szError )); \
- /* PaUtil_SetLastHostErrorInfo should only be used in the main thread */ \
- if( pthread_equal( pthread_self(), paUnixMainThread ) ) \
+ { \
+ PA_DEBUG(( "Host error description: %s\n", szError )); \
+ /* PaUtil_SetLastHostErrorInfo should only be used in the main thread */ \
+ if( pthread_equal( pthread_self(), paUnixMainThread ) ) \
{ \
- PaUtil_SetLastHostErrorInfo( paInDevelopment, hpiError, szError ); \
+ PaUtil_SetLastHostErrorInfo( paInDevelopment, hpiError, szError ); \
} \
- } \
- /* If paNoError is specified, continue as usual */ \
+ } \
+ /* If paNoError is specified, continue as usual */ \
/* (useful if you only want to print out the debug messages above) */ \
- if( (paError) < 0 ) \
- { \
- result = (paError); \
- goto error; \
- } \
+ if( (paError) < 0 ) \
+ { \
+ result = (paError); \
+ goto error; \
+ } \
} \
} while( 0 );
@@ -231,9 +231,9 @@
PA_DEBUG(( "HPI error %d occurred: %s\n", hpiError, szError )); \
/* PaUtil_SetLastHostErrorInfo should only be used in the main thread */ \
if( pthread_equal( pthread_self(), paUnixMainThread ) ) \
- { \
- PaUtil_SetLastHostErrorInfo( paInDevelopment, (hpiErrorCode), szError ); \
- } \
+ { \
+ PaUtil_SetLastHostErrorInfo( paInDevelopment, (hpiErrorCode), szError ); \
+ } \
} while( 0 );
/* Defaults */
@@ -556,7 +556,7 @@ static PaError PaAsiHpi_BuildDeviceList( PaAsiHpiHostApiRepresentation *hpiHostA
continue;
}
hpiError = HPI_AdapterGetInfo( NULL, idx, &outStreams, &inStreams,
- &version, &serial, &type );
+ &version, &serial, &type );
/* Skip to next device on failure */
if( hpiError )
{
@@ -738,7 +738,7 @@ PaError PaAsiHpi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
* interface and paNoError */
PA_DEBUG(( "Could not open HPI interface\n" ));
- *hostApi = NULL;
+ *hostApi = NULL;
return paNoError;
}
else
@@ -1584,7 +1584,7 @@ static PaError PaAsiHpi_SetupBuffers( PaAsiHpiStreamComponent *streamComp, uint3
/* If BBM not supported, foreground transfers will be used, but not a show-stopper */
/* Anything else is an error */
else if (( hpiError != HPI_ERROR_INVALID_OPERATION ) &&
- ( hpiError != HPI_ERROR_INVALID_FUNC ))
+ ( hpiError != HPI_ERROR_INVALID_FUNC ))
{
PA_ASIHPI_REPORT_ERROR_( hpiError );
result = paUnanticipatedHostError;
diff --git a/src/hostapi/jack/pa_jack.c b/src/hostapi/jack/pa_jack.c
index 5ec55c6..0dad24f 100644
--- a/src/hostapi/jack/pa_jack.c
+++ b/src/hostapi/jack/pa_jack.c
@@ -277,10 +277,10 @@ static PaError BlockingTermFIFO( PaUtilRingBuffer *rbuf )
static int
BlockingCallback( const void *inputBuffer,
void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData )
+ unsigned long framesPerBuffer,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
+ void *userData )
{
struct PaJackStream *stream = (PaJackStream *)userData;
long numBytes = stream->bytesPerFrame * framesPerBuffer;
@@ -918,7 +918,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
#define ABS(x) ( (x) > 0 ? (x) : -(x) )
if( ABS(sampleRate - jack_get_sample_rate(((PaJackHostApiRepresentation *) hostApi)->jack_client )) > 1 )
- return paInvalidSampleRate;
+ return paInvalidSampleRate;
#undef ABS
return paFormatIsSupported;
@@ -1161,7 +1161,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
#define ABS(x) ( (x) > 0 ? (x) : -(x) )
if( ABS(sampleRate - jackSr) > 1 )
- return paInvalidSampleRate;
+ return paInvalidSampleRate;
#undef ABS
UNLESS( stream = (PaJackStream*)PaUtil_AllocateMemory( sizeof(PaJackStream) ), paInsufficientMemory );
@@ -1610,7 +1610,7 @@ static PaError StartStream( PaStream *s )
{
int r = jack_connect( stream->jack_client, jack_port_name( stream->remote_output_ports[i] ),
jack_port_name( stream->local_input_ports[i] ) );
- UNLESS( 0 == r || EEXIST == r, paUnanticipatedHostError );
+ UNLESS( 0 == r || EEXIST == r, paUnanticipatedHostError );
}
}
@@ -1620,7 +1620,7 @@ static PaError StartStream( PaStream *s )
{
int r = jack_connect( stream->jack_client, jack_port_name( stream->local_output_ports[i] ),
jack_port_name( stream->remote_input_ports[i] ) );
- UNLESS( 0 == r || EEXIST == r, paUnanticipatedHostError );
+ UNLESS( 0 == r || EEXIST == r, paUnanticipatedHostError );
}
}
diff --git a/src/hostapi/oss/pa_unix_oss.c b/src/hostapi/oss/pa_unix_oss.c
index 83ab558..80df4c3 100644
--- a/src/hostapi/oss/pa_unix_oss.c
+++ b/src/hostapi/oss/pa_unix_oss.c
@@ -537,40 +537,40 @@ static PaError BuildDeviceList( PaOSSHostApiRepresentation *ossApi )
for( i = -1; i < 100; i++ )
{
- char deviceName[32];
- PaDeviceInfo *deviceInfo;
- int testResult;
+ char deviceName[32];
+ PaDeviceInfo *deviceInfo;
+ int testResult;
- if( i == -1 )
- snprintf(deviceName, sizeof (deviceName), "%s", DEVICE_NAME_BASE);
- else
- snprintf(deviceName, sizeof (deviceName), "%s%d", DEVICE_NAME_BASE, i);
+ if( i == -1 )
+ snprintf(deviceName, sizeof (deviceName), "%s", DEVICE_NAME_BASE);
+ else
+ snprintf(deviceName, sizeof (deviceName), "%s%d", DEVICE_NAME_BASE, i);
- /* PA_DEBUG(("%s: trying device %s\n", __FUNCTION__, deviceName )); */
- if( (testResult = QueryDevice( deviceName, ossApi, &deviceInfo )) != paNoError )
- {
- if( testResult != paDeviceUnavailable )
- PA_ENSURE( testResult );
+ /* PA_DEBUG(("%s: trying device %s\n", __FUNCTION__, deviceName )); */
+ if( (testResult = QueryDevice( deviceName, ossApi, &deviceInfo )) != paNoError )
+ {
+ if( testResult != paDeviceUnavailable )
+ PA_ENSURE( testResult );
- continue;
- }
+ continue;
+ }
- ++numDevices;
- if( !deviceInfos || numDevices > maxDeviceInfos )
- {
- maxDeviceInfos *= 2;
- PA_UNLESS( deviceInfos = (PaDeviceInfo **) realloc( deviceInfos, maxDeviceInfos * sizeof (PaDeviceInfo *) ),
- paInsufficientMemory );
- }
- {
- int devIdx = numDevices - 1;
- deviceInfos[devIdx] = deviceInfo;
+ ++numDevices;
+ if( !deviceInfos || numDevices > maxDeviceInfos )
+ {
+ maxDeviceInfos *= 2;
+ PA_UNLESS( deviceInfos = (PaDeviceInfo **) realloc( deviceInfos, maxDeviceInfos * sizeof (PaDeviceInfo *) ),
+ paInsufficientMemory );
+ }
+ {
+ int devIdx = numDevices - 1;
+ deviceInfos[devIdx] = deviceInfo;
- if( commonApi->info.defaultInputDevice == paNoDevice && deviceInfo->maxInputChannels > 0 )
- commonApi->info.defaultInputDevice = devIdx;
- if( commonApi->info.defaultOutputDevice == paNoDevice && deviceInfo->maxOutputChannels > 0 )
- commonApi->info.defaultOutputDevice = devIdx;
- }
+ if( commonApi->info.defaultInputDevice == paNoDevice && deviceInfo->maxInputChannels > 0 )
+ commonApi->info.defaultInputDevice = devIdx;
+ if( commonApi->info.defaultOutputDevice == paNoDevice && deviceInfo->maxOutputChannels > 0 )
+ commonApi->info.defaultOutputDevice = devIdx;
+ }
}
/* Make an array of PaDeviceInfo pointers out of the linked list */
@@ -670,14 +670,14 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
/* if full duplex, make sure that they're the same device */
if (inputChannelCount > 0 && outputChannelCount > 0 &&
- inputParameters->device != outputParameters->device)
+ inputParameters->device != outputParameters->device)
return paInvalidDevice;
/* if full duplex, also make sure that they're the same number of channels */
if (inputChannelCount > 0 && outputChannelCount > 0 &&
- inputChannelCount != outputChannelCount)
- return paInvalidChannelCount;
+ inputChannelCount != outputChannelCount)
+ return paInvalidChannelCount;
/* open the device so we can do more tests */
@@ -699,11 +699,11 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
flags = O_NONBLOCK;
if (inputChannelCount > 0 && outputChannelCount > 0)
- flags |= O_RDWR;
+ flags |= O_RDWR;
else if (inputChannelCount > 0)
- flags |= O_RDONLY;
+ flags |= O_RDONLY;
else
- flags |= O_WRONLY;
+ flags |= O_WRONLY;
ENSURE_( tempDevHandle = open( deviceInfo->name, flags ), paDeviceUnavailable );
@@ -712,7 +712,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
/* everything succeeded! */
- error:
+error:
if( tempDevHandle >= 0 )
close( tempDevHandle );
@@ -734,8 +734,7 @@ static PaError ValidateParameters( const PaStreamParameters *parameters, const P
return paInvalidDevice;
}
- maxChans = (mode == StreamMode_In ? deviceInfo->maxInputChannels :
- deviceInfo->maxOutputChannels);
+ maxChans = (mode == StreamMode_In ? deviceInfo->maxInputChannels : deviceInfo->maxOutputChannels);
if( parameters->channelCount > maxChans )
{
return paInvalidChannelCount;
@@ -1617,7 +1616,7 @@ static void *PaOSS_AudioThreadProc( void *userData )
assert( stream );
- pthread_cleanup_push( &OnExit, stream ); /* Execute OnExit when exiting */
+ pthread_cleanup_push( &OnExit, stream ); /* Execute OnExit when exiting */
/* The first time the stream is started we use SNDCTL_DSP_TRIGGER to accurately start capture and
* playback in sync, when the stream is restarted after being stopped we simply start by reading/
@@ -1948,19 +1947,19 @@ static PaError ReadStream( PaStream* s,
{
framesRequested = PA_MIN( frames, stream->capture->hostFrames );
- bytesRequested = framesRequested * PaOssStreamComponent_FrameSize( stream->capture );
- ENSURE_( (bytesRead = read( stream->capture->fd, stream->capture->buffer, bytesRequested )),
- paUnanticipatedHostError );
- if ( bytesRequested != bytesRead )
- {
- PA_DEBUG(( "Requested %d bytes, read %d\n", bytesRequested, bytesRead ));
- return paUnanticipatedHostError;
- }
+ bytesRequested = framesRequested * PaOssStreamComponent_FrameSize( stream->capture );
+ ENSURE_( (bytesRead = read( stream->capture->fd, stream->capture->buffer, bytesRequested )),
+ paUnanticipatedHostError );
+ if ( bytesRequested != bytesRead )
+ {
+ PA_DEBUG(( "Requested %d bytes, read %d\n", bytesRequested, bytesRead ));
+ return paUnanticipatedHostError;
+ }
- PaUtil_SetInputFrameCount( &stream->bufferProcessor, stream->capture->hostFrames );
- PaUtil_SetInterleavedInputChannels( &stream->bufferProcessor, 0, stream->capture->buffer, stream->capture->hostChannelCount );
+ PaUtil_SetInputFrameCount( &stream->bufferProcessor, stream->capture->hostFrames );
+ PaUtil_SetInterleavedInputChannels( &stream->bufferProcessor, 0, stream->capture->buffer, stream->capture->hostChannelCount );
PaUtil_CopyInput( &stream->bufferProcessor, &userBuffer, framesRequested );
- frames -= framesRequested;
+ frames -= framesRequested;
}
error:
@@ -1989,21 +1988,21 @@ static PaError WriteStream( PaStream *s, const void *buffer, unsigned long frame
while( frames )
{
- PaUtil_SetOutputFrameCount( &stream->bufferProcessor, stream->playback->hostFrames );
- PaUtil_SetInterleavedOutputChannels( &stream->bufferProcessor, 0, stream->playback->buffer, stream->playback->hostChannelCount );
+ PaUtil_SetOutputFrameCount( &stream->bufferProcessor, stream->playback->hostFrames );
+ PaUtil_SetInterleavedOutputChannels( &stream->bufferProcessor, 0, stream->playback->buffer, stream->playback->hostChannelCount );
- framesConverted = PaUtil_CopyOutput( &stream->bufferProcessor, &userBuffer, frames );
- frames -= framesConverted;
+ framesConverted = PaUtil_CopyOutput( &stream->bufferProcessor, &userBuffer, frames );
+ frames -= framesConverted;
- bytesRequested = framesConverted * PaOssStreamComponent_FrameSize( stream->playback );
- ENSURE_( (bytesWritten = write( stream->playback->fd, stream->playback->buffer, bytesRequested )),
- paUnanticipatedHostError );
+ bytesRequested = framesConverted * PaOssStreamComponent_FrameSize( stream->playback );
+ ENSURE_( (bytesWritten = write( stream->playback->fd, stream->playback->buffer, bytesRequested )),
+ paUnanticipatedHostError );
- if ( bytesRequested != bytesWritten )
- {
- PA_DEBUG(( "Requested %d bytes, wrote %d\n", bytesRequested, bytesWritten ));
- return paUnanticipatedHostError;
- }
+ if ( bytesRequested != bytesWritten )
+ {
+ PA_DEBUG(( "Requested %d bytes, wrote %d\n", bytesRequested, bytesWritten ));
+ return paUnanticipatedHostError;
+ }
}
error:
diff --git a/src/hostapi/oss/recplay.c b/src/hostapi/oss/recplay.c
index 9d4c78c..fe6dfdb 100644
--- a/src/hostapi/oss/recplay.c
+++ b/src/hostapi/oss/recplay.c
@@ -2,7 +2,7 @@
* recplay.c
* Phil Burk
* Minimal record and playback test.
- *
+ *
*/
#include
#include
diff --git a/src/hostapi/skeleton/pa_hostapi_skeleton.c b/src/hostapi/skeleton/pa_hostapi_skeleton.c
index cc31435..716ca7f 100644
--- a/src/hostapi/skeleton/pa_hostapi_skeleton.c
+++ b/src/hostapi/skeleton/pa_hostapi_skeleton.c
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -152,10 +152,10 @@ PaError PaSkeleton_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiI
(*hostApi)->info.defaultInputDevice = paNoDevice; /* IMPLEMENT ME */
(*hostApi)->info.defaultOutputDevice = paNoDevice; /* IMPLEMENT ME */
- (*hostApi)->info.deviceCount = 0;
+ (*hostApi)->info.deviceCount = 0;
deviceCount = 0; /* IMPLEMENT ME */
-
+
if( deviceCount > 0 )
{
(*hostApi)->deviceInfos = (PaDeviceInfo**)PaUtil_GroupAllocateMemory(
@@ -193,14 +193,14 @@ PaError PaSkeleton_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiI
deviceInfo->maxInputChannels = 0; /* IMPLEMENT ME */
deviceInfo->maxOutputChannels = 0; /* IMPLEMENT ME */
-
+
deviceInfo->defaultLowInputLatency = 0.; /* IMPLEMENT ME */
deviceInfo->defaultLowOutputLatency = 0.; /* IMPLEMENT ME */
deviceInfo->defaultHighInputLatency = 0.; /* IMPLEMENT ME */
- deviceInfo->defaultHighOutputLatency = 0.; /* IMPLEMENT ME */
+ deviceInfo->defaultHighOutputLatency = 0.; /* IMPLEMENT ME */
deviceInfo->defaultSampleRate = 0.; /* IMPLEMENT ME */
-
+
(*hostApi)->deviceInfos[i] = deviceInfo;
++(*hostApi)->info.deviceCount;
}
@@ -231,7 +231,7 @@ error:
PaUtil_FreeAllAllocations( skeletonHostApi->allocations );
PaUtil_DestroyAllocationGroup( skeletonHostApi->allocations );
}
-
+
PaUtil_FreeMemory( skeletonHostApi );
}
return result;
@@ -264,7 +264,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
{
int inputChannelCount, outputChannelCount;
PaSampleFormat inputSampleFormat, outputSampleFormat;
-
+
if( inputParameters )
{
inputChannelCount = inputParameters->channelCount;
@@ -274,7 +274,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
this implementation doesn't support any custom sample formats */
if( inputSampleFormat & paCustomFormat )
return paSampleFormatNotSupported;
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
@@ -303,7 +303,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
this implementation doesn't support any custom sample formats */
if( outputSampleFormat & paCustomFormat )
return paSampleFormatNotSupported;
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
@@ -322,7 +322,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
{
outputChannelCount = 0;
}
-
+
/*
IMPLEMENT ME:
@@ -420,7 +420,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
{
outputChannelCount = outputParameters->channelCount;
outputSampleFormat = outputParameters->sampleFormat;
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
@@ -499,10 +499,10 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
/* we assume a fixed host buffer size in this example, but the buffer processor
- can also support bounded and unknown host buffer sizes by passing
+ can also support bounded and unknown host buffer sizes by passing
paUtilBoundedHostBufferSize or paUtilUnknownHostBufferSize instead of
paUtilFixedHostBufferSize below. */
-
+
result = PaUtil_InitializeBufferProcessor( &stream->bufferProcessor,
inputChannelCount, inputSampleFormat, hostInputSampleFormat,
outputChannelCount, outputSampleFormat, hostOutputSampleFormat,
@@ -523,7 +523,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
(PaTime)PaUtil_GetBufferProcessorOutputLatencyFrames(&stream->bufferProcessor) / sampleRate; /* outputLatency is specified in _seconds_ */
stream->streamRepresentation.streamInfo.sampleRate = sampleRate;
-
+
/*
IMPLEMENT ME:
- additional stream setup + opening
@@ -545,7 +545,7 @@ error:
/*
ExampleHostProcessingLoop() illustrates the kind of processing which may
occur in a host implementation.
-
+
*/
static void ExampleHostProcessingLoop( void *inputBuffer, void *outputBuffer, void *userData )
{
@@ -553,9 +553,9 @@ static void ExampleHostProcessingLoop( void *inputBuffer, void *outputBuffer, vo
PaStreamCallbackTimeInfo timeInfo = {0,0,0}; /* IMPLEMENT ME */
int callbackResult;
unsigned long framesProcessed;
-
+
PaUtil_BeginCpuLoadMeasurement( &stream->cpuLoadMeasurer );
-
+
/*
IMPLEMENT ME:
- generate timing information
@@ -576,7 +576,7 @@ static void ExampleHostProcessingLoop( void *inputBuffer, void *outputBuffer, vo
or a mixture, you will want to call PaUtil_SetInterleaved*Channels(),
PaUtil_SetNonInterleaved*Channel() or PaUtil_Set*Channel() here.
*/
-
+
PaUtil_SetInputFrameCount( &stream->bufferProcessor, 0 /* default to host buffer size */ );
PaUtil_SetInterleavedInputChannels( &stream->bufferProcessor,
0, /* first channel of inputBuffer is channel 0 */
@@ -598,7 +598,7 @@ static void ExampleHostProcessingLoop( void *inputBuffer, void *outputBuffer, vo
callbackResult = paContinue;
framesProcessed = PaUtil_EndBufferProcessing( &stream->bufferProcessor, &callbackResult );
-
+
/*
If you need to byte swap or shift outputBuffer to convert it to
host format, do it here.
@@ -694,7 +694,7 @@ static PaError AbortStream( PaStream *s )
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior */
return result;
@@ -707,7 +707,7 @@ static PaError IsStreamStopped( PaStream *s )
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior */
return 0;
@@ -720,7 +720,7 @@ static PaError IsStreamActive( PaStream *s )
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior */
return 0;
@@ -733,7 +733,7 @@ static PaTime GetStreamTime( PaStream *s )
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return 0;
@@ -764,7 +764,7 @@ static PaError ReadStream( PaStream* s,
(void) buffer;
(void) frames;
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return paNoError;
@@ -781,7 +781,7 @@ static PaError WriteStream( PaStream* s,
(void) buffer;
(void) frames;
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return paNoError;
@@ -794,7 +794,7 @@ static signed long GetStreamReadAvailable( PaStream* s )
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return 0;
@@ -807,7 +807,7 @@ static signed long GetStreamWriteAvailable( PaStream* s )
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return 0;
From 80c5f2712075f6cc361b32566a74c99449b5def6 Mon Sep 17 00:00:00 2001
From: Etienne Dechamps
Date: Thu, 21 Jan 2021 11:16:44 +0000
Subject: [PATCH 079/157] Ignore the Visual Studio CMake settings file. (#422)
When using CMake, this file is written by Visual Studio to hold custom
CMake parameters.
---
.gitignore | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.gitignore b/.gitignore
index 8efca60..9b787f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,3 +46,6 @@ portaudio-2.0.pc
# Visual Studio CMake build output folder
out/
+
+# Visual Studio CMake settings file
+CMakeSettings.json
From f476839ab8ab8523fdecaf087984c51d9a3746f7 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 21 Jan 2021 22:17:17 +1100
Subject: [PATCH 080/157] Clean up whitespace in pa_asio.cpp in preparation for
.editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing
whitespace. Ensure EOL at EOF. (#411)
---
src/hostapi/asio/pa_asio.cpp | 342 +++++++++++++++++------------------
1 file changed, 171 insertions(+), 171 deletions(-)
diff --git a/src/hostapi/asio/pa_asio.cpp b/src/hostapi/asio/pa_asio.cpp
index c9ca786..ffb77ef 100644
--- a/src/hostapi/asio/pa_asio.cpp
+++ b/src/hostapi/asio/pa_asio.cpp
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -142,8 +142,8 @@
/* external reference to ASIO SDK's asioDrivers.
- This is a bit messy because we want to explicitly manage
- allocation/deallocation of this structure, but some layers of the SDK
+ This is a bit messy because we want to explicitly manage
+ allocation/deallocation of this structure, but some layers of the SDK
which we currently use (eg the implementation in asio.cpp) still
use this global version.
@@ -295,7 +295,7 @@ typedef struct
AsioDrivers *asioDrivers;
void *systemSpecific;
-
+
/* the ASIO C API only allows one ASIO driver to be open at a time,
so we keep track of whether we have the driver open here, and
use this information to return errors from OpenStream if the
@@ -942,7 +942,7 @@ PaError PaAsio_GetAvailableBufferSizes( PaDeviceIndex device,
*/
static void UnloadAsioDriver( void )
{
- ASIOExit();
+ ASIOExit();
}
/*
@@ -1005,9 +1005,9 @@ static PaError LoadAsioDriver( PaAsioHostApiRepresentation *asioHostApi, const c
error:
if( asioIsInitialized )
- {
- ASIOExit();
- }
+ {
+ ASIOExit();
+ }
return result;
}
@@ -1019,7 +1019,7 @@ static ASIOSampleRate defaultSampleRateSearchOrder_[]
192000.0, 16000.0, 12000.0, 11025.0, 9600.0, 8000.0 };
-static PaError InitPaDeviceInfoFromAsioDriver( PaAsioHostApiRepresentation *asioHostApi,
+static PaError InitPaDeviceInfoFromAsioDriver( PaAsioHostApiRepresentation *asioHostApi,
const char *driverName, int driverIndex,
PaDeviceInfo *deviceInfo, PaAsioDeviceInfo *asioDeviceInfo )
{
@@ -1083,11 +1083,11 @@ static PaError InitPaDeviceInfoFromAsioDriver( PaAsioHostApiRepresentation *asio
paAsioDriver.info.bufferMaxSize / deviceInfo->defaultSampleRate;
if( defaultHighLatency < defaultLowLatency )
- defaultHighLatency = defaultLowLatency; /* just in case the driver returns something strange */
-
+ defaultHighLatency = defaultLowLatency; /* just in case the driver returns something strange */
+
deviceInfo->defaultHighInputLatency = defaultHighLatency;
deviceInfo->defaultHighOutputLatency = defaultHighLatency;
-
+
}else{
deviceInfo->defaultLowInputLatency = 0.;
@@ -1192,7 +1192,7 @@ PaError PaAsio_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex
There used to be code that initialized COM in other situations
such as when creating a Stream. This made PA work when calling Pa_CreateStream
- from a non-main thread. However we currently consider initialization
+ from a non-main thread. However we currently consider initialization
of COM in non-main threads to be the caller's responsibility.
*/
result = PaWinUtil_CoInitialize( paASIO, &asioHostApi->comInitializationResult );
@@ -1214,7 +1214,7 @@ PaError PaAsio_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex
try
{
asioHostApi->asioDrivers = new AsioDrivers(); /* invokes CoInitialize(0) in AsioDriverList::AsioDriverList */
- }
+ }
catch (std::bad_alloc)
{
asioHostApi->asioDrivers = 0;
@@ -1291,7 +1291,7 @@ PaError PaAsio_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex
// we face fact that some drivers were not meant for it, drivers which act
// like shells on top of REAL drivers, for instance.
// so we get duplicate handles, locks and other problems.
- // so lets NOT try to load any such wrappers.
+ // so lets NOT try to load any such wrappers.
// The ones i [davidv] know of so far are:
if ( strcmp (names[i],"ASIO DirectX Full Duplex Driver") == 0
@@ -1305,16 +1305,16 @@ PaError PaAsio_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex
}
- if( IsDebuggerPresent_ && IsDebuggerPresent_() )
+ if( IsDebuggerPresent_ && IsDebuggerPresent_() )
{
/* ASIO Digidesign Driver uses PACE copy protection which quits out
if a debugger is running. So we don't load it if a debugger is running. */
- if( strcmp(names[i], "ASIO Digidesign Driver") == 0 )
+ if( strcmp(names[i], "ASIO Digidesign Driver") == 0 )
{
- PA_DEBUG(("BLACKLISTED!!! ASIO Digidesign Driver would quit the debugger\n"));
+ PA_DEBUG(("BLACKLISTED!!! ASIO Digidesign Driver would quit the debugger\n"));
continue;
- }
- }
+ }
+ }
/* Attempt to init device info from the asio driver... */
@@ -1332,8 +1332,8 @@ PaError PaAsio_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex
(*hostApi)->deviceInfos[ (*hostApi)->info.deviceCount ] = deviceInfo;
++(*hostApi)->info.deviceCount;
}
- else
- {
+ else
+ {
PA_DEBUG(("Skipping ASIO device:%s\n",names[i]));
continue;
}
@@ -1425,9 +1425,9 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
PaAsioDriverInfo *driverInfo = &asioHostApi->openAsioDriverInfo;
int inputChannelCount, outputChannelCount;
PaSampleFormat inputSampleFormat, outputSampleFormat;
- PaDeviceIndex asioDeviceIndex;
+ PaDeviceIndex asioDeviceIndex;
ASIOError asioError;
-
+
if( inputParameters && outputParameters )
{
/* full duplex ASIO stream must use the same device for input and output */
@@ -1435,7 +1435,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
if( inputParameters->device != outputParameters->device )
return paBadIODeviceCombination;
}
-
+
if( inputParameters )
{
inputChannelCount = inputParameters->channelCount;
@@ -1445,7 +1445,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
this implementation doesn't support any custom sample formats */
if( inputSampleFormat & paCustomFormat )
return paSampleFormatNotSupported;
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
@@ -1473,7 +1473,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
this implementation doesn't support any custom sample formats */
if( outputSampleFormat & paCustomFormat )
return paSampleFormatNotSupported;
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
@@ -1496,7 +1496,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
/* if an ASIO device is open we can only get format information for the currently open device */
- if( asioHostApi->openAsioDeviceIndex != paNoDevice
+ if( asioHostApi->openAsioDeviceIndex != paNoDevice
&& asioHostApi->openAsioDeviceIndex != asioDeviceIndex )
{
return paDeviceUnavailable;
@@ -1534,7 +1534,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
goto done;
}
}
-
+
/* query for sample rate support */
asioError = ASIOCanSampleRate( sampleRate );
if( asioError == ASE_NoClock || asioError == ASE_NotPresent )
@@ -1659,9 +1659,9 @@ static void ZeroOutputBuffers( PaAsioStream *stream, long index )
}
-/* return the next power of two >= x.
- Returns the input parameter if it is already a power of two.
- http://stackoverflow.com/questions/364985/algorithm-for-finding-the-smallest-power-of-two-thats-greater-or-equal-to-a-giv
+/* return the next power of two >= x.
+ Returns the input parameter if it is already a power of two.
+ http://stackoverflow.com/questions/364985/algorithm-for-finding-the-smallest-power-of-two-thats-greater-or-equal-to-a-giv
*/
static unsigned long NextPowerOfTwo( unsigned long x )
{
@@ -1671,8 +1671,8 @@ static unsigned long NextPowerOfTwo( unsigned long x )
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
- /* If you needed to deal with numbers > 2^32 the following would be needed.
- For latencies, we don't deal with values this large.
+ /* If you needed to deal with numbers > 2^32 the following would be needed.
+ For latencies, we don't deal with values this large.
x |= x >> 16;
*/
@@ -1680,16 +1680,16 @@ static unsigned long NextPowerOfTwo( unsigned long x )
}
-static unsigned long SelectHostBufferSizeForUnspecifiedUserFramesPerBuffer(
+static unsigned long SelectHostBufferSizeForUnspecifiedUserFramesPerBuffer(
unsigned long targetBufferingLatencyFrames, PaAsioDriverInfo *driverInfo )
{
- /* Choose a host buffer size based only on targetBufferingLatencyFrames and the
- device's supported buffer sizes. Always returns a valid value.
- */
+ /* Choose a host buffer size based only on targetBufferingLatencyFrames and the
+ device's supported buffer sizes. Always returns a valid value.
+ */
- unsigned long result;
+ unsigned long result;
- if( targetBufferingLatencyFrames <= (unsigned long)driverInfo->bufferMinSize )
+ if( targetBufferingLatencyFrames <= (unsigned long)driverInfo->bufferMinSize )
{
result = driverInfo->bufferMinSize;
}
@@ -1699,18 +1699,18 @@ static unsigned long SelectHostBufferSizeForUnspecifiedUserFramesPerBuffer(
}
else
{
- if( driverInfo->bufferGranularity == 0 ) /* single fixed host buffer size */
+ if( driverInfo->bufferGranularity == 0 ) /* single fixed host buffer size */
{
- /* The documentation states that bufferGranularity should be zero
- when bufferMinSize, bufferMaxSize and bufferPreferredSize are the
+ /* The documentation states that bufferGranularity should be zero
+ when bufferMinSize, bufferMaxSize and bufferPreferredSize are the
same. We assume that is the case.
*/
result = driverInfo->bufferPreferredSize;
}
- else if( driverInfo->bufferGranularity == -1 ) /* power-of-two */
+ else if( driverInfo->bufferGranularity == -1 ) /* power-of-two */
{
- /* We assume bufferMinSize and bufferMaxSize are powers of two. */
+ /* We assume bufferMinSize and bufferMaxSize are powers of two. */
result = NextPowerOfTwo( targetBufferingLatencyFrames );
@@ -1723,9 +1723,9 @@ static unsigned long SelectHostBufferSizeForUnspecifiedUserFramesPerBuffer(
else /* modulo bufferGranularity */
{
/* round up to the next multiple of granularity */
- unsigned long n = (targetBufferingLatencyFrames + driverInfo->bufferGranularity - 1)
+ unsigned long n = (targetBufferingLatencyFrames + driverInfo->bufferGranularity - 1)
/ driverInfo->bufferGranularity;
-
+
result = n * driverInfo->bufferGranularity;
if( result < (unsigned long)driverInfo->bufferMinSize )
@@ -1736,137 +1736,137 @@ static unsigned long SelectHostBufferSizeForUnspecifiedUserFramesPerBuffer(
}
}
- return result;
+ return result;
}
-static unsigned long SelectHostBufferSizeForSpecifiedUserFramesPerBuffer(
+static unsigned long SelectHostBufferSizeForSpecifiedUserFramesPerBuffer(
unsigned long targetBufferingLatencyFrames, unsigned long userFramesPerBuffer,
PaAsioDriverInfo *driverInfo )
{
- /* Select a host buffer size conforming to targetBufferingLatencyFrames
- and the device's supported buffer sizes.
- The return value will always be a multiple of userFramesPerBuffer.
- If a valid buffer size can not be found the function returns 0.
+ /* Select a host buffer size conforming to targetBufferingLatencyFrames
+ and the device's supported buffer sizes.
+ The return value will always be a multiple of userFramesPerBuffer.
+ If a valid buffer size can not be found the function returns 0.
- The current implementation uses a simple iterative search for clarity.
- Feel free to suggest a closed form solution.
- */
- unsigned long result = 0;
+ The current implementation uses a simple iterative search for clarity.
+ Feel free to suggest a closed form solution.
+ */
+ unsigned long result = 0;
- assert( userFramesPerBuffer != 0 );
-
- if( driverInfo->bufferGranularity == 0 ) /* single fixed host buffer size */
+ assert( userFramesPerBuffer != 0 );
+
+ if( driverInfo->bufferGranularity == 0 ) /* single fixed host buffer size */
{
- /* The documentation states that bufferGranularity should be zero
- when bufferMinSize, bufferMaxSize and bufferPreferredSize are the
+ /* The documentation states that bufferGranularity should be zero
+ when bufferMinSize, bufferMaxSize and bufferPreferredSize are the
same. We assume that is the case.
*/
- if( (driverInfo->bufferPreferredSize % userFramesPerBuffer) == 0 )
- result = driverInfo->bufferPreferredSize;
+ if( (driverInfo->bufferPreferredSize % userFramesPerBuffer) == 0 )
+ result = driverInfo->bufferPreferredSize;
}
- else if( driverInfo->bufferGranularity == -1 ) /* power-of-two */
+ else if( driverInfo->bufferGranularity == -1 ) /* power-of-two */
{
- /* We assume bufferMinSize and bufferMaxSize are powers of two. */
+ /* We assume bufferMinSize and bufferMaxSize are powers of two. */
- /* Search all powers of two in the range [bufferMinSize,bufferMaxSize]
+ /* Search all powers of two in the range [bufferMinSize,bufferMaxSize]
for multiples of userFramesPerBuffer. We prefer the first multiple
- that is equal or greater than targetBufferingLatencyFrames, or
- failing that, the largest multiple less than
+ that is equal or greater than targetBufferingLatencyFrames, or
+ failing that, the largest multiple less than
targetBufferingLatencyFrames.
*/
- unsigned long x = (unsigned long)driverInfo->bufferMinSize;
- do {
- if( (x % userFramesPerBuffer) == 0 )
- {
+ unsigned long x = (unsigned long)driverInfo->bufferMinSize;
+ do {
+ if( (x % userFramesPerBuffer) == 0 )
+ {
/* any multiple of userFramesPerBuffer is acceptable */
- result = x;
- if( result >= targetBufferingLatencyFrames )
- break; /* stop. a value >= to targetBufferingLatencyFrames is ideal. */
- }
+ result = x;
+ if( result >= targetBufferingLatencyFrames )
+ break; /* stop. a value >= to targetBufferingLatencyFrames is ideal. */
+ }
- x *= 2;
- } while( x <= (unsigned long)driverInfo->bufferMaxSize );
+ x *= 2;
+ } while( x <= (unsigned long)driverInfo->bufferMaxSize );
}
else /* modulo granularity */
{
- /* We assume bufferMinSize is a multiple of bufferGranularity. */
+ /* We assume bufferMinSize is a multiple of bufferGranularity. */
- /* Search all multiples of bufferGranularity in the range
- [bufferMinSize,bufferMaxSize] for multiples of userFramesPerBuffer.
- We prefer the first multiple that is equal or greater than
- targetBufferingLatencyFrames, or failing that, the largest multiple
+ /* Search all multiples of bufferGranularity in the range
+ [bufferMinSize,bufferMaxSize] for multiples of userFramesPerBuffer.
+ We prefer the first multiple that is equal or greater than
+ targetBufferingLatencyFrames, or failing that, the largest multiple
less than targetBufferingLatencyFrames.
*/
- unsigned long x = (unsigned long)driverInfo->bufferMinSize;
- do {
- if( (x % userFramesPerBuffer) == 0 )
- {
+ unsigned long x = (unsigned long)driverInfo->bufferMinSize;
+ do {
+ if( (x % userFramesPerBuffer) == 0 )
+ {
/* any multiple of userFramesPerBuffer is acceptable */
- result = x;
- if( result >= targetBufferingLatencyFrames )
- break; /* stop. a value >= to targetBufferingLatencyFrames is ideal. */
- }
+ result = x;
+ if( result >= targetBufferingLatencyFrames )
+ break; /* stop. a value >= to targetBufferingLatencyFrames is ideal. */
+ }
- x += driverInfo->bufferGranularity;
- } while( x <= (unsigned long)driverInfo->bufferMaxSize );
+ x += driverInfo->bufferGranularity;
+ } while( x <= (unsigned long)driverInfo->bufferMaxSize );
}
- return result;
+ return result;
}
-static unsigned long SelectHostBufferSize(
- unsigned long targetBufferingLatencyFrames,
+static unsigned long SelectHostBufferSize(
+ unsigned long targetBufferingLatencyFrames,
unsigned long userFramesPerBuffer, PaAsioDriverInfo *driverInfo )
{
unsigned long result = 0;
- /* We select a host buffer size based on the following requirements
+ /* We select a host buffer size based on the following requirements
(in priority order):
- 1. The host buffer size must be permissible according to the ASIO
- driverInfo buffer size constraints (min, max, granularity or
+ 1. The host buffer size must be permissible according to the ASIO
+ driverInfo buffer size constraints (min, max, granularity or
powers-of-two).
- 2. If the user specifies a non-zero framesPerBuffer parameter
- (userFramesPerBuffer here) the host buffer should be a multiple of
+ 2. If the user specifies a non-zero framesPerBuffer parameter
+ (userFramesPerBuffer here) the host buffer should be a multiple of
this (subject to the constraints in (1) above).
- [NOTE: Where no permissible host buffer size is a multiple of
- userFramesPerBuffer, we choose a value as if userFramesPerBuffer were
- zero (i.e. we ignore it). This strategy is open for review ~ perhaps
- there are still "more optimal" buffer sizes related to
+ [NOTE: Where no permissible host buffer size is a multiple of
+ userFramesPerBuffer, we choose a value as if userFramesPerBuffer were
+ zero (i.e. we ignore it). This strategy is open for review ~ perhaps
+ there are still "more optimal" buffer sizes related to
userFramesPerBuffer that we could use.]
- 3. The host buffer size should be greater than or equal to
- targetBufferingLatencyFrames, subject to (1) and (2) above. Where it
- is not possible to select a host buffer size equal or greater than
- targetBufferingLatencyFrames, the highest buffer size conforming to
+ 3. The host buffer size should be greater than or equal to
+ targetBufferingLatencyFrames, subject to (1) and (2) above. Where it
+ is not possible to select a host buffer size equal or greater than
+ targetBufferingLatencyFrames, the highest buffer size conforming to
(1) and (2) should be chosen.
*/
- if( userFramesPerBuffer != 0 )
- {
- /* userFramesPerBuffer is specified, try to find a buffer size that's
+ if( userFramesPerBuffer != 0 )
+ {
+ /* userFramesPerBuffer is specified, try to find a buffer size that's
a multiple of it */
- result = SelectHostBufferSizeForSpecifiedUserFramesPerBuffer(
+ result = SelectHostBufferSizeForSpecifiedUserFramesPerBuffer(
targetBufferingLatencyFrames, userFramesPerBuffer, driverInfo );
- }
+ }
- if( result == 0 )
- {
- /* either userFramesPerBuffer was not specified, or we couldn't find a
- host buffer size that is a multiple of it. Select a host buffer size
- according to targetBufferingLatencyFrames and the ASIO driverInfo
+ if( result == 0 )
+ {
+ /* either userFramesPerBuffer was not specified, or we couldn't find a
+ host buffer size that is a multiple of it. Select a host buffer size
+ according to targetBufferingLatencyFrames and the ASIO driverInfo
buffer size constraints.
- */
- result = SelectHostBufferSizeForUnspecifiedUserFramesPerBuffer(
+ */
+ result = SelectHostBufferSizeForUnspecifiedUserFramesPerBuffer(
targetBufferingLatencyFrames, driverInfo );
- }
+ }
- return result;
+ return result;
}
@@ -1893,10 +1893,10 @@ static PaError ValidateAsioSpecificStreamInfo(
return paIncompatibleHostApiSpecificStreamInfo;
for( int i=0; i < streamParameters->channelCount; ++i ){
- if( (*channelSelectors)[i] < 0
+ if( (*channelSelectors)[i] < 0
|| (*channelSelectors)[i] >= deviceChannelCount ){
return paInvalidChannelCount;
- }
+ }
}
}
@@ -1914,7 +1914,7 @@ static bool IsUsingExternalClockSource()
/* davidv: listing ASIO Clock sources. there is an ongoing investigation by
me about whether or not to call ASIOSetSampleRate if an external Clock is
used. A few drivers expected different things here */
-
+
asioError = ASIOGetClockSources(clocks, &numSources);
if( asioError != ASE_OK ){
PA_DEBUG(("ERROR: ASIOGetClockSources: %s\n", PaAsio_GetAsioErrorText(asioError) ));
@@ -1922,7 +1922,7 @@ static bool IsUsingExternalClockSource()
PA_DEBUG(("INFO ASIOGetClockSources listing %d clocks\n", numSources ));
for (int i=0;ichannelNum = i;
}
-
+
info->buffers[0] = info->buffers[1] = 0;
}
@@ -2273,14 +2273,14 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else /* Using callback interface... */
{
/* Select the host buffer size based on user framesPerBuffer and the
- maximum of suggestedInputLatencyFrames and
+ maximum of suggestedInputLatencyFrames and
suggestedOutputLatencyFrames.
- We should subtract any fixed known driver latency from
+ We should subtract any fixed known driver latency from
suggestedLatencyFrames before computing the host buffer size.
- However, the ASIO API doesn't provide a method for determining fixed
- latencies independent of the host buffer size. ASIOGetLatencies()
- only returns latencies after the buffer size has been configured, so
+ However, the ASIO API doesn't provide a method for determining fixed
+ latencies independent of the host buffer size. ASIOGetLatencies()
+ only returns latencies after the buffer size has been configured, so
we can't reliably use it to determine fixed latencies here.
We could set the preferred buffer size and then subtract it from
@@ -2288,12 +2288,12 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
reliable, so we don't do it.
*/
- unsigned long targetBufferingLatencyFrames =
+ unsigned long targetBufferingLatencyFrames =
(( suggestedInputLatencyFrames > suggestedOutputLatencyFrames )
- ? suggestedInputLatencyFrames
+ ? suggestedInputLatencyFrames
: suggestedOutputLatencyFrames);
- framesPerHostBuffer = SelectHostBufferSize( targetBufferingLatencyFrames,
+ framesPerHostBuffer = SelectHostBufferSize( targetBufferingLatencyFrames,
framesPerBuffer, driverInfo );
}
@@ -2404,8 +2404,8 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
if( inputChannelCount > 0 )
{
- /* FIXME: assume all channels use the same type for now
-
+ /* FIXME: assume all channels use the same type for now
+
see: "ASIO devices with multiple sample formats are unsupported"
http://www.portaudio.com/trac/ticket/106
*/
@@ -2425,8 +2425,8 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
if( outputChannelCount > 0 )
{
- /* FIXME: assume all channels use the same type for now
-
+ /* FIXME: assume all channels use the same type for now
+
see: "ASIO devices with multiple sample formats are unsupported"
http://www.portaudio.com/trac/ticket/106
*/
@@ -2444,7 +2444,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->outputBufferConverter = 0;
}
- /* Values returned by ASIOGetLatencies() include the latency introduced by
+ /* Values returned by ASIOGetLatencies() include the latency introduced by
the ASIO double buffer. */
ASIOGetLatencies( &stream->asioInputLatencyFrames, &stream->asioOutputLatencyFrames );
@@ -2729,14 +2729,14 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
// buffer processor latency. it reports the added latency separately
PA_DEBUG(("PaAsio : ASIO InputLatency = %ld (%ld ms), added buffProc:%ld (%ld ms)\n",
stream->asioInputLatencyFrames,
- (long)((stream->asioInputLatencyFrames*1000)/ sampleRate),
+ (long)((stream->asioInputLatencyFrames*1000)/ sampleRate),
PaUtil_GetBufferProcessorInputLatencyFrames(&stream->bufferProcessor),
(long)((PaUtil_GetBufferProcessorInputLatencyFrames(&stream->bufferProcessor)*1000)/ sampleRate)
));
PA_DEBUG(("PaAsio : ASIO OuputLatency = %ld (%ld ms), added buffProc:%ld (%ld ms)\n",
stream->asioOutputLatencyFrames,
- (long)((stream->asioOutputLatencyFrames*1000)/ sampleRate),
+ (long)((stream->asioOutputLatencyFrames*1000)/ sampleRate),
PaUtil_GetBufferProcessorOutputLatencyFrames(&stream->bufferProcessor),
(long)((PaUtil_GetBufferProcessorOutputLatencyFrames(&stream->bufferProcessor)*1000)/ sampleRate)
));
@@ -2750,7 +2750,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->postOutput = driverInfo->postOutput;
stream->isStopped = 1;
stream->isActive = 0;
-
+
asioHostApi->openAsioDeviceIndex = asioDeviceIndex;
theAsioStream = stream;
@@ -2806,9 +2806,9 @@ error:
ASIODisposeBuffers();
if( asioIsInitialized )
- {
- UnloadAsioDriver();
- }
+ {
+ UnloadAsioDriver();
+ }
return result;
}
@@ -2972,17 +2972,17 @@ static ASIOTime *bufferSwitchTimeInfo( ASIOTime *timeInfo, long index, ASIOBool
}
int buffersDone = 0;
-
+
do
{
if( buffersDone > 0 )
{
// this is a reentered buffer, we missed processing it on time
// set the input overflow and output underflow flags as appropriate
-
+
if( theAsioStream->inputChannelCount > 0 )
theAsioStream->callbackFlags |= paInputOverflow;
-
+
if( theAsioStream->outputChannelCount > 0 )
theAsioStream->callbackFlags |= paOutputUnderflow;
}
@@ -3177,7 +3177,7 @@ previousTime = paTimeInfo.currentTime;
}
}
}
-
+
++buffersDone;
}while( PaAsio_AtomicDecrement(&theAsioStream->reenterCount) >= 0 );
@@ -3518,7 +3518,7 @@ static PaError AbortStream( PaStream *s )
static PaError IsStreamStopped( PaStream *s )
{
PaAsioStream *stream = (PaAsioStream*)s;
-
+
return stream->isStopped;
}
@@ -3677,7 +3677,7 @@ static PaError ReadStream( PaStream *s ,
&lRingBufferSize2nd);
/* Set number of frames to be copied from the ring buffer. */
- PaUtil_SetInputFrameCount( pBp, lRingBufferSize1st );
+ PaUtil_SetInputFrameCount( pBp, lRingBufferSize1st );
/* Setup ring buffer access. */
PaUtil_SetInterleavedInputChannels(pBp , /* Buffer processor. */
0 , /* The first channel's index. */
@@ -3824,7 +3824,7 @@ static PaError WriteStream( PaStream *s ,
/* If block processing has stopped, abort! */
if( blockingState->stopFlag ) { return result = paStreamIsStopped; }
-
+
/* If a timeout is encountered, give up eventually. */
return result = paTimedOut;
}
@@ -3849,7 +3849,7 @@ static PaError WriteStream( PaStream *s ,
&lRingBufferSize2nd);
/* Set number of frames to be copied to the ring buffer. */
- PaUtil_SetOutputFrameCount( pBp, lRingBufferSize1st );
+ PaUtil_SetOutputFrameCount( pBp, lRingBufferSize1st );
/* Setup ring buffer access. */
PaUtil_SetInterleavedOutputChannels(pBp , /* Buffer processor. */
0 , /* The first channel's index. */
@@ -4093,10 +4093,10 @@ PaError PaAsio_ShowControlPanel( PaDeviceIndex device, void* systemSpecific )
}
PA_DEBUG(("PaAsio_ShowControlPanel: ASIOInit(): %s\n", PaAsio_GetAsioErrorText(asioError) ));
-PA_DEBUG(("asioVersion: ASIOInit(): %ld\n", asioDriverInfo.asioVersion ));
-PA_DEBUG(("driverVersion: ASIOInit(): %ld\n", asioDriverInfo.driverVersion ));
-PA_DEBUG(("Name: ASIOInit(): %s\n", asioDriverInfo.name ));
-PA_DEBUG(("ErrorMessage: ASIOInit(): %s\n", asioDriverInfo.errorMessage ));
+PA_DEBUG(("asioVersion: ASIOInit(): %ld\n", asioDriverInfo.asioVersion ));
+PA_DEBUG(("driverVersion: ASIOInit(): %ld\n", asioDriverInfo.driverVersion ));
+PA_DEBUG(("Name: ASIOInit(): %s\n", asioDriverInfo.name ));
+PA_DEBUG(("ErrorMessage: ASIOInit(): %s\n", asioDriverInfo.errorMessage ));
asioError = ASIOControlPanel();
if( asioError != ASE_OK )
@@ -4124,9 +4124,9 @@ PA_DEBUG(("PaAsio_ShowControlPanel: ASIOExit(): %s\n", PaAsio_GetAsioErrorText(a
error:
if( asioIsInitialized )
- {
- ASIOExit();
- }
+ {
+ ASIOExit();
+ }
PaWinUtil_CoUninitialize( paASIO, &comInitializationResult );
@@ -4161,7 +4161,7 @@ PaError PaAsio_GetInputChannelName( PaDeviceIndex device, int channelIndex,
*channelName = asioDeviceInfo->asioChannelInfos[channelIndex].name;
return paNoError;
-
+
error:
return result;
}
@@ -4195,7 +4195,7 @@ PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex,
asioDeviceInfo->commonDeviceInfo.maxInputChannels + channelIndex].name;
return paNoError;
-
+
error:
return result;
}
@@ -4211,7 +4211,7 @@ static PaError GetAsioStreamPointer( PaAsioStream **stream, PaStream *s )
PaError result;
PaUtilHostApiRepresentation *hostApi;
PaAsioHostApiRepresentation *asioHostApi;
-
+
result = PaUtil_ValidateStreamPointer( s );
if( result != paNoError )
return result;
@@ -4221,7 +4221,7 @@ static PaError GetAsioStreamPointer( PaAsioStream **stream, PaStream *s )
return result;
asioHostApi = (PaAsioHostApiRepresentation*)hostApi;
-
+
if( PA_STREAM_REP( s )->streamInterface == &asioHostApi->callbackStreamInterface
|| PA_STREAM_REP( s )->streamInterface == &asioHostApi->blockingStreamInterface )
{
From 238d8db31a094eee59d187d734efd414245edb89 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 21 Jan 2021 22:23:23 +1100
Subject: [PATCH 081/157] Clean up whitespace in examples/ in preparation for
.editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing
whitespace. Ensure EOL at EOF. (#416)
---
examples/pa_devs.c | 26 +++----
examples/pa_fuzz.c | 20 +++---
examples/paex_mono_asio_channel_select.c | 24 +++----
examples/paex_ocean_shore.c | 48 ++++++-------
examples/paex_pink.c | 42 +++++------
examples/paex_read_write_wire.c | 18 ++---
examples/paex_record.c | 18 ++---
examples/paex_record_file.c | 16 ++---
examples/paex_saw.c | 16 ++---
examples/paex_sine.c | 28 ++++----
examples/paex_sine_c++.cpp | 16 ++---
examples/paex_wmme_ac3.c | 52 +++++++-------
examples/paex_wmme_surround.c | 92 ++++++++++++------------
examples/paex_write_sine.c | 42 +++++------
examples/paex_write_sine_nonint.c | 42 +++++------
15 files changed, 250 insertions(+), 250 deletions(-)
diff --git a/examples/pa_devs.c b/examples/pa_devs.c
index 595a05d..27acfd5 100644
--- a/examples/pa_devs.c
+++ b/examples/pa_devs.c
@@ -1,7 +1,7 @@
/** @file pa_devs.c
- @ingroup examples_src
+ @ingroup examples_src
@brief List available devices, including device information.
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
@note Define PA_USE_ASIO=0 to compile this code on Windows without
ASIO support.
@@ -34,13 +34,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -106,14 +106,14 @@ int main(void)
PaStreamParameters inputParameters, outputParameters;
PaError err;
-
+
err = Pa_Initialize();
if( err != paNoError )
{
printf( "ERROR: Pa_Initialize returned 0x%x\n", err );
goto error;
}
-
+
printf( "PortAudio version: 0x%08X\n", Pa_GetVersion());
printf( "Version text: '%s'\n", Pa_GetVersionInfo()->versionText );
@@ -124,13 +124,13 @@ int main(void)
err = numDevices;
goto error;
}
-
+
printf( "Number of devices = %d\n", numDevices );
for( i=0; iname );
defaultDisplayed = 1;
}
-
+
if( i == Pa_GetDefaultOutputDevice() )
{
printf( (defaultDisplayed ? "," : "[") );
@@ -154,7 +154,7 @@ int main(void)
else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultOutputDevice )
{
const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
- printf( (defaultDisplayed ? "," : "[") );
+ printf( (defaultDisplayed ? "," : "[") );
printf( " Default %s Output", hostInfo->name );
defaultDisplayed = 1;
}
@@ -188,7 +188,7 @@ int main(void)
long minLatency, maxLatency, preferredLatency, granularity;
err = PaAsio_GetAvailableLatencyValues( i,
- &minLatency, &maxLatency, &preferredLatency, &granularity );
+ &minLatency, &maxLatency, &preferredLatency, &granularity );
printf( "ASIO minimum buffer size = %ld\n", minLatency );
printf( "ASIO maximum buffer size = %ld\n", maxLatency );
@@ -210,7 +210,7 @@ int main(void)
inputParameters.sampleFormat = paInt16;
inputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
inputParameters.hostApiSpecificStreamInfo = NULL;
-
+
outputParameters.device = i;
outputParameters.channelCount = deviceInfo->maxOutputChannels;
outputParameters.sampleFormat = paInt16;
diff --git a/examples/pa_fuzz.c b/examples/pa_fuzz.c
index 337e06d..0c24d35 100644
--- a/examples/pa_fuzz.c
+++ b/examples/pa_fuzz.c
@@ -1,7 +1,7 @@
/** @file pa_fuzz.c
- @ingroup examples_src
+ @ingroup examples_src
@brief Distort input like a fuzz box.
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -116,7 +116,7 @@ static int fuzzCallback( const void *inputBuffer, void *outputBuffer,
*out++ = *in++; /* right - clean */
}
}
-
+
return paContinue;
}
@@ -133,8 +133,8 @@ int main(void)
inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
if (inputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default input device.\n");
- goto error;
+ fprintf(stderr,"Error: No default input device.\n");
+ goto error;
}
inputParameters.channelCount = 2; /* stereo input */
inputParameters.sampleFormat = PA_SAMPLE_TYPE;
@@ -143,8 +143,8 @@ int main(void)
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = PA_SAMPLE_TYPE;
diff --git a/examples/paex_mono_asio_channel_select.c b/examples/paex_mono_asio_channel_select.c
index 71b0198..4b55d31 100644
--- a/examples/paex_mono_asio_channel_select.c
+++ b/examples/paex_mono_asio_channel_select.c
@@ -1,8 +1,8 @@
/** @file paex_mono_asio_channel_select.c
- @ingroup examples_src
- @brief Play a monophonic sine wave on a specific ASIO channel.
- @author Ross Bencina
- @author Phil Burk
+ @ingroup examples_src
+ @brief Play a monophonic sine wave on a specific ASIO channel.
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
@@ -36,13 +36,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -114,7 +114,7 @@ int main(void)
data.sine[i] = (float) (AMPLITUDE * sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. ));
}
data.phase = 0;
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
@@ -123,7 +123,7 @@ int main(void)
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
- /* Use an ASIO specific structure. WARNING - this is not portable. */
+ /* Use an ASIO specific structure. WARNING - this is not portable. */
asioOutputInfo.size = sizeof(PaAsioStreamInfo);
asioOutputInfo.hostApiType = paASIO;
asioOutputInfo.version = 1;
@@ -145,16 +145,16 @@ int main(void)
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
-
+
printf("Play for %d seconds.\n", NUM_SECONDS ); fflush(stdout);
Pa_Sleep( NUM_SECONDS * 1000 );
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
printf("Test finished.\n");
return err;
diff --git a/examples/paex_ocean_shore.c b/examples/paex_ocean_shore.c
index ae645d6..9424e8b 100644
--- a/examples/paex_ocean_shore.c
+++ b/examples/paex_ocean_shore.c
@@ -1,21 +1,21 @@
-/** @file paex_ocean_shore.c
- @ingroup examples_src
- @brief Generate Pink Noise using Gardner method, and make "waves". Provides an example of how to
+/** @file paex_ocean_shore.c
+ @ingroup examples_src
+ @brief Generate Pink Noise using Gardner method, and make "waves". Provides an example of how to
post stuff to/from the audio callback using lock-free FIFOs implemented by the PA ringbuffer.
- Optimization suggested by James McCartney uses a tree
- to select which random value to replace.
+ Optimization suggested by James McCartney uses a tree
+ to select which random value to replace.
- x x x x x x x x x x x x x x x x
- x x x x x x x x
- x x x x
- x x
- x
-
- Tree is generated by counting trailing zeros in an increasing index.
- When the index is zero, no random number is selected.
+ x x x x x x x x x x x x x x x x
+ x x x x x x x x
+ x x x x
+ x x
+ x
+
+ Tree is generated by counting trailing zeros in an increasing index.
+ When the index is zero, no random number is selected.
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
Robert Bielik
*/
/*
@@ -46,13 +46,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -80,7 +80,7 @@ typedef struct
}
PinkNoise;
-typedef struct
+typedef struct
{
float bq_b0;
float bq_b1;
@@ -213,7 +213,7 @@ unsigned GenerateWave( OceanWave* wave, float* output, unsigned noOfFrames )
targetLevel = wave->wave_envelope_max_level;
}
/* Calculate lowpass biquad coeffs
-
+
alpha = sin(w0)/(2*Q)
b0 = (1 - cos(w0))/2
@@ -324,8 +324,8 @@ paTestData;
static int patestCallback(const void* inputBuffer,
void* outputBuffer,
unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
void* userData)
{
int i;
@@ -427,8 +427,8 @@ int main(void)
/* Open a stereo PortAudio stream so we can hear the result. */
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Take the default output device. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* Stereo output, most likely supported. */
outputParameters.hostApiSpecificStreamInfo = NULL;
@@ -518,7 +518,7 @@ int main(void)
{
PaUtil_FreeMemory(data.rBufFromRTData);
}
-
+
Pa_Sleep(1000);
Pa_Terminate();
diff --git a/examples/paex_pink.c b/examples/paex_pink.c
index cd84324..519f979 100644
--- a/examples/paex_pink.c
+++ b/examples/paex_pink.c
@@ -1,20 +1,20 @@
/** @file paex_pink.c
- @ingroup examples_src
- @brief Generate Pink Noise using Gardner method.
+ @ingroup examples_src
+ @brief Generate Pink Noise using Gardner method.
- Optimization suggested by James McCartney uses a tree
- to select which random value to replace.
+ Optimization suggested by James McCartney uses a tree
+ to select which random value to replace.
- x x x x x x x x x x x x x x x x
- x x x x x x x x
- x x x x
- x x
- x
-
- Tree is generated by counting trailing zeros in an increasing index.
- When the index is zero, no random number is selected.
+ x x x x x x x x x x x x x x x x
+ x x x x x x x x
+ x x x x
+ x x
+ x
+
+ Tree is generated by counting trailing zeros in an increasing index.
+ When the index is zero, no random number is selected.
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -44,13 +44,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -172,8 +172,8 @@ paTestData;
static int patestCallback(const void* inputBuffer,
void* outputBuffer,
unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
void* userData)
{
int finished;
@@ -214,7 +214,7 @@ int main(void)
int totalSamps;
static const double SR = 44100.0;
static const int FPB = 2048; /* Frames per buffer: 46 ms buffers. */
-
+
/* Initialize two pink noise signals with different numbers of rows. */
InitializePinkNoise( &data.leftPink, 12 );
InitializePinkNoise( &data.rightPink, 16 );
@@ -237,8 +237,8 @@ int main(void)
/* Open a stereo PortAudio stream so we can hear the result. */
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Take the default output device. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* Stereo output, most likely supported. */
outputParameters.hostApiSpecificStreamInfo = NULL;
diff --git a/examples/paex_read_write_wire.c b/examples/paex_read_write_wire.c
index 813c74d..69f15ff 100644
--- a/examples/paex_read_write_wire.c
+++ b/examples/paex_read_write_wire.c
@@ -1,7 +1,7 @@
/** @file paex_read_write_wire.c
- @ingroup examples_src
- @brief Tests full duplex blocking I/O by passing input straight to output.
- @author Bjorn Roche. XO Audio LLC for Z-Systems Engineering.
+ @ingroup examples_src
+ @brief Tests full duplex blocking I/O by passing input straight to output.
+ @author Bjorn Roche. XO Audio LLC for Z-Systems Engineering.
@author based on code by: Phil Burk http://www.softsynth.com
@author based on code by: Ross Bencina rossb@audiomulch.com
*/
@@ -179,22 +179,22 @@ int main(void)
xrun:
printf("err = %d\n", err); fflush(stdout);
if( stream ) {
- Pa_AbortStream( stream );
- Pa_CloseStream( stream );
+ Pa_AbortStream( stream );
+ Pa_CloseStream( stream );
}
free( sampleBlock );
Pa_Terminate();
if( err & paInputOverflow )
- fprintf( stderr, "Input Overflow.\n" );
+ fprintf( stderr, "Input Overflow.\n" );
if( err & paOutputUnderflow )
- fprintf( stderr, "Output Underflow.\n" );
+ fprintf( stderr, "Output Underflow.\n" );
return -2;
error1:
free( sampleBlock );
error2:
if( stream ) {
- Pa_AbortStream( stream );
- Pa_CloseStream( stream );
+ Pa_AbortStream( stream );
+ Pa_CloseStream( stream );
}
Pa_Terminate();
fprintf( stderr, "An error occurred while using the portaudio stream\n" );
diff --git a/examples/paex_record.c b/examples/paex_record.c
index 4c9105c..4407787 100644
--- a/examples/paex_record.c
+++ b/examples/paex_record.c
@@ -1,7 +1,7 @@
/** @file paex_record.c
- @ingroup examples_src
- @brief Record input into an array; Save array to a file; Playback recorded data.
- @author Phil Burk http://www.softsynth.com
+ @ingroup examples_src
+ @brief Record input into an array; Save array to a file; Playback recorded data.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -326,15 +326,15 @@ int main(void)
{
err = Pa_StartStream( stream );
if( err != paNoError ) goto done;
-
+
printf("Waiting for playback to finish.\n"); fflush(stdout);
while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) Pa_Sleep(100);
if( err < 0 ) goto done;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto done;
-
+
printf("Done.\n"); fflush(stdout);
}
diff --git a/examples/paex_record_file.c b/examples/paex_record_file.c
index 1e1f473..c4e5b44 100644
--- a/examples/paex_record_file.c
+++ b/examples/paex_record_file.c
@@ -1,7 +1,7 @@
/** @file paex_record_file.c
- @ingroup examples_src
- @brief Record input into a file, then playback recorded data from file (Windows only at the moment)
- @author Robert Bielik
+ @ingroup examples_src
+ @brief Record input into a file, then playback recorded data from file (Windows only at the moment)
+ @author Robert Bielik
*/
/*
* $Id: paex_record_file.c 1752 2011-09-08 03:21:55Z philburk $
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -433,12 +433,12 @@ int main(void)
}
if( err < 0 ) goto done;
}
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto done;
fclose(data.file);
-
+
printf("Done.\n"); fflush(stdout);
}
diff --git a/examples/paex_saw.c b/examples/paex_saw.c
index 6f477b8..caec0b0 100644
--- a/examples/paex_saw.c
+++ b/examples/paex_saw.c
@@ -1,7 +1,7 @@
/** @file paex_saw.c
- @ingroup examples_src
- @brief Play a simple (aliasing) sawtooth wave.
- @author Phil Burk http://www.softsynth.com
+ @ingroup examples_src
+ @brief Play a simple (aliasing) sawtooth wave.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -92,14 +92,14 @@ int main(void)
{
PaStream *stream;
PaError err;
-
+
printf("PortAudio Test: output sawtooth wave.\n");
/* Initialize our data for use by callback. */
data.left_phase = data.right_phase = 0.0;
/* Initialize library before making any other calls. */
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
/* Open an audio I/O stream. */
err = Pa_OpenDefaultStream( &stream,
0, /* no input channels */
diff --git a/examples/paex_sine.c b/examples/paex_sine.c
index 99fecf7..50ef205 100644
--- a/examples/paex_sine.c
+++ b/examples/paex_sine.c
@@ -1,7 +1,7 @@
/** @file paex_sine.c
- @ingroup examples_src
- @brief Play a sine wave for several seconds.
- @author Ross Bencina
+ @ingroup examples_src
+ @brief Play a sine wave for several seconds.
+ @author Ross Bencina
@author Phil Burk
*/
/*
@@ -32,13 +32,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include
@@ -80,7 +80,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; isine[data->left_phase]; /* left */
@@ -90,7 +90,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
}
-
+
return paContinue;
}
@@ -99,8 +99,8 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
*/
static void StreamFinished( void* userData )
{
- paTestData *data = (paTestData *) userData;
- printf( "Stream Completed: %s\n", data->message );
+ paTestData *data = (paTestData *) userData;
+ printf( "Stream Completed: %s\n", data->message );
}
/*******************************************************************/
@@ -121,14 +121,14 @@ int main(void)
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
data.left_phase = data.right_phase = 0;
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
@@ -164,7 +164,7 @@ int main(void)
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
diff --git a/examples/paex_sine_c++.cpp b/examples/paex_sine_c++.cpp
index 64d7829..5d96522 100644
--- a/examples/paex_sine_c++.cpp
+++ b/examples/paex_sine_c++.cpp
@@ -1,7 +1,7 @@
/** @file paex_sine.c
- @ingroup examples_src
- @brief Play a sine wave for several seconds.
- @author Ross Bencina
+ @ingroup examples_src
+ @brief Play a sine wave for several seconds.
+ @author Ross Bencina
@author Phil Burk
*/
/*
@@ -32,13 +32,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include
@@ -189,7 +189,7 @@ private:
PaStreamCallbackFlags statusFlags,
void *userData )
{
- /* Here we cast userData to Sine* type so we can call the instance method paCallbackMethod, we can do that since
+ /* Here we cast userData to Sine* type so we can call the instance method paCallbackMethod, we can do that since
we called Pa_OpenStream with 'this' for userData */
return ((Sine*)userData)->paCallbackMethod(inputBuffer, outputBuffer,
framesPerBuffer,
@@ -247,7 +247,7 @@ int main(void)
Sine sine;
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
-
+
ScopedPaHandler paInit;
if( paInit.result() != paNoError ) goto error;
diff --git a/examples/paex_wmme_ac3.c b/examples/paex_wmme_ac3.c
index ac9212a..67c2786 100644
--- a/examples/paex_wmme_ac3.c
+++ b/examples/paex_wmme_ac3.c
@@ -1,7 +1,7 @@
/** @file paex_wmme_ac3.c
- @ingroup examples_src
- @brief Use WMME-specific interface to send raw AC3 data to a S/PDIF output.
- @author Ross Bencina
+ @ingroup examples_src
+ @brief Use WMME-specific interface to send raw AC3 data to a S/PDIF output.
+ @author Ross Bencina
*/
/*
* $Id: $
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -91,17 +91,17 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) inputBuffer;
/* stream out contents of data->buffer looping at end */
-
+
for( i=0; ibuffer[ data->playbackIndex++ ];
if( data->playbackIndex >= data->bufferSampleCount )
data->playbackIndex = 0; /* loop at end of buffer */
- }
- }
-
+ }
+ }
+
return paContinue;
}
@@ -120,10 +120,10 @@ int main(int argc, char* argv[])
printf("usage: patest_wmme_ac3 fileName [paDeviceIndex]\n");
printf("**IMPORTANT*** The provided file must include the spdif preamble at the start of every AC-3 frame. Using a normal ac3 file won't work.\n");
- printf("PortAudio Test: output a raw spdif ac3 stream. SR = %d, BufSize = %d, Chans = %d\n",
+ printf("PortAudio Test: output a raw spdif ac3 stream. SR = %d, BufSize = %d, Chans = %d\n",
SAMPLE_RATE, FRAMES_PER_BUFFER, CHANNEL_COUNT);
-
+
if( argc >= 2 )
fileName = argv[1];
@@ -154,14 +154,14 @@ int main(int argc, char* argv[])
err = Pa_Initialize();
if( err != paNoError ) goto error;
- deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
- if( argc >= 3 ){
- sscanf( argv[1], "%d", &deviceIndex );
- }
+ deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
+ if( argc >= 3 ){
+ sscanf( argv[1], "%d", &deviceIndex );
+ }
+
+ printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
- printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
-
outputParameters.device = deviceIndex;
outputParameters.channelCount = CHANNEL_COUNT;
outputParameters.sampleFormat = paInt16; /* IMPORTANT must use paInt16 for WMME AC3 */
@@ -169,17 +169,17 @@ int main(int argc, char* argv[])
outputParameters.hostApiSpecificStreamInfo = NULL;
wmmeStreamInfo.size = sizeof(PaWinMmeStreamInfo);
- wmmeStreamInfo.hostApiType = paMME;
+ wmmeStreamInfo.hostApiType = paMME;
wmmeStreamInfo.version = 1;
wmmeStreamInfo.flags = paWinMmeWaveFormatDolbyAc3Spdif;
outputParameters.hostApiSpecificStreamInfo = &wmmeStreamInfo;
- if( Pa_IsFormatSupported( 0, &outputParameters, SAMPLE_RATE ) == paFormatIsSupported ){
- printf( "Pa_IsFormatSupported reports device will support %d channels.\n", CHANNEL_COUNT );
- }else{
- printf( "Pa_IsFormatSupported reports device will not support %d channels.\n", CHANNEL_COUNT );
- }
+ if( Pa_IsFormatSupported( 0, &outputParameters, SAMPLE_RATE ) == paFormatIsSupported ){
+ printf( "Pa_IsFormatSupported reports device will support %d channels.\n", CHANNEL_COUNT );
+ }else{
+ printf( "Pa_IsFormatSupported reports device will not support %d channels.\n", CHANNEL_COUNT );
+ }
err = Pa_OpenStream(
&stream,
@@ -207,7 +207,7 @@ int main(int argc, char* argv[])
Pa_Terminate();
free( data.buffer );
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
diff --git a/examples/paex_wmme_surround.c b/examples/paex_wmme_surround.c
index dfccc99..86a7e37 100644
--- a/examples/paex_wmme_surround.c
+++ b/examples/paex_wmme_surround.c
@@ -1,7 +1,7 @@
/** @file paex_wmme_surround.c
- @ingroup examples_src
- @brief Use WMME-specific channelMask to request 5.1 surround sound output.
- @author Ross Bencina
+ @ingroup examples_src
+ @brief Use WMME-specific channelMask to request 5.1 surround sound output.
+ @author Ross Bencina
*/
/*
* $Id: $
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -67,9 +67,9 @@
typedef struct
{
float sine[TABLE_SIZE];
- int phase;
- int currentChannel;
- int cycleCount;
+ int phase;
+ int currentChannel;
+ int cycleCount;
}
paTestData;
@@ -90,31 +90,31 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; icurrentChannel && data->cycleCount < 4410 ){
- *out++ = data->sine[data->phase];
- data->phase += 1 + j; // play each channel at a different pitch so they can be distinguished
- if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
- }else{
- *out++ = 0;
- }
- }
-
- data->cycleCount++;
- if( data->cycleCount > 44100 ){
- data->cycleCount = 0;
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
+ if( j == data->currentChannel && data->cycleCount < 4410 ){
+ *out++ = data->sine[data->phase];
+ data->phase += 1 + j; // play each channel at a different pitch so they can be distinguished
+ if( data->phase >= TABLE_SIZE ){
+ data->phase -= TABLE_SIZE;
+ }
+ }else{
+ *out++ = 0;
+ }
+ }
+
+ data->cycleCount++;
+ if( data->cycleCount > 44100 ){
+ data->cycleCount = 0;
+
+ ++data->currentChannel;
+ if( data->currentChannel >= CHANNEL_COUNT )
+ data->currentChannel -= CHANNEL_COUNT;
+ }
+ }
- ++data->currentChannel;
- if( data->currentChannel >= CHANNEL_COUNT )
- data->currentChannel -= CHANNEL_COUNT;
- }
- }
-
return paContinue;
}
@@ -134,12 +134,12 @@ int main(int argc, char* argv[])
err = Pa_Initialize();
if( err != paNoError ) goto error;
- deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
- if( argc == 2 ){
- sscanf( argv[1], "%d", &deviceIndex );
- }
+ deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
+ if( argc == 2 ){
+ sscanf( argv[1], "%d", &deviceIndex );
+ }
- printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
+ printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
/* initialise sinusoidal wavetable */
for( i=0; i
+ @ingroup examples_src
+ @brief Play a sine wave for several seconds using the blocking API (Pa_WriteStream())
+ @author Ross Bencina
@author Phil Burk
*/
/*
@@ -32,13 +32,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -71,23 +71,23 @@ int main(void)
int right_inc = 3; /* higher pitch so we can distinguish left and right. */
int i, j, k;
int bufferCount;
-
+
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
-
+
/* initialise sinusoidal wavetable */
for( i=0; ierrorCode, hostErrorInfo->hostApiType );
- fprintf( stderr, "Host API error = %s\n", hostErrorInfo->errorText );
- }
+ // Print more information about the error.
+ if( err == paUnanticipatedHostError )
+ {
+ const PaHostErrorInfo *hostErrorInfo = Pa_GetLastHostErrorInfo();
+ fprintf( stderr, "Host API error = #%ld, hostApiType = %d\n", hostErrorInfo->errorCode, hostErrorInfo->hostApiType );
+ fprintf( stderr, "Host API error = %s\n", hostErrorInfo->errorText );
+ }
Pa_Terminate();
return err;
}
diff --git a/examples/paex_write_sine_nonint.c b/examples/paex_write_sine_nonint.c
index bc266c0..db78ed7 100644
--- a/examples/paex_write_sine_nonint.c
+++ b/examples/paex_write_sine_nonint.c
@@ -1,7 +1,7 @@
/** @file paex_write_sine_nonint.c
- @ingroup examples_src
- @brief Play a non-interleaved sine wave using the blocking API (Pa_WriteStream())
- @author Ross Bencina
+ @ingroup examples_src
+ @brief Play a non-interleaved sine wave using the blocking API (Pa_WriteStream())
+ @author Ross Bencina
@author Phil Burk
*/
/*
@@ -32,13 +32,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -63,11 +63,11 @@ int main(void)
PaStreamParameters outputParameters;
PaStream *stream;
PaError err;
-
- float leftBuffer[FRAMES_PER_BUFFER];
+
+ float leftBuffer[FRAMES_PER_BUFFER];
float rightBuffer[FRAMES_PER_BUFFER];
void *buffers[2]; /* points to both non-interleaved buffers. */
-
+
float sine[TABLE_SIZE]; /* sine wavetable */
int left_phase = 0;
int right_phase = 0;
@@ -76,23 +76,23 @@ int main(void)
int i, j, k;
int bufferCount;
-
+
printf("PortAudio Test: output sine wave NON-INTERLEAVED. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
-
+
/* initialise sinusoidal wavetable */
for( i=0; i
Date: Thu, 21 Jan 2021 22:32:05 +1100
Subject: [PATCH 082/157] Clean up whitespace in src\hostapi\dsound in
preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces.
Strip trailing whitespace. Ensure EOL at EOF. (#412)
---
src/hostapi/dsound/pa_win_ds.c | 254 ++++++++++++-------------
src/hostapi/dsound/pa_win_ds_dynlink.c | 10 +-
src/hostapi/dsound/pa_win_ds_dynlink.h | 10 +-
3 files changed, 137 insertions(+), 137 deletions(-)
diff --git a/src/hostapi/dsound/pa_win_ds.c b/src/hostapi/dsound/pa_win_ds.c
index f2dcf90..2a7f1a4 100644
--- a/src/hostapi/dsound/pa_win_ds.c
+++ b/src/hostapi/dsound/pa_win_ds.c
@@ -27,13 +27,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -278,7 +278,7 @@ typedef struct PaWinDsStream
UINT readOffset; /* last read position */
UINT inputBufferSizeBytes;
-
+
int hostBufferSizeFrames; /* input and output host ringbuffers have the same number of frames */
double framesWritten;
double secondsPerHostByte; /* Used to optimize latency calculation for outTime */
@@ -289,14 +289,14 @@ typedef struct PaWinDsStream
PaStreamFlags streamFlags;
int callbackResult;
HANDLE processingCompleted;
-
+
/* FIXME - move all below to PaUtilStreamRepresentation */
volatile int isStarted;
volatile int isActive;
volatile int stopProcessing; /* stop thread once existing buffers have been returned */
volatile int abortProcessing; /* stop thread immediately */
- UINT systemTimerResolutionPeriodMs; /* set to 0 if we were unable to set the timer period */
+ UINT systemTimerResolutionPeriodMs; /* set to 0 if we were unable to set the timer period */
#ifdef PA_WIN_DS_USE_WMME_TIMER
MMRESULT timerID;
@@ -361,7 +361,7 @@ See: http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprec
/*************************************************************************
** Return minimum workable latency required for this host. This is returned
** As the default stream latency in PaDeviceInfo.
-** Latency can be optionally set by user by setting an environment variable.
+** Latency can be optionally set by user by setting an environment variable.
** For example, to set latency to 200 msec, put:
**
** set PA_MIN_LATENCY_MSEC=200
@@ -405,7 +405,7 @@ static double PaWinDs_GetMinLatencySeconds( double sampleRate )
static char *DuplicateDeviceNameString( PaUtilAllocationGroup *allocations, const wchar_t* src )
{
char *result = 0;
-
+
if( src != NULL )
{
size_t len = WideCharToMultiByte(CP_UTF8, 0, src, -1, NULL, 0, NULL, NULL);
@@ -466,7 +466,7 @@ static PaError InitializeDSDeviceNameAndGUIDVector(
guidVector->items = (DSDeviceNameAndGUID*)LocalAlloc( LMEM_FIXED, sizeof(DSDeviceNameAndGUID) * guidVector->free );
if( guidVector->items == NULL )
result = paInsufficientMemory;
-
+
return result;
}
@@ -475,7 +475,7 @@ static PaError ExpandDSDeviceNameAndGUIDVector( DSDeviceNameAndGUIDVector *guidV
PaError result = paNoError;
DSDeviceNameAndGUID *newItems;
int i;
-
+
/* double size of vector */
int size = guidVector->count + guidVector->free;
guidVector->free += size;
@@ -504,7 +504,7 @@ static PaError ExpandDSDeviceNameAndGUIDVector( DSDeviceNameAndGUIDVector *guidV
LocalFree( guidVector->items );
guidVector->items = newItems;
- }
+ }
return result;
}
@@ -528,7 +528,7 @@ static PaError TerminateDSDeviceNameAndGUIDVector( DSDeviceNameAndGUIDVector *gu
}
/************************************************************************************
-** Collect preliminary device information during DirectSound enumeration
+** Collect preliminary device information during DirectSound enumeration
*/
static BOOL CALLBACK CollectGUIDsProcW(LPGUID lpGUID,
LPCWSTR lpszDesc,
@@ -549,7 +549,7 @@ static BOOL CALLBACK CollectGUIDsProcW(LPGUID lpGUID,
return FALSE;
}
}
-
+
/* Set GUID pointer, copy GUID to storage in DSDeviceNameAndGUIDVector. */
if( lpGUID == NULL )
{
@@ -559,7 +559,7 @@ static BOOL CALLBACK CollectGUIDsProcW(LPGUID lpGUID,
{
namesAndGUIDs->items[namesAndGUIDs->count].lpGUID =
&namesAndGUIDs->items[namesAndGUIDs->count].guid;
-
+
memcpy( &namesAndGUIDs->items[namesAndGUIDs->count].guid, lpGUID, sizeof(GUID) );
}
@@ -575,7 +575,7 @@ static BOOL CALLBACK CollectGUIDsProcW(LPGUID lpGUID,
++namesAndGUIDs->count;
--namesAndGUIDs->free;
-
+
return TRUE;
}
@@ -599,7 +599,7 @@ static BOOL CALLBACK KsPropertySetEnumerateCallback( PDSPROPERTY_DIRECTSOUNDDEVI
DSDeviceNamesAndGUIDs *deviceNamesAndGUIDs = (DSDeviceNamesAndGUIDs*)context;
/*
- Apparently data->Interface can be NULL in some cases.
+ Apparently data->Interface can be NULL in some cases.
Possibly virtual devices without hardware.
So we check for NULLs now. See mailing list message November 10, 2012:
"[Portaudio] portaudio initialization crash in KsPropertySetEnumerateCallback(pa_win_ds.c)"
@@ -613,7 +613,7 @@ static BOOL CALLBACK KsPropertySetEnumerateCallback( PDSPROPERTY_DIRECTSOUNDDEVI
if( deviceNamesAndGUIDs->outputNamesAndGUIDs.items[i].lpGUID
&& memcmp( &data->DeviceId, deviceNamesAndGUIDs->outputNamesAndGUIDs.items[i].lpGUID, sizeof(GUID) ) == 0 )
{
- deviceNamesAndGUIDs->outputNamesAndGUIDs.items[i].pnpInterface =
+ deviceNamesAndGUIDs->outputNamesAndGUIDs.items[i].pnpInterface =
(char*)DuplicateWCharString( deviceNamesAndGUIDs->winDsHostApi->allocations, data->Interface );
break;
}
@@ -626,7 +626,7 @@ static BOOL CALLBACK KsPropertySetEnumerateCallback( PDSPROPERTY_DIRECTSOUNDDEVI
if( deviceNamesAndGUIDs->inputNamesAndGUIDs.items[i].lpGUID
&& memcmp( &data->DeviceId, deviceNamesAndGUIDs->inputNamesAndGUIDs.items[i].lpGUID, sizeof(GUID) ) == 0 )
{
- deviceNamesAndGUIDs->inputNamesAndGUIDs.items[i].pnpInterface =
+ deviceNamesAndGUIDs->inputNamesAndGUIDs.items[i].pnpInterface =
(char*)DuplicateWCharString( deviceNamesAndGUIDs->winDsHostApi->allocations, data->Interface );
break;
}
@@ -638,13 +638,13 @@ static BOOL CALLBACK KsPropertySetEnumerateCallback( PDSPROPERTY_DIRECTSOUNDDEVI
}
-static GUID pawin_CLSID_DirectSoundPrivate =
+static GUID pawin_CLSID_DirectSoundPrivate =
{ 0x11ab3ec0, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca };
-static GUID pawin_DSPROPSETID_DirectSoundDevice =
+static GUID pawin_DSPROPSETID_DirectSoundDevice =
{ 0x84624f82, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca };
-static GUID pawin_IID_IKsPropertySet =
+static GUID pawin_IID_IKsPropertySet =
{ 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93 };
@@ -652,17 +652,17 @@ static GUID pawin_IID_IKsPropertySet =
FindDevicePnpInterfaces fills in the pnpInterface fields in deviceNamesAndGUIDs
with UNICODE file paths to the devices. The DS documentation mentions
at least two techniques by which these Interface paths can be found using IKsPropertySet on
- the DirectSound class object. One is using the DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION
+ the DirectSound class object. One is using the DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION
property, and the other is using DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE.
I tried both methods and only the second worked. I found two postings on the
- net from people who had the same problem with the first method, so I think the method used here is
+ net from people who had the same problem with the first method, so I think the method used here is
more common/likely to work. The problem is that IKsPropertySet_Get returns S_OK
but the fields of the device description are not filled in.
- The mechanism we use works by registering an enumeration callback which is called for
+ The mechanism we use works by registering an enumeration callback which is called for
every DSound device. Our callback searches for a device in our deviceNamesAndGUIDs list
with the matching GUID and copies the pointer to the Interface path.
- Note that we could have used this enumeration callback to perform the original
+ Note that we could have used this enumeration callback to perform the original
device enumeration, however we choose not to so we can disable this step easily.
Apparently the IKsPropertySet mechanism was added in DirectSound 9c 2004
@@ -673,11 +673,11 @@ static GUID pawin_IID_IKsPropertySet =
static void FindDevicePnpInterfaces( DSDeviceNamesAndGUIDs *deviceNamesAndGUIDs )
{
IClassFactory *pClassFactory;
-
+
if( paWinDsDSoundEntryPoints.DllGetClassObject(&pawin_CLSID_DirectSoundPrivate, &IID_IClassFactory, (PVOID *) &pClassFactory) == S_OK ){
IKsPropertySet *pPropertySet;
if( pClassFactory->lpVtbl->CreateInstance( pClassFactory, NULL, &pawin_IID_IKsPropertySet, (PVOID *) &pPropertySet) == S_OK ){
-
+
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
ULONG bytesReturned;
@@ -693,14 +693,14 @@ static void FindDevicePnpInterfaces( DSDeviceNamesAndGUIDs *deviceNamesAndGUIDs
sizeof(data),
&bytesReturned
);
-
+
IKsPropertySet_Release( pPropertySet );
}
pClassFactory->lpVtbl->Release( pClassFactory );
}
/*
- The following code fragment, which I chose not to use, queries for the
+ The following code fragment, which I chose not to use, queries for the
device interface for a device with a specific GUID:
ULONG BytesReturned;
@@ -708,7 +708,7 @@ static void FindDevicePnpInterfaces( DSDeviceNamesAndGUIDs *deviceNamesAndGUIDs
memset (&Property, 0, sizeof(Property));
Property.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
- Property.DeviceId = *lpGUID;
+ Property.DeviceId = *lpGUID;
hr = IKsPropertySet_Get( pPropertySet,
&pawin_DSPROPSETID_DirectSoundDevice,
@@ -729,7 +729,7 @@ static void FindDevicePnpInterfaces( DSDeviceNamesAndGUIDs *deviceNamesAndGUIDs
#endif /* PAWIN_USE_WDMKS_DEVICE_INFO */
-/*
+/*
GUIDs for emulated devices which we blacklist below.
are there more than two of them??
*/
@@ -773,7 +773,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
memcpy( &winDsDeviceInfo->guid, lpGUID, sizeof(GUID) );
winDsDeviceInfo->lpGUID = &winDsDeviceInfo->guid;
}
-
+
if( lpGUID )
{
if (IsEqualGUID (&IID_IRolandVSCEmulated1,lpGUID) ||
@@ -804,7 +804,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
hr = IDirectSound_Initialize( lpDirectSound, lpGUID );
}
*/
-
+
if( hr != DS_OK )
{
if (hr == DSERR_ALLOCATED)
@@ -830,7 +830,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
else
{
/* Query device characteristics. */
- memset( &caps, 0, sizeof(caps) );
+ memset( &caps, 0, sizeof(caps) );
caps.dwSize = sizeof(caps);
hr = IDirectSound_GetCaps( lpDirectSound, &caps );
if( hr != DS_OK )
@@ -861,7 +861,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
set deviceOutputChannelCountIsKnown to 0 (unknown).
In this case OpenStream will try to open the device
when the user requests more than 2 channels, rather than
- returning an error.
+ returning an error.
*/
if( caps.dwFlags & DSCAPS_PRIMARYSTEREO )
{
@@ -874,7 +874,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
winDsDeviceInfo->deviceOutputChannelCountIsKnown = 1;
}
- /* Guess channels count from speaker configuration. We do it only when
+ /* Guess channels count from speaker configuration. We do it only when
pnpInterface is NULL or when PAWIN_USE_WDMKS_DEVICE_INFO is undefined.
*/
#ifdef PAWIN_USE_WDMKS_DEVICE_INFO
@@ -899,7 +899,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
case DSSPEAKER_7POINT1: count = 8; break;
#ifndef DSSPEAKER_7POINT1_SURROUND
#define DSSPEAKER_7POINT1_SURROUND 0x00000008
-#endif
+#endif
case DSSPEAKER_7POINT1_SURROUND: count = 8; break;
#ifndef DSSPEAKER_5POINT1_SURROUND
#define DSSPEAKER_5POINT1_SURROUND 0x00000009
@@ -927,7 +927,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
#endif /* PAWIN_USE_WDMKS_DEVICE_INFO */
/* initialize defaultSampleRate */
-
+
if( caps.dwFlags & DSCAPS_CONTINUOUSRATE )
{
/* initialize to caps.dwMaxSecondarySampleRate incase none of the standard rates match */
@@ -973,7 +973,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
else deviceInfo->defaultSampleRate = caps.dwMaxSecondarySampleRate;
//printf( "min %d max %d\n", caps.dwMinSecondarySampleRate, caps.dwMaxSecondarySampleRate );
- // dwFlags | DSCAPS_CONTINUOUSRATE
+ // dwFlags | DSCAPS_CONTINUOUSRATE
deviceInfo->defaultLowInputLatency = 0.;
deviceInfo->defaultHighInputLatency = 0.;
@@ -992,7 +992,7 @@ static PaError AddOutputDeviceInfoFromDirectSound(
if( lpGUID == NULL )
hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
-
+
hostApi->info.deviceCount++;
}
@@ -1018,7 +1018,7 @@ static PaError AddInputDeviceInfoFromDirectSoundCapture(
DSCCAPS caps;
int deviceOK = TRUE;
PaError result = paNoError;
-
+
/* Copy GUID to the device info structure. Set pointer. */
if( lpGUID == NULL )
{
@@ -1150,12 +1150,12 @@ static PaError AddInputDeviceInfoFromDirectSoundCapture(
deviceInfo->defaultLowInputLatency = PaWinDs_GetMinLatencySeconds( deviceInfo->defaultSampleRate );
deviceInfo->defaultHighInputLatency = deviceInfo->defaultLowInputLatency * 2;
-
+
deviceInfo->defaultLowOutputLatency = 0.;
deviceInfo->defaultHighOutputLatency = 0.;
}
}
-
+
IDirectSoundCapture_Release( lpDirectSoundCapture );
}
@@ -1215,12 +1215,12 @@ PaError PaWinDs_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInde
(*hostApi)->info.structVersion = 1;
(*hostApi)->info.type = paDirectSound;
(*hostApi)->info.name = "Windows DirectSound";
-
+
(*hostApi)->info.deviceCount = 0;
(*hostApi)->info.defaultInputDevice = paNoDevice;
(*hostApi)->info.defaultOutputDevice = paNoDevice;
-
+
/* DSound - enumerate devices to count them and to gather their GUIDs */
result = InitializeDSDeviceNameAndGUIDVector( &deviceNamesAndGUIDs.inputNamesAndGUIDs, winDsHostApi->allocations );
@@ -1305,7 +1305,7 @@ PaError PaWinDs_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInde
if( result != paNoError )
goto error;
}
- }
+ }
result = TerminateDSDeviceNameAndGUIDVector( &deviceNamesAndGUIDs.inputNamesAndGUIDs );
if( result != paNoError )
@@ -1315,7 +1315,7 @@ PaError PaWinDs_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInde
if( result != paNoError )
goto error;
-
+
(*hostApi)->Terminate = Terminate;
(*hostApi)->OpenStream = OpenStream;
(*hostApi)->IsFormatSupported = IsFormatSupported;
@@ -1435,7 +1435,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
outputChannelCount = outputParameters->channelCount;
outputSampleFormat = outputParameters->sampleFormat;
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
@@ -1456,7 +1456,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
{
outputChannelCount = 0;
}
-
+
/*
IMPLEMENT ME:
@@ -1486,12 +1486,12 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
static HRESULT InitFullDuplexInputOutputBuffers( PaWinDsStream *stream,
PaWinDsDeviceInfo *inputDevice,
PaSampleFormat hostInputSampleFormat,
- WORD inputChannelCount,
+ WORD inputChannelCount,
int bytesPerInputBuffer,
PaWinWaveFormatChannelMask inputChannelMask,
PaWinDsDeviceInfo *outputDevice,
PaSampleFormat hostOutputSampleFormat,
- WORD outputChannelCount,
+ WORD outputChannelCount,
int bytesPerOutputBuffer,
PaWinWaveFormatChannelMask outputChannelMask,
unsigned long nFrameRate
@@ -1508,7 +1508,7 @@ static HRESULT InitFullDuplexInputOutputBuffers( PaWinDsStream *stream,
// capture buffer description
// only try wave format extensible. assume it's available on all ds 8 systems
- PaWin_InitializeWaveFormatExtensible( &captureWaveFormat, inputChannelCount,
+ PaWin_InitializeWaveFormatExtensible( &captureWaveFormat, inputChannelCount,
hostInputSampleFormat, PaWin_SampleFormatToLinearWaveFormatTag( hostInputSampleFormat ),
nFrameRate, inputChannelMask );
@@ -1520,7 +1520,7 @@ static HRESULT InitFullDuplexInputOutputBuffers( PaWinDsStream *stream,
// render buffer description
- PaWin_InitializeWaveFormatExtensible( &renderWaveFormat, outputChannelCount,
+ PaWin_InitializeWaveFormatExtensible( &renderWaveFormat, outputChannelCount,
hostOutputSampleFormat, PaWin_SampleFormatToLinearWaveFormatTag( hostOutputSampleFormat ),
nFrameRate, outputChannelMask );
@@ -1532,7 +1532,7 @@ static HRESULT InitFullDuplexInputOutputBuffers( PaWinDsStream *stream,
/* note that we don't create a primary buffer here at all */
- hr = paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8(
+ hr = paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8(
inputDevice->lpGUID, outputDevice->lpGUID,
&captureDesc, &secondaryRenderDesc,
GetDesktopWindow(), /* see InitOutputBuffer() for a discussion of whether this is a good idea */
@@ -1540,7 +1540,7 @@ static HRESULT InitFullDuplexInputOutputBuffers( PaWinDsStream *stream,
&stream->pDirectSoundFullDuplex8,
&pCaptureBuffer8,
&pRenderBuffer8,
- NULL /* pUnkOuter must be NULL */
+ NULL /* pUnkOuter must be NULL */
);
if( hr == DS_OK )
@@ -1550,7 +1550,7 @@ static HRESULT InitFullDuplexInputOutputBuffers( PaWinDsStream *stream,
/* retrieve the pre ds 8 buffer interfaces which are used by the rest of the code */
hr = IUnknown_QueryInterface( pCaptureBuffer8, &IID_IDirectSoundCaptureBuffer, (LPVOID *)&stream->pDirectSoundInputBuffer );
-
+
if( hr == DS_OK )
hr = IUnknown_QueryInterface( pRenderBuffer8, &IID_IDirectSoundBuffer, (LPVOID *)&stream->pDirectSoundOutputBuffer );
@@ -1571,7 +1571,7 @@ static HRESULT InitFullDuplexInputOutputBuffers( PaWinDsStream *stream,
IUnknown_Release( stream->pDirectSoundOutputBuffer );
stream->pDirectSoundOutputBuffer = NULL;
}
-
+
IUnknown_Release( stream->pDirectSoundFullDuplex8 );
stream->pDirectSoundFullDuplex8 = NULL;
}
@@ -1586,22 +1586,22 @@ static HRESULT InitFullDuplexInputOutputBuffers( PaWinDsStream *stream,
#endif /* PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE */
-static HRESULT InitInputBuffer( PaWinDsStream *stream,
- PaWinDsDeviceInfo *device,
- PaSampleFormat sampleFormat,
- unsigned long nFrameRate,
- WORD nChannels,
- int bytesPerBuffer,
+static HRESULT InitInputBuffer( PaWinDsStream *stream,
+ PaWinDsDeviceInfo *device,
+ PaSampleFormat sampleFormat,
+ unsigned long nFrameRate,
+ WORD nChannels,
+ int bytesPerBuffer,
PaWinWaveFormatChannelMask channelMask )
{
DSCBUFFERDESC captureDesc;
PaWinWaveFormat waveFormat;
HRESULT result;
-
- if( (result = paWinDsDSoundEntryPoints.DirectSoundCaptureCreate(
+
+ if( (result = paWinDsDSoundEntryPoints.DirectSoundCaptureCreate(
device->lpGUID, &stream->pDirectSoundCapture, NULL) ) != DS_OK ){
- ERR_RPT(("PortAudio: DirectSoundCaptureCreate() failed!\n"));
- return result;
+ ERR_RPT(("PortAudio: DirectSoundCaptureCreate() failed!\n"));
+ return result;
}
// Setup the secondary buffer description
@@ -1610,18 +1610,18 @@ static HRESULT InitInputBuffer( PaWinDsStream *stream,
captureDesc.dwFlags = 0;
captureDesc.dwBufferBytes = bytesPerBuffer;
captureDesc.lpwfxFormat = (WAVEFORMATEX*)&waveFormat;
-
+
// Create the capture buffer
// first try WAVEFORMATEXTENSIBLE. if this fails, fall back to WAVEFORMATEX
- PaWin_InitializeWaveFormatExtensible( &waveFormat, nChannels,
+ PaWin_InitializeWaveFormatExtensible( &waveFormat, nChannels,
sampleFormat, PaWin_SampleFormatToLinearWaveFormatTag( sampleFormat ),
nFrameRate, channelMask );
if( IDirectSoundCapture_CreateCaptureBuffer( stream->pDirectSoundCapture,
&captureDesc, &stream->pDirectSoundInputBuffer, NULL) != DS_OK )
{
- PaWin_InitializeWaveFormatEx( &waveFormat, nChannels, sampleFormat,
+ PaWin_InitializeWaveFormatEx( &waveFormat, nChannels, sampleFormat,
PaWin_SampleFormatToLinearWaveFormatTag( sampleFormat ), nFrameRate );
if ((result = IDirectSoundCapture_CreateCaptureBuffer( stream->pDirectSoundCapture,
@@ -1633,9 +1633,9 @@ static HRESULT InitInputBuffer( PaWinDsStream *stream,
}
-static HRESULT InitOutputBuffer( PaWinDsStream *stream, PaWinDsDeviceInfo *device,
- PaSampleFormat sampleFormat, unsigned long nFrameRate,
- WORD nChannels, int bytesPerBuffer,
+static HRESULT InitOutputBuffer( PaWinDsStream *stream, PaWinDsDeviceInfo *device,
+ PaSampleFormat sampleFormat, unsigned long nFrameRate,
+ WORD nChannels, int bytesPerBuffer,
PaWinWaveFormatChannelMask channelMask )
{
HRESULT result;
@@ -1644,8 +1644,8 @@ static HRESULT InitOutputBuffer( PaWinDsStream *stream, PaWinDsDeviceInfo *devic
PaWinWaveFormat waveFormat;
DSBUFFERDESC primaryDesc;
DSBUFFERDESC secondaryDesc;
-
- if( (hr = paWinDsDSoundEntryPoints.DirectSoundCreate(
+
+ if( (hr = paWinDsDSoundEntryPoints.DirectSoundCreate(
device->lpGUID, &stream->pDirectSound, NULL )) != DS_OK ){
ERR_RPT(("PortAudio: DirectSoundCreate() failed!\n"));
return hr;
@@ -1688,13 +1688,13 @@ static HRESULT InitOutputBuffer( PaWinDsStream *stream, PaWinDsDeviceInfo *devic
// Set the primary buffer's format
// first try WAVEFORMATEXTENSIBLE. if this fails, fall back to WAVEFORMATEX
- PaWin_InitializeWaveFormatExtensible( &waveFormat, nChannels,
+ PaWin_InitializeWaveFormatExtensible( &waveFormat, nChannels,
sampleFormat, PaWin_SampleFormatToLinearWaveFormatTag( sampleFormat ),
nFrameRate, channelMask );
if( IDirectSoundBuffer_SetFormat( stream->pDirectSoundPrimaryBuffer, (WAVEFORMATEX*)&waveFormat) != DS_OK )
{
- PaWin_InitializeWaveFormatEx( &waveFormat, nChannels, sampleFormat,
+ PaWin_InitializeWaveFormatEx( &waveFormat, nChannels, sampleFormat,
PaWin_SampleFormatToLinearWaveFormatTag( sampleFormat ), nFrameRate );
if((result = IDirectSoundBuffer_SetFormat( stream->pDirectSoundPrimaryBuffer, (WAVEFORMATEX*)&waveFormat)) != DS_OK)
@@ -1711,8 +1711,8 @@ static HRESULT InitOutputBuffer( PaWinDsStream *stream, PaWinDsDeviceInfo *devic
// Create the secondary buffer
if ((result = IDirectSound_CreateSoundBuffer( stream->pDirectSound,
&secondaryDesc, &stream->pDirectSoundOutputBuffer, NULL)) != DS_OK)
- goto error;
-
+ goto error;
+
return DS_OK;
error:
@@ -1727,7 +1727,7 @@ error:
}
-static void CalculateBufferSettings( unsigned long *hostBufferSizeFrames,
+static void CalculateBufferSettings( unsigned long *hostBufferSizeFrames,
unsigned long *pollingPeriodFrames,
int isFullDuplex,
unsigned long suggestedInputLatencyFrames,
@@ -1737,7 +1737,7 @@ static void CalculateBufferSettings( unsigned long *hostBufferSizeFrames,
unsigned long minimumPollingPeriodFrames = (unsigned long)(sampleRate * PA_DS_MINIMUM_POLLING_PERIOD_SECONDS);
unsigned long maximumPollingPeriodFrames = (unsigned long)(sampleRate * PA_DS_MAXIMUM_POLLING_PERIOD_SECONDS);
unsigned long pollingJitterFrames = (unsigned long)(sampleRate * PA_DS_POLLING_JITTER_SECONDS);
-
+
if( userFramesPerBuffer == paFramesPerBufferUnspecified )
{
unsigned long targetBufferingLatencyFrames = max( suggestedInputLatencyFrames, suggestedOutputLatencyFrames );
@@ -1752,7 +1752,7 @@ static void CalculateBufferSettings( unsigned long *hostBufferSizeFrames,
*pollingPeriodFrames = maximumPollingPeriodFrames;
}
- *hostBufferSizeFrames = *pollingPeriodFrames
+ *hostBufferSizeFrames = *pollingPeriodFrames
+ max( *pollingPeriodFrames + pollingJitterFrames, targetBufferingLatencyFrames);
}
else
@@ -1763,14 +1763,14 @@ static void CalculateBufferSettings( unsigned long *hostBufferSizeFrames,
/* In full duplex streams we know that the buffer adapter adds userFramesPerBuffer
extra fixed latency. so we subtract it here as a fixed latency before computing
the buffer size. being careful not to produce an unrepresentable negative result.
-
+
Note: this only works as expected if output latency is greater than input latency.
Otherwise we use input latency anyway since we do max(in,out).
*/
if( userFramesPerBuffer < suggestedOutputLatencyFrames )
{
- unsigned long adjustedSuggestedOutputLatencyFrames =
+ unsigned long adjustedSuggestedOutputLatencyFrames =
suggestedOutputLatencyFrames - userFramesPerBuffer;
/* maximum of input and adjusted output suggested latency */
@@ -1783,9 +1783,9 @@ static void CalculateBufferSettings( unsigned long *hostBufferSizeFrames,
/* maximum of input and output suggested latency */
if( suggestedOutputLatencyFrames > suggestedInputLatencyFrames )
targetBufferingLatencyFrames = suggestedOutputLatencyFrames;
- }
+ }
- *hostBufferSizeFrames = userFramesPerBuffer
+ *hostBufferSizeFrames = userFramesPerBuffer
+ max( userFramesPerBuffer + pollingJitterFrames, targetBufferingLatencyFrames);
*pollingPeriodFrames = max( max(1, userFramesPerBuffer / 4), targetBufferingLatencyFrames / 16 );
@@ -1794,11 +1794,11 @@ static void CalculateBufferSettings( unsigned long *hostBufferSizeFrames,
{
*pollingPeriodFrames = maximumPollingPeriodFrames;
}
- }
+ }
}
-static void CalculatePollingPeriodFrames( unsigned long hostBufferSizeFrames,
+static void CalculatePollingPeriodFrames( unsigned long hostBufferSizeFrames,
unsigned long *pollingPeriodFrames,
double sampleRate, unsigned long userFramesPerBuffer )
{
@@ -1815,12 +1815,12 @@ static void CalculatePollingPeriodFrames( unsigned long hostBufferSizeFrames,
}
-static void SetStreamInfoLatencies( PaWinDsStream *stream,
- unsigned long userFramesPerBuffer,
+static void SetStreamInfoLatencies( PaWinDsStream *stream,
+ unsigned long userFramesPerBuffer,
unsigned long pollingPeriodFrames,
double sampleRate )
{
- /* compute the stream info actual latencies based on framesPerBuffer, polling period, hostBufferSizeFrames,
+ /* compute the stream info actual latencies based on framesPerBuffer, polling period, hostBufferSizeFrames,
and the configuration of the buffer processor */
unsigned long effectiveFramesPerBuffer = (userFramesPerBuffer == paFramesPerBufferUnspecified)
@@ -1829,7 +1829,7 @@ static void SetStreamInfoLatencies( PaWinDsStream *stream,
if( stream->bufferProcessor.inputChannelCount > 0 )
{
- /* stream info input latency is the minimum buffering latency
+ /* stream info input latency is the minimum buffering latency
(unlike suggested and default which are *maximums*) */
stream->streamRepresentation.streamInfo.inputLatency =
(double)(PaUtil_GetBufferProcessorInputLatencyFrames(&stream->bufferProcessor)
@@ -1894,7 +1894,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
/* IDEA: the following 3 checks could be performed by default by pa_front
unless some flag indicated otherwise */
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
if( inputParameters->device == paUseHostApiSpecificDeviceSpecification )
@@ -1904,7 +1904,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
if( inputWinDsDeviceInfo->deviceInputChannelCountIsKnown
&& inputChannelCount > inputDeviceInfo->maxInputChannels )
return paInvalidChannelCount;
-
+
/* validate hostApiSpecificStreamInfo */
inputStreamInfo = (PaWinDirectSoundStreamInfo*)inputParameters->hostApiSpecificStreamInfo;
result = ValidateWinDirectSoundSpecificStreamInfo( inputParameters, inputStreamInfo );
@@ -1948,7 +1948,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
/* validate hostApiSpecificStreamInfo */
outputStreamInfo = (PaWinDirectSoundStreamInfo*)outputParameters->hostApiSpecificStreamInfo;
result = ValidateWinDirectSoundSpecificStreamInfo( outputParameters, outputStreamInfo );
- if( result != paNoError ) return result;
+ if( result != paNoError ) return result;
if( outputStreamInfo && outputStreamInfo->flags & paWinDirectSoundUseLowLevelLatencyParameters )
userRequestedHostOutputBufferSizeFrames = outputStreamInfo->framesPerBuffer;
@@ -2025,7 +2025,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
PaUtil_InitializeStreamRepresentation( &stream->streamRepresentation,
&winDsHostApi->blockingStreamInterface, streamCallback, userData );
}
-
+
streamRepresentationIsInitialized = 1;
stream->streamFlags = streamFlags;
@@ -2074,12 +2074,12 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
bufferProcessorIsInitialized = 1;
-
-/* DirectSound specific initialization */
+
+/* DirectSound specific initialization */
{
HRESULT hr;
unsigned long integerSampleRate = (unsigned long) (sampleRate + 0.5);
-
+
stream->processingCompleted = CreateEvent( NULL, /* bManualReset = */ TRUE, /* bInitialState = */ FALSE, NULL );
if( stream->processingCompleted == NULL )
{
@@ -2122,7 +2122,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
*/
stream->hostBufferSizeFrames = max( userRequestedHostInputBufferSizeFrames, userRequestedHostOutputBufferSizeFrames );
- CalculatePollingPeriodFrames(
+ CalculatePollingPeriodFrames(
stream->hostBufferSizeFrames, &pollingPeriodFrames,
sampleRate, framesPerBuffer );
}
@@ -2131,13 +2131,13 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
CalculateBufferSettings( (unsigned long*)&stream->hostBufferSizeFrames, &pollingPeriodFrames,
/* isFullDuplex = */ (inputParameters && outputParameters),
suggestedInputLatencyFrames,
- suggestedOutputLatencyFrames,
+ suggestedOutputLatencyFrames,
sampleRate, framesPerBuffer );
}
stream->pollingPeriodSeconds = pollingPeriodFrames / sampleRate;
- DBUG(("DirectSound host buffer size frames: %d, polling period seconds: %f, @ sr: %f\n",
+ DBUG(("DirectSound host buffer size frames: %d, polling period seconds: %f, @ sr: %f\n",
stream->hostBufferSizeFrames, stream->pollingPeriodSeconds, sampleRate ));
@@ -2150,7 +2150,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
PaDeviceInfo *deviceInfo = hostApi->deviceInfos[ outputParameters->device ];
DBUG(("PaHost_OpenStream: deviceID = 0x%x\n", outputParameters->device));
*/
-
+
int sampleSizeBytes = Pa_GetSampleSize(hostOutputSampleFormat);
stream->outputFrameSizeBytes = outputParameters->channelCount * sampleSizeBytes;
@@ -2173,7 +2173,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->outputIsRunning = FALSE;
stream->outputUnderflowCount = 0;
-
+
/* perfCounterTicksPerBuffer is used by QueryOutputSpace for overflow detection */
if( QueryPerformanceFrequency( &counterFrequency ) )
{
@@ -2192,7 +2192,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
PaDeviceInfo *deviceInfo = hostApi->deviceInfos[ inputParameters->device ];
DBUG(("PaHost_OpenStream: deviceID = 0x%x\n", inputParameters->device));
*/
-
+
int sampleSizeBytes = Pa_GetSampleSize(hostInputSampleFormat);
stream->inputFrameSizeBytes = inputParameters->channelCount * sampleSizeBytes;
@@ -2217,7 +2217,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
assert( stream->pDirectSound == NULL );
assert( stream->pDirectSoundPrimaryBuffer == NULL );
assert( stream->pDirectSoundOutputBuffer == NULL );
-
+
if( inputParameters && outputParameters )
{
@@ -2237,14 +2237,14 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
integerSampleRate
);
DBUG(("InitFullDuplexInputOutputBuffers() returns %x\n", hr));
- /* ignore any error returned by InitFullDuplexInputOutputBuffers.
+ /* ignore any error returned by InitFullDuplexInputOutputBuffers.
we retry opening the buffers below */
#endif /* PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE */
}
- /* create half duplex buffers. also used for full-duplex streams which didn't
+ /* create half duplex buffers. also used for full-duplex streams which didn't
succeed when using the full duplex API. that could happen because
- DX8 or greater isn't installed, the i/o devices aren't the same
+ DX8 or greater isn't installed, the i/o devices aren't the same
physical device. etc.
*/
@@ -2426,11 +2426,11 @@ static HRESULT QueryOutputSpace( PaWinDsStream *stream, long *bytesEmpty )
/*
From MSDN:
- The write cursor indicates the position at which it is safe
+ The write cursor indicates the position at which it is safe
to write new data to the buffer. The write cursor always leads the
play cursor, typically by about 15 milliseconds' worth of audio
data.
- It is always safe to change data that is behind the position
+ It is always safe to change data that is behind the position
indicated by the lpdwCurrentPlayCursor parameter.
*/
@@ -2456,7 +2456,7 @@ static int TimeSlice( PaWinDsStream *stream )
double outputLatency = 0;
double inputLatency = 0;
PaStreamCallbackTimeInfo timeInfo = {0,0,0};
-
+
/* Input */
LPBYTE lpInBuf1 = NULL;
LPBYTE lpInBuf2 = NULL;
@@ -2489,7 +2489,7 @@ static int TimeSlice( PaWinDsStream *stream )
}
// FIXME: what happens if IDirectSoundCaptureBuffer_GetCurrentPosition fails?
- framesToXfer = numInFramesReady = bytesFilled / stream->inputFrameSizeBytes;
+ framesToXfer = numInFramesReady = bytesFilled / stream->inputFrameSizeBytes;
/** @todo Check for overflow */
}
@@ -2502,7 +2502,7 @@ static int TimeSlice( PaWinDsStream *stream )
framesToXfer = numOutFramesReady = bytesEmpty / stream->outputFrameSizeBytes;
/* Check for underflow */
- /* FIXME QueryOutputSpace should not adjust underflow count as a side effect.
+ /* FIXME QueryOutputSpace should not adjust underflow count as a side effect.
A query function should be a const operator on the stream and return a flag on underflow. */
if( stream->outputUnderflowCount != previousUnderflowCount )
stream->callbackFlags |= paOutputUnderflow;
@@ -2532,11 +2532,11 @@ static int TimeSlice( PaWinDsStream *stream )
PaUtil_BeginBufferProcessing( &stream->bufferProcessor, &timeInfo, stream->callbackFlags );
stream->callbackFlags = 0;
-
+
/* Input */
if( stream->bufferProcessor.inputChannelCount > 0 )
{
- timeInfo.inputBufferAdcTime = timeInfo.currentTime - inputLatency;
+ timeInfo.inputBufferAdcTime = timeInfo.currentTime - inputLatency;
bytesToXfer = framesToXfer * stream->inputFrameSizeBytes;
hresult = IDirectSoundCaptureBuffer_Lock ( stream->pDirectSoundInputBuffer,
@@ -2603,7 +2603,7 @@ static int TimeSlice( PaWinDsStream *stream )
numFrames = PaUtil_EndBufferProcessing( &stream->bufferProcessor, &stream->callbackResult );
stream->framesWritten += numFrames;
-
+
if( stream->bufferProcessor.outputChannelCount > 0 )
{
/* FIXME: an underflow could happen here */
@@ -2626,7 +2626,7 @@ error1:
}
error2:
- PaUtil_EndCpuLoadMeasurement( &stream->cpuLoadMeasurer, numFrames );
+ PaUtil_EndCpuLoadMeasurement( &stream->cpuLoadMeasurer, numFrames );
}
if( stream->callbackResult == paComplete && !PaUtil_IsBufferProcessorOutputEmpty( &stream->bufferProcessor ) )
@@ -2684,7 +2684,7 @@ static void CALLBACK TimerCallback(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD
(void) uMsg;
(void) dw1;
(void) dw2;
-
+
stream = (PaWinDsStream *) dwUser;
if( stream == NULL ) return;
@@ -2715,8 +2715,8 @@ static void CALLBACK TimerCallback(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD
int callbackResult = TimeSlice( stream );
if( callbackResult != paContinue )
{
- /* FIXME implement handling of paComplete and paAbort if possible
- At the moment this should behave as if paComplete was called and
+ /* FIXME implement handling of paComplete and paAbort if possible
+ At the moment this should behave as if paComplete was called and
flush the buffer.
*/
@@ -2892,7 +2892,7 @@ static HRESULT ClearOutputBuffer( PaWinDsStream *stream )
// Unlock the DS buffer
if ((hr = IDirectSoundBuffer_Unlock( stream->pDirectSoundOutputBuffer, pDSBuffData, dwDataLen, NULL, 0)) != DS_OK)
return hr;
-
+
// Let DSound set the starting write position because if we set it to zero, it looks like the
// buffer is full to begin with. This causes a long pause before sound starts when using large buffers.
if ((hr = IDirectSoundBuffer_GetCurrentPosition( stream->pDirectSoundOutputBuffer,
@@ -2909,10 +2909,10 @@ static PaError StartStream( PaStream *s )
PaError result = paNoError;
PaWinDsStream *stream = (PaWinDsStream*)s;
HRESULT hr;
-
+
stream->callbackResult = paContinue;
PaUtil_ResetBufferProcessor( &stream->bufferProcessor );
-
+
ResetEvent( stream->processingCompleted );
#ifndef PA_WIN_DS_USE_WMME_TIMER
@@ -3017,7 +3017,7 @@ static PaError StartStream( PaStream *s )
*/
stream->timerID = timeSetEvent( timerPeriodMs, stream->systemTimerResolutionPeriodMs, (LPTIMECALLBACK) TimerCallback,
(DWORD_PTR) stream, TIME_PERIODIC | TIME_KILL_SYNCHRONOUS );
-
+
if( stream->timerID == 0 )
{
stream->isActive = 0;
@@ -3112,7 +3112,7 @@ static PaError StopStream( PaStream *s )
if( stream->systemTimerResolutionPeriodMs > 0 ){
timeEndPeriod( stream->systemTimerResolutionPeriodMs );
stream->systemTimerResolutionPeriodMs = 0;
- }
+ }
if( stream->bufferProcessor.outputChannelCount > 0 )
{
@@ -3252,7 +3252,7 @@ static signed long GetStreamWriteAvailable( PaStream* s )
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return 0;
diff --git a/src/hostapi/dsound/pa_win_ds_dynlink.c b/src/hostapi/dsound/pa_win_ds_dynlink.c
index fdfc8bd..e54df99 100644
--- a/src/hostapi/dsound/pa_win_ds_dynlink.c
+++ b/src/hostapi/dsound/pa_win_ds_dynlink.c
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -180,7 +180,7 @@ void PaWinDs_InitializeDSoundEntryPoints(void)
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE
paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 =
(HRESULT (WINAPI *)(LPCGUID, LPCGUID, LPCDSCBUFFERDESC, LPCDSBUFFERDESC,
- HWND, DWORD, LPDIRECTSOUNDFULLDUPLEX *, LPDIRECTSOUNDCAPTUREBUFFER8 *,
+ HWND, DWORD, LPDIRECTSOUNDFULLDUPLEX *, LPDIRECTSOUNDCAPTUREBUFFER8 *,
LPDIRECTSOUNDBUFFER8 *, LPUNKNOWN))
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundFullDuplexCreate" );
if( paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 == NULL )
@@ -221,4 +221,4 @@ void PaWinDs_TerminateDSoundEntryPoints(void)
FreeLibrary( paWinDsDSoundEntryPoints.hInstance_ );
paWinDsDSoundEntryPoints.hInstance_ = NULL;
}
-}
\ No newline at end of file
+}
diff --git a/src/hostapi/dsound/pa_win_ds_dynlink.h b/src/hostapi/dsound/pa_win_ds_dynlink.h
index 0fcf967..2cdf6f0 100644
--- a/src/hostapi/dsound/pa_win_ds_dynlink.h
+++ b/src/hostapi/dsound/pa_win_ds_dynlink.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -74,7 +74,7 @@ extern "C"
typedef struct
{
HINSTANCE hInstance_;
-
+
HRESULT (WINAPI *DllGetClassObject)(REFCLSID , REFIID , LPVOID *);
HRESULT (WINAPI *DirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
@@ -88,7 +88,7 @@ typedef struct
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE
HRESULT (WINAPI *DirectSoundFullDuplexCreate8)(
LPCGUID, LPCGUID, LPCDSCBUFFERDESC, LPCDSBUFFERDESC,
- HWND, DWORD, LPDIRECTSOUNDFULLDUPLEX *, LPDIRECTSOUNDCAPTUREBUFFER8 *,
+ HWND, DWORD, LPDIRECTSOUNDFULLDUPLEX *, LPDIRECTSOUNDCAPTUREBUFFER8 *,
LPDIRECTSOUNDBUFFER8 *, LPUNKNOWN );
#endif
}PaWinDsDSoundEntryPoints;
From af9f4e3e194f5697dcdd841ca2c43f0855bcb69d Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 21 Jan 2021 22:46:49 +1100
Subject: [PATCH 083/157] Clean up whitespace in pa_win_wmme.c in preparation
for .editorconfig (#413)
* Clean up whitespace in pa_win_wmme.c in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF.
* vertically align trailing comments on 4 space boundary
---
src/hostapi/wmme/pa_win_wmme.c | 450 ++++++++++++++++-----------------
1 file changed, 225 insertions(+), 225 deletions(-)
diff --git a/src/hostapi/wmme/pa_win_wmme.c b/src/hostapi/wmme/pa_win_wmme.c
index d5337b8..18256c8 100644
--- a/src/hostapi/wmme/pa_win_wmme.c
+++ b/src/hostapi/wmme/pa_win_wmme.c
@@ -1,8 +1,8 @@
/*
* $Id$
* pa_win_wmme.c
- * Implementation of PortAudio for Windows MultiMedia Extensions (WMME)
- *
+ * Implementation of PortAudio for Windows MultiMedia Extensions (WMME)
+ *
* PortAudio Portable Real-Time Audio Library
* Latest Version at: http://www.portaudio.com
*
@@ -30,13 +30,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -155,21 +155,21 @@
#define PA_MME_USE_HIGH_DEFAULT_LATENCY_ (0) /* For debugging glitches. */
#if PA_MME_USE_HIGH_DEFAULT_LATENCY_
- #define PA_MME_WIN_9X_DEFAULT_LATENCY_ (0.4)
- #define PA_MME_MIN_HOST_OUTPUT_BUFFER_COUNT_ (4)
- #define PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_ (4)
- #define PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_HALF_DUPLEX_ (4)
- #define PA_MME_HOST_BUFFER_GRANULARITY_FRAMES_WHEN_UNSPECIFIED_ (16)
- #define PA_MME_MAX_HOST_BUFFER_SECS_ (0.3) /* Do not exceed unless user buffer exceeds */
- #define PA_MME_MAX_HOST_BUFFER_BYTES_ (32 * 1024) /* Has precedence over PA_MME_MAX_HOST_BUFFER_SECS_, some drivers are known to crash with buffer sizes > 32k */
+ #define PA_MME_WIN_9X_DEFAULT_LATENCY_ (0.4)
+ #define PA_MME_MIN_HOST_OUTPUT_BUFFER_COUNT_ (4)
+ #define PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_ (4)
+ #define PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_HALF_DUPLEX_ (4)
+ #define PA_MME_HOST_BUFFER_GRANULARITY_FRAMES_WHEN_UNSPECIFIED_ (16)
+ #define PA_MME_MAX_HOST_BUFFER_SECS_ (0.3) /* Do not exceed unless user buffer exceeds */
+ #define PA_MME_MAX_HOST_BUFFER_BYTES_ (32 * 1024) /* Has precedence over PA_MME_MAX_HOST_BUFFER_SECS_, some drivers are known to crash with buffer sizes > 32k */
#else
- #define PA_MME_WIN_9X_DEFAULT_LATENCY_ (0.2)
- #define PA_MME_MIN_HOST_OUTPUT_BUFFER_COUNT_ (2)
- #define PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_ (3) /* always use at least 3 input buffers for full duplex */
- #define PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_HALF_DUPLEX_ (2)
- #define PA_MME_HOST_BUFFER_GRANULARITY_FRAMES_WHEN_UNSPECIFIED_ (16)
- #define PA_MME_MAX_HOST_BUFFER_SECS_ (0.1) /* Do not exceed unless user buffer exceeds */
- #define PA_MME_MAX_HOST_BUFFER_BYTES_ (32 * 1024) /* Has precedence over PA_MME_MAX_HOST_BUFFER_SECS_, some drivers are known to crash with buffer sizes > 32k */
+ #define PA_MME_WIN_9X_DEFAULT_LATENCY_ (0.2)
+ #define PA_MME_MIN_HOST_OUTPUT_BUFFER_COUNT_ (2)
+ #define PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_ (3) /* always use at least 3 input buffers for full duplex */
+ #define PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_HALF_DUPLEX_ (2)
+ #define PA_MME_HOST_BUFFER_GRANULARITY_FRAMES_WHEN_UNSPECIFIED_ (16)
+ #define PA_MME_MAX_HOST_BUFFER_SECS_ (0.1) /* Do not exceed unless user buffer exceeds */
+ #define PA_MME_MAX_HOST_BUFFER_BYTES_ (32 * 1024) /* Has precedence over PA_MME_MAX_HOST_BUFFER_SECS_, some drivers are known to crash with buffer sizes > 32k */
#endif
/* Use higher latency for NT because it is even worse at real-time
@@ -181,7 +181,7 @@
survey of workable latency settings using patest_wmme_find_best_latency_params.c.
See pdf attached to ticket 185 for a graph of the survey results:
http://www.portaudio.com/trac/ticket/185
-
+
Workable latencies varied between 40ms and ~80ms on different systems (different
combinations of hardware, 32 and 64 bit, WinXP, Vista and Win7. We didn't
get enough Vista results to know if Vista has systemically worse latency.
@@ -190,10 +190,10 @@
#define PA_MME_WIN_WDM_DEFAULT_LATENCY_ (0.090)
-/* When client suggestedLatency could result in many host buffers, we aim to have around 8,
+/* When client suggestedLatency could result in many host buffers, we aim to have around 8,
based off Windows documentation that suggests that the kmixer uses 8 buffers. This choice
- is somewhat arbitrary here, since we haven't observed significant stability degredation
- with using either more, or less buffers.
+ is somewhat arbitrary here, since we haven't observed significant stability degredation
+ with using either more, or less buffers.
*/
#define PA_MME_TARGET_HOST_BUFFER_COUNT_ 8
@@ -209,8 +209,8 @@ static char *CopyWCharStringToUtf8CString(char *destination, size_t destLengthBy
{
/* The cbMultiByte parameter ["destLengthBytes" below] is:
"""
- Size, in bytes, of the buffer indicated by lpMultiByteStr ["destination" below].
- If this parameter is set to 0, the function returns the required buffer
+ Size, in bytes, of the buffer indicated by lpMultiByteStr ["destination" below].
+ If this parameter is set to 0, the function returns the required buffer
size for lpMultiByteStr and makes no use of the output parameter itself.
"""
Source: WideCharToMultiByte at MSDN:
@@ -230,13 +230,13 @@ static char *CopyWCharStringToUtf8CString(char *destination, size_t destLengthBy
{
intDestLengthBytes = INT_MAX;
}
-
+
if (WideCharToMultiByte(CP_UTF8, 0, source, -1, destination, /*cbMultiByte=*/intDestLengthBytes, NULL, NULL) == 0)
return NULL;
return destination;
}
-/* returns required length (in bytes) of destination buffer when
+/* returns required length (in bytes) of destination buffer when
converting WCHAR string to UTF8 bytes, not including the terminating null. */
static size_t WCharStringLen(const WCHAR *str)
{
@@ -344,7 +344,7 @@ static PaError CreateEventWithPaError( HANDLE *handle,
PaError result = paNoError;
*handle = NULL;
-
+
*handle = CreateEvent( lpEventAttributes, bManualReset, bInitialState, lpName );
if( *handle == NULL )
{
@@ -376,7 +376,7 @@ static PaError ResetEventWithPaError( HANDLE handle )
static PaError CloseHandleWithPaError( HANDLE handle )
{
PaError result = paNoError;
-
+
if( handle )
{
if( CloseHandle( handle ) == 0 )
@@ -385,7 +385,7 @@ static PaError CloseHandleWithPaError( HANDLE handle )
PA_MME_SET_LAST_SYSTEM_ERROR( GetLastError() );
}
}
-
+
return result;
}
@@ -399,14 +399,14 @@ typedef struct
PaUtilStreamInterface blockingStreamInterface;
PaUtilAllocationGroup *allocations;
-
+
int inputDeviceCount, outputDeviceCount;
/** winMmeDeviceIds is an array of WinMme device ids.
fields in the range [0, inputDeviceCount) are input device ids,
and [inputDeviceCount, inputDeviceCount + outputDeviceCount) are output
device ids.
- */
+ */
UINT *winMmeDeviceIds;
}
PaWinMmeHostApiRepresentation;
@@ -507,21 +507,21 @@ static int SampleFormatAndWinWmmeSpecificFlagsToLinearWaveFormatTag( PaSampleFor
static PaError QueryInputWaveFormatEx( int deviceId, WAVEFORMATEX *waveFormatEx )
{
MMRESULT mmresult;
-
+
switch( mmresult = waveInOpen( NULL, deviceId, waveFormatEx, 0, 0, WAVE_FORMAT_QUERY ) )
{
case MMSYSERR_NOERROR:
return paNoError;
case MMSYSERR_ALLOCATED: /* Specified resource is already allocated. */
return paDeviceUnavailable;
- case MMSYSERR_NODRIVER: /* No device driver is present. */
+ case MMSYSERR_NODRIVER: /* No device driver is present. */
return paDeviceUnavailable;
- case MMSYSERR_NOMEM: /* Unable to allocate or lock memory. */
+ case MMSYSERR_NOMEM: /* Unable to allocate or lock memory. */
return paInsufficientMemory;
case WAVERR_BADFORMAT: /* Attempted to open with an unsupported waveform-audio format. */
return paSampleFormatNotSupported;
-
- case MMSYSERR_BADDEVICEID: /* Specified device identifier is out of range. */
+
+ case MMSYSERR_BADDEVICEID: /* Specified device identifier is out of range. */
/* falls through */
default:
PA_MME_SET_LAST_WAVEIN_ERROR( mmresult );
@@ -533,21 +533,21 @@ static PaError QueryInputWaveFormatEx( int deviceId, WAVEFORMATEX *waveFormatEx
static PaError QueryOutputWaveFormatEx( int deviceId, WAVEFORMATEX *waveFormatEx )
{
MMRESULT mmresult;
-
+
switch( mmresult = waveOutOpen( NULL, deviceId, waveFormatEx, 0, 0, WAVE_FORMAT_QUERY ) )
{
case MMSYSERR_NOERROR:
return paNoError;
case MMSYSERR_ALLOCATED: /* Specified resource is already allocated. */
return paDeviceUnavailable;
- case MMSYSERR_NODRIVER: /* No device driver is present. */
+ case MMSYSERR_NODRIVER: /* No device driver is present. */
return paDeviceUnavailable;
- case MMSYSERR_NOMEM: /* Unable to allocate or lock memory. */
+ case MMSYSERR_NOMEM: /* Unable to allocate or lock memory. */
return paInsufficientMemory;
case WAVERR_BADFORMAT: /* Attempted to open with an unsupported waveform-audio format. */
return paSampleFormatNotSupported;
-
- case MMSYSERR_BADDEVICEID: /* Specified device identifier is out of range. */
+
+ case MMSYSERR_BADDEVICEID: /* Specified device identifier is out of range. */
/* falls through */
default:
PA_MME_SET_LAST_WAVEOUT_ERROR( mmresult );
@@ -564,14 +564,14 @@ static PaError QueryFormatSupported( PaDeviceInfo *deviceInfo,
PaWinWaveFormat waveFormat;
PaSampleFormat sampleFormat;
int waveFormatTag;
-
+
/* @todo at the moment we only query with 16 bit sample format and directout speaker config*/
sampleFormat = paInt16;
waveFormatTag = SampleFormatAndWinWmmeSpecificFlagsToLinearWaveFormatTag( sampleFormat, winMmeSpecificFlags );
if( waveFormatTag == PaWin_SampleFormatToLinearWaveFormatTag( paInt16 ) ){
-
+
/* attempt bypass querying the device for linear formats */
if( sampleRate == 11025.0
@@ -597,7 +597,7 @@ static PaError QueryFormatSupported( PaDeviceInfo *deviceInfo,
}
- /* first, attempt to query the device using WAVEFORMATEXTENSIBLE,
+ /* first, attempt to query the device using WAVEFORMATEXTENSIBLE,
if this fails we fall back to WAVEFORMATEX */
PaWin_InitializeWaveFormatExtensible( &waveFormat, channels, sampleFormat, waveFormatTag,
@@ -622,12 +622,12 @@ static void DetectDefaultSampleRate( PaWinMmeDeviceInfo *winMmeDeviceInfo, int w
{
PaDeviceInfo *deviceInfo = &winMmeDeviceInfo->inheritedDeviceInfo;
int i;
-
+
deviceInfo->defaultSampleRate = 0.;
for( i=0; i < PA_DEFAULTSAMPLERATESEARCHORDER_COUNT_; ++i )
{
- double sampleRate = defaultSampleRateSearchOrder_[ i ];
+ double sampleRate = defaultSampleRateSearchOrder_[ i ];
PaError paerror = QueryFormatSupported( deviceInfo, waveFormatExQueryFunction, winMmeDeviceId, maxChannels, sampleRate, 0 );
if( paerror == paNoError )
{
@@ -684,7 +684,7 @@ static PaError InitializeInputDeviceInfo( PaWinMmeHostApiRepresentation *winMmeH
WAVEINCAPSW wic;
PaDeviceInfo *deviceInfo = &winMmeDeviceInfo->inheritedDeviceInfo;
size_t len;
-
+
*success = 0;
mmresult = waveInGetDevCapsW( winMmeInputDeviceId, &wic, sizeof( WAVEINCAPSW ) );
@@ -701,7 +701,7 @@ static PaError InitializeInputDeviceInfo( PaWinMmeHostApiRepresentation *winMmeH
the entire initialisation process.
*/
return paNoError;
- }
+ }
/* NOTE: the WAVEOUTCAPS.szPname is a null-terminated array of 32 characters,
so we are limited to displaying only the first 31 characters of the device name. */
@@ -755,7 +755,7 @@ static PaError InitializeInputDeviceInfo( PaWinMmeHostApiRepresentation *winMmeH
}
#ifdef PAWIN_USE_WDMKS_DEVICE_INFO
- winMmeDeviceInfo->deviceInputChannelCountIsKnown =
+ winMmeDeviceInfo->deviceInputChannelCountIsKnown =
QueryWaveInKSFilterMaxChannels( winMmeInputDeviceId, &deviceInfo->maxInputChannels );
#endif /* PAWIN_USE_WDMKS_DEVICE_INFO */
@@ -765,7 +765,7 @@ static PaError InitializeInputDeviceInfo( PaWinMmeHostApiRepresentation *winMmeH
QueryInputWaveFormatEx, deviceInfo->maxInputChannels );
*success = 1;
-
+
error:
return result;
}
@@ -846,7 +846,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
/* Append I/O suffix to WAVE_MAPPER device. */
len = WCharStringLen( woc.szPname ) + 1 + sizeof(constOutputMapperSuffix_);
deviceName = (char*)PaUtil_GroupAllocateMemory(
- winMmeHostApi->allocations,
+ winMmeHostApi->allocations,
(long)len );
if( !deviceName )
{
@@ -860,7 +860,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
{
len = WCharStringLen( woc.szPname ) + 1;
deviceName = (char*)PaUtil_GroupAllocateMemory(
- winMmeHostApi->allocations,
+ winMmeHostApi->allocations,
(long)len );
if( !deviceName )
{
@@ -880,7 +880,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
* device*ChannelCountIsKnown is false, OpenStream will try whatever
* channel count you supply.
* see also InitializeInputDeviceInfo() above.
- */
+ */
PA_DEBUG(("Pa_GetDeviceInfo: Num output channels reported as %d! Changed to 2.\n", woc.wChannels ));
deviceInfo->maxOutputChannels = 2;
@@ -891,7 +891,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
}
#ifdef PAWIN_USE_WDMKS_DEVICE_INFO
- wdmksDeviceOutputChannelCountIsKnown = QueryWaveOutKSFilterMaxChannels(
+ wdmksDeviceOutputChannelCountIsKnown = QueryWaveOutKSFilterMaxChannels(
winMmeOutputDeviceId, &deviceInfo->maxOutputChannels );
if( wdmksDeviceOutputChannelCountIsKnown && !winMmeDeviceInfo->deviceOutputChannelCountIsKnown )
winMmeDeviceInfo->deviceOutputChannelCountIsKnown = 1;
@@ -903,7 +903,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
QueryOutputWaveFormatEx, deviceInfo->maxOutputChannels );
*success = 1;
-
+
error:
return result;
}
@@ -932,12 +932,12 @@ See: http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprec
}
else if(osvi.dwMajorVersion >= 5)
{
- *defaultLowLatency = PA_MME_WIN_WDM_DEFAULT_LATENCY_;
+ *defaultLowLatency = PA_MME_WIN_WDM_DEFAULT_LATENCY_;
}
else
{
- *defaultLowLatency = PA_MME_WIN_9X_DEFAULT_LATENCY_;
- }
+ *defaultLowLatency = PA_MME_WIN_9X_DEFAULT_LATENCY_;
+ }
*defaultHighLatency = *defaultLowLatency * 2;
@@ -976,7 +976,7 @@ PaError PaWinMme_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
(*hostApi)->info.type = paMME;
(*hostApi)->info.name = "MME";
-
+
/* initialise device counts and default devices under the assumption that
there are no devices. These values are incremented below if and when
devices are successfully initialized.
@@ -1005,11 +1005,11 @@ PaError PaWinMme_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
inputDeviceCount = waveInGetNumDevs();
if( inputDeviceCount > 0 )
- maximumPossibleDeviceCount += inputDeviceCount + 1; /* assume there is a WAVE_MAPPER */
+ maximumPossibleDeviceCount += inputDeviceCount + 1; /* assume there is a WAVE_MAPPER */
outputDeviceCount = waveOutGetNumDevs();
if( outputDeviceCount > 0 )
- maximumPossibleDeviceCount += outputDeviceCount + 1; /* assume there is a WAVE_MAPPER */
+ maximumPossibleDeviceCount += outputDeviceCount + 1; /* assume there is a WAVE_MAPPER */
if( maximumPossibleDeviceCount > 0 ){
@@ -1069,7 +1069,7 @@ PaError PaWinMme_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
if( (*hostApi)->info.defaultInputDevice == paNoDevice ){
/* if there is currently no default device, use the first one available */
(*hostApi)->info.defaultInputDevice = (*hostApi)->info.deviceCount;
-
+
}else if( winMmeDeviceId == waveInPreferredDevice ){
/* set the default device to the system preferred device */
(*hostApi)->info.defaultInputDevice = (*hostApi)->info.deviceCount;
@@ -1101,7 +1101,7 @@ PaError PaWinMme_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
deviceInfo->defaultLowInputLatency = defaultLowLatency;
deviceInfo->defaultLowOutputLatency = defaultLowLatency;
deviceInfo->defaultHighInputLatency = defaultHighLatency;
- deviceInfo->defaultHighOutputLatency = defaultHighLatency;
+ deviceInfo->defaultHighOutputLatency = defaultHighLatency;
result = InitializeOutputDeviceInfo( winMmeHostApi, wmmeDeviceInfo,
winMmeDeviceId, &deviceInfoInitializationSucceeded );
@@ -1127,7 +1127,7 @@ PaError PaWinMme_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
}
}
}
-
+
InitializeDefaultDeviceIdsFromEnv( winMmeHostApi );
(*hostApi)->Terminate = Terminate;
@@ -1155,7 +1155,7 @@ error:
PaUtil_FreeAllAllocations( winMmeHostApi->allocations );
PaUtil_DestroyAllocationGroup( winMmeHostApi->allocations );
}
-
+
PaUtil_FreeMemory( winMmeHostApi );
}
@@ -1185,7 +1185,7 @@ static PaError IsInputChannelCountSupported( PaWinMmeDeviceInfo* deviceInfo, int
&& deviceInfo->deviceInputChannelCountIsKnown
&& channelCount > deviceInfo->inheritedDeviceInfo.maxInputChannels ){
- result = paInvalidChannelCount;
+ result = paInvalidChannelCount;
}
return result;
@@ -1199,7 +1199,7 @@ static PaError IsOutputChannelCountSupported( PaWinMmeDeviceInfo* deviceInfo, in
&& deviceInfo->deviceOutputChannelCountIsKnown
&& channelCount > deviceInfo->inheritedDeviceInfo.maxOutputChannels ){
- result = paInvalidChannelCount;
+ result = paInvalidChannelCount;
}
return result;
@@ -1225,14 +1225,14 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
then the only thing that could fail is the sample rate. This isn't
strictly true, but I can't think of a better way to test that the
sample rate is valid.
- */
-
+ */
+
if( inputParameters )
{
inputChannelCount = inputParameters->channelCount;
inputSampleFormat = inputParameters->sampleFormat;
inputStreamInfo = inputParameters->hostApiSpecificStreamInfo;
-
+
/* all standard sample formats are supported by the buffer adapter,
this implementation doesn't support any custom sample formats */
if( inputSampleFormat & paCustomFormat )
@@ -1245,29 +1245,29 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
for( i=0; i< inputStreamInfo->deviceCount; ++i )
{
inputMultipleDeviceChannelCount += inputStreamInfo->devices[i].channelCount;
-
+
inputDeviceInfo = hostApi->deviceInfos[ inputStreamInfo->devices[i].device ];
/* check that input device can support inputChannelCount */
if( inputStreamInfo->devices[i].channelCount < 1 )
return paInvalidChannelCount;
- paerror = IsInputChannelCountSupported( (PaWinMmeDeviceInfo*)inputDeviceInfo,
+ paerror = IsInputChannelCountSupported( (PaWinMmeDeviceInfo*)inputDeviceInfo,
inputStreamInfo->devices[i].channelCount );
if( paerror != paNoError )
return paerror;
/* test for valid sample rate, see comment above */
winMmeInputDeviceId = LocalDeviceIndexToWinMmeDeviceId( winMmeHostApi, inputStreamInfo->devices[i].device );
- paerror = QueryFormatSupported( inputDeviceInfo, QueryInputWaveFormatEx,
- winMmeInputDeviceId, inputStreamInfo->devices[i].channelCount, sampleRate,
+ paerror = QueryFormatSupported( inputDeviceInfo, QueryInputWaveFormatEx,
+ winMmeInputDeviceId, inputStreamInfo->devices[i].channelCount, sampleRate,
((inputStreamInfo) ? inputStreamInfo->flags : 0) );
if( paerror != paNoError )
return paInvalidSampleRate;
}
-
+
if( inputMultipleDeviceChannelCount != inputChannelCount )
- return paIncompatibleHostApiSpecificStreamInfo;
+ return paIncompatibleHostApiSpecificStreamInfo;
}
else
{
@@ -1283,7 +1283,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
/* test for valid sample rate, see comment above */
winMmeInputDeviceId = LocalDeviceIndexToWinMmeDeviceId( winMmeHostApi, inputParameters->device );
- paerror = QueryFormatSupported( inputDeviceInfo, QueryInputWaveFormatEx,
+ paerror = QueryFormatSupported( inputDeviceInfo, QueryInputWaveFormatEx,
winMmeInputDeviceId, inputChannelCount, sampleRate,
((inputStreamInfo) ? inputStreamInfo->flags : 0) );
if( paerror != paNoError )
@@ -1309,29 +1309,29 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
for( i=0; i< outputStreamInfo->deviceCount; ++i )
{
outputMultipleDeviceChannelCount += outputStreamInfo->devices[i].channelCount;
-
+
outputDeviceInfo = hostApi->deviceInfos[ outputStreamInfo->devices[i].device ];
/* check that output device can support outputChannelCount */
if( outputStreamInfo->devices[i].channelCount < 1 )
return paInvalidChannelCount;
- paerror = IsOutputChannelCountSupported( (PaWinMmeDeviceInfo*)outputDeviceInfo,
+ paerror = IsOutputChannelCountSupported( (PaWinMmeDeviceInfo*)outputDeviceInfo,
outputStreamInfo->devices[i].channelCount );
if( paerror != paNoError )
return paerror;
/* test for valid sample rate, see comment above */
winMmeOutputDeviceId = LocalDeviceIndexToWinMmeDeviceId( winMmeHostApi, outputStreamInfo->devices[i].device );
- paerror = QueryFormatSupported( outputDeviceInfo, QueryOutputWaveFormatEx,
+ paerror = QueryFormatSupported( outputDeviceInfo, QueryOutputWaveFormatEx,
winMmeOutputDeviceId, outputStreamInfo->devices[i].channelCount, sampleRate,
((outputStreamInfo) ? outputStreamInfo->flags : 0) );
if( paerror != paNoError )
return paInvalidSampleRate;
}
-
+
if( outputMultipleDeviceChannelCount != outputChannelCount )
- return paIncompatibleHostApiSpecificStreamInfo;
+ return paIncompatibleHostApiSpecificStreamInfo;
}
else
{
@@ -1347,24 +1347,24 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
/* test for valid sample rate, see comment above */
winMmeOutputDeviceId = LocalDeviceIndexToWinMmeDeviceId( winMmeHostApi, outputParameters->device );
- paerror = QueryFormatSupported( outputDeviceInfo, QueryOutputWaveFormatEx,
+ paerror = QueryFormatSupported( outputDeviceInfo, QueryOutputWaveFormatEx,
winMmeOutputDeviceId, outputChannelCount, sampleRate,
((outputStreamInfo) ? outputStreamInfo->flags : 0) );
if( paerror != paNoError )
return paInvalidSampleRate;
}
}
-
+
/*
- - if a full duplex stream is requested, check that the combination
- of input and output parameters is supported
+ - if a full duplex stream is requested, check that the combination
+ of input and output parameters is supported
- - check that the device supports sampleRate
+ - check that the device supports sampleRate
- for mme all we can do is test that the input and output devices
- support the requested sample rate and number of channels. we
- cannot test for full duplex compatibility.
- */
+ for mme all we can do is test that the input and output devices
+ support the requested sample rate and number of channels. we
+ cannot test for full duplex compatibility.
+ */
return paFormatIsSupported;
}
@@ -1375,7 +1375,7 @@ static unsigned long ComputeHostBufferCountForFixedBufferSizeFrames(
unsigned long hostBufferSizeFrames,
unsigned long minimumBufferCount )
{
- /* Calculate the number of buffers of length hostFramesPerBuffer
+ /* Calculate the number of buffers of length hostFramesPerBuffer
that fit in suggestedLatencyFrames, rounding up to the next integer.
The value (hostBufferSizeFrames - 1) below is to ensure the buffer count is rounded up.
@@ -1394,11 +1394,11 @@ static unsigned long ComputeHostBufferCountForFixedBufferSizeFrames(
}
-static unsigned long ComputeHostBufferSizeGivenHardUpperLimit(
+static unsigned long ComputeHostBufferSizeGivenHardUpperLimit(
unsigned long userFramesPerBuffer,
unsigned long absoluteMaximumBufferSizeFrames )
{
- static unsigned long primes_[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23,
+ static unsigned long primes_[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23,
29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 0 }; /* zero terminated */
unsigned long result = userFramesPerBuffer;
@@ -1406,15 +1406,15 @@ static unsigned long ComputeHostBufferSizeGivenHardUpperLimit(
assert( absoluteMaximumBufferSizeFrames > 67 ); /* assume maximum is large and we're only factoring by small primes */
- /* search for the largest integer factor of userFramesPerBuffer less
+ /* search for the largest integer factor of userFramesPerBuffer less
than or equal to absoluteMaximumBufferSizeFrames */
- /* repeatedly divide by smallest prime factors until a buffer size
+ /* repeatedly divide by smallest prime factors until a buffer size
smaller than absoluteMaximumBufferSizeFrames is found */
while( result > absoluteMaximumBufferSizeFrames ){
/* search for the smallest prime factor of result */
- for( i=0; primes_[i] != 0; ++i )
+ for( i=0; primes_[i] != 0; ++i )
{
unsigned long p = primes_[i];
unsigned long divided = result / p;
@@ -1467,17 +1467,17 @@ static PaError SelectHostBufferSizeFramesAndHostBufferCount(
effectiveUserFramesPerBuffer = ComputeHostBufferSizeGivenHardUpperLimit( userFramesPerBuffer, absoluteMaximumBufferSizeFrames );
assert( effectiveUserFramesPerBuffer <= absoluteMaximumBufferSizeFrames );
- /* try to ensure that duration of host buffering is at least as
+ /* try to ensure that duration of host buffering is at least as
large as duration of user buffer. */
if( suggestedLatencyFrames < userFramesPerBuffer )
- suggestedLatencyFrames = userFramesPerBuffer;
+ suggestedLatencyFrames = userFramesPerBuffer;
}else{
effectiveUserFramesPerBuffer = userFramesPerBuffer;
}
}
-
+
/* compute a host buffer count based on suggestedLatencyFrames and our granularity */
*hostBufferSizeFrames = effectiveUserFramesPerBuffer;
@@ -1488,12 +1488,12 @@ static PaError SelectHostBufferSizeFramesAndHostBufferCount(
if( *hostBufferSizeFrames >= userFramesPerBuffer )
{
/*
- If there are too many host buffers we would like to coalesce
+ If there are too many host buffers we would like to coalesce
them by packing an integer number of user buffers into each host buffer.
- We try to coalesce such that hostBufferCount will lie between
+ We try to coalesce such that hostBufferCount will lie between
PA_MME_TARGET_HOST_BUFFER_COUNT_ and (PA_MME_TARGET_HOST_BUFFER_COUNT_*2)-1.
We limit coalescing to avoid exceeding either absoluteMaximumBufferSizeFrames and
- preferredMaximumBufferSizeFrames.
+ preferredMaximumBufferSizeFrames.
First, compute a coalescing factor: the number of user buffers per host buffer.
The goal is to achieve PA_MME_TARGET_HOST_BUFFER_COUNT_ total buffer count.
@@ -1503,7 +1503,7 @@ static PaError SelectHostBufferSizeFramesAndHostBufferCount(
The + (PA_MME_TARGET_HOST_BUFFER_COUNT_-2) term below is intended to round up.
*/
numberOfUserBuffersPerHostBuffer = ((*hostBufferCount - 1) + (PA_MME_TARGET_HOST_BUFFER_COUNT_-2)) / (PA_MME_TARGET_HOST_BUFFER_COUNT_ - 1);
-
+
if( numberOfUserBuffersPerHostBuffer > 1 )
{
unsigned long maxCoalescedBufferSizeFrames = (absoluteMaximumBufferSizeFrames < preferredMaximumBufferSizeFrames) /* minimum of our limits */
@@ -1534,8 +1534,8 @@ static PaError CalculateMaxHostSampleFrameSizeBytes(
int *hostSampleFrameSizeBytes )
{
unsigned int i;
- /* PA WMME streams may aggregate multiple WMME devices. When the stream addresses
- more than one device in a single direction, maxDeviceChannelCount is the maximum
+ /* PA WMME streams may aggregate multiple WMME devices. When the stream addresses
+ more than one device in a single direction, maxDeviceChannelCount is the maximum
number of channels used by a single device.
*/
int maxDeviceChannelCount = channelCount;
@@ -1576,11 +1576,11 @@ static PaError CalculateBufferSettings(
double sampleRate, unsigned long userFramesPerBuffer )
{
PaError result = paNoError;
-
+
if( inputChannelCount > 0 ) /* stream has input */
{
int hostInputFrameSizeBytes;
- result = CalculateMaxHostSampleFrameSizeBytes(
+ result = CalculateMaxHostSampleFrameSizeBytes(
inputChannelCount, hostInputSampleFormat, inputStreamInfo, &hostInputFrameSizeBytes );
if( result != paNoError )
goto error;
@@ -1602,7 +1602,7 @@ static PaError CalculateBufferSettings(
}
else
{
- /* input - not using low level latency parameters, so compute
+ /* input - not using low level latency parameters, so compute
hostFramesPerInputBuffer and hostInputBufferCount
based on userFramesPerBuffer and suggestedInputLatency. */
@@ -1615,7 +1615,7 @@ static PaError CalculateBufferSettings(
userFramesPerBuffer,
minimumBufferCount,
(unsigned long)(PA_MME_MAX_HOST_BUFFER_SECS_ * sampleRate), /* in frames. preferred maximum */
- (PA_MME_MAX_HOST_BUFFER_BYTES_ / hostInputFrameSizeBytes), /* in frames. a hard limit. note truncation due to
+ (PA_MME_MAX_HOST_BUFFER_BYTES_ / hostInputFrameSizeBytes), /* in frames. a hard limit. note truncation due to
division is intentional here to limit max bytes */
hostFramesPerInputBuffer,
hostInputBufferCount );
@@ -1654,7 +1654,7 @@ static PaError CalculateBufferSettings(
{
if( inputStreamInfo
&& ( inputStreamInfo->flags & paWinMmeUseLowLevelLatencyParameters ) )
- {
+ {
/* a custom StreamInfo was used for specifying both input
and output buffer sizes. We require that the larger buffer size
must be a multiple of the smaller buffer size */
@@ -1675,7 +1675,7 @@ static PaError CalculateBufferSettings(
result = paIncompatibleHostApiSpecificStreamInfo;
goto error;
}
- }
+ }
}
else
{
@@ -1685,8 +1685,8 @@ static PaError CalculateBufferSettings(
*hostFramesPerInputBuffer = *hostFramesPerOutputBuffer;
*hostInputBufferCount = ComputeHostBufferCountForFixedBufferSizeFrames(
- (unsigned long)(suggestedInputLatency * sampleRate),
- *hostFramesPerInputBuffer,
+ (unsigned long)(suggestedInputLatency * sampleRate),
+ *hostFramesPerInputBuffer,
PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_ );
}
}
@@ -1698,7 +1698,7 @@ static PaError CalculateBufferSettings(
based on userFramesPerBuffer and suggestedOutputLatency. */
int hostOutputFrameSizeBytes;
- result = CalculateMaxHostSampleFrameSizeBytes(
+ result = CalculateMaxHostSampleFrameSizeBytes(
outputChannelCount, hostOutputSampleFormat, outputStreamInfo, &hostOutputFrameSizeBytes );
if( result != paNoError )
goto error;
@@ -1710,7 +1710,7 @@ static PaError CalculateBufferSettings(
userFramesPerBuffer,
PA_MME_MIN_HOST_OUTPUT_BUFFER_COUNT_,
(unsigned long)(PA_MME_MAX_HOST_BUFFER_SECS_ * sampleRate), /* in frames. preferred maximum */
- (PA_MME_MAX_HOST_BUFFER_BYTES_ / hostOutputFrameSizeBytes), /* in frames. a hard limit. note truncation due to
+ (PA_MME_MAX_HOST_BUFFER_BYTES_ / hostOutputFrameSizeBytes), /* in frames. a hard limit. note truncation due to
division is intentional here to limit max bytes */
hostFramesPerOutputBuffer,
hostOutputBufferCount );
@@ -1734,8 +1734,8 @@ static PaError CalculateBufferSettings(
*hostFramesPerOutputBuffer = *hostFramesPerInputBuffer;
*hostOutputBufferCount = ComputeHostBufferCountForFixedBufferSizeFrames(
- (unsigned long)(suggestedOutputLatency * sampleRate),
- *hostOutputBufferCount,
+ (unsigned long)(suggestedOutputLatency * sampleRate),
+ *hostOutputBufferCount,
PA_MME_MIN_HOST_OUTPUT_BUFFER_COUNT_ );
}
else
@@ -1743,11 +1743,11 @@ static PaError CalculateBufferSettings(
*hostFramesPerInputBuffer = *hostFramesPerOutputBuffer;
*hostInputBufferCount = ComputeHostBufferCountForFixedBufferSizeFrames(
- (unsigned long)(suggestedInputLatency * sampleRate),
- *hostFramesPerInputBuffer,
+ (unsigned long)(suggestedInputLatency * sampleRate),
+ *hostFramesPerInputBuffer,
PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_ );
}
- }
+ }
}
}
}
@@ -1801,7 +1801,7 @@ static void InitializeSingleDirectionHandlesAndBuffers( PaWinMmeSingleDirectionH
handlesAndBuffers->deviceCount = 0;
handlesAndBuffers->waveHeaders = 0;
handlesAndBuffers->bufferCount = 0;
-}
+}
static PaError InitializeWaveHandles( PaWinMmeHostApiRepresentation *winMmeHostApi,
PaWinMmeSingleDirectionHandlesAndBuffers *handlesAndBuffers,
@@ -1817,7 +1817,7 @@ static PaError InitializeWaveHandles( PaWinMmeHostApiRepresentation *winMmeHostA
int waveFormatTag;
/* for error cleanup we expect that InitializeSingleDirectionHandlesAndBuffers()
- has already been called to zero some fields */
+ has already been called to zero some fields */
result = CreateEventWithPaError( &handlesAndBuffers->bufferEvent, NULL, FALSE, FALSE, NULL );
if( result != paNoError ) goto error;
@@ -1850,25 +1850,25 @@ static PaError InitializeWaveHandles( PaWinMmeHostApiRepresentation *winMmeHostA
{
PaWinWaveFormat waveFormat;
UINT winMmeDeviceId = LocalDeviceIndexToWinMmeDeviceId( winMmeHostApi, devices[i].device );
-
- /* @todo: consider providing a flag or #define to not try waveformat extensible
+
+ /* @todo: consider providing a flag or #define to not try waveformat extensible
this could just initialize j to 1 the first time round. */
for( j = 0; j < 2; ++j )
{
switch(j){
- case 0:
- /* first, attempt to open the device using WAVEFORMATEXTENSIBLE,
+ case 0:
+ /* first, attempt to open the device using WAVEFORMATEXTENSIBLE,
if this fails we fall back to WAVEFORMATEX */
- PaWin_InitializeWaveFormatExtensible( &waveFormat, devices[i].channelCount,
+ PaWin_InitializeWaveFormatExtensible( &waveFormat, devices[i].channelCount,
sampleFormat, waveFormatTag, sampleRate, channelMask );
break;
-
+
case 1:
/* retry with WAVEFORMATEX */
- PaWin_InitializeWaveFormatEx( &waveFormat, devices[i].channelCount,
+ PaWin_InitializeWaveFormatEx( &waveFormat, devices[i].channelCount,
sampleFormat, waveFormatTag, sampleRate );
break;
}
@@ -1879,13 +1879,13 @@ static PaError InitializeWaveHandles( PaWinMmeHostApiRepresentation *winMmeHostA
if( isInput )
{
- mmresult = waveInOpen( &((HWAVEIN*)handlesAndBuffers->waveHandles)[i], winMmeDeviceId,
+ mmresult = waveInOpen( &((HWAVEIN*)handlesAndBuffers->waveHandles)[i], winMmeDeviceId,
(WAVEFORMATEX*)&waveFormat,
(DWORD_PTR)handlesAndBuffers->bufferEvent, (DWORD_PTR)0, CALLBACK_EVENT );
}
else
{
- mmresult = waveOutOpen( &((HWAVEOUT*)handlesAndBuffers->waveHandles)[i], winMmeDeviceId,
+ mmresult = waveOutOpen( &((HWAVEOUT*)handlesAndBuffers->waveHandles)[i], winMmeDeviceId,
(WAVEFORMATEX*)&waveFormat,
(DWORD_PTR)handlesAndBuffers->bufferEvent, (DWORD_PTR)0, CALLBACK_EVENT );
}
@@ -1905,20 +1905,20 @@ static PaError InitializeWaveHandles( PaWinMmeHostApiRepresentation *winMmeHostA
case MMSYSERR_ALLOCATED: /* Specified resource is already allocated. */
result = paDeviceUnavailable;
break;
- case MMSYSERR_NODRIVER: /* No device driver is present. */
+ case MMSYSERR_NODRIVER: /* No device driver is present. */
result = paDeviceUnavailable;
break;
- case MMSYSERR_NOMEM: /* Unable to allocate or lock memory. */
+ case MMSYSERR_NOMEM: /* Unable to allocate or lock memory. */
result = paInsufficientMemory;
break;
- case MMSYSERR_BADDEVICEID: /* Specified device identifier is out of range. */
+ case MMSYSERR_BADDEVICEID: /* Specified device identifier is out of range. */
/* falls through */
case WAVERR_BADFORMAT: /* Attempted to open with an unsupported waveform-audio format. */
/* This can also occur if we try to open the device with an unsupported
* number of channels. This is attempted when device*ChannelCountIsKnown is
- * set to 0.
+ * set to 0.
*/
/* falls through */
default:
@@ -1951,7 +1951,7 @@ static PaError TerminateWaveHandles( PaWinMmeSingleDirectionHandlesAndBuffers *h
PaError result = paNoError;
MMRESULT mmresult;
signed int i;
-
+
if( handlesAndBuffers->waveHandles )
{
for( i = handlesAndBuffers->deviceCount-1; i >= 0; --i )
@@ -1996,7 +1996,7 @@ static PaError TerminateWaveHandles( PaWinMmeSingleDirectionHandlesAndBuffers *h
result = CloseHandleWithPaError( handlesAndBuffers->bufferEvent );
handlesAndBuffers->bufferEvent = 0;
}
-
+
return result;
}
@@ -2015,7 +2015,7 @@ static PaError InitializeWaveHeaders( PaWinMmeSingleDirectionHandlesAndBuffers *
/* for error cleanup we expect that InitializeSingleDirectionHandlesAndBuffers()
has already been called to zero some fields */
-
+
/* allocate an array of pointers to arrays of wave headers, one array of
wave headers per device */
@@ -2025,7 +2025,7 @@ static PaError InitializeWaveHeaders( PaWinMmeSingleDirectionHandlesAndBuffers *
result = paInsufficientMemory;
goto error;
}
-
+
for( i = 0; i < (signed int)handlesAndBuffers->deviceCount; ++i )
handlesAndBuffers->waveHeaders[i] = 0;
@@ -2094,7 +2094,7 @@ static PaError InitializeWaveHeaders( PaWinMmeSingleDirectionHandlesAndBuffers *
error:
TerminateWaveHeaders( handlesAndBuffers, isInput );
-
+
return result;
}
@@ -2103,7 +2103,7 @@ static void TerminateWaveHeaders( PaWinMmeSingleDirectionHandlesAndBuffers *hand
{
signed int i, j;
WAVEHDR *deviceWaveHeaders;
-
+
if( handlesAndBuffers->waveHeaders )
{
for( i = handlesAndBuffers->deviceCount-1; i >= 0 ; --i )
@@ -2156,7 +2156,7 @@ struct PaWinMmeStream
HANDLE processingThread;
PA_THREAD_ID processingThreadId;
- char throttleProcessingThreadOnOverload; /* 0 -> don't throtte, non-0 -> throttle */
+ char throttleProcessingThreadOnOverload; /* 0 -> don't throtte, non-0 -> throttle */
int processingThreadPriority;
int highThreadPriority;
int throttledThreadPriority;
@@ -2164,10 +2164,10 @@ struct PaWinMmeStream
int isStopped;
volatile int isActive;
- volatile int stopProcessing; /* stop thread once existing buffers have been returned */
- volatile int abortProcessing; /* stop thread immediately */
+ volatile int stopProcessing; /* stop thread once existing buffers have been returned */
+ volatile int abortProcessing; /* stop thread immediately */
- DWORD allBuffersDurationMs; /* used to calculate timeouts */
+ DWORD allBuffersDurationMs; /* used to calculate timeouts */
};
/* updates deviceCount if PaWinMmeUseMultipleDevices is used */
@@ -2191,14 +2191,14 @@ static PaError ValidateWinMmeSpecificStreamInfo(
if( streamInfo->flags & paWinMmeDontThrottleOverloadedProcessingThread )
*throttleProcessingThreadOnOverload = 0;
-
+
if( streamInfo->flags & paWinMmeUseMultipleDevices )
{
if( streamParameters->device != paUseHostApiSpecificDeviceSpecification )
return paInvalidDevice;
-
+
*deviceCount = streamInfo->deviceCount;
- }
+ }
}
return paNoError;
@@ -2215,7 +2215,7 @@ static PaError RetrieveDevicesFromStreamParameters(
unsigned int i;
int totalChannelCount;
PaDeviceIndex hostApiDevice;
-
+
if( streamInfo && streamInfo->flags & paWinMmeUseMultipleDevices )
{
totalChannelCount = 0;
@@ -2226,21 +2226,21 @@ static PaError RetrieveDevicesFromStreamParameters(
streamInfo->devices[i].device, hostApi );
if( result != paNoError )
return result;
-
+
devices[i].device = hostApiDevice;
devices[i].channelCount = streamInfo->devices[i].channelCount;
-
+
totalChannelCount += devices[i].channelCount;
}
-
+
if( totalChannelCount != streamParameters->channelCount )
{
/* channelCount must match total channels specified by multiple devices */
return paInvalidChannelCount; /* REVIEW use of this error code */
}
- }
+ }
else
- {
+ {
devices[0].device = streamParameters->device;
devices[0].channelCount = streamParameters->channelCount;
}
@@ -2262,7 +2262,7 @@ static PaError ValidateInputChannelCounts(
if( devices[i].channelCount < 1 )
return paInvalidChannelCount;
- inputDeviceInfo =
+ inputDeviceInfo =
(PaWinMmeDeviceInfo*)hostApi->deviceInfos[ devices[i].device ];
paerror = IsInputChannelCountSupported( inputDeviceInfo, devices[i].channelCount );
@@ -2287,7 +2287,7 @@ static PaError ValidateOutputChannelCounts(
if( devices[i].channelCount < 1 )
return paInvalidChannelCount;
- outputDeviceInfo =
+ outputDeviceInfo =
(PaWinMmeDeviceInfo*)hostApi->deviceInfos[ devices[i].device ];
paerror = IsOutputChannelCountSupported( outputDeviceInfo, devices[i].channelCount );
@@ -2331,15 +2331,15 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
unsigned long framesPerHostOutputBuffer;
unsigned long hostOutputBufferCount;
unsigned long framesPerBufferProcessorCall;
- PaWinMmeDeviceAndChannelCount *inputDevices = 0; /* contains all devices and channel counts as local host api ids, even when PaWinMmeUseMultipleDevices is not used */
+ PaWinMmeDeviceAndChannelCount *inputDevices = 0; /* contains all devices and channel counts as local host api ids, even when PaWinMmeUseMultipleDevices is not used */
unsigned long winMmeSpecificInputFlags = 0;
- unsigned long inputDeviceCount = 0;
+ unsigned long inputDeviceCount = 0;
PaWinMmeDeviceAndChannelCount *outputDevices = 0;
unsigned long winMmeSpecificOutputFlags = 0;
unsigned long outputDeviceCount = 0; /* contains all devices and channel counts as local host api ids, even when PaWinMmeUseMultipleDevices is not used */
char throttleProcessingThreadOnOverload = 1;
-
+
if( inputParameters )
{
inputChannelCount = inputParameters->channelCount;
@@ -2370,7 +2370,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
if( inputDeviceCount != 1 ){
/* always use direct speakers when using multi-device multichannel mode */
- inputChannelMask = PAWIN_SPEAKER_DIRECTOUT;
+ inputChannelMask = PAWIN_SPEAKER_DIRECTOUT;
}
else
{
@@ -2420,7 +2420,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
if( outputDeviceCount != 1 ){
/* always use direct speakers when using multi-device multichannel mode */
- outputChannelMask = PAWIN_SPEAKER_DIRECTOUT;
+ outputChannelMask = PAWIN_SPEAKER_DIRECTOUT;
}
else
{
@@ -2503,7 +2503,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else
{
assert( (framesPerHostInputBuffer % framesPerHostOutputBuffer) == 0 ); /* CalculateBufferSettings() should guarantee this condition */
-
+
framesPerBufferProcessorCall = framesPerHostOutputBuffer;
}
}
@@ -2526,7 +2526,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
framesPerBufferProcessorCall, paUtilFixedHostBufferSize,
streamCallback, userData );
if( result != paNoError ) goto error;
-
+
bufferProcessorIsInitialized = 1;
/* stream info input latency is the minimum buffering latency (unlike suggested and default which are *maximums*) */
@@ -2563,7 +2563,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
inputDevices, inputDeviceCount, inputChannelMask, 1 /* isInput */ );
if( result != paNoError ) goto error;
}
-
+
if( outputParameters )
{
result = InitializeWaveHandles( winMmeHostApi, &stream->output,
@@ -2593,7 +2593,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->allBuffersDurationMs = (DWORD) (1000.0 * (framesPerHostInputBuffer * stream->input.bufferCount) / sampleRate);
}
-
+
if( streamCallback )
{
/* abort event is only needed for callback streams */
@@ -2611,7 +2611,7 @@ error:
{
if( stream->abortEvent )
CloseHandle( stream->abortEvent );
-
+
TerminateWaveHeaders( &stream->output, 0 /* not isInput */ );
TerminateWaveHeaders( &stream->input, 1 /* isInput */ );
@@ -2635,13 +2635,13 @@ error:
static int BuffersAreDone( WAVEHDR **waveHeaders, unsigned int deviceCount, int bufferIndex )
{
unsigned int i;
-
+
for( i=0; i < deviceCount; ++i )
{
if( !(waveHeaders[i][ bufferIndex ].dwFlags & WHDR_DONE) )
{
return 0;
- }
+ }
}
return 1;
@@ -2686,13 +2686,13 @@ static int NoBuffersAreQueued( PaWinMmeSingleDirectionHandlesAndBuffers *handles
#define PA_CIRCULAR_DECREMENT_( current, max )\
( ((current) == 0) ? ((max)-1) : (current-1) )
-
+
static signed long GetAvailableFrames( PaWinMmeSingleDirectionHandlesAndBuffers *handlesAndBuffers )
{
signed long result = 0;
unsigned int i;
-
+
if( BuffersAreDone( handlesAndBuffers->waveHeaders, handlesAndBuffers->deviceCount, handlesAndBuffers->currentBufferIndex ) )
{
/* we could calculate the following in O(1) if we kept track of the
@@ -2766,7 +2766,7 @@ static PaError AdvanceToNextOutputBuffer( PaWinMmeStream *stream )
PA_CIRCULAR_INCREMENT_( stream->output.currentBufferIndex, stream->output.bufferCount );
stream->output.framesUsedInCurrentBuffer = 0;
-
+
return result;
}
@@ -2777,7 +2777,7 @@ static PaError CatchUpInputBuffers( PaWinMmeStream *stream )
{
PaError result = paNoError;
unsigned int i;
-
+
for( i=0; i < stream->input.bufferCount - 1; ++i )
{
result = AdvanceToNextInputBuffer( stream );
@@ -2836,7 +2836,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
int done = 0;
unsigned int channel, i;
unsigned long framesProcessed;
-
+
/* prepare event array for call to WaitForMultipleObjects() */
if( stream->input.bufferEvent )
events[eventCount++] = stream->input.bufferEvent;
@@ -2845,7 +2845,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
events[eventCount++] = stream->abortEvent;
statusFlags = 0; /** @todo support paInputUnderflow, paOutputOverflow and paNeverDropInput */
-
+
/* loop until something causes us to stop */
do{
/* wait for MME to signal that a buffer is available, or for
@@ -2905,7 +2905,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
{
hostInputBufferIndex = -1;
hostOutputBufferIndex = -1;
-
+
if( PA_IS_INPUT_STREAM_(stream) )
{
if( CurrentInputBuffersAreDone( stream ) )
@@ -2939,7 +2939,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
if( CurrentOutputBuffersAreDone( stream ) )
{
/* ok, we have an output buffer */
-
+
if( NoBuffersAreQueued( &stream->output ) )
{
/*
@@ -2966,7 +2966,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
}
}
-
+
if( (PA_IS_FULL_DUPLEX_STREAM_(stream) && hostInputBufferIndex != -1 && hostOutputBufferIndex != -1) ||
(PA_IS_HALF_DUPLEX_STREAM_(stream) && ( hostInputBufferIndex != -1 || hostOutputBufferIndex != -1 ) ) )
{
@@ -2980,11 +2980,11 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
MMTIME mmtime;
double timeBeforeGetPosition, timeAfterGetPosition;
double time;
- long framesInBufferRing;
+ long framesInBufferRing;
long writePosition;
long playbackPosition;
HWAVEOUT firstWaveOutDevice = ((HWAVEOUT*)stream->output.waveHandles)[0];
-
+
mmtime.wType = TIME_SAMPLES;
timeBeforeGetPosition = PaUtil_GetTime();
waveOutGetPosition( firstWaveOutDevice, &mmtime, sizeof(MMTIME) );
@@ -2995,13 +2995,13 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
/* approximate time at which wave out position was measured
as half way between timeBeforeGetPosition and timeAfterGetPosition */
time = timeBeforeGetPosition + (timeAfterGetPosition - timeBeforeGetPosition) * .5;
-
+
framesInBufferRing = stream->output.bufferCount * stream->bufferProcessor.framesPerHostBuffer;
playbackPosition = mmtime.u.sample % framesInBufferRing;
writePosition = stream->output.currentBufferIndex * stream->bufferProcessor.framesPerHostBuffer
+ stream->output.framesUsedInCurrentBuffer;
-
+
if( playbackPosition >= writePosition ){
timeInfo.outputBufferDacTime =
time + ((double)( writePosition + (framesInBufferRing - playbackPosition) ) * stream->bufferProcessor.samplePeriod );
@@ -3028,13 +3028,13 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
{
/* we have stored the number of channels in the buffer in dwUser */
int channelCount = (int)stream->input.waveHeaders[i][ hostInputBufferIndex ].dwUser;
-
+
PaUtil_SetInterleavedInputChannels( &stream->bufferProcessor, channel,
stream->input.waveHeaders[i][ hostInputBufferIndex ].lpData +
stream->input.framesUsedInCurrentBuffer * channelCount *
stream->bufferProcessor.bytesPerHostInputSample,
channelCount );
-
+
channel += channelCount;
}
@@ -3043,7 +3043,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
if( PA_IS_OUTPUT_STREAM_(stream) )
{
PaUtil_SetOutputFrameCount( &stream->bufferProcessor, 0 /* default to host buffer size */ );
-
+
channel = 0;
for( i=0; ioutput.deviceCount; ++i )
{
@@ -3076,7 +3076,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
{
stream->abortProcessing = 1;
done = 1;
- /** @todo FIXME: should probably reset the output device immediately once the callback returns paAbort
+ /** @todo FIXME: should probably reset the output device immediately once the callback returns paAbort
see: http://www.portaudio.com/trac/ticket/141
*/
result = paNoError;
@@ -3108,7 +3108,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
done = 1;
}
-
+
if( PA_IS_OUTPUT_STREAM_(stream) && !stream->abortProcessing )
{
if( stream->stopProcessing &&
@@ -3150,7 +3150,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
}
}
}
-
+
if( stream->throttleProcessingThreadOnOverload != 0 )
{
if( stream->stopProcessing || stream->abortProcessing )
@@ -3201,7 +3201,7 @@ PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
stream->streamRepresentation.streamFinishedCallback( stream->streamRepresentation.userData );
PaUtil_ResetCpuLoadMeasurer( &stream->cpuLoadMeasurer );
-
+
return result;
}
@@ -3217,13 +3217,13 @@ static PaError CloseStream( PaStream* s )
result = CloseHandleWithPaError( stream->abortEvent );
if( result != paNoError ) goto error;
-
+
TerminateWaveHeaders( &stream->output, 0 /* not isInput */ );
TerminateWaveHeaders( &stream->input, 1 /* isInput */ );
TerminateWaveHandles( &stream->output, 0 /* not isInput */, 0 /* not currentlyProcessingAnError */ );
TerminateWaveHandles( &stream->input, 1 /* isInput */, 0 /* not currentlyProcessingAnError */ );
-
+
PaUtil_TerminateBufferProcessor( &stream->bufferProcessor );
PaUtil_TerminateStreamRepresentation( &stream->streamRepresentation );
PaUtil_FreeMemory( stream );
@@ -3244,9 +3244,9 @@ static PaError StartStream( PaStream *s )
unsigned int channel;
unsigned long framesProcessed;
PaStreamCallbackTimeInfo timeInfo = {0,0,0}; /** @todo implement this for stream priming */
-
+
PaUtil_ResetBufferProcessor( &stream->bufferProcessor );
-
+
if( PA_IS_INPUT_STREAM_(stream) )
{
for( i=0; iinput.bufferCount; ++i )
@@ -3335,7 +3335,7 @@ static PaError StartStream( PaStream *s )
{
ZeroMemory( stream->output.waveHeaders[j][i].lpData, stream->output.waveHeaders[j][i].dwBufferLength );
}
- }
+ }
/* we queue all channels of a single buffer frame (across all
devices, because some multidevice multichannel drivers work
@@ -3366,8 +3366,8 @@ static PaError StartStream( PaStream *s )
result = ResetEventWithPaError( stream->output.bufferEvent );
if( result != paNoError ) goto error;
-
-
+
+
if( stream->streamRepresentation.streamCallback )
{
/* callback stream */
@@ -3449,8 +3449,8 @@ static PaError StopStream( PaStream *s )
DWORD waitResult;
MMRESULT mmresult;
signed int hostOutputBufferIndex;
- unsigned int channel, waitCount, i;
-
+ unsigned int channel, waitCount, i;
+
/** @todo
REVIEW: the error checking in this function needs review. the basic
idea is to return from this function in a known state - for example
@@ -3503,7 +3503,7 @@ static PaError StopStream( PaStream *s )
PaUtil_SetOutputFrameCount( &stream->bufferProcessor,
stream->output.framesPerBuffer - stream->output.framesUsedInCurrentBuffer );
-
+
channel = 0;
for( i=0; ioutput.deviceCount; ++i )
{
@@ -3528,7 +3528,7 @@ static PaError StopStream( PaStream *s )
*/
AdvanceToNextOutputBuffer( stream );
}
-
+
timeout = (stream->allBuffersDurationMs / stream->output.bufferCount) + 1;
if( timeout < PA_MME_MIN_TIMEOUT_MSEC_ )
@@ -3594,7 +3594,7 @@ static PaError AbortStream( PaStream *s )
DWORD waitResult;
MMRESULT mmresult;
unsigned int i;
-
+
/** @todo
REVIEW: the error checking in this function needs review. the basic
idea is to return from this function in a known state - for example
@@ -3605,7 +3605,7 @@ static PaError AbortStream( PaStream *s )
if( stream->processingThread )
{
/* callback stream */
-
+
/* Tell processing thread to abort immediately */
stream->abortProcessing = 1;
SetEvent( stream->abortEvent );
@@ -3642,14 +3642,14 @@ static PaError AbortStream( PaStream *s )
if( stream->processingThread )
{
/* callback stream */
-
+
PA_DEBUG(("WinMME AbortStream: waiting for background thread.\n"));
/* Calculate timeOut longer than longest time it could take to return all buffers. */
timeout = (int)(stream->allBuffersDurationMs * 1.5);
if( timeout < PA_MME_MIN_TIMEOUT_MSEC_ )
timeout = PA_MME_MIN_TIMEOUT_MSEC_;
-
+
waitResult = WaitForSingleObject( stream->processingThread, timeout );
if( waitResult == WAIT_TIMEOUT )
{
@@ -3687,7 +3687,7 @@ static PaError IsStreamActive( PaStream *s )
static PaTime GetStreamTime( PaStream *s )
{
(void) s; /* unused parameter */
-
+
return PaUtil_GetTime();
}
@@ -3719,7 +3719,7 @@ static PaError ReadStream( PaStream* s,
DWORD waitResult;
DWORD timeout = (unsigned long)(stream->allBuffersDurationMs * 0.5);
unsigned int channel, i;
-
+
if( PA_IS_INPUT_STREAM_(stream) )
{
/* make a local copy of the user buffer pointer(s). this is necessary
@@ -3738,7 +3738,7 @@ static PaError ReadStream( PaStream* s,
for( i = 0; ibufferProcessor.inputChannelCount; ++i )
((void**)userBuffer)[i] = ((void**)buffer)[i];
}
-
+
do{
if( CurrentInputBuffersAreDone( stream ) )
{
@@ -3746,7 +3746,7 @@ static PaError ReadStream( PaStream* s,
{
/** @todo REVIEW: consider what to do if the input overflows.
do we requeue all of the buffers? should we be running
- a thread to make sure they are always queued?
+ a thread to make sure they are always queued?
see: http://www.portaudio.com/trac/ticket/117
*/
@@ -3757,7 +3757,7 @@ static PaError ReadStream( PaStream* s,
PaUtil_SetInputFrameCount( &stream->bufferProcessor,
stream->input.framesPerBuffer - stream->input.framesUsedInCurrentBuffer );
-
+
channel = 0;
for( i=0; iinput.deviceCount; ++i )
{
@@ -3772,7 +3772,7 @@ static PaError ReadStream( PaStream* s,
channel += channelCount;
}
-
+
framesProcessed = PaUtil_CopyInput( &stream->bufferProcessor, &userBuffer, frames - framesRead );
stream->input.framesUsedInCurrentBuffer += framesProcessed;
@@ -3783,7 +3783,7 @@ static PaError ReadStream( PaStream* s,
break;
}
- framesRead += framesProcessed;
+ framesRead += framesProcessed;
}else{
/* wait for MME to signal that a buffer is available */
@@ -3798,7 +3798,7 @@ static PaError ReadStream( PaStream* s,
/* if a timeout is encountered, continue,
perhaps we should give up eventually
*/
- }
+ }
}
}while( framesRead < frames );
}
@@ -3825,7 +3825,7 @@ static PaError WriteStream( PaStream* s,
DWORD timeout = (unsigned long)(stream->allBuffersDurationMs * 0.5);
unsigned int channel, i;
-
+
if( PA_IS_OUTPUT_STREAM_(stream) )
{
/* make a local copy of the user buffer pointer(s). this is necessary
@@ -3853,7 +3853,7 @@ static PaError WriteStream( PaStream* s,
/** @todo REVIEW: consider what to do if the output
underflows. do we requeue all the existing buffers with
zeros? should we run a separate thread to keep the buffers
- enqueued at all times?
+ enqueued at all times?
see: http://www.portaudio.com/trac/ticket/117
*/
@@ -3864,7 +3864,7 @@ static PaError WriteStream( PaStream* s,
PaUtil_SetOutputFrameCount( &stream->bufferProcessor,
stream->output.framesPerBuffer - stream->output.framesUsedInCurrentBuffer );
-
+
channel = 0;
for( i=0; ioutput.deviceCount; ++i )
{
@@ -3879,7 +3879,7 @@ static PaError WriteStream( PaStream* s,
channel += channelCount;
}
-
+
framesProcessed = PaUtil_CopyOutput( &stream->bufferProcessor, &userBuffer, frames - framesWritten );
stream->output.framesUsedInCurrentBuffer += framesProcessed;
@@ -3906,15 +3906,15 @@ static PaError WriteStream( PaStream* s,
/* if a timeout is encountered, continue,
perhaps we should give up eventually
*/
- }
- }
+ }
+ }
}while( framesWritten < frames );
}
else
{
result = paCanNotWriteToAnInputOnlyStream;
}
-
+
return result;
}
@@ -3922,7 +3922,7 @@ static PaError WriteStream( PaStream* s,
static signed long GetStreamReadAvailable( PaStream* s )
{
PaWinMmeStream *stream = (PaWinMmeStream*)s;
-
+
if( PA_IS_INPUT_STREAM_(stream) )
return GetAvailableFrames( &stream->input );
else
@@ -3933,7 +3933,7 @@ static signed long GetStreamReadAvailable( PaStream* s )
static signed long GetStreamWriteAvailable( PaStream* s )
{
PaWinMmeStream *stream = (PaWinMmeStream*)s;
-
+
if( PA_IS_OUTPUT_STREAM_(stream) )
return GetAvailableFrames( &stream->output );
else
@@ -3951,7 +3951,7 @@ static PaError GetWinMMEStreamPointer( PaWinMmeStream **stream, PaStream *s )
PaError result;
PaUtilHostApiRepresentation *hostApi;
PaWinMmeHostApiRepresentation *winMmeHostApi;
-
+
result = PaUtil_ValidateStreamPointer( s );
if( result != paNoError )
return result;
@@ -3961,10 +3961,10 @@ static PaError GetWinMMEStreamPointer( PaWinMmeStream **stream, PaStream *s )
return result;
winMmeHostApi = (PaWinMmeHostApiRepresentation*)hostApi;
-
+
/* note, the following would be easier if there was a generic way of testing
that a stream belongs to a specific host API */
-
+
if( PA_STREAM_REP( s )->streamInterface == &winMmeHostApi->callbackStreamInterface
|| PA_STREAM_REP( s )->streamInterface == &winMmeHostApi->blockingStreamInterface )
{
From fac71001ee55c62c71801979eb3216b92b009988 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 21 Jan 2021 23:06:08 +1100
Subject: [PATCH 084/157] Clean up whitespace in src/common in preparation for
.editorconfig. (#408)
* Clean up whitespace in src/common in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace.
---
src/common/pa_allocation.c | 16 +-
src/common/pa_allocation.h | 8 +-
src/common/pa_converters.c | 146 ++++++++--------
src/common/pa_converters.h | 12 +-
src/common/pa_cpuload.c | 8 +-
src/common/pa_cpuload.h | 8 +-
src/common/pa_debugprint.c | 48 +++---
src/common/pa_debugprint.h | 16 +-
src/common/pa_dither.c | 82 ++++-----
src/common/pa_dither.h | 6 +-
src/common/pa_endianness.h | 30 ++--
src/common/pa_front.c | 24 +--
src/common/pa_hostapi.h | 78 ++++-----
src/common/pa_memorybarrier.h | 56 +++---
src/common/pa_process.c | 312 +++++++++++++++++-----------------
src/common/pa_process.h | 50 +++---
src/common/pa_ringbuffer.c | 14 +-
src/common/pa_ringbuffer.h | 18 +-
src/common/pa_stream.c | 6 +-
src/common/pa_stream.h | 10 +-
src/common/pa_trace.c | 8 +-
src/common/pa_trace.h | 16 +-
src/common/pa_types.h | 8 +-
src/common/pa_util.h | 8 +-
24 files changed, 494 insertions(+), 494 deletions(-)
diff --git a/src/common/pa_allocation.c b/src/common/pa_allocation.c
index 51fe15a..265a4e6 100644
--- a/src/common/pa_allocation.c
+++ b/src/common/pa_allocation.c
@@ -27,13 +27,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -78,7 +78,7 @@ static struct PaUtilAllocationGroupLink *AllocateLinks( long count,
{
struct PaUtilAllocationGroupLink *result;
int i;
-
+
result = (struct PaUtilAllocationGroupLink *)PaUtil_AllocateMemory(
sizeof(struct PaUtilAllocationGroupLink) * count );
if( result )
@@ -95,7 +95,7 @@ static struct PaUtilAllocationGroupLink *AllocateLinks( long count,
}
result[count-1].next = nextSpare;
}
-
+
return result;
}
@@ -147,7 +147,7 @@ void* PaUtil_GroupAllocateMemory( PaUtilAllocationGroup* group, long size )
{
struct PaUtilAllocationGroupLink *links, *link;
void *result = 0;
-
+
/* allocate more links if necessary */
if( !group->spareLinks )
{
@@ -176,7 +176,7 @@ void* PaUtil_GroupAllocateMemory( PaUtilAllocationGroup* group, long size )
}
}
- return result;
+ return result;
}
@@ -208,7 +208,7 @@ void PaUtil_GroupFreeMemory( PaUtilAllocationGroup* group, void *buffer )
break;
}
-
+
previous = current;
current = current->next;
}
diff --git a/src/common/pa_allocation.h b/src/common/pa_allocation.h
index bc1bb7d..5c3cf53 100644
--- a/src/common/pa_allocation.h
+++ b/src/common/pa_allocation.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -44,7 +44,7 @@
@brief Allocation Group prototypes. An Allocation Group makes it easy to
allocate multiple blocks of memory and free them all at once.
-
+
An allocation group is useful for keeping track of multiple blocks
of memory which are allocated at the same time (such as during initialization)
and need to be deallocated at the same time. The allocation group maintains
diff --git a/src/common/pa_converters.c b/src/common/pa_converters.c
index 16f5864..93e44a3 100644
--- a/src/common/pa_converters.c
+++ b/src/common/pa_converters.c
@@ -26,13 +26,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -40,17 +40,17 @@
@ingroup common_src
@brief Conversion function implementations.
-
+
If the C9x function lrintf() is available, define PA_USE_C99_LRINTF to use it
@todo Consider whether functions which dither but don't clip should exist,
V18 automatically enabled clipping whenever dithering was selected. Perhaps
- we should do the same.
+ we should do the same.
see: "require clipping for dithering sample conversion functions?"
http://www.portaudio.com/trac/ticket/112
@todo implement the converters marked IMPLEMENT ME: Int32_To_Int24_Dither,
- Int32_To_UInt8_Dither, Int24_To_Int16_Dither, Int24_To_Int8_Dither,
+ Int32_To_UInt8_Dither, Int24_To_Int16_Dither, Int24_To_Int8_Dither,
Int24_To_UInt8_Dither, Int16_To_Int8_Dither, Int16_To_UInt8_Dither
see: "some conversion functions are not implemented in pa_converters.c"
http://www.portaudio.com/trac/ticket/35
@@ -74,7 +74,7 @@ PaSampleFormat PaUtil_SelectClosestAvailableFormat(
format &= ~paNonInterleaved;
availableFormats &= ~paNonInterleaved;
-
+
if( (format & availableFormats) == 0 )
{
/* NOTE: this code depends on the sample format constants being in
@@ -97,7 +97,7 @@ PaSampleFormat PaUtil_SelectClosestAvailableFormat(
{
result = 0;
}
-
+
if( result == 0 ){
/* scan for worse formats */
result = format;
@@ -110,7 +110,7 @@ PaSampleFormat PaUtil_SelectClosestAvailableFormat(
if( (result & availableFormats) == 0 )
result = paSampleFormatNotSupported;
}
-
+
}else{
result = format;
}
@@ -286,7 +286,7 @@ PaUtilConverterTable paConverters = {
0, /* PaUtilConverter *Int24_To_Int8_Dither; */
0, /* PaUtilConverter *Int24_To_UInt8; */
0, /* PaUtilConverter *Int24_To_UInt8_Dither; */
-
+
0, /* PaUtilConverter *Int16_To_Float32; */
0, /* PaUtilConverter *Int16_To_Int32; */
0, /* PaUtilConverter *Int16_To_Int24; */
@@ -348,9 +348,9 @@ static void Float32_To_Int32(
*dest = lrintf(scaled-0.5f);
#else
double scaled = *src * 0x7FFFFFFF;
- *dest = (PaInt32) scaled;
+ *dest = (PaInt32) scaled;
#endif
-
+
src += sourceStride;
dest += destinationStride;
}
@@ -395,7 +395,7 @@ static void Float32_To_Int32_Clip(
float *src = (float*)sourceBuffer;
PaInt32 *dest = (PaInt32*)destinationBuffer;
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
/* REVIEW */
@@ -458,13 +458,13 @@ static void Float32_To_Int24(
PaInt32 temp;
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
/* convert to 32 bit and drop the low 8 bits */
double scaled = (double)(*src) * 2147483647.0;
temp = (PaInt32) scaled;
-
+
#if defined(PA_LITTLE_ENDIAN)
dest[0] = (unsigned char)(temp >> 8);
dest[1] = (unsigned char)(temp >> 16);
@@ -498,7 +498,7 @@ static void Float32_To_Int24_Dither(
double dither = PaUtil_GenerateFloatTriangularDither( ditherGenerator );
/* use smaller scaler to prevent overflow when we add the dither */
double dithered = ((double)*src * (2147483646.0)) + dither;
-
+
temp = (PaInt32) dithered;
#if defined(PA_LITTLE_ENDIAN)
@@ -528,7 +528,7 @@ static void Float32_To_Int24_Clip(
PaInt32 temp;
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
/* convert to 32 bit and drop the low 8 bits */
@@ -561,16 +561,16 @@ static void Float32_To_Int24_DitherClip(
float *src = (float*)sourceBuffer;
unsigned char *dest = (unsigned char*)destinationBuffer;
PaInt32 temp;
-
+
while( count-- )
{
/* convert to 32 bit and drop the low 8 bits */
-
+
double dither = PaUtil_GenerateFloatTriangularDither( ditherGenerator );
/* use smaller scaler to prevent overflow when we add the dither */
double dithered = ((double)*src * (2147483646.0)) + dither;
PA_CLIP_( dithered, -2147483648., 2147483647. );
-
+
temp = (PaInt32) dithered;
#if defined(PA_LITTLE_ENDIAN)
@@ -728,7 +728,7 @@ static void Float32_To_Int8_Dither(
{
float *src = (float*)sourceBuffer;
signed char *dest = (signed char*)destinationBuffer;
-
+
while( count-- )
{
float dither = PaUtil_GenerateFloatTriangularDither( ditherGenerator );
@@ -819,7 +819,7 @@ static void Float32_To_UInt8_Dither(
{
float *src = (float*)sourceBuffer;
unsigned char *dest = (unsigned char*)destinationBuffer;
-
+
while( count-- )
{
float dither = PaUtil_GenerateFloatTriangularDither( ditherGenerator );
@@ -827,7 +827,7 @@ static void Float32_To_UInt8_Dither(
float dithered = (*src * (126.0f)) + dither;
PaInt32 samp = (PaInt32) dithered;
*dest = (unsigned char) (128 + samp);
-
+
src += sourceStride;
dest += destinationStride;
}
@@ -910,10 +910,10 @@ static void Int32_To_Int24(
PaInt32 *src = (PaInt32*)sourceBuffer;
unsigned char *dest = (unsigned char*)destinationBuffer;
(void) ditherGenerator; /* unused parameter */
-
- while( count-- )
+
+ while( count-- )
{
- /* REVIEW */
+ /* REVIEW */
#if defined(PA_LITTLE_ENDIAN)
dest[0] = (unsigned char)(*src >> 8);
dest[1] = (unsigned char)(*src >> 16);
@@ -1041,7 +1041,7 @@ static void Int32_To_UInt8(
while( count-- )
{
- (*dest) = (unsigned char)(((*src) >> 24) + 128);
+ (*dest) = (unsigned char)(((*src) >> 24) + 128);
src += sourceStride;
dest += destinationStride;
@@ -1080,12 +1080,12 @@ static void Int24_To_Float32(
PaInt32 temp;
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
#if defined(PA_LITTLE_ENDIAN)
- temp = (((PaInt32)src[0]) << 8);
+ temp = (((PaInt32)src[0]) << 8);
temp = temp | (((PaInt32)src[1]) << 16);
temp = temp | (((PaInt32)src[2]) << 24);
#elif defined(PA_BIG_ENDIAN)
@@ -1113,12 +1113,12 @@ static void Int24_To_Int32(
PaInt32 temp;
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
#if defined(PA_LITTLE_ENDIAN)
- temp = (((PaInt32)src[0]) << 8);
+ temp = (((PaInt32)src[0]) << 8);
temp = temp | (((PaInt32)src[1]) << 16);
temp = temp | (((PaInt32)src[2]) << 24);
#elif defined(PA_BIG_ENDIAN)
@@ -1143,20 +1143,20 @@ static void Int24_To_Int16(
{
unsigned char *src = (unsigned char*)sourceBuffer;
PaInt16 *dest = (PaInt16*)destinationBuffer;
-
+
PaInt16 temp;
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
-
+
#if defined(PA_LITTLE_ENDIAN)
- /* src[0] is discarded */
+ /* src[0] is discarded */
temp = (((PaInt16)src[1]));
temp = temp | (PaInt16)(((PaInt16)src[2]) << 8);
#elif defined(PA_BIG_ENDIAN)
- /* src[2] is discarded */
+ /* src[2] is discarded */
temp = (PaInt16)(((PaInt16)src[0]) << 8);
temp = temp | (((PaInt16)src[1]));
#endif
@@ -1184,7 +1184,7 @@ static void Int24_To_Int16_Dither(
{
#if defined(PA_LITTLE_ENDIAN)
- temp = (((PaInt32)src[0]) << 8);
+ temp = (((PaInt32)src[0]) << 8);
temp = temp | (((PaInt32)src[1]) << 16);
temp = temp | (((PaInt32)src[2]) << 24);
#elif defined(PA_BIG_ENDIAN)
@@ -1211,20 +1211,20 @@ static void Int24_To_Int8(
{
unsigned char *src = (unsigned char*)sourceBuffer;
signed char *dest = (signed char*)destinationBuffer;
-
+
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
- {
-
+ {
+
#if defined(PA_LITTLE_ENDIAN)
- /* src[0] is discarded */
- /* src[1] is discarded */
+ /* src[0] is discarded */
+ /* src[1] is discarded */
*dest = src[2];
#elif defined(PA_BIG_ENDIAN)
- /* src[2] is discarded */
- /* src[1] is discarded */
- *dest = src[0];
+ /* src[2] is discarded */
+ /* src[1] is discarded */
+ *dest = src[0];
#endif
src += sourceStride * 3;
@@ -1241,14 +1241,14 @@ static void Int24_To_Int8_Dither(
{
unsigned char *src = (unsigned char*)sourceBuffer;
signed char *dest = (signed char*)destinationBuffer;
-
+
PaInt32 temp, dither;
while( count-- )
{
#if defined(PA_LITTLE_ENDIAN)
- temp = (((PaInt32)src[0]) << 8);
+ temp = (((PaInt32)src[0]) << 8);
temp = temp | (((PaInt32)src[1]) << 16);
temp = temp | (((PaInt32)src[2]) << 24);
#elif defined(PA_BIG_ENDIAN)
@@ -1275,20 +1275,20 @@ static void Int24_To_UInt8(
{
unsigned char *src = (unsigned char*)sourceBuffer;
unsigned char *dest = (unsigned char*)destinationBuffer;
-
+
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
-
+
#if defined(PA_LITTLE_ENDIAN)
- /* src[0] is discarded */
- /* src[1] is discarded */
+ /* src[0] is discarded */
+ /* src[1] is discarded */
*dest = (unsigned char)(src[2] + 128);
#elif defined(PA_BIG_ENDIAN)
*dest = (unsigned char)(src[0] + 128);
- /* src[1] is discarded */
- /* src[2] is discarded */
+ /* src[1] is discarded */
+ /* src[2] is discarded */
#endif
src += sourceStride * 3;
@@ -1349,7 +1349,7 @@ static void Int16_To_Int32(
/* REVIEW: we should consider something like
(*src << 16) | (*src & 0xFFFF)
*/
-
+
*dest = *src << 16;
src += sourceStride;
@@ -1369,11 +1369,11 @@ static void Int16_To_Int24(
PaInt16 temp;
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
temp = *src;
-
+
#if defined(PA_LITTLE_ENDIAN)
dest[0] = 0;
dest[1] = (unsigned char)(temp);
@@ -1442,7 +1442,7 @@ static void Int16_To_UInt8(
while( count-- )
{
- (*dest) = (unsigned char)(((*src) >> 8) + 128);
+ (*dest) = (unsigned char)(((*src) >> 8) + 128);
src += sourceStride;
dest += destinationStride;
@@ -1503,7 +1503,7 @@ static void Int8_To_Int32(
while( count-- )
{
- (*dest) = (*src) << 24;
+ (*dest) = (*src) << 24;
src += sourceStride;
dest += destinationStride;
@@ -1613,7 +1613,7 @@ static void UInt8_To_Int32(
while( count-- )
{
- (*dest) = (*src - 128) << 24;
+ (*dest) = (*src - 128) << 24;
src += sourceStride;
dest += destinationStride;
@@ -1627,11 +1627,11 @@ static void UInt8_To_Int24(
void *sourceBuffer, signed int sourceStride,
unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator )
{
- unsigned char *src = (unsigned char*)sourceBuffer;
+ unsigned char *src = (unsigned char*)sourceBuffer;
unsigned char *dest = (unsigned char*)destinationBuffer;
(void) ditherGenerator; /* unused parameters */
-
- while( count-- )
+
+ while( count-- )
{
#if defined(PA_LITTLE_ENDIAN)
@@ -1643,10 +1643,10 @@ static void UInt8_To_Int24(
dest[1] = 0;
dest[2] = 0;
#endif
-
+
src += sourceStride;
- dest += destinationStride * 3;
- }
+ dest += destinationStride * 3;
+ }
}
/* -------------------------------------------------------------------------- */
@@ -1698,7 +1698,7 @@ static void Copy_8_To_8(
{
unsigned char *src = (unsigned char*)sourceBuffer;
unsigned char *dest = (unsigned char*)destinationBuffer;
-
+
(void) ditherGenerator; /* unused parameter */
while( count-- )
@@ -1719,9 +1719,9 @@ static void Copy_16_To_16(
{
PaUint16 *src = (PaUint16 *)sourceBuffer;
PaUint16 *dest = (PaUint16 *)destinationBuffer;
-
+
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
*dest = *src;
@@ -1742,7 +1742,7 @@ static void Copy_24_To_24(
unsigned char *dest = (unsigned char*)destinationBuffer;
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
dest[0] = src[0];
@@ -1765,7 +1765,7 @@ static void Copy_32_To_32(
PaUint32 *src = (PaUint32 *)sourceBuffer;
(void) ditherGenerator; /* unused parameter */
-
+
while( count-- )
{
*dest = *src;
@@ -1787,7 +1787,7 @@ PaUtilConverterTable paConverters = {
Float32_To_Int24_Dither, /* PaUtilConverter *Float32_To_Int24_Dither; */
Float32_To_Int24_Clip, /* PaUtilConverter *Float32_To_Int24_Clip; */
Float32_To_Int24_DitherClip, /* PaUtilConverter *Float32_To_Int24_DitherClip; */
-
+
Float32_To_Int16, /* PaUtilConverter *Float32_To_Int16; */
Float32_To_Int16_Dither, /* PaUtilConverter *Float32_To_Int16_Dither; */
Float32_To_Int16_Clip, /* PaUtilConverter *Float32_To_Int16_Clip; */
diff --git a/src/common/pa_converters.h b/src/common/pa_converters.h
index 1a912eb..96edf1c 100644
--- a/src/common/pa_converters.h
+++ b/src/common/pa_converters.h
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -119,7 +119,7 @@ PaUtilConverter* PaUtil_SelectConverter( PaSampleFormat sourceFormat,
typedef void PaUtilZeroer(
void *destinationBuffer, signed int destinationStride, unsigned int count );
-
+
/** Find a buffer zeroer function for the given destination format.
@return
A pointer to a PaUtilZeroer which will perform the requested
@@ -145,7 +145,7 @@ typedef struct{
PaUtilConverter *Float32_To_Int24_Dither;
PaUtilConverter *Float32_To_Int24_Clip;
PaUtilConverter *Float32_To_Int24_DitherClip;
-
+
PaUtilConverter *Float32_To_Int16;
PaUtilConverter *Float32_To_Int16_Dither;
PaUtilConverter *Float32_To_Int16_Clip;
@@ -193,7 +193,7 @@ typedef struct{
PaUtilConverter *Int8_To_Int24;
PaUtilConverter *Int8_To_Int16;
PaUtilConverter *Int8_To_UInt8;
-
+
PaUtilConverter *UInt8_To_Float32;
PaUtilConverter *UInt8_To_Int32;
PaUtilConverter *UInt8_To_Int24;
diff --git a/src/common/pa_cpuload.c b/src/common/pa_cpuload.c
index 4adf21a..de57db2 100644
--- a/src/common/pa_cpuload.c
+++ b/src/common/pa_cpuload.c
@@ -27,13 +27,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -94,7 +94,7 @@ void PaUtil_EndCpuLoadMeasurement( PaUtilCpuLoadMeasurer* measurer, unsigned lon
#define LOWPASS_COEFFICIENT_1 (0.99999 - LOWPASS_COEFFICIENT_0)
measurer->averageLoad = (LOWPASS_COEFFICIENT_0 * measurer->averageLoad) +
- (LOWPASS_COEFFICIENT_1 * measuredLoad);
+ (LOWPASS_COEFFICIENT_1 * measuredLoad);
}
}
diff --git a/src/common/pa_cpuload.h b/src/common/pa_cpuload.h
index 2a323aa..8d3f618 100644
--- a/src/common/pa_cpuload.h
+++ b/src/common/pa_cpuload.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -68,5 +68,5 @@ double PaUtil_GetCpuLoad( PaUtilCpuLoadMeasurer* measurer );
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
#endif /* PA_CPULOAD_H */
diff --git a/src/common/pa_debugprint.c b/src/common/pa_debugprint.c
index 7e9e628..3e4024c 100644
--- a/src/common/pa_debugprint.c
+++ b/src/common/pa_debugprint.c
@@ -43,11 +43,11 @@
@brief Implements log function.
PaUtil_SetLogPrintFunction can be user called to replace the provided
- DefaultLogPrint function, which writes to stderr.
- One can NOT pass var_args across compiler/dll boundaries as it is not
- "byte code/abi portable". So the technique used here is to allocate a local
- a static array, write in it, then callback the user with a pointer to its
- start.
+ DefaultLogPrint function, which writes to stderr.
+ One can NOT pass var_args across compiler/dll boundaries as it is not
+ "byte code/abi portable". So the technique used here is to allocate a local
+ a static array, write in it, then callback the user with a pointer to its
+ start.
*/
#include
@@ -57,8 +57,8 @@
// for OutputDebugStringA
#if defined(_MSC_VER) && defined(PA_ENABLE_MSVC_DEBUG_OUTPUT)
- #define WIN32_LEAN_AND_MEAN // exclude rare headers
- #include "windows.h"
+ #define WIN32_LEAN_AND_MEAN // exclude rare headers
+ #include "windows.h"
#endif
// User callback
@@ -75,32 +75,32 @@ void PaUtil_SetDebugPrintFunction(PaUtilLogCallback cb)
VERY dangerous alternative, vsprintf (with no n)
*/
#if _MSC_VER
- /* Some Windows Mobile SDKs don't define vsnprintf but all define _vsnprintf (hopefully).
- According to MSDN "vsnprintf is identical to _vsnprintf". So we use _vsnprintf with MSC.
- */
- #define VSNPRINTF _vsnprintf
+ /* Some Windows Mobile SDKs don't define vsnprintf but all define _vsnprintf (hopefully).
+ According to MSDN "vsnprintf is identical to _vsnprintf". So we use _vsnprintf with MSC.
+ */
+ #define VSNPRINTF _vsnprintf
#else
- #define VSNPRINTF vsnprintf
+ #define VSNPRINTF vsnprintf
#endif
#define PA_LOG_BUF_SIZE 2048
void PaUtil_DebugPrint( const char *format, ... )
{
- // Optional logging into Output console of Visual Studio
+ // Optional logging into Output console of Visual Studio
#if defined(_MSC_VER) && defined(PA_ENABLE_MSVC_DEBUG_OUTPUT)
- {
- char buf[PA_LOG_BUF_SIZE];
- va_list ap;
- va_start(ap, format);
- VSNPRINTF(buf, sizeof(buf), format, ap);
- buf[sizeof(buf)-1] = 0;
- OutputDebugStringA(buf);
- va_end(ap);
- }
+ {
+ char buf[PA_LOG_BUF_SIZE];
+ va_list ap;
+ va_start(ap, format);
+ VSNPRINTF(buf, sizeof(buf), format, ap);
+ buf[sizeof(buf)-1] = 0;
+ OutputDebugStringA(buf);
+ va_end(ap);
+ }
#endif
- // Output to User-Callback
+ // Output to User-Callback
if (userCB != NULL)
{
char strdump[PA_LOG_BUF_SIZE];
@@ -112,7 +112,7 @@ void PaUtil_DebugPrint( const char *format, ... )
va_end(ap);
}
else
- // Standard output to stderr
+ // Standard output to stderr
{
va_list ap;
va_start(ap, format);
diff --git a/src/common/pa_debugprint.h b/src/common/pa_debugprint.h
index 5fba766..ca81724 100644
--- a/src/common/pa_debugprint.h
+++ b/src/common/pa_debugprint.h
@@ -101,7 +101,7 @@ void PaUtil_DebugPrint( const char *format, ... );
#ifdef PA_LOG_API_CALLS
-#define PA_LOGAPI(x) PaUtil_DebugPrint x
+#define PA_LOGAPI(x) PaUtil_DebugPrint x
#define PA_LOGAPI_ENTER(functionName) PaUtil_DebugPrint( functionName " called.\n" )
@@ -110,16 +110,16 @@ void PaUtil_DebugPrint( const char *format, ... );
#define PA_LOGAPI_EXIT(functionName) PaUtil_DebugPrint( functionName " returned.\n" )
#define PA_LOGAPI_EXIT_PAERROR( functionName, result ) \
- PaUtil_DebugPrint( functionName " returned:\n" ); \
- PaUtil_DebugPrint("\tPaError: %d ( %s )\n", result, Pa_GetErrorText( result ) )
+ PaUtil_DebugPrint( functionName " returned:\n" ); \
+ PaUtil_DebugPrint("\tPaError: %d ( %s )\n", result, Pa_GetErrorText( result ) )
#define PA_LOGAPI_EXIT_T( functionName, resultFormatString, result ) \
- PaUtil_DebugPrint( functionName " returned:\n" ); \
- PaUtil_DebugPrint("\t" resultFormatString "\n", result )
+ PaUtil_DebugPrint( functionName " returned:\n" ); \
+ PaUtil_DebugPrint("\t" resultFormatString "\n", result )
#define PA_LOGAPI_EXIT_PAERROR_OR_T_RESULT( functionName, positiveResultFormatString, result ) \
- PaUtil_DebugPrint( functionName " returned:\n" ); \
- if( result > 0 ) \
+ PaUtil_DebugPrint( functionName " returned:\n" ); \
+ if( result > 0 ) \
PaUtil_DebugPrint("\t" positiveResultFormatString "\n", result ); \
else \
PaUtil_DebugPrint("\tPaError: %d ( %s )\n", result, Pa_GetErrorText( result ) )
@@ -133,7 +133,7 @@ void PaUtil_DebugPrint( const char *format, ... );
#define PA_LOGAPI_EXIT_PAERROR_OR_T_RESULT( functionName, positiveResultFormatString, result )
#endif
-
+
typedef void (*PaUtilLogCallback ) (const char *log);
/**
diff --git a/src/common/pa_dither.c b/src/common/pa_dither.c
index 140e480..0d1666a 100644
--- a/src/common/pa_dither.c
+++ b/src/common/pa_dither.c
@@ -26,13 +26,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -72,10 +72,10 @@ PaInt32 PaUtil_Generate16BitTriangularDither( PaUtilTriangularDitherGenerator *s
/* Generate triangular distribution about 0.
* Shift before adding to prevent overflow which would skew the distribution.
- * Also shift an extra bit for the high pass filter.
+ * Also shift an extra bit for the high pass filter.
*/
#define DITHER_SHIFT_ ((sizeof(PaInt32)*8 - PA_DITHER_BITS_) + 1)
-
+
current = (((PaInt32)state->randSeed1)>>DITHER_SHIFT_) +
(((PaInt32)state->randSeed2)>>DITHER_SHIFT_);
@@ -100,7 +100,7 @@ float PaUtil_GenerateFloatTriangularDither( PaUtilTriangularDitherGenerator *sta
/* Generate triangular distribution about 0.
* Shift before adding to prevent overflow which would skew the distribution.
- * Also shift an extra bit for the high pass filter.
+ * Also shift an extra bit for the high pass filter.
*/
current = (((PaInt32)state->randSeed1)>>DITHER_SHIFT_) +
(((PaInt32)state->randSeed2)>>DITHER_SHIFT_);
@@ -137,7 +137,7 @@ things like this: r3=(r1 & 0x7F)<<8; instead of calling rand() again.
float s1, s2; //error feedback buffers
float s = 0.5f; //set to 0.0f for no noise shaping
float w = pow(2.0,bits-1); //word length (usually bits=16)
- float wi= 1.0f/w;
+ float wi= 1.0f/w;
float d = wi / RAND_MAX; //dither amplitude (2 lsb)
float o = wi * 0.5f; //remove dc offset
float in, tmp;
@@ -148,19 +148,19 @@ things like this: r3=(r1 & 0x7F)<<8; instead of calling rand() again.
r2=r1; //can make HP-TRI dither by
r1=rand(); //subtracting previous rand()
-
+
in += s * (s1 + s1 - s2); //error feedback
- tmp = in + o + d * (float)(r1 - r2); //dc offset and dither
-
+ tmp = in + o + d * (float)(r1 - r2); //dc offset and dither
+
out = (int)(w * tmp); //truncate downwards
if(tmp<0.0f) out--; //this is faster than floor()
- s2 = s1;
+ s2 = s1;
s1 = in - wi * (float)out; //error
---
+--
paul.kellett@maxim.abel.co.uk
http://www.maxim.abel.co.uk
*/
@@ -172,7 +172,7 @@ http://www.maxim.abel.co.uk
Type : First order error feedforward dithering code
References : Posted by Jon Watte
-Notes :
+Notes :
This is about as simple a dithering algorithm as you can implement, but it's
likely to sound better than just truncating to N bits.
@@ -183,36 +183,36 @@ and integer SIMD type instructions, or CMOV.
Last, if sound quality is paramount (such as when going from > 16 bits to 16
bits) you probably want to use a higher-order dither function found elsewhere
-on this site.
+on this site.
-Code :
-// This code will down-convert and dither a 16-bit signed short
-// mono signal into an 8-bit unsigned char signal, using a first
-// order forward-feeding error term dither.
+Code :
+// This code will down-convert and dither a 16-bit signed short
+// mono signal into an 8-bit unsigned char signal, using a first
+// order forward-feeding error term dither.
-#define uchar unsigned char
+#define uchar unsigned char
-void dither_one_channel_16_to_8( short * input, uchar * output, int count, int * memory )
-{
- int m = *memory;
- while( count-- > 0 ) {
- int i = *input++;
- i += m;
- int j = i + 32768 - 128;
- uchar o;
- if( j < 0 ) {
- o = 0;
- }
- else if( j > 65535 ) {
- o = 255;
- }
- else {
- o = (uchar)((j>>8)&0xff);
- }
- m = ((j-32768+128)-i);
- *output++ = o;
- }
- *memory = m;
-}
+void dither_one_channel_16_to_8( short * input, uchar * output, int count, int * memory )
+{
+ int m = *memory;
+ while( count-- > 0 ) {
+ int i = *input++;
+ i += m;
+ int j = i + 32768 - 128;
+ uchar o;
+ if( j < 0 ) {
+ o = 0;
+ }
+ else if( j > 65535 ) {
+ o = 255;
+ }
+ else {
+ o = (uchar)((j>>8)&0xff);
+ }
+ m = ((j-32768+128)-i);
+ *output++ = o;
+ }
+ *memory = m;
+}
*/
diff --git a/src/common/pa_dither.h b/src/common/pa_dither.h
index 12ffc4f..4f81123 100644
--- a/src/common/pa_dither.h
+++ b/src/common/pa_dither.h
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
diff --git a/src/common/pa_endianness.h b/src/common/pa_endianness.h
index 7496651..e074836 100644
--- a/src/common/pa_endianness.h
+++ b/src/common/pa_endianness.h
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -67,19 +67,19 @@ extern "C"
#if defined(__APPLE__)
/* we need to do some endian detection that is sensitive to hardware arch */
#if defined(__LITTLE_ENDIAN__)
- #if !defined( PA_LITTLE_ENDIAN )
- #define PA_LITTLE_ENDIAN
- #endif
- #if defined( PA_BIG_ENDIAN )
- #undef PA_BIG_ENDIAN
- #endif
+ #if !defined( PA_LITTLE_ENDIAN )
+ #define PA_LITTLE_ENDIAN
+ #endif
+ #if defined( PA_BIG_ENDIAN )
+ #undef PA_BIG_ENDIAN
+ #endif
#else
- #if !defined( PA_BIG_ENDIAN )
- #define PA_BIG_ENDIAN
- #endif
- #if defined( PA_LITTLE_ENDIAN )
- #undef PA_LITTLE_ENDIAN
- #endif
+ #if !defined( PA_BIG_ENDIAN )
+ #define PA_BIG_ENDIAN
+ #endif
+ #if defined( PA_LITTLE_ENDIAN )
+ #undef PA_LITTLE_ENDIAN
+ #endif
#endif
#else
/* this is not an apple, so first check the existing defines, and, failing that,
diff --git a/src/common/pa_front.c b/src/common/pa_front.c
index 9a258eb..6456e33 100644
--- a/src/common/pa_front.c
+++ b/src/common/pa_front.c
@@ -457,10 +457,10 @@ const char *Pa_GetErrorText( PaError errorCode )
case paIncompatibleStreamHostApi: result = "Incompatible stream host API"; break;
case paBadBufferPtr: result = "Bad buffer pointer"; break;
default:
- if( errorCode > 0 )
- result = "Invalid error code (value greater than zero)";
+ if( errorCode > 0 )
+ result = "Invalid error code (value greater than zero)";
else
- result = "Invalid error code";
+ result = "Invalid error code";
break;
}
return result;
@@ -637,7 +637,7 @@ const PaHostApiInfo* Pa_GetHostApiInfo( PaHostApiIndex hostApi )
}
- return info;
+ return info;
}
@@ -884,9 +884,9 @@ static PaError ValidateOpenStreamParameters(
PaDeviceIndex *hostApiInputDevice,
PaDeviceIndex *hostApiOutputDevice )
{
- int inputHostApiIndex = -1, /* Suppress uninitialised var warnings: compiler does */
- outputHostApiIndex = -1; /* not see that if inputParameters and outputParame- */
- /* ters are both nonzero, these indices are set. */
+ int inputHostApiIndex = -1; /* Suppress uninitialised var warnings: compiler does */
+ int outputHostApiIndex = -1; /* not see that if inputParameters and outputParameters */
+ /* are both nonzero, these indices are set. */
if( (inputParameters == NULL) && (outputParameters == NULL) )
{
@@ -1016,7 +1016,7 @@ static PaError ValidateOpenStreamParameters(
{
/* must be a callback stream */
if( !streamCallback )
- return paInvalidFlag;
+ return paInvalidFlag;
/* must be a full duplex stream */
if( (inputParameters == NULL) || (outputParameters == NULL) )
@@ -1296,8 +1296,8 @@ PaError Pa_OpenDefaultStream( PaStream** stream,
if( inputChannelCount > 0 )
{
hostApiInputParameters.device = Pa_GetDefaultInputDevice();
- if( hostApiInputParameters.device == paNoDevice )
- return paDeviceUnavailable;
+ if( hostApiInputParameters.device == paNoDevice )
+ return paDeviceUnavailable;
hostApiInputParameters.channelCount = inputChannelCount;
hostApiInputParameters.sampleFormat = sampleFormat;
@@ -1319,8 +1319,8 @@ PaError Pa_OpenDefaultStream( PaStream** stream,
if( outputChannelCount > 0 )
{
hostApiOutputParameters.device = Pa_GetDefaultOutputDevice();
- if( hostApiOutputParameters.device == paNoDevice )
- return paDeviceUnavailable;
+ if( hostApiOutputParameters.device == paNoDevice )
+ return paDeviceUnavailable;
hostApiOutputParameters.channelCount = outputChannelCount;
hostApiOutputParameters.sampleFormat = sampleFormat;
diff --git a/src/common/pa_hostapi.h b/src/common/pa_hostapi.h
index 54b527e..4ac3ab6 100644
--- a/src/common/pa_hostapi.h
+++ b/src/common/pa_hostapi.h
@@ -29,20 +29,20 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
/** @file
@ingroup common_src
- @brief Interfaces and representation structures used by pa_front.c
+ @brief Interfaces and representation structures used by pa_front.c
to manage and communicate with host API implementations.
*/
@@ -51,12 +51,12 @@
/**
The PA_NO_* host API macros are now deprecated in favor of PA_USE_* macros.
PA_USE_* indicates whether a particular host API will be initialized by PortAudio.
-An undefined or 0 value indicates that the host API will not be used. A value of 1
-indicates that the host API will be used. PA_USE_* macros should be left undefined
+An undefined or 0 value indicates that the host API will not be used. A value of 1
+indicates that the host API will be used. PA_USE_* macros should be left undefined
or defined to either 0 or 1.
The code below ensures that PA_USE_* macros are always defined and have value
-0 or 1. Undefined symbols are defaulted to 0. Symbols that are neither 0 nor 1
+0 or 1. Undefined symbols are defaulted to 0. Symbols that are neither 0 nor 1
are defaulted to 1.
*/
@@ -65,7 +65,7 @@ are defaulted to 1.
#elif (PA_USE_SKELETON != 0) && (PA_USE_SKELETON != 1)
#undef PA_USE_SKELETON
#define PA_USE_SKELETON 1
-#endif
+#endif
#if defined(PA_NO_ASIO) || defined(PA_NO_DS) || defined(PA_NO_WMME) || defined(PA_NO_WASAPI) || defined(PA_NO_WDMKS)
#error "Portaudio: PA_NO_ is no longer supported, please remove definition and use PA_USE_ instead"
@@ -76,35 +76,35 @@ are defaulted to 1.
#elif (PA_USE_ASIO != 0) && (PA_USE_ASIO != 1)
#undef PA_USE_ASIO
#define PA_USE_ASIO 1
-#endif
+#endif
#ifndef PA_USE_DS
#define PA_USE_DS 0
#elif (PA_USE_DS != 0) && (PA_USE_DS != 1)
#undef PA_USE_DS
#define PA_USE_DS 1
-#endif
+#endif
#ifndef PA_USE_WMME
#define PA_USE_WMME 0
#elif (PA_USE_WMME != 0) && (PA_USE_WMME != 1)
#undef PA_USE_WMME
#define PA_USE_WMME 1
-#endif
+#endif
#ifndef PA_USE_WASAPI
#define PA_USE_WASAPI 0
#elif (PA_USE_WASAPI != 0) && (PA_USE_WASAPI != 1)
#undef PA_USE_WASAPI
#define PA_USE_WASAPI 1
-#endif
+#endif
#ifndef PA_USE_WDMKS
#define PA_USE_WDMKS 0
#elif (PA_USE_WDMKS != 0) && (PA_USE_WDMKS != 1)
#undef PA_USE_WDMKS
#define PA_USE_WDMKS 1
-#endif
+#endif
/* Set default values for Unix based APIs. */
#if defined(PA_NO_OSS) || defined(PA_NO_ALSA) || defined(PA_NO_JACK) || defined(PA_NO_COREAUDIO) || defined(PA_NO_SGI) || defined(PA_NO_ASIHPI)
@@ -116,42 +116,42 @@ are defaulted to 1.
#elif (PA_USE_OSS != 0) && (PA_USE_OSS != 1)
#undef PA_USE_OSS
#define PA_USE_OSS 1
-#endif
+#endif
#ifndef PA_USE_ALSA
#define PA_USE_ALSA 0
#elif (PA_USE_ALSA != 0) && (PA_USE_ALSA != 1)
#undef PA_USE_ALSA
#define PA_USE_ALSA 1
-#endif
+#endif
#ifndef PA_USE_JACK
#define PA_USE_JACK 0
#elif (PA_USE_JACK != 0) && (PA_USE_JACK != 1)
#undef PA_USE_JACK
#define PA_USE_JACK 1
-#endif
+#endif
#ifndef PA_USE_SGI
#define PA_USE_SGI 0
#elif (PA_USE_SGI != 0) && (PA_USE_SGI != 1)
#undef PA_USE_SGI
#define PA_USE_SGI 1
-#endif
+#endif
#ifndef PA_USE_COREAUDIO
#define PA_USE_COREAUDIO 0
#elif (PA_USE_COREAUDIO != 0) && (PA_USE_COREAUDIO != 1)
#undef PA_USE_COREAUDIO
#define PA_USE_COREAUDIO 1
-#endif
+#endif
#ifndef PA_USE_ASIHPI
#define PA_USE_ASIHPI 0
#elif (PA_USE_ASIHPI != 0) && (PA_USE_ASIHPI != 1)
#undef PA_USE_ASIHPI
#define PA_USE_ASIHPI 1
-#endif
+#endif
#ifdef __cplusplus
extern "C"
@@ -216,13 +216,13 @@ typedef struct PaUtilHostApiRepresentation {
The inputParameters and outputParameters pointers should not be saved
as they will not remain valid after OpenStream is called.
-
+
The following guarantees are made about parameters to (*OpenStream)():
[NOTE: the following list up to *END PA FRONT VALIDATIONS* should be
kept in sync with the one for ValidateOpenStreamParameters and
Pa_OpenStream in pa_front.c]
-
+
PaHostApiRepresentation *hostApi
- is valid for this implementation
@@ -233,7 +233,7 @@ typedef struct PaUtilHostApiRepresentation {
- if inputParameters & outputParmeters are both valid, that
inputParameters->device & outputParmeters->device both use the same host api
-
+
PaDeviceIndex inputParameters->device
- is within range (0 to Pa_CountDevices-1) Or:
- is paUseHostApiSpecificDeviceSpecification and
@@ -243,30 +243,30 @@ typedef struct PaUtilHostApiRepresentation {
int inputParameters->numChannels
- if inputParameters->device is not paUseHostApiSpecificDeviceSpecification, numInputChannels is > 0
- upper bound is NOT validated against device capabilities
-
+
PaSampleFormat inputParameters->sampleFormat
- is one of the sample formats defined in portaudio.h
void *inputParameters->hostApiSpecificStreamInfo
- if supplied its hostApi field matches the input device's host Api
-
+
PaDeviceIndex outputParmeters->device
- is within range (0 to Pa_CountDevices-1)
-
+
int outputParmeters->numChannels
- if inputDevice is valid, numInputChannels is > 0
- upper bound is NOT validated against device capabilities
-
+
PaSampleFormat outputParmeters->sampleFormat
- is one of the sample formats defined in portaudio.h
-
+
void *outputParmeters->hostApiSpecificStreamInfo
- if supplied its hostApi field matches the output device's host Api
-
+
double sampleRate
- is not an 'absurd' rate (less than 1000. or greater than 384000.)
- sampleRate is NOT validated against device capabilities
-
+
PaStreamFlags streamFlags
- unused platform neutral flags are zero
- paNeverDropInput is only used for full-duplex callback streams
@@ -278,7 +278,7 @@ typedef struct PaUtilHostApiRepresentation {
The following validations MUST be performed by (*OpenStream)():
- check that input device can support numInputChannels
-
+
- check that input device can support inputSampleFormat, or that
we have the capability to convert from outputSampleFormat to
a native format
@@ -287,7 +287,7 @@ typedef struct PaUtilHostApiRepresentation {
or return an error if no inputStreamInfo is expected
- check that output device can support numOutputChannels
-
+
- check that output device can support outputSampleFormat, or that
we have the capability to convert from outputSampleFormat to
a native format
@@ -327,11 +327,11 @@ typedef struct PaUtilHostApiRepresentation {
/** Prototype for the initialization function which must be implemented by every
host API.
-
- This function should only return an error other than paNoError if it encounters
- an unexpected and fatal error (memory allocation error for example). In general,
- there may be conditions under which it returns a NULL interface pointer and also
- returns paNoError. For example, if the ASIO implementation detects that ASIO is
+
+ This function should only return an error other than paNoError if it encounters
+ an unexpected and fatal error (memory allocation error for example). In general,
+ there may be conditions under which it returns a NULL interface pointer and also
+ returns paNoError. For example, if the ASIO implementation detects that ASIO is
not installed, it should return a NULL interface, and paNoError.
@see paHostApiInitializers
@@ -341,11 +341,11 @@ typedef PaError PaUtilHostApiInitializer( PaUtilHostApiRepresentation**, PaHostA
/** paHostApiInitializers is a NULL-terminated array of host API initialization
functions. These functions are called by pa_front.c to initialize the host APIs
- when the client calls Pa_Initialize().
-
+ when the client calls Pa_Initialize().
+
The initialization functions are invoked in order.
- The first successfully initialized host API that has a default input *or* output
+ The first successfully initialized host API that has a default input *or* output
device is used as the default PortAudio host API. This is based on the logic that
there is only one default host API, and it must contain the default input and output
devices (if defined).
diff --git a/src/common/pa_memorybarrier.h b/src/common/pa_memorybarrier.h
index 2879ce3..0dca6aa 100644
--- a/src/common/pa_memorybarrier.h
+++ b/src/common/pa_memorybarrier.h
@@ -30,13 +30,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -71,32 +71,32 @@
#elif defined(__GNUC__)
/* GCC >= 4.1 has built-in intrinsics. We'll use those */
# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
-# define PaUtil_FullMemoryBarrier() __sync_synchronize()
-# define PaUtil_ReadMemoryBarrier() __sync_synchronize()
-# define PaUtil_WriteMemoryBarrier() __sync_synchronize()
+# define PaUtil_FullMemoryBarrier() __sync_synchronize()
+# define PaUtil_ReadMemoryBarrier() __sync_synchronize()
+# define PaUtil_WriteMemoryBarrier() __sync_synchronize()
/* as a fallback, GCC understands volatile asm and "memory" to mean it
* should not reorder memory read/writes */
/* Note that it is not clear that any compiler actually defines __PPC__,
* it can probably removed safely. */
# elif defined( __ppc__ ) || defined( __powerpc__) || defined( __PPC__ )
-# define PaUtil_FullMemoryBarrier() asm volatile("sync":::"memory")
-# define PaUtil_ReadMemoryBarrier() asm volatile("sync":::"memory")
-# define PaUtil_WriteMemoryBarrier() asm volatile("sync":::"memory")
+# define PaUtil_FullMemoryBarrier() asm volatile("sync":::"memory")
+# define PaUtil_ReadMemoryBarrier() asm volatile("sync":::"memory")
+# define PaUtil_WriteMemoryBarrier() asm volatile("sync":::"memory")
# elif defined( __i386__ ) || defined( __i486__ ) || defined( __i586__ ) || \
- defined( __i686__ ) || defined( __x86_64__ )
-# define PaUtil_FullMemoryBarrier() asm volatile("mfence":::"memory")
-# define PaUtil_ReadMemoryBarrier() asm volatile("lfence":::"memory")
-# define PaUtil_WriteMemoryBarrier() asm volatile("sfence":::"memory")
+ defined( __i686__ ) || defined( __x86_64__ )
+# define PaUtil_FullMemoryBarrier() asm volatile("mfence":::"memory")
+# define PaUtil_ReadMemoryBarrier() asm volatile("lfence":::"memory")
+# define PaUtil_WriteMemoryBarrier() asm volatile("sfence":::"memory")
# else
-# ifdef ALLOW_SMP_DANGERS
-# warning Memory barriers not defined on this system or system unknown
-# warning For SMP safety, you should fix this.
-# define PaUtil_FullMemoryBarrier()
-# define PaUtil_ReadMemoryBarrier()
-# define PaUtil_WriteMemoryBarrier()
-# else
-# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
-# endif
+# ifdef ALLOW_SMP_DANGERS
+# warning Memory barriers not defined on this system or system unknown
+# warning For SMP safety, you should fix this.
+# define PaUtil_FullMemoryBarrier()
+# define PaUtil_ReadMemoryBarrier()
+# define PaUtil_WriteMemoryBarrier()
+# else
+# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
+# endif
# endif
#elif (_MSC_VER >= 1400) && !defined(_WIN32_WCE)
# include
@@ -117,12 +117,12 @@
# define PaUtil_WriteMemoryBarrier() _asm { lock add [esp], 0 }
#else
# ifdef ALLOW_SMP_DANGERS
-# warning Memory barriers not defined on this system or system unknown
-# warning For SMP safety, you should fix this.
-# define PaUtil_FullMemoryBarrier()
-# define PaUtil_ReadMemoryBarrier()
-# define PaUtil_WriteMemoryBarrier()
+# warning Memory barriers not defined on this system or system unknown
+# warning For SMP safety, you should fix this.
+# define PaUtil_FullMemoryBarrier()
+# define PaUtil_ReadMemoryBarrier()
+# define PaUtil_WriteMemoryBarrier()
# else
-# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
+# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
# endif
#endif
diff --git a/src/common/pa_process.c b/src/common/pa_process.c
index 0faf841..084cabb 100644
--- a/src/common/pa_process.c
+++ b/src/common/pa_process.c
@@ -27,13 +27,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -142,7 +142,7 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp,
}
else /* unknown host buffer size */
{
- bp->framesPerTempBuffer = PA_FRAMES_PER_TEMP_BUFFER_WHEN_HOST_BUFFER_SIZE_IS_UNKNOWN_;
+ bp->framesPerTempBuffer = PA_FRAMES_PER_TEMP_BUFFER_WHEN_HOST_BUFFER_SIZE_IS_UNKNOWN_;
}
}
else
@@ -198,7 +198,7 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp,
bp->framesInTempInputBuffer = bp->initialFramesInTempInputBuffer;
bp->framesInTempOutputBuffer = bp->initialFramesInTempOutputBuffer;
-
+
if( inputChannelCount > 0 )
{
bytesPerSample = Pa_GetSampleSize( hostInputSampleFormat );
@@ -224,7 +224,7 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp,
}
/* Under the assumption that no ADC in existence delivers better than 24bits resolution,
- we disable dithering when host input format is paInt32 and user format is paInt24,
+ we disable dithering when host input format is paInt32 and user format is paInt24,
since the host samples will just be padded with zeros anyway. */
tempInputStreamFlags = streamFlags;
@@ -239,23 +239,23 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp,
PaUtil_SelectConverter( hostInputSampleFormat, userInputSampleFormat, tempInputStreamFlags );
bp->inputZeroer = PaUtil_SelectZeroer( userInputSampleFormat );
-
+
bp->userInputIsInterleaved = (userInputSampleFormat & paNonInterleaved)?0:1;
-
+
bp->hostInputIsInterleaved = (hostInputSampleFormat & paNonInterleaved)?0:1;
bp->userInputSampleFormatIsEqualToHost = ((userInputSampleFormat & ~paNonInterleaved) == (hostInputSampleFormat & ~paNonInterleaved));
tempInputBufferSize =
bp->framesPerTempBuffer * bp->bytesPerUserInputSample * inputChannelCount;
-
+
bp->tempInputBuffer = PaUtil_AllocateMemory( tempInputBufferSize );
if( bp->tempInputBuffer == 0 )
{
result = paInsufficientMemory;
goto error;
}
-
+
if( bp->framesInTempInputBuffer > 0 )
memset( bp->tempInputBuffer, 0, tempInputBufferSize );
@@ -328,7 +328,7 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp,
if( bp->framesInTempOutputBuffer > 0 )
memset( bp->tempOutputBuffer, 0, tempOutputBufferSize );
-
+
if( userOutputSampleFormat & paNonInterleaved )
{
bp->tempOutputBufferPtrs =
@@ -343,7 +343,7 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp,
bp->hostOutputChannels[0] = (PaUtilChannelDescriptor*)
PaUtil_AllocateMemory( sizeof(PaUtilChannelDescriptor)*outputChannelCount * 2 );
if( bp->hostOutputChannels[0] == 0 )
- {
+ {
result = paInsufficientMemory;
goto error;
}
@@ -393,7 +393,7 @@ void PaUtil_TerminateBufferProcessor( PaUtilBufferProcessor* bp )
if( bp->hostInputChannels[0] )
PaUtil_FreeMemory( bp->hostInputChannels[0] );
-
+
if( bp->tempOutputBuffer )
PaUtil_FreeMemory( bp->tempOutputBuffer );
@@ -420,7 +420,7 @@ void PaUtil_ResetBufferProcessor( PaUtilBufferProcessor* bp )
}
if( bp->framesInTempOutputBuffer > 0 )
- {
+ {
tempOutputBufferSize =
bp->framesPerTempBuffer * bp->bytesPerUserOutputSample * bp->outputChannelCount;
memset( bp->tempOutputBuffer, 0, tempOutputBufferSize );
@@ -448,7 +448,7 @@ void PaUtil_SetInputFrameCount( PaUtilBufferProcessor* bp,
else
bp->hostInputFrameCount[0] = frameCount;
}
-
+
void PaUtil_SetNoInput( PaUtilBufferProcessor* bp )
{
@@ -462,7 +462,7 @@ void PaUtil_SetInputChannel( PaUtilBufferProcessor* bp,
unsigned int channel, void *data, unsigned int stride )
{
assert( channel < bp->inputChannelCount );
-
+
bp->hostInputChannels[0][channel].data = data;
bp->hostInputChannels[0][channel].stride = stride;
}
@@ -496,7 +496,7 @@ void PaUtil_SetNonInterleavedInputChannel( PaUtilBufferProcessor* bp,
{
assert( channel < bp->inputChannelCount );
assert( !bp->hostInputIsInterleaved );
-
+
bp->hostInputChannels[0][channel].data = data;
bp->hostInputChannels[0][channel].stride = 1;
}
@@ -532,7 +532,7 @@ void PaUtil_Set2ndInterleavedInputChannels( PaUtilBufferProcessor* bp,
assert( firstChannel < bp->inputChannelCount );
assert( firstChannel + channelCount <= bp->inputChannelCount );
assert( bp->hostInputIsInterleaved );
-
+
for( i=0; i< channelCount; ++i )
{
bp->hostInputChannels[1][channel+i].data = p;
@@ -541,13 +541,13 @@ void PaUtil_Set2ndInterleavedInputChannels( PaUtilBufferProcessor* bp,
}
}
-
+
void PaUtil_Set2ndNonInterleavedInputChannel( PaUtilBufferProcessor* bp,
unsigned int channel, void *data )
{
assert( channel < bp->inputChannelCount );
assert( !bp->hostInputIsInterleaved );
-
+
bp->hostInputChannels[1][channel].data = data;
bp->hostInputChannels[1][channel].stride = 1;
}
@@ -597,7 +597,7 @@ void PaUtil_SetInterleavedOutputChannels( PaUtilBufferProcessor* bp,
assert( firstChannel < bp->outputChannelCount );
assert( firstChannel + channelCount <= bp->outputChannelCount );
assert( bp->hostOutputIsInterleaved );
-
+
for( i=0; i< channelCount; ++i )
{
PaUtil_SetOutputChannel( bp, channel + i, p, channelCount );
@@ -647,7 +647,7 @@ void PaUtil_Set2ndInterleavedOutputChannels( PaUtilBufferProcessor* bp,
assert( firstChannel < bp->outputChannelCount );
assert( firstChannel + channelCount <= bp->outputChannelCount );
assert( bp->hostOutputIsInterleaved );
-
+
for( i=0; i< channelCount; ++i )
{
PaUtil_Set2ndOutputChannel( bp, channel + i, p, channelCount );
@@ -655,13 +655,13 @@ void PaUtil_Set2ndInterleavedOutputChannels( PaUtilBufferProcessor* bp,
}
}
-
+
void PaUtil_Set2ndNonInterleavedOutputChannel( PaUtilBufferProcessor* bp,
unsigned int channel, void *data )
{
assert( channel < bp->outputChannelCount );
assert( !bp->hostOutputIsInterleaved );
-
+
PaUtil_Set2ndOutputChannel( bp, channel, data, 1 );
}
@@ -673,11 +673,11 @@ void PaUtil_BeginBufferProcessing( PaUtilBufferProcessor* bp,
/* the first streamCallback will be called to process samples which are
currently in the input buffer before the ones starting at the timeInfo time */
-
+
bp->timeInfo->inputBufferAdcTime -= bp->framesInTempInputBuffer * bp->samplePeriod;
-
+
/* We just pass through timeInfo->currentTime provided by the caller. This is
- not strictly conformant to the word of the spec, since the buffer processor
+ not strictly conformant to the word of the spec, since the buffer processor
might call the callback multiple times, and we never refresh currentTime. */
/* the first streamCallback will be called to generate samples which will be
@@ -735,7 +735,7 @@ static unsigned long NonAdaptingProcess( PaUtilBufferProcessor *bp,
}
else /* there are input channels */
{
-
+
destBytePtr = (unsigned char *)bp->tempInputBuffer;
if( bp->userInputIsInterleaved )
@@ -779,7 +779,7 @@ static unsigned long NonAdaptingProcess( PaUtilBufferProcessor *bp,
i * bp->bytesPerUserInputSample * frameCount;
}
}
-
+
userInput = bp->tempInputBufferPtrs;
}
@@ -795,7 +795,7 @@ static unsigned long NonAdaptingProcess( PaUtilBufferProcessor *bp,
}
}
else
- {
+ {
if( skipInputConvert )
{
for( i=0; iinputChannelCount; ++i )
@@ -837,7 +837,7 @@ static unsigned long NonAdaptingProcess( PaUtilBufferProcessor *bp,
/* process host buffer directly, or use temp buffer if formats differ or host buffer non-interleaved,
* or if num channels differs between the host (set in stride) and the user (eg with some Alsa hw:) */
if( bp->userOutputSampleFormatIsEqualToHost && bp->hostOutputIsInterleaved
- && bp->outputChannelCount == hostOutputChannels[0].stride )
+ && bp->outputChannelCount == hostOutputChannels[0].stride )
{
userOutput = hostOutputChannels[0].data;
skipOutputConvert = 1;
@@ -869,7 +869,7 @@ static unsigned long NonAdaptingProcess( PaUtilBufferProcessor *bp,
userOutput = bp->tempOutputBufferPtrs;
}
}
-
+
*streamCallbackResult = bp->streamCallback( userInput, userOutput,
frameCount, bp->timeInfo, bp->callbackStatusFlags, bp->userData );
@@ -884,50 +884,50 @@ static unsigned long NonAdaptingProcess( PaUtilBufferProcessor *bp,
bp->timeInfo->outputBufferDacTime += frameCount * bp->samplePeriod;
/* convert output data (user -> host) */
-
+
if( bp->outputChannelCount != 0 && bp->hostOutputChannels[0][0].data )
{
if( skipOutputConvert )
- {
- for( i=0; ioutputChannelCount; ++i )
- {
- /* advance dest ptr for next iteration */
- hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) +
- frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample;
- }
- }
- else
- {
+ {
+ for( i=0; ioutputChannelCount; ++i )
+ {
+ /* advance dest ptr for next iteration */
+ hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) +
+ frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample;
+ }
+ }
+ else
+ {
- srcBytePtr = (unsigned char *)bp->tempOutputBuffer;
+ srcBytePtr = (unsigned char *)bp->tempOutputBuffer;
- if( bp->userOutputIsInterleaved )
- {
- srcSampleStrideSamples = bp->outputChannelCount;
- srcChannelStrideBytes = bp->bytesPerUserOutputSample;
- }
- else /* user output is not interleaved */
- {
- srcSampleStrideSamples = 1;
- srcChannelStrideBytes = frameCount * bp->bytesPerUserOutputSample;
- }
+ if( bp->userOutputIsInterleaved )
+ {
+ srcSampleStrideSamples = bp->outputChannelCount;
+ srcChannelStrideBytes = bp->bytesPerUserOutputSample;
+ }
+ else /* user output is not interleaved */
+ {
+ srcSampleStrideSamples = 1;
+ srcChannelStrideBytes = frameCount * bp->bytesPerUserOutputSample;
+ }
- for( i=0; ioutputChannelCount; ++i )
- {
- bp->outputConverter( hostOutputChannels[i].data,
- hostOutputChannels[i].stride,
- srcBytePtr, srcSampleStrideSamples,
- frameCount, &bp->ditherGenerator );
+ for( i=0; ioutputChannelCount; ++i )
+ {
+ bp->outputConverter( hostOutputChannels[i].data,
+ hostOutputChannels[i].stride,
+ srcBytePtr, srcSampleStrideSamples,
+ frameCount, &bp->ditherGenerator );
- srcBytePtr += srcChannelStrideBytes; /* skip to next source channel */
+ srcBytePtr += srcChannelStrideBytes; /* skip to next source channel */
- /* advance dest ptr for next iteration */
- hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) +
- frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample;
- }
- }
+ /* advance dest ptr for next iteration */
+ hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) +
+ frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample;
+ }
+ }
}
-
+
framesProcessed += frameCount;
framesToGo -= frameCount;
@@ -982,7 +982,7 @@ static unsigned long AdaptingInputOnlyProcess( PaUtilBufferProcessor *bp,
unsigned long frameCount;
unsigned long framesToGo = framesToProcess;
unsigned long framesProcessed = 0;
-
+
userOutput = 0;
do
@@ -998,7 +998,7 @@ static unsigned long AdaptingInputOnlyProcess( PaUtilBufferProcessor *bp,
destBytePtr = ((unsigned char*)bp->tempInputBuffer) +
bp->bytesPerUserInputSample * bp->inputChannelCount *
bp->framesInTempInputBuffer;
-
+
destSampleStrideSamples = bp->inputChannelCount;
destChannelStrideBytes = bp->bytesPerUserInputSample;
@@ -1018,7 +1018,7 @@ static unsigned long AdaptingInputOnlyProcess( PaUtilBufferProcessor *bp,
bp->tempInputBufferPtrs[i] = ((unsigned char*)bp->tempInputBuffer) +
i * bp->bytesPerUserInputSample * bp->framesPerUserBuffer;
}
-
+
userInput = bp->tempInputBufferPtrs;
}
@@ -1058,7 +1058,7 @@ static unsigned long AdaptingInputOnlyProcess( PaUtilBufferProcessor *bp,
bp->timeInfo->inputBufferAdcTime += bp->framesPerUserBuffer * bp->samplePeriod;
}
-
+
bp->framesInTempInputBuffer = 0;
}
@@ -1113,7 +1113,7 @@ static unsigned long AdaptingOutputOnlyProcess( PaUtilBufferProcessor *bp,
}
bp->timeInfo->inputBufferAdcTime = 0;
-
+
*streamCallbackResult = bp->streamCallback( userInput, userOutput,
bp->framesPerUserBuffer, bp->timeInfo,
bp->callbackStatusFlags, bp->userData );
@@ -1150,7 +1150,7 @@ static unsigned long AdaptingOutputOnlyProcess( PaUtilBufferProcessor *bp,
srcBytePtr = ((unsigned char*)bp->tempOutputBuffer) +
bp->bytesPerUserOutputSample *
(bp->framesPerUserBuffer - bp->framesInTempOutputBuffer);
-
+
srcSampleStrideSamples = 1;
srcChannelStrideBytes = bp->framesPerUserBuffer * bp->bytesPerUserOutputSample;
}
@@ -1191,9 +1191,9 @@ static unsigned long AdaptingOutputOnlyProcess( PaUtilBufferProcessor *bp,
frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample;
}
}
-
+
framesProcessed += frameCount;
-
+
framesToGo -= frameCount;
}while( framesToGo > 0 );
@@ -1202,8 +1202,8 @@ static unsigned long AdaptingOutputOnlyProcess( PaUtilBufferProcessor *bp,
}
/* CopyTempOutputBuffersToHostOutputBuffers is called from AdaptingProcess to copy frames from
- tempOutputBuffer to hostOutputChannels. This includes data conversion
- and interleaving.
+ tempOutputBuffer to hostOutputChannels. This includes data conversion
+ and interleaving.
*/
static void CopyTempOutputBuffersToHostOutputBuffers( PaUtilBufferProcessor *bp)
{
@@ -1215,65 +1215,65 @@ static void CopyTempOutputBuffersToHostOutputBuffers( PaUtilBufferProcessor *bp)
unsigned int srcChannelStrideBytes; /* stride from one channel to the next, in bytes */
unsigned int i;
- /* copy frames from user to host output buffers */
- while( bp->framesInTempOutputBuffer > 0 &&
- ((bp->hostOutputFrameCount[0] + bp->hostOutputFrameCount[1]) > 0) )
- {
- maxFramesToCopy = bp->framesInTempOutputBuffer;
+ /* copy frames from user to host output buffers */
+ while( bp->framesInTempOutputBuffer > 0 &&
+ ((bp->hostOutputFrameCount[0] + bp->hostOutputFrameCount[1]) > 0) )
+ {
+ maxFramesToCopy = bp->framesInTempOutputBuffer;
- /* select the output buffer set (1st or 2nd) */
- if( bp->hostOutputFrameCount[0] > 0 )
- {
- hostOutputChannels = bp->hostOutputChannels[0];
- frameCount = PA_MIN_( bp->hostOutputFrameCount[0], maxFramesToCopy );
- }
- else
- {
- hostOutputChannels = bp->hostOutputChannels[1];
- frameCount = PA_MIN_( bp->hostOutputFrameCount[1], maxFramesToCopy );
- }
+ /* select the output buffer set (1st or 2nd) */
+ if( bp->hostOutputFrameCount[0] > 0 )
+ {
+ hostOutputChannels = bp->hostOutputChannels[0];
+ frameCount = PA_MIN_( bp->hostOutputFrameCount[0], maxFramesToCopy );
+ }
+ else
+ {
+ hostOutputChannels = bp->hostOutputChannels[1];
+ frameCount = PA_MIN_( bp->hostOutputFrameCount[1], maxFramesToCopy );
+ }
- if( bp->userOutputIsInterleaved )
- {
- srcBytePtr = ((unsigned char*)bp->tempOutputBuffer) +
- bp->bytesPerUserOutputSample * bp->outputChannelCount *
- (bp->framesPerUserBuffer - bp->framesInTempOutputBuffer);
-
- srcSampleStrideSamples = bp->outputChannelCount;
- srcChannelStrideBytes = bp->bytesPerUserOutputSample;
- }
- else /* user output is not interleaved */
- {
- srcBytePtr = ((unsigned char*)bp->tempOutputBuffer) +
- bp->bytesPerUserOutputSample *
- (bp->framesPerUserBuffer - bp->framesInTempOutputBuffer);
+ if( bp->userOutputIsInterleaved )
+ {
+ srcBytePtr = ((unsigned char*)bp->tempOutputBuffer) +
+ bp->bytesPerUserOutputSample * bp->outputChannelCount *
+ (bp->framesPerUserBuffer - bp->framesInTempOutputBuffer);
- srcSampleStrideSamples = 1;
- srcChannelStrideBytes = bp->framesPerUserBuffer * bp->bytesPerUserOutputSample;
- }
+ srcSampleStrideSamples = bp->outputChannelCount;
+ srcChannelStrideBytes = bp->bytesPerUserOutputSample;
+ }
+ else /* user output is not interleaved */
+ {
+ srcBytePtr = ((unsigned char*)bp->tempOutputBuffer) +
+ bp->bytesPerUserOutputSample *
+ (bp->framesPerUserBuffer - bp->framesInTempOutputBuffer);
- for( i=0; ioutputChannelCount; ++i )
- {
- assert( hostOutputChannels[i].data != NULL );
- bp->outputConverter( hostOutputChannels[i].data,
- hostOutputChannels[i].stride,
- srcBytePtr, srcSampleStrideSamples,
- frameCount, &bp->ditherGenerator );
+ srcSampleStrideSamples = 1;
+ srcChannelStrideBytes = bp->framesPerUserBuffer * bp->bytesPerUserOutputSample;
+ }
- srcBytePtr += srcChannelStrideBytes; /* skip to next source channel */
+ for( i=0; ioutputChannelCount; ++i )
+ {
+ assert( hostOutputChannels[i].data != NULL );
+ bp->outputConverter( hostOutputChannels[i].data,
+ hostOutputChannels[i].stride,
+ srcBytePtr, srcSampleStrideSamples,
+ frameCount, &bp->ditherGenerator );
- /* advance dest ptr for next iteration */
- hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) +
- frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample;
- }
+ srcBytePtr += srcChannelStrideBytes; /* skip to next source channel */
- if( bp->hostOutputFrameCount[0] > 0 )
- bp->hostOutputFrameCount[0] -= frameCount;
- else
- bp->hostOutputFrameCount[1] -= frameCount;
+ /* advance dest ptr for next iteration */
+ hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) +
+ frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample;
+ }
- bp->framesInTempOutputBuffer -= frameCount;
- }
+ if( bp->hostOutputFrameCount[0] > 0 )
+ bp->hostOutputFrameCount[0] -= frameCount;
+ else
+ bp->hostOutputFrameCount[1] -= frameCount;
+
+ bp->framesInTempOutputBuffer -= frameCount;
+ }
}
/*
@@ -1300,7 +1300,7 @@ static unsigned long AdaptingProcess( PaUtilBufferProcessor *bp,
unsigned int destSampleStrideSamples; /* stride from one sample to the next within a channel, in samples */
unsigned int destChannelStrideBytes; /* stride from one channel to the next, in bytes */
unsigned int i, j;
-
+
framesAvailable = bp->hostInputFrameCount[0] + bp->hostInputFrameCount[1];/* this is assumed to be the same as the output buffer's frame count */
@@ -1310,9 +1310,9 @@ static unsigned long AdaptingProcess( PaUtilBufferProcessor *bp,
endProcessingMinFrameCount = (bp->framesPerUserBuffer - 1);
/* Fill host output with remaining frames in user output (tempOutputBuffer) */
- CopyTempOutputBuffersToHostOutputBuffers( bp );
+ CopyTempOutputBuffersToHostOutputBuffers( bp );
- while( framesAvailable > endProcessingMinFrameCount )
+ while( framesAvailable > endProcessingMinFrameCount )
{
if( bp->framesInTempOutputBuffer == 0 && *streamCallbackResult != paContinue )
@@ -1326,7 +1326,7 @@ static unsigned long AdaptingProcess( PaUtilBufferProcessor *bp,
if( frameCount > 0 )
{
hostOutputChannels = bp->hostOutputChannels[i];
-
+
for( j=0; joutputChannelCount; ++j )
{
bp->outputZeroer( hostOutputChannels[j].data,
@@ -1340,7 +1340,7 @@ static unsigned long AdaptingProcess( PaUtilBufferProcessor *bp,
bp->hostOutputFrameCount[i] = 0;
}
}
- }
+ }
/* copy frames from host to user input buffers */
@@ -1398,7 +1398,7 @@ static unsigned long AdaptingProcess( PaUtilBufferProcessor *bp,
bp->hostInputFrameCount[0] -= frameCount;
else
bp->hostInputFrameCount[1] -= frameCount;
-
+
bp->framesInTempInputBuffer += frameCount;
/* update framesAvailable and framesProcessed based on input consumed
@@ -1470,13 +1470,13 @@ static unsigned long AdaptingProcess( PaUtilBufferProcessor *bp,
}
}
- /* copy frames from user (tempOutputBuffer) to host output buffers (hostOutputChannels)
+ /* copy frames from user (tempOutputBuffer) to host output buffers (hostOutputChannels)
Means to process the user output provided by the callback. Has to be called after
each callback. */
- CopyTempOutputBuffersToHostOutputBuffers( bp );
+ CopyTempOutputBuffersToHostOutputBuffers( bp );
}
-
+
return framesProcessed;
}
@@ -1485,7 +1485,7 @@ unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bp, int *stream
{
unsigned long framesToProcess, framesToGo;
unsigned long framesProcessed = 0;
-
+
if( bp->inputChannelCount != 0 && bp->outputChannelCount != 0
&& bp->hostInputChannels[0][0].data /* input was supplied (see PaUtil_SetNoInput) */
&& bp->hostOutputChannels[0][0].data /* output was supplied (see PaUtil_SetNoOutput) */ )
@@ -1560,17 +1560,17 @@ unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bp, int *stream
*hostOutputFrameCount );
assert( framesToProcess != 0 );
-
+
framesProcessedThisIteration = NonAdaptingProcess( bp, streamCallbackResult,
hostInputChannels, hostOutputChannels,
- framesToProcess );
+ framesToProcess );
*hostInputFrameCount -= framesProcessedThisIteration;
*hostOutputFrameCount -= framesProcessedThisIteration;
framesProcessed += framesProcessedThisIteration;
framesToGo -= framesProcessedThisIteration;
-
+
}while( framesToGo > 0 );
}
else
@@ -1587,7 +1587,7 @@ unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bp, int *stream
framesToProcess );
/* process second buffer if provided */
-
+
framesToProcess = (bp->inputChannelCount != 0)
? bp->hostInputFrameCount[1]
: bp->hostOutputFrameCount[1];
@@ -1605,7 +1605,7 @@ unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bp, int *stream
if( bp->inputChannelCount != 0 && bp->outputChannelCount != 0 )
{
/* full duplex */
-
+
if( bp->hostBufferSizeMode == paUtilVariableHostBufferSizePartialUsageAllowed )
{
framesProcessed = AdaptingProcess( bp, streamCallbackResult,
@@ -1656,7 +1656,7 @@ unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bp, int *stream
int PaUtil_IsBufferProcessorOutputEmpty( PaUtilBufferProcessor* bp )
{
return (bp->framesInTempOutputBuffer) ? 0 : 1;
-}
+}
unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bp,
@@ -1676,7 +1676,7 @@ unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bp,
if( bp->userInputIsInterleaved )
{
destBytePtr = (unsigned char*)*buffer;
-
+
destSampleStrideSamples = bp->inputChannelCount;
destChannelStrideBytes = bp->bytesPerUserInputSample;
@@ -1701,11 +1701,11 @@ unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bp,
else
{
/* user input is not interleaved */
-
+
nonInterleavedDestPtrs = (void**)*buffer;
destSampleStrideSamples = 1;
-
+
for( i=0; iinputChannelCount; ++i )
{
destBytePtr = (unsigned char*)nonInterleavedDestPtrs[i];
@@ -1718,7 +1718,7 @@ unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bp,
/* advance callers dest pointer (nonInterleavedDestPtrs[i]) */
destBytePtr += bp->bytesPerUserInputSample * framesToCopy;
nonInterleavedDestPtrs[i] = destBytePtr;
-
+
/* advance source ptr for next iteration */
hostInputChannels[i].data = ((unsigned char*)hostInputChannels[i].data) +
framesToCopy * hostInputChannels[i].stride * bp->bytesPerHostInputSample;
@@ -1726,7 +1726,7 @@ unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bp,
}
bp->hostInputFrameCount[0] -= framesToCopy;
-
+
return framesToCopy;
}
@@ -1747,7 +1747,7 @@ unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bp,
if( bp->userOutputIsInterleaved )
{
srcBytePtr = (unsigned char*)*buffer;
-
+
srcSampleStrideSamples = bp->outputChannelCount;
srcChannelStrideBytes = bp->bytesPerUserOutputSample;
@@ -1773,15 +1773,15 @@ unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bp,
else
{
/* user output is not interleaved */
-
+
nonInterleavedSrcPtrs = (void**)*buffer;
srcSampleStrideSamples = 1;
-
+
for( i=0; ioutputChannelCount; ++i )
{
srcBytePtr = (unsigned char*)nonInterleavedSrcPtrs[i];
-
+
bp->outputConverter( hostOutputChannels[i].data,
hostOutputChannels[i].stride,
srcBytePtr, srcSampleStrideSamples,
@@ -1791,7 +1791,7 @@ unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bp,
/* advance callers source pointer (nonInterleavedSrcPtrs[i]) */
srcBytePtr += bp->bytesPerUserOutputSample * framesToCopy;
nonInterleavedSrcPtrs[i] = srcBytePtr;
-
+
/* advance dest ptr for next iteration */
hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) +
framesToCopy * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample;
@@ -1799,7 +1799,7 @@ unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bp,
}
bp->hostOutputFrameCount[0] += framesToCopy;
-
+
return framesToCopy;
}
@@ -1826,6 +1826,6 @@ unsigned long PaUtil_ZeroOutput( PaUtilBufferProcessor* bp, unsigned long frameC
}
bp->hostOutputFrameCount[0] += framesToZero;
-
+
return framesToZero;
}
diff --git a/src/common/pa_process.h b/src/common/pa_process.h
index 803144a..444bdf5 100644
--- a/src/common/pa_process.h
+++ b/src/common/pa_process.h
@@ -28,16 +28,16 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
-
+
/** @file
@ingroup common_src
@@ -72,7 +72,7 @@
The following sections provide an overview of how to use the buffer processor.
Interested readers are advised to consult the host API implementations for
examples of buffer processor usage.
-
+
Initialization, resetting and termination
@@ -92,7 +92,7 @@
When the buffer processor is no longer used call
PaUtil_TerminateBufferProcessor.
-
+
Using the buffer processor for a callback stream
The buffer processor's role in a callback stream is to take host input buffers
@@ -176,7 +176,7 @@
host buffer(s), so the above steps need to be repeated until the user
buffer(s) are full.
-
+
To copy data to the host output buffer from the user buffers(s) supplied
to Pa_WriteStream use the following calling sequence.
@@ -192,7 +192,7 @@
-# Call PaUtil_CopyOutput with the user buffer pointer (or a copy of the
array of buffer pointers for a non-interleaved stream) passed to
Pa_WriteStream, along with the number of frames in the user buffer(s).
- Be careful to pass a copy of the user buffer pointers to
+ Be careful to pass a copy of the user buffer pointers to
PaUtil_CopyOutput because PaUtil_CopyOutput advances the pointers to
the start of the next region to copy.
- PaUtil_CopyOutput will not copy more data than fits in the host buffer(s),
@@ -266,7 +266,7 @@ typedef struct {
int userInputIsInterleaved;
PaUtilConverter *inputConverter;
PaUtilZeroer *inputZeroer;
-
+
unsigned int outputChannelCount;
unsigned int bytesPerHostOutputSample;
unsigned int bytesPerUserOutputSample;
@@ -327,7 +327,7 @@ typedef struct {
@param userInputSampleFormat Format of user input samples, as passed to
Pa_OpenStream. This parameter is ignored for ouput-only streams.
-
+
@param hostInputSampleFormat Format of host input samples. This parameter is
ignored for output-only streams. See note about host buffer interleave below.
@@ -336,17 +336,17 @@ typedef struct {
@param userOutputSampleFormat Format of user output samples, as passed to
Pa_OpenStream. This parameter is ignored for input-only streams.
-
+
@param hostOutputSampleFormat Format of host output samples. This parameter is
ignored for input-only streams. See note about host buffer interleave below.
@param sampleRate Sample rate of the stream. The more accurate this is the
better - it is used for updating time stamps when adapting buffers.
-
+
@param streamFlags Stream flags as passed to Pa_OpenStream, this parameter is
used for selecting special sample conversion options such as clipping and
dithering.
-
+
@param framesPerUserBuffer Number of frames per user buffer, as requested
by the framesPerBuffer parameter to Pa_OpenStream. This parameter may be
zero to indicate that the user will accept any (and varying) buffer sizes.
@@ -359,11 +359,11 @@ typedef struct {
@param hostBufferSizeMode A mode flag indicating the size variability of
host buffers that will be passed to the buffer processor. See
PaUtilHostBufferSizeMode for further details.
-
+
@param streamCallback The user stream callback passed to Pa_OpenStream.
@param userData The user data field passed to Pa_OpenStream.
-
+
@note The interleave flag is ignored for host buffer formats. Host
interleave is determined by the use of different SetInput and SetOutput
functions.
@@ -371,7 +371,7 @@ typedef struct {
@return An error code indicating whether the initialization was successful.
If the error code is not PaNoError, the buffer processor was not initialized
and should not be used.
-
+
@see Pa_OpenStream, PaUtilHostBufferSizeMode, PaUtil_TerminateBufferProcessor
*/
PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bufferProcessor,
@@ -389,7 +389,7 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bufferProcessor
/** Terminate a buffer processor's representation. Deallocates any temporary
buffers allocated by PaUtil_InitializeBufferProcessor.
-
+
@param bufferProcessor The buffer processor structure to terminate.
@see PaUtil_InitializeBufferProcessor.
@@ -434,7 +434,7 @@ unsigned long PaUtil_GetBufferProcessorOutputLatencyFrames( PaUtilBufferProcesso
Functions to set host input and output buffers, used by both callback streams
and blocking read/write streams.
*/
-/*@{*/
+/*@{*/
/** Set the number of frames in the input host buffer(s) specified by the
@@ -451,7 +451,7 @@ unsigned long PaUtil_GetBufferProcessorOutputLatencyFrames( PaUtilBufferProcesso
void PaUtil_SetInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
unsigned long frameCount );
-
+
/** Indicate that no input is available. This function should be used when
priming the output of a full-duplex stream opened with the
paPrimeOutputBuffersUsingStreamCallback flag. Note that it is not necessary
@@ -524,7 +524,7 @@ void PaUtil_Set2ndInterleavedInputChannels( PaUtilBufferProcessor* bufferProcess
void PaUtil_Set2ndNonInterleavedInputChannel( PaUtilBufferProcessor* bufferProcessor,
unsigned int channel, void *data );
-
+
/** Set the number of frames in the output host buffer(s) specified by the
PaUtil_Set*OutputChannel functions.
@@ -574,7 +574,7 @@ void PaUtil_SetOutputChannel( PaUtilBufferProcessor* bufferProcessor,
void PaUtil_SetInterleavedOutputChannels( PaUtilBufferProcessor* bufferProcessor,
unsigned int firstChannel, void *data, unsigned int channelCount );
-
+
/** Provide the buffer processor with a pointer to one non-interleaved host
output channel.
@@ -632,12 +632,12 @@ void PaUtil_Set2ndNonInterleavedOutputChannel( PaUtilBufferProcessor* bufferProc
void PaUtil_BeginBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags callbackStatusFlags );
-
+
/** Finish processing a host buffer (or a pair of host buffers in the
full-duplex case) for a callback stream.
@param bufferProcessor The buffer processor.
-
+
@param callbackResult On input, indicates a previous callback result, and on
exit, the result of the user stream callback, if it is called.
On entry callbackResult should contain one of { paContinue, paComplete, or
@@ -666,7 +666,7 @@ unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bufferProcessor
a callbackResult of paComplete.
@param bufferProcessor The buffer processor.
-
+
@return Returns non-zero when callback generated output remains in the internal
buffer and zero (0) when there internal buffer contains no callback generated
data.
@@ -738,7 +738,7 @@ unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bufferProcessor,
@param bufferProcessor The buffer processor.
@param frameCount The maximum number of frames to zero.
-
+
@return The number of frames zeroed.
*/
unsigned long PaUtil_ZeroOutput( PaUtilBufferProcessor* bufferProcessor,
diff --git a/src/common/pa_ringbuffer.c b/src/common/pa_ringbuffer.c
index 93b3e43..b978d54 100644
--- a/src/common/pa_ringbuffer.c
+++ b/src/common/pa_ringbuffer.c
@@ -7,7 +7,7 @@
* modified for SMP safety on Mac OS X by Bjorn Roche
* modified for SMP safety on Linux by Leland Lucius
* also, allowed for const where possible
- * modified for multiple-byte-sized data elements by Sven Fischer
+ * modified for multiple-byte-sized data elements by Sven Fischer
*
* Note that this is safe only for a single-thread reader and a
* single-thread writer.
@@ -37,13 +37,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -138,7 +138,7 @@ ring_buffer_size_t PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, rin
*/
ring_buffer_size_t PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount )
{
- /* ensure that previous writes are seen before we update the write index
+ /* ensure that previous writes are seen before we update the write index
(write after write)
*/
PaUtil_WriteMemoryBarrier();
@@ -176,7 +176,7 @@ ring_buffer_size_t PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, ring
*dataPtr2 = NULL;
*sizePtr2 = 0;
}
-
+
if( available )
PaUtil_ReadMemoryBarrier(); /* (read-after-read) => read barrier */
@@ -186,7 +186,7 @@ ring_buffer_size_t PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, ring
*/
ring_buffer_size_t PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount )
{
- /* ensure that previous reads (copies out of the ring buffer) are always completed before updating (writing) the read index.
+ /* ensure that previous reads (copies out of the ring buffer) are always completed before updating (writing) the read index.
(write-after-read) => full barrier
*/
PaUtil_FullMemoryBarrier();
diff --git a/src/common/pa_ringbuffer.h b/src/common/pa_ringbuffer.h
index 9edba0d..400aaac 100644
--- a/src/common/pa_ringbuffer.h
+++ b/src/common/pa_ringbuffer.h
@@ -8,7 +8,7 @@
* Author: Phil Burk, http://www.softsynth.com
* modified for SMP safety on OS X by Bjorn Roche.
* also allowed for const where possible.
- * modified for multiple-byte-sized data elements by Sven Fischer
+ * modified for multiple-byte-sized data elements by Sven Fischer
*
* Note that this is safe only for a single-thread reader
* and a single-thread writer.
@@ -38,13 +38,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -58,15 +58,15 @@
a single reader and a single writer (ie. one thread or callback writes
to the ring buffer, another thread or callback reads from it).
- The PaUtilRingBuffer structure manages a ring buffer containing N
- elements, where N must be a power of two. An element may be any size
+ The PaUtilRingBuffer structure manages a ring buffer containing N
+ elements, where N must be a power of two. An element may be any size
(specified in bytes).
- The memory area used to store the buffer elements must be allocated by
+ The memory area used to store the buffer elements must be allocated by
the client prior to calling PaUtil_InitializeRingBuffer() and must outlive
the use of the ring buffer.
-
- @note The ring buffer functions are not normally exposed in the PortAudio libraries.
+
+ @note The ring buffer functions are not normally exposed in the PortAudio libraries.
If you want to call them then you will need to add pa_ringbuffer.c to your application source code.
*/
diff --git a/src/common/pa_stream.c b/src/common/pa_stream.c
index 03a0ee6..ffbf530 100644
--- a/src/common/pa_stream.c
+++ b/src/common/pa_stream.c
@@ -27,13 +27,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
diff --git a/src/common/pa_stream.h b/src/common/pa_stream.h
index 678e2ad..4afda39 100644
--- a/src/common/pa_stream.h
+++ b/src/common/pa_stream.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -164,7 +164,7 @@ void PaUtil_InitializeStreamRepresentation(
PaUtilStreamInterface *streamInterface,
PaStreamCallback *streamCallback,
void *userData );
-
+
/** Clean up a PaUtilStreamRepresentation structure previously initialized
by a call to PaUtil_InitializeStreamRepresentation.
@@ -198,7 +198,7 @@ PaError PaUtil_ValidateStreamPointer( PaStream *stream );
PA_STREAM_REP( (stream) )->streamInterface
-
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/src/common/pa_trace.c b/src/common/pa_trace.c
index 818abff..6763dfa 100644
--- a/src/common/pa_trace.c
+++ b/src/common/pa_trace.c
@@ -27,13 +27,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -233,6 +233,6 @@ void PaUtil_DiscardHighSpeedLog( LogHandle hLog )
*/
int PaUtil_TraceStubToSatisfyLinker(void)
{
- return 0;
+ return 0;
}
#endif /* TRACE_REALTIME_EVENTS */
diff --git a/src/common/pa_trace.h b/src/common/pa_trace.h
index 6dfaeb7..7827766 100644
--- a/src/common/pa_trace.h
+++ b/src/common/pa_trace.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -45,8 +45,8 @@
@brief Real-time safe event trace logging facility for debugging.
Allows data to be logged to a fixed size trace buffer in a real-time
- execution context (such as at interrupt time). Each log entry consists
- of a message comprising a string pointer and an int. The trace buffer
+ execution context (such as at interrupt time). Each log entry consists
+ of a message comprising a string pointer and an int. The trace buffer
may be dumped to stdout later.
This facility is only active if PA_TRACE_REALTIME_EVENTS is set to 1,
@@ -57,8 +57,8 @@
@fn PaUtil_AddTraceMessage
@brief Add a message to the trace buffer. A message consists of string and an int.
- @param msg The string pointer must remain valid until PaUtil_DumpTraceMessages
- is called. As a result, usually only string literals should be passed as
+ @param msg The string pointer must remain valid until PaUtil_DumpTraceMessages
+ is called. As a result, usually only string literals should be passed as
the msg parameter.
@fn PaUtil_DumpTraceMessages
@@ -70,7 +70,7 @@
#endif
#ifndef PA_MAX_TRACE_RECORDS
-#define PA_MAX_TRACE_RECORDS (2048) /**< Maximum number of records stored in trace buffer */
+#define PA_MAX_TRACE_RECORDS (2048) /**< Maximum number of records stored in trace buffer */
#endif
#ifdef __cplusplus
diff --git a/src/common/pa_types.h b/src/common/pa_types.h
index 5b647d6..f628783 100644
--- a/src/common/pa_types.h
+++ b/src/common/pa_types.h
@@ -1,7 +1,7 @@
#ifndef PA_TYPES_H
#define PA_TYPES_H
-/*
+/*
* Portable Audio I/O Library
* integer type definitions
*
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
diff --git a/src/common/pa_util.h b/src/common/pa_util.h
index 43ea894..08dc0ec 100644
--- a/src/common/pa_util.h
+++ b/src/common/pa_util.h
@@ -29,13 +29,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -112,7 +112,7 @@ void PaUtil_SetLastHostErrorInfo( PaHostApiTypeId hostApiType, long errorCode,
const char *errorText );
-
+
/* the following functions are implemented in a platform platform specific
.c file
*/
From 4c673d1f2b84dacc16b27e6192ec5f3e5f4a7260 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 21 Jan 2021 23:23:00 +1100
Subject: [PATCH 085/157] Clean up whitespace in src/os/win in preparation for
.editorconfig. (#409)
* Clean up whitespace in src/os/win in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF.
---
src/os/win/pa_win_coinitialize.c | 30 +++----
src/os/win/pa_win_coinitialize.h | 16 ++--
src/os/win/pa_win_hostapis.c | 8 +-
src/os/win/pa_win_util.c | 28 +++----
src/os/win/pa_win_waveformat.c | 100 ++++++++++++------------
src/os/win/pa_win_wdmks_utils.c | 40 +++++-----
src/os/win/pa_win_wdmks_utils.h | 8 +-
src/os/win/pa_x86_plain_converters.c | 112 +++++++++++++--------------
src/os/win/pa_x86_plain_converters.h | 6 +-
9 files changed, 174 insertions(+), 174 deletions(-)
diff --git a/src/os/win/pa_win_coinitialize.c b/src/os/win/pa_win_coinitialize.c
index ace97f5..cdb1fb9 100644
--- a/src/os/win/pa_win_coinitialize.c
+++ b/src/os/win/pa_win_coinitialize.c
@@ -72,14 +72,14 @@ PaError PaWinUtil_CoInitialize( PaHostApiTypeId hostApiType, PaWinUtilComInitial
If COM is already initialized CoInitialize will either return
FALSE, or RPC_E_CHANGED_MODE if it was initialised in a different
threading mode. In either case we shouldn't consider it an error
- but we need to be careful to not call CoUninitialize() if
+ but we need to be careful to not call CoUninitialize() if
RPC_E_CHANGED_MODE was returned.
*/
#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
hr = CoInitialize(0); /* use legacy-safe equivalent to CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) */
#else
- hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
#endif
if( FAILED(hr) && hr != RPC_E_CHANGED_MODE )
{
@@ -111,8 +111,8 @@ PaError PaWinUtil_CoInitialize( PaHostApiTypeId hostApiType, PaWinUtilComInitial
comInitializationResult->state = PAWINUTIL_COM_INITIALIZED;
/*
- Memorize calling thread id and report warning on Uninitialize if
- calling thread is different as CoInitialize must match CoUninitialize
+ Memorize calling thread id and report warning on Uninitialize if
+ calling thread is different as CoInitialize must match CoUninitialize
in the same thread.
*/
comInitializationResult->initializingThreadId = GetCurrentThreadId();
@@ -126,23 +126,23 @@ void PaWinUtil_CoUninitialize( PaHostApiTypeId hostApiType, PaWinUtilComInitiali
{
if( comInitializationResult->state != PAWINUTIL_COM_NOT_INITIALIZED
&& comInitializationResult->state != PAWINUTIL_COM_INITIALIZED ){
-
+
PA_DEBUG(("ERROR: PaWinUtil_CoUninitialize called without calling PaWinUtil_CoInitialize\n"));
}
if( comInitializationResult->state == PAWINUTIL_COM_INITIALIZED )
{
DWORD currentThreadId = GetCurrentThreadId();
- if( comInitializationResult->initializingThreadId != currentThreadId )
- {
- PA_DEBUG(("ERROR: failed PaWinUtil_CoUninitialize calling thread[%lu] does not match initializing thread[%lu]\n",
- currentThreadId, comInitializationResult->initializingThreadId));
- }
- else
- {
- CoUninitialize();
+ if( comInitializationResult->initializingThreadId != currentThreadId )
+ {
+ PA_DEBUG(("ERROR: failed PaWinUtil_CoUninitialize calling thread[%lu] does not match initializing thread[%lu]\n",
+ currentThreadId, comInitializationResult->initializingThreadId));
+ }
+ else
+ {
+ CoUninitialize();
comInitializationResult->state = PAWINUTIL_COM_NOT_INITIALIZED;
- }
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/os/win/pa_win_coinitialize.h b/src/os/win/pa_win_coinitialize.h
index 63fac7c..deb60c3 100644
--- a/src/os/win/pa_win_coinitialize.h
+++ b/src/os/win/pa_win_coinitialize.h
@@ -23,13 +23,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -50,7 +50,7 @@ extern "C"
/**
@brief Data type used to hold the result of an attempt to initialize COM
- using PaWinUtil_CoInitialize. Must be retained between a call to
+ using PaWinUtil_CoInitialize. Must be retained between a call to
PaWinUtil_CoInitialize and a matching call to PaWinUtil_CoUninitialize.
*/
typedef struct PaWinUtilComInitializationResult{
@@ -64,9 +64,9 @@ typedef struct PaWinUtilComInitializationResult{
@param hostApiType the host API type id of the caller. Used for error reporting.
- @param comInitializationResult An output parameter. The value pointed to by
- this parameter stores information required by PaWinUtil_CoUninitialize
- to correctly uninitialize COM. The value should be retained and later
+ @param comInitializationResult An output parameter. The value pointed to by
+ this parameter stores information required by PaWinUtil_CoUninitialize
+ to correctly uninitialize COM. The value should be retained and later
passed to PaWinUtil_CoUninitialize.
If PaWinUtil_CoInitialize returns paNoError, the caller must later call
@@ -76,7 +76,7 @@ PaError PaWinUtil_CoInitialize( PaHostApiTypeId hostApiType, PaWinUtilComInitial
/**
- @brief Uninitialize the Microsoft COM subsystem on the current thread using
+ @brief Uninitialize the Microsoft COM subsystem on the current thread using
the result of a previous call to PaWinUtil_CoInitialize. Must be called on the same
thread as PaWinUtil_CoInitialize.
diff --git a/src/os/win/pa_win_hostapis.c b/src/os/win/pa_win_hostapis.c
index 9c9927a..942540c 100644
--- a/src/os/win/pa_win_hostapis.c
+++ b/src/os/win/pa_win_hostapis.c
@@ -26,13 +26,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -85,7 +85,7 @@ PaUtilHostApiInitializer *paHostApiInitializers[] =
#endif
#if PA_USE_WASAPI
- PaWasapi_Initialize,
+ PaWasapi_Initialize,
#endif
#if PA_USE_WDMKS
diff --git a/src/os/win/pa_win_util.c b/src/os/win/pa_win_util.c
index 1cd3525..b86f7af 100644
--- a/src/os/win/pa_win_util.c
+++ b/src/os/win/pa_win_util.c
@@ -27,13 +27,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -42,16 +42,16 @@
@brief Win32 implementation of platform-specific PaUtil support functions.
*/
-
+
#include
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
- #include /* for _ftime_s() */
+ #include /* for _ftime_s() */
#else
- #include /* for timeGetTime() */
- #if (defined(WIN32) && (defined(_MSC_VER) && (_MSC_VER >= 1200))) && !defined(_WIN32_WCE) /* MSC version 6 and above */
- #pragma comment( lib, "winmm.lib" )
- #endif
+ #include /* for timeGetTime() */
+ #if (defined(WIN32) && (defined(_MSC_VER) && (_MSC_VER >= 1200))) && !defined(_WIN32_WCE) /* MSC version 6 and above */
+ #pragma comment( lib, "winmm.lib" )
+ #endif
#endif
#include "pa_util.h"
@@ -135,7 +135,7 @@ double PaUtil_GetTime( void )
This is documented here:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q274323&
- The work-arounds are not very paletable and involve querying GetTickCount
+ The work-arounds are not very paletable and involve querying GetTickCount
at every time step.
Using rdtsc is not a good option on multi-core systems.
@@ -148,13 +148,13 @@ double PaUtil_GetTime( void )
else
{
#ifndef UNDER_CE
- #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
+ #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
return GetTickCount64() * .001;
- #else
+ #else
return timeGetTime() * .001;
- #endif
+ #endif
#else
return GetTickCount() * .001;
-#endif
+#endif
}
}
diff --git a/src/os/win/pa_win_waveformat.c b/src/os/win/pa_win_waveformat.c
index 933cb78..0436a39 100644
--- a/src/os/win/pa_win_waveformat.c
+++ b/src/os/win/pa_win_waveformat.c
@@ -26,13 +26,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -51,52 +51,52 @@
#endif
-static GUID pawin_ksDataFormatSubtypeGuidBase =
- { (USHORT)(WAVE_FORMAT_PCM), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 };
+static GUID pawin_ksDataFormatSubtypeGuidBase =
+ { (USHORT)(WAVE_FORMAT_PCM), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 };
int PaWin_SampleFormatToLinearWaveFormatTag( PaSampleFormat sampleFormat )
{
if( sampleFormat == paFloat32 )
return PAWIN_WAVE_FORMAT_IEEE_FLOAT;
-
+
return PAWIN_WAVE_FORMAT_PCM;
}
-void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat,
- int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate )
+void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat,
+ int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate )
{
- WAVEFORMATEX *waveFormatEx = (WAVEFORMATEX*)waveFormat;
+ WAVEFORMATEX *waveFormatEx = (WAVEFORMATEX*)waveFormat;
int bytesPerSample = Pa_GetSampleSize(sampleFormat);
- unsigned long bytesPerFrame = numChannels * bytesPerSample;
-
+ unsigned long bytesPerFrame = numChannels * bytesPerSample;
+
waveFormatEx->wFormatTag = waveFormatTag;
- waveFormatEx->nChannels = (WORD)numChannels;
- waveFormatEx->nSamplesPerSec = (DWORD)sampleRate;
- waveFormatEx->nAvgBytesPerSec = waveFormatEx->nSamplesPerSec * bytesPerFrame;
- waveFormatEx->nBlockAlign = (WORD)bytesPerFrame;
- waveFormatEx->wBitsPerSample = bytesPerSample * 8;
- waveFormatEx->cbSize = 0;
+ waveFormatEx->nChannels = (WORD)numChannels;
+ waveFormatEx->nSamplesPerSec = (DWORD)sampleRate;
+ waveFormatEx->nAvgBytesPerSec = waveFormatEx->nSamplesPerSec * bytesPerFrame;
+ waveFormatEx->nBlockAlign = (WORD)bytesPerFrame;
+ waveFormatEx->wBitsPerSample = bytesPerSample * 8;
+ waveFormatEx->cbSize = 0;
}
-void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
- int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate,
- PaWinWaveFormatChannelMask channelMask )
+void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
+ int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate,
+ PaWinWaveFormatChannelMask channelMask )
{
- WAVEFORMATEX *waveFormatEx = (WAVEFORMATEX*)waveFormat;
+ WAVEFORMATEX *waveFormatEx = (WAVEFORMATEX*)waveFormat;
int bytesPerSample = Pa_GetSampleSize(sampleFormat);
- unsigned long bytesPerFrame = numChannels * bytesPerSample;
+ unsigned long bytesPerFrame = numChannels * bytesPerSample;
GUID guid;
- waveFormatEx->wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- waveFormatEx->nChannels = (WORD)numChannels;
- waveFormatEx->nSamplesPerSec = (DWORD)sampleRate;
- waveFormatEx->nAvgBytesPerSec = waveFormatEx->nSamplesPerSec * bytesPerFrame;
- waveFormatEx->nBlockAlign = (WORD)bytesPerFrame;
- waveFormatEx->wBitsPerSample = bytesPerSample * 8;
- waveFormatEx->cbSize = 22;
+ waveFormatEx->wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ waveFormatEx->nChannels = (WORD)numChannels;
+ waveFormatEx->nSamplesPerSec = (DWORD)sampleRate;
+ waveFormatEx->nAvgBytesPerSec = waveFormatEx->nSamplesPerSec * bytesPerFrame;
+ waveFormatEx->nBlockAlign = (WORD)bytesPerFrame;
+ waveFormatEx->wBitsPerSample = bytesPerSample * 8;
+ waveFormatEx->cbSize = 22;
memcpy(&waveFormat->fields[PAWIN_INDEXOF_WVALIDBITSPERSAMPLE],
&waveFormatEx->wBitsPerSample, sizeof(WORD));
@@ -111,42 +111,42 @@ void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels )
{
- switch( numChannels ){
- case 1:
- return PAWIN_SPEAKER_MONO;
- case 2:
- return PAWIN_SPEAKER_STEREO;
- case 3:
+ switch( numChannels ){
+ case 1:
+ return PAWIN_SPEAKER_MONO;
+ case 2:
+ return PAWIN_SPEAKER_STEREO;
+ case 3:
return PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_FRONT_RIGHT;
- case 4:
- return PAWIN_SPEAKER_QUAD;
- case 5:
+ case 4:
+ return PAWIN_SPEAKER_QUAD;
+ case 5:
return PAWIN_SPEAKER_QUAD | PAWIN_SPEAKER_FRONT_CENTER;
- case 6:
+ case 6:
/* The meaning of the PAWIN_SPEAKER_5POINT1 flag has changed over time:
http://msdn2.microsoft.com/en-us/library/aa474707.aspx
We use PAWIN_SPEAKER_5POINT1 (not PAWIN_SPEAKER_5POINT1_SURROUND)
- because on some cards (eg Audigy) PAWIN_SPEAKER_5POINT1_SURROUND
- results in a virtual mixdown placing the rear output in the
+ because on some cards (eg Audigy) PAWIN_SPEAKER_5POINT1_SURROUND
+ results in a virtual mixdown placing the rear output in the
front _and_ rear speakers.
*/
- return PAWIN_SPEAKER_5POINT1;
+ return PAWIN_SPEAKER_5POINT1;
/* case 7: */
- case 8:
+ case 8:
/* RoBi: PAWIN_SPEAKER_7POINT1_SURROUND fits normal surround sound setups better than PAWIN_SPEAKER_7POINT1, f.i. NVidia HDMI Audio
- output is silent on channels 5&6 with NVidia drivers, and channel 7&8 with Microsoft HD Audio driver using PAWIN_SPEAKER_7POINT1.
+ output is silent on channels 5&6 with NVidia drivers, and channel 7&8 with Microsoft HD Audio driver using PAWIN_SPEAKER_7POINT1.
With PAWIN_SPEAKER_7POINT1_SURROUND both setups work OK. */
- return PAWIN_SPEAKER_7POINT1_SURROUND;
- }
+ return PAWIN_SPEAKER_7POINT1_SURROUND;
+ }
- /* Apparently some Audigy drivers will output silence
- if the direct-out constant (0) is used. So this is not ideal.
+ /* Apparently some Audigy drivers will output silence
+ if the direct-out constant (0) is used. So this is not ideal.
RoBi 2012-12-19: Also, NVidia driver seem to output garbage instead. Again not very ideal.
*/
- return PAWIN_SPEAKER_DIRECTOUT;
+ return PAWIN_SPEAKER_DIRECTOUT;
- /* Note that Alec Rogers proposed the following as an alternate method to
+ /* Note that Alec Rogers proposed the following as an alternate method to
generate the default channel mask, however it doesn't seem to be an improvement
over the above, since some drivers will matrix outputs mapping to non-present
speakers across multiple physical speakers.
diff --git a/src/os/win/pa_win_wdmks_utils.c b/src/os/win/pa_win_wdmks_utils.c
index 4bd067a..3373146 100644
--- a/src/os/win/pa_win_wdmks_utils.c
+++ b/src/os/win/pa_win_wdmks_utils.c
@@ -25,13 +25,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -39,14 +39,14 @@
#include
#ifndef WAVE_FORMAT_IEEE_FLOAT
#define WAVE_FORMAT_IEEE_FLOAT 0x0003 // MinGW32 does not define this
-#endif
+#endif
#ifndef _WAVEFORMATEXTENSIBLE_
#define _WAVEFORMATEXTENSIBLE_ // MinGW32 does not define this
#endif
#ifndef _INC_MMREG
#define _INC_MMREG // for STATIC_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
#endif
-#include // MinGW32 does not define this automatically
+#include // MinGW32 does not define this automatically
#if defined(__GNUC__)
@@ -198,7 +198,7 @@ static KSPIN_DATAFLOW GetKSFilterPinPropertyDataflow( HANDLE deviceHandle, int p
}
-static int KSFilterPinPropertyIdentifiersInclude(
+static int KSFilterPinPropertyIdentifiersInclude(
HANDLE deviceHandle, int pinId, unsigned long property, const GUID *identifierSet, unsigned long identifierId )
{
KSMULTIPLE_ITEM* item = NULL;
@@ -208,13 +208,13 @@ static int KSFilterPinPropertyIdentifiersInclude(
if( WdmGetPinPropertyMulti( deviceHandle, pinId, property, &item) != paNoError )
return 0;
-
+
identifier = (KSIDENTIFIER*)(item+1);
for( i = 0; i < (int)item->Count; i++ )
{
if( !memcmp( (void*)&identifier[i].Set, (void*)identifierSet, sizeof( GUID ) ) &&
- ( identifier[i].Id == identifierId ) )
+ ( identifier[i].Id == identifierId ) )
{
result = 1;
break;
@@ -227,17 +227,17 @@ static int KSFilterPinPropertyIdentifiersInclude(
}
-/* return the maximum channel count supported by any pin on the device.
+/* return the maximum channel count supported by any pin on the device.
if isInput is non-zero we query input pins, otherwise output pins.
*/
int PaWin_WDMKS_QueryFilterMaximumChannelCount( void *wcharDevicePath, int isInput )
{
HANDLE deviceHandle;
- ULONG i;
+ ULONG i;
int pinCount, pinId;
int result = 0;
KSPIN_DATAFLOW requiredDataflowDirection = (isInput ? KSPIN_DATAFLOW_OUT : KSPIN_DATAFLOW_IN );
-
+
if( !wcharDevicePath )
return 0;
@@ -252,14 +252,14 @@ int PaWin_WDMKS_QueryFilterMaximumChannelCount( void *wcharDevicePath, int isInp
KSPIN_DATAFLOW dataflow = GetKSFilterPinPropertyDataflow( deviceHandle, pinId );
if( ( dataflow == requiredDataflowDirection ) &&
(( communication == KSPIN_COMMUNICATION_SINK) ||
- ( communication == KSPIN_COMMUNICATION_BOTH))
- && ( KSFilterPinPropertyIdentifiersInclude( deviceHandle, pinId,
+ ( communication == KSPIN_COMMUNICATION_BOTH))
+ && ( KSFilterPinPropertyIdentifiersInclude( deviceHandle, pinId,
KSPROPERTY_PIN_INTERFACES, &pa_KSINTERFACESETID_Standard, KSINTERFACE_STANDARD_STREAMING )
- || KSFilterPinPropertyIdentifiersInclude( deviceHandle, pinId,
+ || KSFilterPinPropertyIdentifiersInclude( deviceHandle, pinId,
KSPROPERTY_PIN_INTERFACES, &pa_KSINTERFACESETID_Standard, KSINTERFACE_STANDARD_LOOPED_STREAMING ) )
- && KSFilterPinPropertyIdentifiersInclude( deviceHandle, pinId,
+ && KSFilterPinPropertyIdentifiersInclude( deviceHandle, pinId,
KSPROPERTY_PIN_MEDIUMS, &pa_KSMEDIUMSETID_Standard, KSMEDIUM_STANDARD_DEVIO ) )
- {
+ {
KSMULTIPLE_ITEM* item = NULL;
if( WdmGetPinPropertyMulti( deviceHandle, pinId, KSPROPERTY_PIN_DATARANGES, &item ) == paNoError )
{
@@ -274,10 +274,10 @@ int PaWin_WDMKS_QueryFilterMaximumChannelCount( void *wcharDevicePath, int isInp
&& ( memcmp( (void*)&dataRange->SubFormat, (void*)&KSDATAFORMAT_SUBTYPE_WILDCARD, sizeof(GUID) ) == 0 ) ) )
{
KSDATARANGE_AUDIO *dataRangeAudio = (KSDATARANGE_AUDIO*)dataRange;
-
+
/*
printf( ">>> %d %d %d %d %S\n", isInput, dataflow, communication, dataRangeAudio->MaximumChannels, devicePath );
-
+
if( memcmp((void*)&dataRange->Specifier, (void*)&KSDATAFORMAT_SPECIFIER_WAVEFORMATEX, sizeof(GUID) ) == 0 )
printf( "\tspecifier: KSDATAFORMAT_SPECIFIER_WAVEFORMATEX\n" );
else if( memcmp((void*)&dataRange->Specifier, (void*)&KSDATAFORMAT_SPECIFIER_DSOUND, sizeof(GUID) ) == 0 )
@@ -295,7 +295,7 @@ int PaWin_WDMKS_QueryFilterMaximumChannelCount( void *wcharDevicePath, int isInp
if( dataRangeAudio->MaximumChannels < 0xFFFFUL && (int)dataRangeAudio->MaximumChannels > result )
result = (int)dataRangeAudio->MaximumChannels;
}
-
+
dataRange = (KSDATARANGE*)( ((char*)dataRange) + dataRange->FormatSize);
}
@@ -303,7 +303,7 @@ int PaWin_WDMKS_QueryFilterMaximumChannelCount( void *wcharDevicePath, int isInp
}
}
}
-
+
CloseHandle( deviceHandle );
return result;
}
diff --git a/src/os/win/pa_win_wdmks_utils.h b/src/os/win/pa_win_wdmks_utils.h
index 5a7a338..f524cf7 100644
--- a/src/os/win/pa_win_wdmks_utils.h
+++ b/src/os/win/pa_win_wdmks_utils.h
@@ -28,13 +28,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -62,4 +62,4 @@ int PaWin_WDMKS_QueryFilterMaximumChannelCount( void *wcharDevicePath, int isInp
}
#endif /* __cplusplus */
-#endif /* PA_WIN_WDMKS_UTILS_H */
\ No newline at end of file
+#endif /* PA_WIN_WDMKS_UTILS_H */
diff --git a/src/os/win/pa_x86_plain_converters.c b/src/os/win/pa_x86_plain_converters.c
index 44a6d67..1096994 100644
--- a/src/os/win/pa_x86_plain_converters.c
+++ b/src/os/win/pa_x86_plain_converters.c
@@ -23,13 +23,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -115,8 +115,8 @@ TODO:
#if defined(_WIN64) || defined(_WIN32_WCE)
/*
- -EMT64/AMD64 uses different asm
- -VC2005 doesn't allow _WIN64 with inline assembly either!
+ -EMT64/AMD64 uses different asm
+ -VC2005 doesn't allow _WIN64 with inline assembly either!
*/
void PaUtil_InitializeX86PlainConverters( void )
{
@@ -185,9 +185,9 @@ static void Float32_To_Int32(
mov ecx, count
imul ecx, eax
add ecx, esi
-
+
mov edi, destinationBuffer
-
+
mov ebx, destinationStride
imul ebx, edx
@@ -195,7 +195,7 @@ static void Float32_To_Int32(
fstcw savedFpuControlWord
fldcw fpuControlWord_
- fld int32Scaler_ // stack: (int)0x7FFFFFFF
+ fld int32Scaler_ // stack: (int)0x7FFFFFFF
Float32_To_Int32_loop:
@@ -272,9 +272,9 @@ static void Float32_To_Int32_Clip(
mov ecx, count
imul ecx, eax
add ecx, esi
-
+
mov edi, destinationBuffer
-
+
mov ebx, destinationStride
imul ebx, edx
@@ -282,7 +282,7 @@ static void Float32_To_Int32_Clip(
fstcw savedFpuControlWord
fldcw fpuControlWord_
- fld int32Scaler_ // stack: (int)0x7FFFFFFF
+ fld int32Scaler_ // stack: (int)0x7FFFFFFF
Float32_To_Int32_Clip_loop:
@@ -300,7 +300,7 @@ static void Float32_To_Int32_Clip(
fmul st(0), st(1) // st(0) *= st(1), stack: value*0x7FFFFFFF, (int)0x7FFFFFFF
fistp dword ptr [edi] // pop st(0) into dest, stack: (int)0x7FFFFFFF
jmp Float32_To_Int32_Clip_stored
-
+
Float32_To_Int32_Clip_clamp:
mov edx, dword ptr [esi] // load floating point value into integer register
shr edx, 31 // move sign bit into bit 0
@@ -311,7 +311,7 @@ static void Float32_To_Int32_Clip(
Float32_To_Int32_Clip_stored:
- //add edi, ebx // increment destination ptr
+ //add edi, ebx // increment destination ptr
lea edi, [edi+ebx]
cmp esi, ecx // has src ptr reached end?
@@ -362,7 +362,7 @@ static void Float32_To_Int32_DitherClip(
unsigned long ditherPrevious = ditherGenerator->previous;
unsigned long ditherRandSeed1 = ditherGenerator->randSeed1;
unsigned long ditherRandSeed2 = ditherGenerator->randSeed2;
-
+
__asm{
// esi -> source ptr
// eax -> source byte stride
@@ -380,9 +380,9 @@ static void Float32_To_Int32_DitherClip(
mov ecx, count
imul ecx, eax
add ecx, esi
-
+
mov edi, destinationBuffer
-
+
mov ebx, destinationStride
imul ebx, edx
@@ -412,8 +412,8 @@ static void Float32_To_Int32_DitherClip(
mov sourceByteStride, eax // save eax
mov sourceEnd, ecx // save ecx
push ditherGenerator // pass ditherGenerator parameter on stack
- call PaUtil_GenerateFloatTriangularDither // stack: dither, value*(int scaler), int scaler
- pop edx // clear parameter off stack
+ call PaUtil_GenerateFloatTriangularDither // stack: dither, value*(int scaler), int scaler
+ pop edx // clear parameter off stack
mov ecx, sourceEnd // restore ecx
mov eax, sourceByteStride // restore eax
*/
@@ -435,7 +435,7 @@ static void Float32_To_Int32_DitherClip(
shr edx, PA_DITHER_SHIFT_
mov ditherRandSeed2, eax
shr eax, PA_DITHER_SHIFT_
- //add eax, edx // eax -> current
+ //add eax, edx // eax -> current
lea eax, [eax+edx]
mov edx, ditherPrevious
neg edx
@@ -446,11 +446,11 @@ static void Float32_To_Int32_DitherClip(
fild highpassedDither
fmul const_float_dither_scale_
// end generate dither, dither signal in st(0)
-
+
faddp st(1), st(0) // stack: dither + value*(int scaler), int scaler
fistp dword ptr [edi] // pop st(0) into dest, stack: int scaler
jmp Float32_To_Int32_DitherClip_stored
-
+
Float32_To_Int32_DitherClip_clamp:
mov edx, dword ptr [esi] // load floating point value into integer register
shr edx, 31 // move sign bit into bit 0
@@ -493,7 +493,7 @@ static void Float32_To_Int24(
signed long temp;
(void) ditherGenerator; // unused parameter
-
+
while( count-- )
{
// convert to 32 bit and drop the low 8 bits
@@ -510,11 +510,11 @@ static void Float32_To_Int24(
*/
short savedFpuControlWord;
-
+
signed long tempInt32;
(void) ditherGenerator; /* unused parameter */
-
+
__asm{
// esi -> source ptr
// eax -> source byte stride
@@ -543,7 +543,7 @@ static void Float32_To_Int24(
fstcw savedFpuControlWord
fldcw fpuControlWord_
- fld int24Scaler_ // stack: (int)0x7FFFFF
+ fld int24Scaler_ // stack: (int)0x7FFFFF
Float32_To_Int24_loop:
@@ -561,7 +561,7 @@ static void Float32_To_Int24(
//mov byte ptr [edi+2], DH
mov word ptr [edi+1], DX
- //add edi, ebx // increment destination ptr
+ //add edi, ebx // increment destination ptr
lea edi, [edi+ebx]
cmp esi, ecx // has src ptr reached end?
@@ -589,7 +589,7 @@ static void Float32_To_Int24_Clip(
signed long temp;
(void) ditherGenerator; // unused parameter
-
+
while( count-- )
{
// convert to 32 bit and drop the low 8 bits
@@ -607,11 +607,11 @@ static void Float32_To_Int24_Clip(
*/
short savedFpuControlWord;
-
+
signed long tempInt32;
(void) ditherGenerator; /* unused parameter */
-
+
__asm{
// esi -> source ptr
// eax -> source byte stride
@@ -640,7 +640,7 @@ static void Float32_To_Int24_Clip(
fstcw savedFpuControlWord
fldcw fpuControlWord_
- fld int24Scaler_ // stack: (int)0x7FFFFF
+ fld int24Scaler_ // stack: (int)0x7FFFFF
Float32_To_Int24_Clip_loop:
@@ -659,7 +659,7 @@ static void Float32_To_Int24_Clip(
fistp tempInt32 // pop st(0) into tempInt32, stack: (int)0x7FFFFF
mov edx, tempInt32
jmp Float32_To_Int24_Clip_store
-
+
Float32_To_Int24_Clip_clamp:
mov edx, dword ptr [esi] // load floating point value into integer register
shr edx, 31 // move sign bit into bit 0
@@ -675,7 +675,7 @@ static void Float32_To_Int24_Clip(
//mov byte ptr [edi+2], DH
mov word ptr [edi+1], DX
- //add edi, ebx // increment destination ptr
+ //add edi, ebx // increment destination ptr
lea edi, [edi+ebx]
cmp esi, ecx // has src ptr reached end?
@@ -701,7 +701,7 @@ static void Float32_To_Int24_DitherClip(
float *src = (float*)sourceBuffer;
unsigned char *dest = (unsigned char*)destinationBuffer;
signed long temp;
-
+
while( count-- )
{
// convert to 32 bit and drop the low 8 bits
@@ -711,7 +711,7 @@ static void Float32_To_Int24_DitherClip(
// use smaller scaler to prevent overflow when we add the dither
double dithered = ((double)*src * (2147483646.0)) + dither;
PA_CLIP_( dithered, -2147483648., 2147483647. );
-
+
temp = (signed long) dithered;
dest[0] = (unsigned char)(temp >> 8);
@@ -733,9 +733,9 @@ static void Float32_To_Int24_DitherClip(
unsigned long ditherPrevious = ditherGenerator->previous;
unsigned long ditherRandSeed1 = ditherGenerator->randSeed1;
unsigned long ditherRandSeed2 = ditherGenerator->randSeed2;
-
+
signed long tempInt32;
-
+
__asm{
// esi -> source ptr
// eax -> source byte stride
@@ -786,12 +786,12 @@ static void Float32_To_Int24_DitherClip(
mov sourceByteStride, eax // save eax
mov sourceEnd, ecx // save ecx
push ditherGenerator // pass ditherGenerator parameter on stack
- call PaUtil_GenerateFloatTriangularDither // stack: dither, value*(int scaler), int scaler
- pop edx // clear parameter off stack
+ call PaUtil_GenerateFloatTriangularDither // stack: dither, value*(int scaler), int scaler
+ pop edx // clear parameter off stack
mov ecx, sourceEnd // restore ecx
mov eax, sourceByteStride // restore eax
*/
-
+
// generate dither
mov sourceByteStride, eax // save eax
mov edx, 196314165
@@ -809,7 +809,7 @@ static void Float32_To_Int24_DitherClip(
shr edx, PA_DITHER_SHIFT_
mov ditherRandSeed2, eax
shr eax, PA_DITHER_SHIFT_
- //add eax, edx // eax -> current
+ //add eax, edx // eax -> current
lea eax, [eax+edx]
mov edx, ditherPrevious
neg edx
@@ -825,7 +825,7 @@ static void Float32_To_Int24_DitherClip(
fistp tempInt32 // pop st(0) into tempInt32, stack: int scaler
mov edx, tempInt32
jmp Float32_To_Int24_DitherClip_store
-
+
Float32_To_Int24_DitherClip_clamp:
mov edx, dword ptr [esi] // load floating point value into integer register
shr edx, 31 // move sign bit into bit 0
@@ -841,7 +841,7 @@ static void Float32_To_Int24_DitherClip(
//mov byte ptr [edi+2], DH
mov word ptr [edi+1], DX
- //add edi, ebx // increment destination ptr
+ //add edi, ebx // increment destination ptr
lea edi, [edi+ebx]
cmp esi, ecx // has src ptr reached end?
@@ -884,7 +884,7 @@ static void Float32_To_Int16(
*/
short savedFpuControlWord;
-
+
(void) ditherGenerator; /* unused parameter */
__asm{
@@ -928,7 +928,7 @@ static void Float32_To_Int16(
add edi, ebx // increment destination ptr
//lea edi, [edi+ebx]
-
+
cmp esi, ecx // has src ptr reached end?
jne Float32_To_Int16_loop
@@ -965,7 +965,7 @@ static void Float32_To_Int16_Clip(
*/
short savedFpuControlWord;
-
+
(void) ditherGenerator; /* unused parameter */
__asm{
@@ -1014,7 +1014,7 @@ static void Float32_To_Int16_Clip(
fmul st(0), st(1) // st(0) *= st(1), stack: value*0x7FFF, (int)0x7FFF
fistp word ptr [edi] // store scaled int into dest, stack: (int)0x7FFF
jmp Float32_To_Int16_Clip_stored
-
+
Float32_To_Int16_Clip_clamp:
mov edx, dword ptr [esi] // load floating point value into integer register
shr edx, 31 // move sign bit into bit 0
@@ -1027,7 +1027,7 @@ static void Float32_To_Int16_Clip(
add edi, ebx // increment destination ptr
//lea edi, [edi+ebx]
-
+
cmp esi, ecx // has src ptr reached end?
jne Float32_To_Int16_Clip_loop
@@ -1056,7 +1056,7 @@ static void Float32_To_Int16_DitherClip(
{
float dither = PaUtil_GenerateFloatTriangularDither( ditherGenerator );
- // use smaller scaler to prevent overflow when we add the dither
+ // use smaller scaler to prevent overflow when we add the dither
float dithered = (*src * (32766.0f)) + dither;
signed long samp = (signed long) dithered;
PA_CLIP_( samp, -0x8000, 0x7FFF );
@@ -1128,8 +1128,8 @@ static void Float32_To_Int16_DitherClip(
mov sourceByteStride, eax // save eax
mov sourceEnd, ecx // save ecx
push ditherGenerator // pass ditherGenerator parameter on stack
- call PaUtil_GenerateFloatTriangularDither // stack: dither, value*(int scaler), int scaler
- pop edx // clear parameter off stack
+ call PaUtil_GenerateFloatTriangularDither // stack: dither, value*(int scaler), int scaler
+ pop edx // clear parameter off stack
mov ecx, sourceEnd // restore ecx
mov eax, sourceByteStride // restore eax
*/
@@ -1151,8 +1151,8 @@ static void Float32_To_Int16_DitherClip(
shr edx, PA_DITHER_SHIFT_
mov ditherRandSeed2, eax
shr eax, PA_DITHER_SHIFT_
- //add eax, edx // eax -> current
- lea eax, [eax+edx] // current = randSeed1>>x + randSeed2>>x
+ //add eax, edx // eax -> current
+ lea eax, [eax+edx] // current = randSeed1>>x + randSeed2>>x
mov edx, ditherPrevious
neg edx
lea edx, [eax+edx] // highpass = current - previous
@@ -1162,11 +1162,11 @@ static void Float32_To_Int16_DitherClip(
fild highpassedDither
fmul const_float_dither_scale_
// end generate dither, dither signal in st(0)
-
+
faddp st(1), st(0) // stack: dither * value*(int scaler), int scaler
fistp word ptr [edi] // store scaled int into dest, stack: int scaler
jmp Float32_To_Int16_DitherClip_stored
-
+
Float32_To_Int16_DitherClip_clamp:
mov edx, dword ptr [esi] // load floating point value into integer register
shr edx, 31 // move sign bit into bit 0
@@ -1179,7 +1179,7 @@ static void Float32_To_Int16_DitherClip(
add edi, ebx // increment destination ptr
//lea edi, [edi+ebx]
-
+
cmp esi, ecx // has src ptr reached end?
jne Float32_To_Int16_DitherClip_loop
@@ -1207,7 +1207,7 @@ void PaUtil_InitializeX86PlainConverters( void )
paConverters.Float32_To_Int24 = Float32_To_Int24;
paConverters.Float32_To_Int24_Clip = Float32_To_Int24_Clip;
paConverters.Float32_To_Int24_DitherClip = Float32_To_Int24_DitherClip;
-
+
paConverters.Float32_To_Int16 = Float32_To_Int16;
paConverters.Float32_To_Int16_Clip = Float32_To_Int16_Clip;
paConverters.Float32_To_Int16_DitherClip = Float32_To_Int16_DitherClip;
diff --git a/src/os/win/pa_x86_plain_converters.h b/src/os/win/pa_x86_plain_converters.h
index 1623115..8914ed1 100644
--- a/src/os/win/pa_x86_plain_converters.h
+++ b/src/os/win/pa_x86_plain_converters.h
@@ -23,13 +23,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
From b251bdd7f82e87b3ec2f5eddf9106645a91639ec Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 21 Jan 2021 23:27:43 +1100
Subject: [PATCH 086/157] Clean up whitespace in src/os/unix in preparation for
.editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing
whitespace. Ensure EOL at EOF. (#410)
---
src/os/unix/pa_unix_hostapis.c | 8 ++++----
src/os/unix/pa_unix_util.c | 34 +++++++++++++++++-----------------
src/os/unix/pa_unix_util.h | 6 +++---
3 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/src/os/unix/pa_unix_hostapis.c b/src/os/unix/pa_unix_hostapis.c
index a9b4a05..7f1a51f 100644
--- a/src/os/unix/pa_unix_hostapis.c
+++ b/src/os/unix/pa_unix_hostapis.c
@@ -26,13 +26,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -83,7 +83,7 @@ PaUtilHostApiInitializer *paHostApiInitializers[] =
PaJack_Initialize,
#endif
/* Added for IRIX, Pieter, oct 2, 2003: */
-#if PA_USE_SGI
+#if PA_USE_SGI
PaSGI_Initialize,
#endif
diff --git a/src/os/unix/pa_unix_util.c b/src/os/unix/pa_unix_util.c
index 5472336..a0d592d 100644
--- a/src/os/unix/pa_unix_util.c
+++ b/src/os/unix/pa_unix_util.c
@@ -27,20 +27,20 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
/** @file
@ingroup unix_src
*/
-
+
#include
#include
#include
@@ -129,7 +129,7 @@ void Pa_Sleep( long msec )
/*
Discussion on the CoreAudio mailing list suggests that calling
gettimeofday (or anything else in the BSD layer) is not real-time
- safe, so we use mach_absolute_time on OSX. This implementation is
+ safe, so we use mach_absolute_time on OSX. This implementation is
based on these two links:
Technical Q&A QA1398 - Mach Absolute Time Units
@@ -140,7 +140,7 @@ void Pa_Sleep( long msec )
*/
/* Scaler to convert the result of mach_absolute_time to seconds */
-static double machSecondsConversionScaler_ = 0.0;
+static double machSecondsConversionScaler_ = 0.0;
#endif
void PaUtil_InitializeClock( void )
@@ -193,8 +193,8 @@ PaError PaUtil_CancelThreading( PaUtilThreading *threading, int wait, PaError *e
if( exitResult )
*exitResult = paNoError;
- /* If pthread_cancel is not supported (Android platform) whole this function can lead to indefinite waiting if
- working thread (callbackThread) has'n received any stop signals from outside, please keep
+ /* If pthread_cancel is not supported (Android platform) whole this function can lead to indefinite waiting if
+ working thread (callbackThread) has'n received any stop signals from outside, please keep
this in mind when considering using PaUtil_CancelThreading
*/
#ifdef PTHREAD_CANCELED
@@ -220,7 +220,7 @@ PaError PaUtil_CancelThreading( PaUtilThreading *threading, int wait, PaError *e
}
/* Threading */
-/* paUnixMainThread
+/* paUnixMainThread
* We have to be a bit careful with defining this global variable,
* as explained below. */
#ifdef __APPLE__
@@ -300,7 +300,7 @@ PaError PaUnixThread_New( PaUnixThread* self, void* (*threadFunc)( void* ), void
PA_UNLESS( !pthread_attr_init( &attr ), paInternalError );
/* Priority relative to other processes */
- PA_UNLESS( !pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM ), paInternalError );
+ PA_UNLESS( !pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM ), paInternalError );
PA_UNLESS( !pthread_create( &self->thread, &attr, threadFunc, threadArg ), paInternalError );
started = 1;
@@ -350,7 +350,7 @@ PaError PaUnixThread_New( PaUnixThread* self, void* (*threadFunc)( void* ), void
pthread_getschedparam(self->thread, &policy, &spm);
}
}
-
+
if( self->parentWaiting )
{
PaTime till;
@@ -513,15 +513,15 @@ PaError PaUnixMutex_Terminate( PaUnixMutex* self )
/** Lock mutex.
*
- * We're disabling thread cancellation while the thread is holding a lock, so mutexes are
+ * We're disabling thread cancellation while the thread is holding a lock, so mutexes are
* properly unlocked at termination time.
*/
PaError PaUnixMutex_Lock( PaUnixMutex* self )
{
PaError result = paNoError;
-
+
#ifdef PTHREAD_CANCEL
- int oldState;
+ int oldState;
PA_ENSURE_SYSTEM( pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &oldState ), 0 );
#endif
PA_ENSURE_SYSTEM( pthread_mutex_lock( &self->mtx ), 0 );
@@ -540,7 +540,7 @@ PaError PaUnixMutex_Unlock( PaUnixMutex* self )
PA_ENSURE_SYSTEM( pthread_mutex_unlock( &self->mtx ), 0 );
#ifdef PTHREAD_CANCEL
- int oldState;
+ int oldState;
PA_ENSURE_SYSTEM( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, &oldState ), 0 );
#endif
@@ -595,7 +595,7 @@ static void *WatchdogFunc( void *userData )
while( 1 )
{
double lowpassCoeff = 0.9, lowpassCoeff1 = 0.99999 - lowpassCoeff;
-
+
/* Test before and after in case whatever underlying sleep call isn't interrupted by pthread_cancel */
pthread_testcancel();
Pa_Sleep( intervalMsec );
@@ -680,7 +680,7 @@ error:
/* Pass on error code */
pres = malloc( sizeof (PaError) );
*pres = result;
-
+
pthread_exit( pres );
}
diff --git a/src/os/unix/pa_unix_util.h b/src/os/unix/pa_unix_util.h
index 2a62fe8..2228cb3 100644
--- a/src/os/unix/pa_unix_util.h
+++ b/src/os/unix/pa_unix_util.h
@@ -27,13 +27,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
From f58b69dc36f26914b17d02c0b31ad6d1d6c8e117 Mon Sep 17 00:00:00 2001
From: Ross Bencina
Date: Thu, 21 Jan 2021 23:45:10 +1100
Subject: [PATCH 087/157] Clean up whitespace in test/ in preparation for
.editorconfig. (#417)
* Clean up whitespace in test/ in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF.
---
test/pa_minlat.c | 70 +--
test/patest1.c | 30 +-
test/patest_buffer.c | 24 +-
test/patest_callbackstop.c | 38 +-
test/patest_clip.c | 26 +-
test/patest_converters.c | 32 +-
test/patest_dither.c | 32 +-
test/patest_dsound_find_best_latency_params.c | 66 +--
test/patest_dsound_low_level_latency_params.c | 50 +-
test/patest_dsound_surround.c | 86 ++--
test/patest_hang.c | 32 +-
test/patest_in_overflow.c | 30 +-
test/patest_jack_wasapi.c | 444 +++++++++---------
test/patest_latency.c | 20 +-
test/patest_leftright.c | 70 +--
test/patest_longsine.c | 18 +-
test/patest_many.c | 16 +-
test/patest_maxsines.c | 26 +-
test/patest_mono.c | 20 +-
test/patest_multi_sine.c | 22 +-
test/patest_out_underflow.c | 36 +-
test/patest_prime.c | 30 +-
test/patest_read_record.c | 28 +-
test/patest_ringmix.c | 14 +-
test/patest_sine8.c | 16 +-
test/patest_sine_channelmaps.c | 26 +-
test/patest_sine_formats.c | 12 +-
test/patest_sine_srate.c | 52 +-
test/patest_sine_time.c | 30 +-
test/patest_start_stop.c | 28 +-
test/patest_stop.c | 38 +-
test/patest_stop_playout.c | 50 +-
test/patest_suggested_vs_streaminfo_latency.c | 38 +-
.../patest_suggested_vs_streaminfo_latency.py | 8 +-
test/patest_sync.c | 58 +--
test/patest_timing.c | 26 +-
test/patest_toomanysines.c | 58 +--
test/patest_two_rates.c | 72 +--
test/patest_underflow.c | 18 +-
test/patest_unplug.c | 12 +-
test/patest_wire.c | 32 +-
test/patest_wmme_find_best_latency_params.c | 64 +--
test/patest_wmme_low_level_latency_params.c | 50 +-
test/patest_write_stop.c | 28 +-
test/patest_write_stop_hang_illegal.c | 8 +-
45 files changed, 992 insertions(+), 992 deletions(-)
diff --git a/test/pa_minlat.c b/test/pa_minlat.c
index a91f9e0..683b2bb 100644
--- a/test/pa_minlat.c
+++ b/test/pa_minlat.c
@@ -1,8 +1,8 @@
/** @file pa_minlat.c
- @ingroup test_src
+ @ingroup test_src
@brief Experiment with different numbers of buffers to determine the
- minimum latency for a computer.
- @author Phil Burk http://www.softsynth.com
+ minimum latency for a computer.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -32,13 +32,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -107,7 +107,7 @@ int main( int argc, char **argv )
int framesPerBuffer;
double sampleRate = 44100.0;
char str[256];
- char *line;
+ char *line;
printf("pa_minlat - Determine minimum latency for your computer.\n");
printf(" usage: pa_minlat {userBufferSize}\n");
@@ -136,7 +136,7 @@ int main( int argc, char **argv )
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output. */
outputParameters.suggestedLatency = (double)outLatency / sampleRate; /* In seconds. */
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
printf("Latency = %d frames = %6.1f msec.\n", outLatency, outputParameters.suggestedLatency * 1000.0 );
err = Pa_OpenStream(
@@ -159,33 +159,33 @@ int main( int argc, char **argv )
printf("\nMove windows around to see if the sound glitches.\n");
printf("Latency now %d, enter new number of frames, or 'q' to quit: ", outLatency );
line = fgets( str, 256, stdin );
- if( line == NULL )
- {
- go = 0;
- }
- else
- {
- {
- /* Get rid of newline */
- size_t l = strlen( str ) - 1;
- if( str[ l ] == '\n')
- str[ l ] = '\0';
- }
-
-
- if( str[0] == 'q' ) go = 0;
- else
- {
- outLatency = atol( str );
- if( outLatency < minLatency )
- {
- printf( "Latency below minimum of %d! Set to minimum!!!\n", minLatency );
- outLatency = minLatency;
- }
- }
-
- }
- /* Stop sound until ENTER hit. */
+ if( line == NULL )
+ {
+ go = 0;
+ }
+ else
+ {
+ {
+ /* Get rid of newline */
+ size_t l = strlen( str ) - 1;
+ if( str[ l ] == '\n')
+ str[ l ] = '\0';
+ }
+
+
+ if( str[0] == 'q' ) go = 0;
+ else
+ {
+ outLatency = atol( str );
+ if( outLatency < minLatency )
+ {
+ printf( "Latency below minimum of %d! Set to minimum!!!\n", minLatency );
+ outLatency = minLatency;
+ }
+ }
+
+ }
+ /* Stop sound until ENTER hit. */
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
err = Pa_CloseStream( stream );
diff --git a/test/patest1.c b/test/patest1.c
index 2ad9c38..110deef 100644
--- a/test/patest1.c
+++ b/test/patest1.c
@@ -1,7 +1,7 @@
/** @file patest1.c
- @ingroup test_src
- @brief Ring modulate the audio input with a sine wave for 20 seconds.
- @author Ross Bencina
+ @ingroup test_src
+ @brief Ring modulate the audio input with a sine wave for 20 seconds.
+ @author Ross Bencina
*/
/*
* $Id$
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -98,7 +98,7 @@ static int patest1Callback( const void *inputBuffer, void *outputBuffer,
*out++ = 0; /* left */
*out++ = 0; /* right */
}
-
+
return finished;
}
@@ -114,7 +114,7 @@ int main(int argc, char* argv[])
printf("patest1.c\n"); fflush(stdout);
printf("Ring modulate input for 20 seconds.\n"); fflush(stdout);
-
+
/* initialise sinusoidal wavetable */
for( i=0; i<100; i++ )
data.sine[i] = sin( ((double)i/100.) * M_PI * 2. );
@@ -126,8 +126,8 @@ int main(int argc, char* argv[])
inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
if (inputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No input default device.\n");
- goto done;
+ printf(stderr,"Error: No input default device.\n");
+ goto done;
}
inputParameters.channelCount = 2; /* stereo input */
inputParameters.sampleFormat = paFloat32; /* 32 bit floating point input */
@@ -136,8 +136,8 @@ int main(int argc, char* argv[])
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto done;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto done;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
@@ -157,14 +157,14 @@ int main(int argc, char* argv[])
err = Pa_StartStream( stream );
if( err != paNoError ) goto done;
-
+
printf( "Press any key to end.\n" ); fflush(stdout);
-
+
getc( stdin ); /* wait for input before exiting */
err = Pa_AbortStream( stream );
if( err != paNoError ) goto done;
-
+
printf( "Waiting for stream to complete...\n" );
/* sleep until playback has finished */
diff --git a/test/patest_buffer.c b/test/patest_buffer.c
index 090b529..d19e121 100644
--- a/test/patest_buffer.c
+++ b/test/patest_buffer.c
@@ -1,7 +1,7 @@
/** @file patest_buffer.c
- @ingroup test_src
- @brief Test opening streams with different buffer sizes.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Test opening streams with different buffer sizes.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -128,10 +128,10 @@ int main(int argc, char **args)
PaError err;
printf("Test opening streams with different buffer sizes\n");
if( argc > 1 ) {
- device=atoi( args[1] );
- printf("Using device number %d.\n\n", device );
+ device=atoi( args[1] );
+ printf("Using device number %d.\n\n", device );
} else {
- printf("Using default device.\n\n" );
+ printf("Using default device.\n\n" );
}
for (i = 0 ; i < BUFFER_TABLE; i++)
@@ -162,15 +162,15 @@ PaError TestOnce( int buffersize, PaDeviceIndex device )
data.sampsToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
if( device == -1 )
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
else
outputParameters.device = device ;
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
diff --git a/test/patest_callbackstop.c b/test/patest_callbackstop.c
index aa7f7fd..fba9dca 100644
--- a/test/patest_callbackstop.c
+++ b/test/patest_callbackstop.c
@@ -1,7 +1,7 @@
/** @file patest_callbackstop.c
- @ingroup test_src
- @brief Test the paComplete callback result code.
- @author Ross Bencina
+ @ingroup test_src
+ @brief Test the paComplete callback result code.
+ @author Ross Bencina
*/
/*
* $Id$
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -86,18 +86,18 @@ static int TestCallback( const void *input, void *output,
(void) timeInfo;
(void) statusFlags;
-
+
if( data->callbackReturnedPaComplete )
data->callbackInvokedAfterReturningPaComplete = 1;
for( i=0; isine[ data->phase++ ];
if( data->phase >= TABLE_SIZE )
data->phase -= TABLE_SIZE;
-
+
*out++ = x; /* left */
*out++ = x; /* right */
}
@@ -119,8 +119,8 @@ static int TestCallback( const void *input, void *output,
*/
static void StreamFinished( void* userData )
{
- TestData *data = (TestData *) userData;
- printf( "Stream Completed: %s\n", data->message );
+ TestData *data = (TestData *) userData;
+ printf( "Stream Completed: %s\n", data->message );
}
@@ -134,23 +134,23 @@ int main(void)
TestData data;
int i, j;
-
+
printf( "PortAudio Test: output sine wave. SR = %d, BufSize = %d\n",
SAMPLE_RATE, FRAMES_PER_BUFFER );
-
+
/* initialise sinusoidal wavetable */
for( i=0; ileft_phase = data->right_phase = 0;
data->amplitude = amplitude;
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
err = Pa_OpenStream(
&stream,
NULL, /* no input */
@@ -182,7 +182,7 @@ PaError PlaySine( paTestData *data, unsigned long flags, float amplitude )
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
return paNoError;
error:
diff --git a/test/patest_converters.c b/test/patest_converters.c
index 1474a71..f76738c 100644
--- a/test/patest_converters.c
+++ b/test/patest_converters.c
@@ -1,7 +1,7 @@
/** @file patest_converters.c
- @ingroup test_src
- @brief Tests the converter functions in pa_converters.c
- @author Ross Bencina
+ @ingroup test_src
+ @brief Tests the converter functions in pa_converters.c
+ @author Ross Bencina
Link with pa_dither.c and pa_converters.c
@@ -35,13 +35,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include
@@ -65,14 +65,14 @@
#define SAMPLE_FORMAT_COUNT (6)
-static PaSampleFormat sampleFormats_[ SAMPLE_FORMAT_COUNT ] =
+static PaSampleFormat sampleFormats_[ SAMPLE_FORMAT_COUNT ] =
{ paFloat32, paInt32, paInt24, paInt16, paInt8, paUInt8 }; /* all standard PA sample formats */
-static const char* sampleFormatNames_[SAMPLE_FORMAT_COUNT] =
+static const char* sampleFormatNames_[SAMPLE_FORMAT_COUNT] =
{ "paFloat32", "paInt32", "paInt24", "paInt16", "paInt8", "paUInt8" };
-static const char* abbreviatedSampleFormatNames_[SAMPLE_FORMAT_COUNT] =
+static const char* abbreviatedSampleFormatNames_[SAMPLE_FORMAT_COUNT] =
{ "f32", "i32", "i24", "i16", " i8", "ui8" };
@@ -140,7 +140,7 @@ static void GenerateOneCycleSine( PaSampleFormat format, void *buffer, int frame
unsigned char *out = (unsigned char*)buffer;
for( i=0; i < frameCount; ++i ){
signed long temp = (PaInt32)(.9 * sin( ((double)i/(double)frameCount) * 2. * M_PI ) * 0x7FFFFFFF);
-
+
#if defined(PA_LITTLE_ENDIAN)
out[0] = (unsigned char)(temp >> 8) & 0xFF;
out[1] = (unsigned char)(temp >> 16) & 0xFF;
@@ -193,11 +193,11 @@ int TestNonZeroPresent( void *buffer, int size )
int i;
for( i=0; i < size; ++i ){
-
+
if( *p != 0 )
return 1;
++p;
- }
+ }
return 0;
}
@@ -213,7 +213,7 @@ float MaximumAbsDifference( float* sourceBuffer, float* referenceBuffer, int cou
}
return result;
-}
+}
int main( const char **argv, int argc )
{
@@ -286,7 +286,7 @@ int main( const char **argv, int argc )
passFailMatrix[sourceFormatIndex][destinationFormatIndex] = 0;
}
-
+
/* try to measure the noise floor (comparing output signal to a float32 sine wave) */
if( passFailMatrix[sourceFormatIndex][destinationFormatIndex] ){
@@ -298,9 +298,9 @@ int main( const char **argv, int argc )
(*converter)( sourceBuffer, 1, destinationBuffer, 1, MAX_PER_CHANNEL_FRAME_COUNT, &ditherState );
if( TestNonZeroPresent( sourceBuffer, MAX_PER_CHANNEL_FRAME_COUNT * My_Pa_GetSampleSize( paFloat32 ) ) ){
-
+
noiseAmplitudeMatrix[sourceFormatIndex][destinationFormatIndex] = MaximumAbsDifference( (float*)sourceBuffer, (float*)referenceBuffer, MAX_PER_CHANNEL_FRAME_COUNT );
-
+
}else{
/* can't test noise floor because there is no conversion from dest format to float available */
noiseAmplitudeMatrix[sourceFormatIndex][destinationFormatIndex] = -1; // mark as failed
diff --git a/test/patest_dither.c b/test/patest_dither.c
index 5f471b1..fc402dc 100644
--- a/test/patest_dither.c
+++ b/test/patest_dither.c
@@ -1,10 +1,10 @@
/** @file patest_dither.c
- @ingroup test_src
- @brief Attempt to hear difference between dithered and non-dithered signal.
+ @ingroup test_src
+ @brief Attempt to hear difference between dithered and non-dithered signal.
- This only has an effect if the native format is 16 bit.
+ This only has an effect if the native format is 16 bit.
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -34,13 +34,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -64,22 +64,22 @@ typedef struct paTestData
int right_phase;
}
paTestData;
-
+
/* This routine will be called by the PortAudio engine when audio is needed.
** It may called at interrupt level on some machines so don't do anything
** that could mess up the system like calling malloc() or free().
*/
static int sineCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo *timeInfo,
- PaStreamCallbackFlags statusFlags, void *userData )
+ const PaStreamCallbackTimeInfo *timeInfo,
+ PaStreamCallbackFlags statusFlags, void *userData )
{
paTestData *data = (paTestData*)userData;
float *out = (float*)outputBuffer;
float amplitude = data->amplitude;
unsigned int i;
(void) inputBuffer;
-
+
for( i=0; isine[data->left_phase]; /* left */
@@ -113,14 +113,14 @@ PaError PlaySine( paTestData *data, PaStreamFlags flags, float amplitude )
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto done;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto done;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.hostApiSpecificStreamInfo = NULL;
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output. */
/* When you change this, also */
- /* adapt the callback routine! */
+ /* adapt the callback routine! */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )
->defaultLowOutputLatency; /* Low latency. */
err = Pa_OpenStream( &stream,
@@ -140,7 +140,7 @@ PaError PlaySine( paTestData *data, PaStreamFlags flags, float amplitude )
Pa_Sleep( NUM_SECONDS * 1000 );
printf("CPULoad = %8.6f\n", Pa_GetStreamCpuLoad(stream));
-
+
err = Pa_CloseStream( stream );
done:
Pa_Sleep( 250 ); /* Just a small silence. */
@@ -157,7 +157,7 @@ int main(void)
paTestData DATA;
int i;
float amplitude = 4.0 / (1<<15);
-
+
printf("PortAudio Test: output EXTREMELY QUIET sine wave with and without dithering.\n");
/* initialise sinusoidal wavetable */
for( i=0; i
#include
-#define _WIN32_WINNT 0x0501 /* for GetNativeSystemInfo */
+#define _WIN32_WINNT 0x0501 /* for GetNativeSystemInfo */
#include
//#include /* required when using pa_win_wmme.h */
@@ -102,11 +102,11 @@ static void printWindowsVersionInfo( FILE *fp )
osVersionInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx( &osVersionInfoEx );
-
+
if( osVersionInfoEx.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ){
switch( osVersionInfoEx.dwMinorVersion ){
case 0: osName = "Windows 95"; break;
- case 10: osName = "Windows 98"; break; // could also be 98SE (I've seen code discriminate based
+ case 10: osName = "Windows 98"; break; // could also be 98SE (I've seen code discriminate based
// on osInfo.Version.Revision.ToString() == "2222A")
case 90: osName = "Windows Me"; break;
}
@@ -132,13 +132,13 @@ static void printWindowsVersionInfo( FILE *fp )
}break;
}break;
case 6:switch( osVersionInfoEx.dwMinorVersion ){
- case 0:
+ case 0:
if( osVersionInfoEx.wProductType == VER_NT_WORKSTATION )
osName = "Windows Vista";
else
osName = "Windows Server 2008";
break;
- case 1:
+ case 1:
if( osVersionInfoEx.wProductType == VER_NT_WORKSTATION )
osName = "Windows 7";
else
@@ -166,7 +166,7 @@ static void printWindowsVersionInfo( FILE *fp )
}
else if(osVersionInfoEx.wProductType == VER_NT_SERVER)
{
- if(osVersionInfoEx.dwMinorVersion == 0)
+ if(osVersionInfoEx.dwMinorVersion == 0)
{
if((osVersionInfoEx.wSuiteMask & VER_SUITE_DATACENTER) == VER_SUITE_DATACENTER)
osProductType = "Datacenter Server"; // Windows 2000 Datacenter Server
@@ -201,8 +201,8 @@ static void printWindowsVersionInfo( FILE *fp )
fprintf( fp, "OS name and edition: %s %s\n", osName, osProductType );
- fprintf( fp, "OS version: %d.%d.%d %S\n",
- osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion,
+ fprintf( fp, "OS version: %d.%d.%d %S\n",
+ osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion,
osVersionInfoEx.dwBuildNumber, osVersionInfoEx.szCSDVersion );
fprintf( fp, "Processor architecture: %s\n", processorArchitecture );
fprintf( fp, "WoW64 process: %s\n", IsWow64() ? "Yes" : "No" );
@@ -225,7 +225,7 @@ static void printTimeAndDate( FILE *fp )
typedef struct
{
float sine[TABLE_SIZE];
- double phase;
+ double phase;
double phaseIncrement;
volatile int fadeIn;
volatile int fadeOut;
@@ -252,14 +252,14 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; isine[(int)data->phase];
data->phase += data->phaseIncrement;
if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
+ data->phase -= TABLE_SIZE;
+ }
x *= data->amp;
if( data->fadeIn ){
@@ -271,11 +271,11 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
data->amp -= .001;
}
- for( j = 0; j < CHANNEL_COUNT; ++j ){
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
*out++ = x;
- }
- }
-
+ }
+ }
+
if( data->amp > 0 )
return paContinue;
else
@@ -287,7 +287,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
#define NO 0
-static int playUntilKeyPress( int deviceIndex, float sampleRate,
+static int playUntilKeyPress( int deviceIndex, float sampleRate,
int framesPerUserBuffer, int framesPerDSoundBuffer )
{
PaStreamParameters outputParameters;
@@ -303,7 +303,7 @@ static int playUntilKeyPress( int deviceIndex, float sampleRate,
outputParameters.hostApiSpecificStreamInfo = NULL;
directSoundStreamInfo.size = sizeof(PaWinDirectSoundStreamInfo);
- directSoundStreamInfo.hostApiType = paDirectSound;
+ directSoundStreamInfo.hostApiType = paDirectSound;
directSoundStreamInfo.version = 2;
directSoundStreamInfo.flags = paWinDirectSoundUseLowLevelLatencyParameters;
directSoundStreamInfo.framesPerBuffer = framesPerDSoundBuffer;
@@ -373,7 +373,7 @@ static void usage( int dsoundHostApiIndex )
}
/*
- ideas:
+ ideas:
o- could be testing with 80% CPU load
o- could test with different channel counts
*/
@@ -401,15 +401,15 @@ int main(int argc, char* argv[])
if( argc > 3 )
usage(dsoundHostApiIndex);
- deviceIndex = dsoundHostApiInfo->defaultOutputDevice;
- if( argc >= 2 ){
+ deviceIndex = dsoundHostApiInfo->defaultOutputDevice;
+ if( argc >= 2 ){
deviceIndex = -1;
- if( sscanf( argv[1], "%d", &deviceIndex ) != 1 )
+ if( sscanf( argv[1], "%d", &deviceIndex ) != 1 )
usage(dsoundHostApiInfo);
if( deviceIndex < 0 || deviceIndex >= Pa_GetDeviceCount() || Pa_GetDeviceInfo(deviceIndex)->hostApi != dsoundHostApiIndex ){
usage(dsoundHostApiInfo);
}
- }
+ }
printf( "Using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
@@ -420,7 +420,7 @@ int main(int argc, char* argv[])
printf( "Testing with sample rate %f.\n", (float)sampleRate );
-
+
/* initialise sinusoidal wavetable */
for( i=0; iname );
fflush( resultsFp );
@@ -463,7 +463,7 @@ int main(int argc, char* argv[])
}else{
min = mid + 1;
}
-
+
}while( (min <= max) && (testResult == YES || testResult == NO) );
smallestWorkingBufferingLatencyFrames = smallestWorkingBufferSize; /* not strictly true, but we're using an unspecified callback size, so kind of */
@@ -490,7 +490,7 @@ int main(int argc, char* argv[])
}
}while( (dsoundBufferSize <= (int)(sampleRate * .3)) && testResult == NO );
-
+
smallestWorkingBufferingLatencyFrames = smallestWorkingBufferSize; /* not strictly true, but we're using an unspecified callback size, so kind of */
fprintf( resultsFp, "%d, %d, %f\n", smallestWorkingBufferSize, smallestWorkingBufferingLatencyFrames, smallestWorkingBufferingLatencyFrames / sampleRate );
@@ -499,10 +499,10 @@ int main(int argc, char* argv[])
fprintf( resultsFp, "###\n" );
fclose( resultsFp );
-
+
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
diff --git a/test/patest_dsound_low_level_latency_params.c b/test/patest_dsound_low_level_latency_params.c
index 59734e2..85667a7 100644
--- a/test/patest_dsound_low_level_latency_params.c
+++ b/test/patest_dsound_low_level_latency_params.c
@@ -26,13 +26,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -61,7 +61,7 @@
typedef struct
{
float sine[TABLE_SIZE];
- double phase;
+ double phase;
}
paTestData;
@@ -82,20 +82,20 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; isine[(int)data->phase];
data->phase += 20;
if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
+ data->phase -= TABLE_SIZE;
+ }
- for( j = 0; j < CHANNEL_COUNT; ++j ){
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
*out++ = x;
- }
- }
-
+ }
+ }
+
return paContinue;
}
@@ -115,12 +115,12 @@ int main(int argc, char* argv[])
err = Pa_Initialize();
if( err != paNoError ) goto error;
- deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paDirectSound ) )->defaultOutputDevice;
- if( argc == 2 ){
- sscanf( argv[1], "%d", &deviceIndex );
- }
+ deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paDirectSound ) )->defaultOutputDevice;
+ if( argc == 2 ){
+ sscanf( argv[1], "%d", &deviceIndex );
+ }
- printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
+ printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
/* initialise sinusoidal wavetable */
for( i=0; icurrentChannel && data->cycleCount < 4410 ){
- *out++ = data->sine[data->phase];
- data->phase += 1 + j; // play each channel at a different pitch so they can be distinguished
- if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
- }else{
- *out++ = 0;
- }
- }
-
- data->cycleCount++;
- if( data->cycleCount > 44100 ){
- data->cycleCount = 0;
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
+ if( j == data->currentChannel && data->cycleCount < 4410 ){
+ *out++ = data->sine[data->phase];
+ data->phase += 1 + j; // play each channel at a different pitch so they can be distinguished
+ if( data->phase >= TABLE_SIZE ){
+ data->phase -= TABLE_SIZE;
+ }
+ }else{
+ *out++ = 0;
+ }
+ }
+
+ data->cycleCount++;
+ if( data->cycleCount > 44100 ){
+ data->cycleCount = 0;
+
+ ++data->currentChannel;
+ if( data->currentChannel >= CHANNEL_COUNT )
+ data->currentChannel -= CHANNEL_COUNT;
+ }
+ }
- ++data->currentChannel;
- if( data->currentChannel >= CHANNEL_COUNT )
- data->currentChannel -= CHANNEL_COUNT;
- }
- }
-
return paContinue;
}
@@ -129,12 +129,12 @@ int main(int argc, char* argv[])
err = Pa_Initialize();
if( err != paNoError ) goto error;
- deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paDirectSound ) )->defaultOutputDevice;
- if( argc == 2 ){
- sscanf( argv[1], "%d", &deviceIndex );
- }
+ deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paDirectSound ) )->defaultOutputDevice;
+ if( argc == 2 ){
+ sscanf( argv[1], "%d", &deviceIndex );
+ }
- printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
+ printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
/* initialise sinusoidal wavetable */
for( i=0; i
- @author Phil Burk
+ @ingroup test_src
+ @brief Play a sine then hang audio callback to test watchdog.
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
@@ -32,13 +32,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -77,7 +77,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
int finished = 0;
double phaseInc = 0.02;
double phase = data->phase;
-
+
(void) inputBuffer; /* Prevent unused argument warning. */
for( i=0; isleepFor > 0 )
{
Pa_Sleep( data->sleepFor );
}
-
+
data->phase = phase;
return finished;
}
@@ -106,7 +106,7 @@ int main(void)
PaError err;
int i;
paTestData data = {0};
-
+
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n",
SAMPLE_RATE, FRAMES_PER_BUFFER );
@@ -115,8 +115,8 @@ int main(void)
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 1; /* Mono output. */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point. */
@@ -132,7 +132,7 @@ int main(void)
patestCallback,
&data);
if (err != paNoError) goto error;
-
+
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
@@ -144,10 +144,10 @@ int main(void)
data.sleepFor = i;
Pa_Sleep( ((i<1000) ? 1000 : i) );
}
-
+
printf("Suffer for 10 seconds.\n");
Pa_Sleep( 10000 );
-
+
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
err = Pa_CloseStream( stream );
diff --git a/test/patest_in_overflow.c b/test/patest_in_overflow.c
index 5ce50d3..31868bd 100644
--- a/test/patest_in_overflow.c
+++ b/test/patest_in_overflow.c
@@ -1,14 +1,14 @@
/** @file patest_in_overflow.c
- @ingroup test_src
- @brief Count input overflows (using paInputOverflow flag) under
- overloaded and normal conditions.
+ @ingroup test_src
+ @brief Count input overflows (using paInputOverflow flag) under
+ overloaded and normal conditions.
This test uses the same method to overload the stream as does
patest_out_underflow.c -- it generates sine waves until the cpu load
exceeds a certain level. However this test is only concerned with
input and so doesn't output any sound.
-
+
@author Ross Bencina
- @author Phil Burk
+ @author Phil Burk
*/
/*
* $Id$
@@ -38,13 +38,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -141,8 +141,8 @@ int main(void)
inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
if (inputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default input device.\n");
- goto error;
+ fprintf(stderr,"Error: No default input device.\n");
+ goto error;
}
inputParameters.channelCount = 1; /* mono output */
inputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
@@ -157,7 +157,7 @@ int main(void)
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
- &data );
+ &data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
@@ -187,7 +187,7 @@ int main(void)
load = Pa_GetStreamCpuLoad( stream );
printf("STRESSING: sineCount = %d, CPU load = %f\n", data.sineCount, load );
}
-
+
printf("Counting overflows for 5 seconds.\n");
data.countOverflows = 1;
Pa_Sleep( 5000 );
@@ -209,14 +209,14 @@ int main(void)
Pa_Sleep( 5000 );
safeOverflowCount = data.inputOverflowCount;
-
+
printf("Stop stream.\n");
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
if( stressedOverflowCount == 0 )
diff --git a/test/patest_jack_wasapi.c b/test/patest_jack_wasapi.c
index 6175f88..bd79881 100644
--- a/test/patest_jack_wasapi.c
+++ b/test/patest_jack_wasapi.c
@@ -1,7 +1,7 @@
/** @file pa_test_jack_wasapi.c
- @ingroup test_src
- @brief Print out jack information for WASAPI endpoints
- @author Reid Bishop
+ @ingroup test_src
+ @brief Print out jack information for WASAPI endpoints
+ @author Reid Bishop
*/
/*
* $Id: pa_test_jack_wasapi.c 1368 2008-03-01 00:38:27Z rbishop $
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include
@@ -51,7 +51,7 @@
*/
static int IsInMask(int val, int val2)
{
- return ((val & val2) == val2);
+ return ((val & val2) == val2);
}
/*
@@ -60,50 +60,50 @@ static int IsInMask(int val, int val2)
static void EnumIJackChannels(int channelMapping)
{
- printf("Channel Mapping: ");
- if(channelMapping == PAWIN_SPEAKER_DIRECTOUT)
- {
- printf("DIRECTOUT\n");
- return;
- }
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT))
- printf("FRONT_LEFT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT))
- printf("FRONT_RIGHT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_CENTER))
- printf("FRONT_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_LOW_FREQUENCY))
- printf("LOW_FREQUENCY, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_LEFT))
- printf("BACK_LEFT, ");
- if(IsInMask(channelMapping,PAWIN_SPEAKER_BACK_RIGHT))
- printf("BACK_RIGHT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER))
- printf("FRONT_LEFT_OF_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER))
- printf("FRONT_RIGHT_OF_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_CENTER))
- printf("BACK_CENTER, ");
- if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_LEFT))
- printf("SIDE_LEFT, ");
- if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_RIGHT))
- printf("SIDE_RIGHT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_CENTER))
- printf("TOP_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_LEFT))
- printf("TOP_FRONT_LEFT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_CENTER))
- printf("TOP_FRONT_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_RIGHT))
- printf("TOP_FRONT_RIGHT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_LEFT))
- printf("TOP_BACK_LEFT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_CENTER))
- printf("TOP_BACK_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_RIGHT))
- printf("TOP_BACK_RIGHT, ");
+ printf("Channel Mapping: ");
+ if(channelMapping == PAWIN_SPEAKER_DIRECTOUT)
+ {
+ printf("DIRECTOUT\n");
+ return;
+ }
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT))
+ printf("FRONT_LEFT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT))
+ printf("FRONT_RIGHT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_CENTER))
+ printf("FRONT_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_LOW_FREQUENCY))
+ printf("LOW_FREQUENCY, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_LEFT))
+ printf("BACK_LEFT, ");
+ if(IsInMask(channelMapping,PAWIN_SPEAKER_BACK_RIGHT))
+ printf("BACK_RIGHT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER))
+ printf("FRONT_LEFT_OF_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER))
+ printf("FRONT_RIGHT_OF_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_CENTER))
+ printf("BACK_CENTER, ");
+ if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_LEFT))
+ printf("SIDE_LEFT, ");
+ if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_RIGHT))
+ printf("SIDE_RIGHT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_CENTER))
+ printf("TOP_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_LEFT))
+ printf("TOP_FRONT_LEFT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_CENTER))
+ printf("TOP_FRONT_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_RIGHT))
+ printf("TOP_FRONT_RIGHT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_LEFT))
+ printf("TOP_BACK_LEFT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_CENTER))
+ printf("TOP_BACK_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_RIGHT))
+ printf("TOP_BACK_RIGHT, ");
- printf("\n");
+ printf("\n");
}
/*
@@ -111,47 +111,47 @@ static void EnumIJackChannels(int channelMapping)
*/
static void EnumIJackConnectionType(int cType)
{
- printf("Connection Type: ");
- switch(cType)
- {
- case eJackConnTypeUnknown:
- printf("eJackConnTypeUnknown");
- break;
- case eJackConnType3Point5mm:
- printf("eJackConnType3Point5mm");
- break;
- case eJackConnTypeQuarter:
- printf("eJackConnTypeQuarter");
- break;
- case eJackConnTypeAtapiInternal:
- printf("eJackConnTypeAtapiInternal");
- break;
- case eJackConnTypeRCA:
- printf("eJackConnTypeRCA");
- break;
- case eJackConnTypeOptical:
- printf("eJackConnTypeOptical");
- break;
- case eJackConnTypeOtherDigital:
- printf("eJackConnTypeOtherDigital");
- break;
- case eJackConnTypeOtherAnalog:
- printf("eJackConnTypeOtherAnalog");
- break;
- case eJackConnTypeMultichannelAnalogDIN:
- printf("eJackConnTypeMultichannelAnalogDIN");
- break;
- case eJackConnTypeXlrProfessional:
- printf("eJackConnTypeXlrProfessional");
- break;
- case eJackConnTypeRJ11Modem:
- printf("eJackConnTypeRJ11Modem");
- break;
- case eJackConnTypeCombination:
- printf("eJackConnTypeCombination");
- break;
- }
- printf("\n");
+ printf("Connection Type: ");
+ switch(cType)
+ {
+ case eJackConnTypeUnknown:
+ printf("eJackConnTypeUnknown");
+ break;
+ case eJackConnType3Point5mm:
+ printf("eJackConnType3Point5mm");
+ break;
+ case eJackConnTypeQuarter:
+ printf("eJackConnTypeQuarter");
+ break;
+ case eJackConnTypeAtapiInternal:
+ printf("eJackConnTypeAtapiInternal");
+ break;
+ case eJackConnTypeRCA:
+ printf("eJackConnTypeRCA");
+ break;
+ case eJackConnTypeOptical:
+ printf("eJackConnTypeOptical");
+ break;
+ case eJackConnTypeOtherDigital:
+ printf("eJackConnTypeOtherDigital");
+ break;
+ case eJackConnTypeOtherAnalog:
+ printf("eJackConnTypeOtherAnalog");
+ break;
+ case eJackConnTypeMultichannelAnalogDIN:
+ printf("eJackConnTypeMultichannelAnalogDIN");
+ break;
+ case eJackConnTypeXlrProfessional:
+ printf("eJackConnTypeXlrProfessional");
+ break;
+ case eJackConnTypeRJ11Modem:
+ printf("eJackConnTypeRJ11Modem");
+ break;
+ case eJackConnTypeCombination:
+ printf("eJackConnTypeCombination");
+ break;
+ }
+ printf("\n");
}
/*
@@ -159,50 +159,50 @@ static void EnumIJackConnectionType(int cType)
*/
static void EnumIJackGeoLocation(int iVal)
{
- printf("Geometric Location: ");
- switch(iVal)
- {
- case eJackGeoLocRear:
- printf("eJackGeoLocRear");
- break;
- case eJackGeoLocFront:
- printf("eJackGeoLocFront");
- break;
- case eJackGeoLocLeft:
- printf("eJackGeoLocLeft");
- break;
- case eJackGeoLocRight:
- printf("eJackGeoLocRight");
- break;
- case eJackGeoLocTop:
- printf("eJackGeoLocTop");
- break;
- case eJackGeoLocBottom:
- printf("eJackGeoLocBottom");
- break;
- case eJackGeoLocRearPanel:
- printf("eJackGeoLocRearPanel");
- break;
- case eJackGeoLocRiser:
- printf("eJackGeoLocRiser");
- break;
- case eJackGeoLocInsideMobileLid:
- printf("eJackGeoLocInsideMobileLid");
- break;
- case eJackGeoLocDrivebay:
- printf("eJackGeoLocDrivebay");
- break;
- case eJackGeoLocHDMI:
- printf("eJackGeoLocHDMI");
- break;
- case eJackGeoLocOutsideMobileLid:
- printf("eJackGeoLocOutsideMobileLid");
- break;
- case eJackGeoLocATAPI:
- printf("eJackGeoLocATAPI");
- break;
- }
- printf("\n");
+ printf("Geometric Location: ");
+ switch(iVal)
+ {
+ case eJackGeoLocRear:
+ printf("eJackGeoLocRear");
+ break;
+ case eJackGeoLocFront:
+ printf("eJackGeoLocFront");
+ break;
+ case eJackGeoLocLeft:
+ printf("eJackGeoLocLeft");
+ break;
+ case eJackGeoLocRight:
+ printf("eJackGeoLocRight");
+ break;
+ case eJackGeoLocTop:
+ printf("eJackGeoLocTop");
+ break;
+ case eJackGeoLocBottom:
+ printf("eJackGeoLocBottom");
+ break;
+ case eJackGeoLocRearPanel:
+ printf("eJackGeoLocRearPanel");
+ break;
+ case eJackGeoLocRiser:
+ printf("eJackGeoLocRiser");
+ break;
+ case eJackGeoLocInsideMobileLid:
+ printf("eJackGeoLocInsideMobileLid");
+ break;
+ case eJackGeoLocDrivebay:
+ printf("eJackGeoLocDrivebay");
+ break;
+ case eJackGeoLocHDMI:
+ printf("eJackGeoLocHDMI");
+ break;
+ case eJackGeoLocOutsideMobileLid:
+ printf("eJackGeoLocOutsideMobileLid");
+ break;
+ case eJackGeoLocATAPI:
+ printf("eJackGeoLocATAPI");
+ break;
+ }
+ printf("\n");
}
/*
@@ -210,23 +210,23 @@ static void EnumIJackGeoLocation(int iVal)
*/
static void EnumIJackGenLocation(int iVal)
{
- printf("General Location: ");
- switch(iVal)
- {
- case eJackGenLocPrimaryBox:
- printf("eJackGenLocPrimaryBox");
- break;
- case eJackGenLocInternal:
- printf("eJackGenLocInternal");
- break;
- case eJackGenLocSeparate:
- printf("eJackGenLocSeparate");
- break;
- case eJackGenLocOther:
- printf("eJackGenLocOther");
- break;
- }
- printf("\n");
+ printf("General Location: ");
+ switch(iVal)
+ {
+ case eJackGenLocPrimaryBox:
+ printf("eJackGenLocPrimaryBox");
+ break;
+ case eJackGenLocInternal:
+ printf("eJackGenLocInternal");
+ break;
+ case eJackGenLocSeparate:
+ printf("eJackGenLocSeparate");
+ break;
+ case eJackGenLocOther:
+ printf("eJackGenLocOther");
+ break;
+ }
+ printf("\n");
}
/*
@@ -234,23 +234,23 @@ static void EnumIJackGenLocation(int iVal)
*/
static void EnumIJackPortConnection(int iVal)
{
- printf("Port Type: ");
- switch(iVal)
- {
- case eJackPortConnJack:
- printf("eJackPortConnJack");
- break;
- case eJackPortConnIntegratedDevice:
- printf("eJackPortConnIntegratedDevice");
- break;
- case eJackPortConnBothIntegratedAndJack:
- printf("eJackPortConnBothIntegratedAndJack");
- break;
- case eJackPortConnUnknown:
- printf("eJackPortConnUnknown");
- break;
- }
- printf("\n");
+ printf("Port Type: ");
+ switch(iVal)
+ {
+ case eJackPortConnJack:
+ printf("eJackPortConnJack");
+ break;
+ case eJackPortConnIntegratedDevice:
+ printf("eJackPortConnIntegratedDevice");
+ break;
+ case eJackPortConnBothIntegratedAndJack:
+ printf("eJackPortConnBothIntegratedAndJack");
+ break;
+ case eJackPortConnUnknown:
+ printf("eJackPortConnUnknown");
+ break;
+ }
+ printf("\n");
}
/*
@@ -260,38 +260,38 @@ static void EnumIJackPortConnection(int iVal)
static PaError GetJackInformation(int deviceId)
{
PaError err;
- int i;
- int jackCount = 0;
- PaWasapiJackDescription jackDesc;
+ int i;
+ int jackCount = 0;
+ PaWasapiJackDescription jackDesc;
- err = PaWasapi_GetJackCount(deviceId, &jackCount);
- if( err != paNoError ) return err;
+ err = PaWasapi_GetJackCount(deviceId, &jackCount);
+ if( err != paNoError ) return err;
- fprintf( stderr,"Number of Jacks: %d \n", jackCount );
+ fprintf( stderr,"Number of Jacks: %d \n", jackCount );
- for( i = 0; ihostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI) )
- {
- if( device->maxOutputChannels == 0 )
- {
- isInput = 1;
- }
- printf("------------------------------------------\n");
- printf("Device: %s",device->name);
- if(isInput)
- printf(" (Input) %d Channels\n",device->maxInputChannels);
- else
- printf(" (Output) %d Channels\n",device->maxOutputChannels);
- // Try to see if this WASAPI device can provide Jack information
- err = GetJackInformation(i);
- if( err != paNoError ) goto error;
- }
- }
+ /* Find all WASAPI devices */
+ for( i = 0; i < Pa_GetDeviceCount(); ++i )
+ {
+ device = Pa_GetDeviceInfo(i);
+ if( Pa_GetDeviceInfo(i)->hostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI) )
+ {
+ if( device->maxOutputChannels == 0 )
+ {
+ isInput = 1;
+ }
+ printf("------------------------------------------\n");
+ printf("Device: %s",device->name);
+ if(isInput)
+ printf(" (Input) %d Channels\n",device->maxInputChannels);
+ else
+ printf(" (Output) %d Channels\n",device->maxOutputChannels);
+ // Try to see if this WASAPI device can provide Jack information
+ err = GetJackInformation(i);
+ if( err != paNoError ) goto error;
+ }
+ }
Pa_Terminate();
printf("Test finished.\n");
return err;
diff --git a/test/patest_latency.c b/test/patest_latency.c
index 2078a04..7f622c1 100644
--- a/test/patest_latency.c
+++ b/test/patest_latency.c
@@ -1,8 +1,8 @@
/** @file
- @ingroup test_src
- @brief Hear the latency caused by big buffers.
- Play a sine wave and change frequency based on letter input.
- @author Phil Burk , and Darren Gibbs
+ @ingroup test_src
+ @brief Hear the latency caused by big buffers.
+ Play a sine wave and change frequency based on letter input.
+ @author Phil Burk , and Darren Gibbs
*/
/*
* $Id$
@@ -32,13 +32,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -136,14 +136,14 @@ int main(void)
outputParameters.device = OUTPUT_DEVICE;
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
printf("Requested output latency = %.4f seconds.\n", outputParameters.suggestedLatency );
printf("%d frames per buffer.\n.", FRAMES_PER_BUFFER );
diff --git a/test/patest_leftright.c b/test/patest_leftright.c
index 11ce463..e61a351 100644
--- a/test/patest_leftright.c
+++ b/test/patest_leftright.c
@@ -1,12 +1,12 @@
/** @file patest_leftright.c
- @ingroup test_src
- @brief Play different tone sine waves that
- alternate between left and right channel.
+ @ingroup test_src
+ @brief Play different tone sine waves that
+ alternate between left and right channel.
- The low tone should be on the left channel.
+ The low tone should be on the left channel.
- @author Ross Bencina
- @author Phil Burk
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
@@ -36,13 +36,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -88,19 +88,19 @@ static int patestCallback( const void *inputBuffer,
for( i=0; icurrentBalance < data->targetBalance )
- {
- data->currentBalance += BALANCE_DELTA;
- }
- else if( data->currentBalance > data->targetBalance )
- {
- data->currentBalance -= BALANCE_DELTA;
- }
- // Apply left/right balance.
+ // Smoothly pan between left and right.
+ if( data->currentBalance < data->targetBalance )
+ {
+ data->currentBalance += BALANCE_DELTA;
+ }
+ else if( data->currentBalance > data->targetBalance )
+ {
+ data->currentBalance -= BALANCE_DELTA;
+ }
+ // Apply left/right balance.
*out++ = data->sine[data->left_phase] * (1.0f - data->currentBalance); /* left */
- *out++ = data->sine[data->right_phase] * data->currentBalance; /* right */
-
+ *out++ = data->sine[data->right_phase] * data->currentBalance; /* right */
+
data->left_phase += 1;
if( data->left_phase >= TABLE_SIZE ) data->left_phase -= TABLE_SIZE;
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
@@ -118,10 +118,10 @@ int main(void)
PaStreamParameters outputParameters;
PaError err;
paTestData data;
- int i;
+ int i;
printf("Play different tone sine waves that alternate between left and right channel.\n");
printf("The low tone should be on the left channel.\n");
-
+
/* initialise sinusoidal wavetable */
for( i=0; i
#include
@@ -111,8 +111,8 @@ int main(void)
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
diff --git a/test/patest_many.c b/test/patest_many.c
index b6bc314..76cc043 100644
--- a/test/patest_many.c
+++ b/test/patest_many.c
@@ -1,7 +1,7 @@
/** @file patest_many.c
- @ingroup test_src
- @brief Start and stop the PortAudio Driver multiple times.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Start and stop the PortAudio Driver multiple times.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -175,8 +175,8 @@ PaError TestOnce( void )
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paInt16;
diff --git a/test/patest_maxsines.c b/test/patest_maxsines.c
index 672a492..638a01a 100644
--- a/test/patest_maxsines.c
+++ b/test/patest_maxsines.c
@@ -1,8 +1,8 @@
/** @file patest_maxsines.c
- @ingroup test_src
- @brief How many sine waves can we calculate and play in less than 80% CPU Load.
- @author Ross Bencina
- @author Phil Burk
+ @ingroup test_src
+ @brief How many sine waves can we calculate and play in less than 80% CPU Load.
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
@@ -32,13 +32,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -110,7 +110,7 @@ static int patestCallback(const void* inputBuffer,
numForScale = data->numSines;
if( numForScale < 8 ) numForScale = 8; /* prevent pops at beginning */
scaler = 1.0f / numForScale;
-
+
for( i=0; i= 1.0 ) phase -= 1.0;
- output += LookupSine(data, phase);
+ output += LookupSine(data, phase);
data->phases[j] = phase;
-
+
phaseInc *= 1.02f;
if( phaseInc > MAX_PHASE_INC ) phaseInc = MIN_PHASE_INC;
}
@@ -141,7 +141,7 @@ static int patestCallback(const void* inputBuffer,
int main(void);
int main(void)
{
- int i;
+ int i;
PaStream* stream;
PaStreamParameters outputParameters;
PaError err;
@@ -162,8 +162,8 @@ int main(void)
goto error;
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* Stereo output. */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output. */
diff --git a/test/patest_mono.c b/test/patest_mono.c
index 3af09f5..c07e0bc 100644
--- a/test/patest_mono.c
+++ b/test/patest_mono.c
@@ -1,7 +1,7 @@
/** @file patest_mono.c
- @ingroup test_src
- @brief Play a monophonic sine wave using the Portable Audio api for several seconds.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Play a monophonic sine wave using the Portable Audio api for several seconds.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -35,13 +35,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -110,7 +110,7 @@ int main(void)
data.sine[i] = (float) (AMPLITUDE * sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. ));
}
data.phase = 0;
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
@@ -133,16 +133,16 @@ int main(void)
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
-
+
printf("Play for %d seconds.\n", NUM_SECONDS ); fflush(stdout);
Pa_Sleep( NUM_SECONDS * 1000 );
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
printf("Test finished.\n");
return err;
diff --git a/test/patest_multi_sine.c b/test/patest_multi_sine.c
index ad3db44..ec9ed8c 100644
--- a/test/patest_multi_sine.c
+++ b/test/patest_multi_sine.c
@@ -1,7 +1,7 @@
/** @file patest_multi_sine.c
- @ingroup test_src
- @brief Play a different sine wave on each channel.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Play a different sine wave on each channel.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -31,16 +31,16 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
-
+
#include
#include
@@ -125,8 +125,8 @@ int test(short interleaved)
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device, max channels. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- return paInvalidDevice;
+ fprintf(stderr,"Error: No default output device.\n");
+ return paInvalidDevice;
}
pdi = Pa_GetDeviceInfo(outputParameters.device);
outputParameters.channelCount = pdi->maxOutputChannels;
@@ -135,7 +135,7 @@ int test(short interleaved)
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = pdi->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
data.interleaved = interleaved;
data.numChannels = outputParameters.channelCount;
for (n = 0; n < data.numChannels; n++)
@@ -169,7 +169,7 @@ int test(short interleaved)
}
Pa_CloseStream( stream );
}
- return err;
+ return err;
}
diff --git a/test/patest_out_underflow.c b/test/patest_out_underflow.c
index 86a35cb..a8c45ea 100644
--- a/test/patest_out_underflow.c
+++ b/test/patest_out_underflow.c
@@ -1,9 +1,9 @@
/** @file patest_out_underflow.c
- @ingroup test_src
- @brief Count output underflows (using paOutputUnderflow flag)
- under overloaded and normal conditions.
- @author Ross Bencina
- @author Phil Burk
+ @ingroup test_src
+ @brief Count output underflows (using paOutputUnderflow flag)
+ under overloaded and normal conditions.
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
@@ -33,13 +33,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -134,11 +134,11 @@ int main(void)
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 1; /* mono output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
@@ -154,7 +154,7 @@ int main(void)
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
- &data );
+ &data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
@@ -163,12 +163,12 @@ int main(void)
/* Determine number of sines required to get to 50% */
do
- {
+ {
Pa_Sleep( 100 );
load = Pa_GetStreamCpuLoad( stream );
printf("sineCount = %d, CPU load = %f\n", data.sineCount, load );
-
+
if( load < 0.3 )
{
data.sineCount += 10;
@@ -198,7 +198,7 @@ int main(void)
load = Pa_GetStreamCpuLoad( stream );
printf("STRESSING: sineCount = %d, CPU load = %f\n", sineCount, load );
}
-
+
printf("Counting underflows for 2 seconds.\n");
data.countUnderflows = 1;
Pa_Sleep( 2000 );
@@ -220,14 +220,14 @@ int main(void)
Pa_Sleep( 5000 );
safeUnderflowCount = data.outputUnderflowCount;
-
+
printf("Stop stream.\n");
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
printf("suggestedLatency = %f\n", suggestedLatency);
diff --git a/test/patest_prime.c b/test/patest_prime.c
index 98acd60..e943310 100644
--- a/test/patest_prime.c
+++ b/test/patest_prime.c
@@ -1,7 +1,7 @@
/** @file patest_prime.c
- @ingroup test_src
- @brief Test stream priming mode.
- @author Ross Bencina http://www.audiomulch.com/~rossb
+ @ingroup test_src
+ @brief Test stream priming mode.
+ @author Ross Bencina http://www.audiomulch.com/~rossb
*/
/*
@@ -32,16 +32,16 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
-
+
#include
#include
#include "portaudio.h"
@@ -83,8 +83,8 @@ static void InitializeTestData( paTestData *testData )
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo *timeInfo,
- PaStreamCallbackFlags statusFlags, void *userData )
+ const PaStreamCallbackTimeInfo *timeInfo,
+ PaStreamCallbackFlags statusFlags, void *userData )
{
/* Cast data passed through stream to our structure. */
paTestData *data = (paTestData*)userData;
@@ -105,7 +105,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
*out++ = 0.0; /* left */
*out++ = 0.0; /* right */
--data->idleCountdown;
-
+
if( data->idleCountdown <= 0 ) result = paComplete;
break;
@@ -133,7 +133,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
break;
}
}
-
+
return result;
}
@@ -145,12 +145,12 @@ static PaError DoTest( int flags )
paTestData data;
PaStreamParameters outputParameters;
- InitializeTestData( &data );
+ InitializeTestData( &data );
outputParameters.device = Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2;
outputParameters.hostApiSpecificStreamInfo = NULL;
@@ -200,7 +200,7 @@ int main(void)
/* Initialize library before making any other calls. */
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
printf("PortAudio Test: Testing stream playback with no priming.\n");
printf("PortAudio Test: you should see BEEP before you hear it.\n");
printf("BEEP %d times.\n", NUM_BEEPS );
diff --git a/test/patest_read_record.c b/test/patest_read_record.c
index ae92ea2..4c5f810 100644
--- a/test/patest_read_record.c
+++ b/test/patest_read_record.c
@@ -1,8 +1,8 @@
/** @file patest_read_record.c
- @ingroup test_src
- @brief Record input into an array; Save array to a file; Playback recorded
+ @ingroup test_src
+ @brief Record input into an array; Save array to a file; Playback recorded
data. Implemented using the blocking API (Pa_ReadStream(), Pa_WriteStream() )
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
@author Ross Bencina rossb@audiomulch.com
*/
/*
@@ -33,13 +33,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -92,8 +92,8 @@ int main(void)
int numSamples;
int numBytes;
SAMPLE max, average, val;
-
-
+
+
printf("patest_read_record.c\n"); fflush(stdout);
totalFrames = NUM_SECONDS * SAMPLE_RATE; /* Record for a few seconds. */
@@ -113,8 +113,8 @@ int main(void)
inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
if (inputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default input device.\n");
- goto error;
+ fprintf(stderr,"Error: No default input device.\n");
+ goto error;
}
inputParameters.channelCount = NUM_CHANNELS;
inputParameters.sampleFormat = PA_SAMPLE_TYPE;
@@ -139,7 +139,7 @@ int main(void)
err = Pa_ReadStream( stream, recordedSamples, totalFrames );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
@@ -193,11 +193,11 @@ int main(void)
#endif
/* Playback recorded data. -------------------------------------------- */
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = NUM_CHANNELS;
outputParameters.sampleFormat = PA_SAMPLE_TYPE;
diff --git a/test/patest_ringmix.c b/test/patest_ringmix.c
index 2b365fb..2db6706 100644
--- a/test/patest_ringmix.c
+++ b/test/patest_ringmix.c
@@ -1,9 +1,9 @@
/** @file patest_ringmix.c
- @ingroup test_src
- @brief Ring modulate inputs to left output, mix inputs to right output.
+ @ingroup test_src
+ @brief Ring modulate inputs to left output, mix inputs to right output.
*/
/*
- * $Id$
+ * $Id$
*
* This program uses the PortAudio Portable Audio Library.
* For more information see: http://www.portaudio.com
@@ -30,13 +30,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -51,7 +51,7 @@ static int myCallback( const void *inputBuffer, void *outputBuffer,
void *userData )
{
const float *in = (const float *) inputBuffer;
- float *out = (float *) outputBuffer;
+ float *out = (float *) outputBuffer;
float leftInput, rightInput;
unsigned int i;
diff --git a/test/patest_sine8.c b/test/patest_sine8.c
index 3688dd1..82de69d 100644
--- a/test/patest_sine8.c
+++ b/test/patest_sine8.c
@@ -1,7 +1,7 @@
/** @file patest_sine8.c
- @ingroup test_src
- @brief Test 8 bit data: play a sine wave for several seconds.
- @author Ross Bencina
+ @ingroup test_src
+ @brief Test 8 bit data: play a sine wave for several seconds.
+ @author Ross Bencina
*/
/*
* $Id$
@@ -31,13 +31,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -150,8 +150,8 @@ int main(void)
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* Stereo output. */
outputParameters.sampleFormat = TEST_FORMAT;
diff --git a/test/patest_sine_channelmaps.c b/test/patest_sine_channelmaps.c
index 83608b8..3476701 100644
--- a/test/patest_sine_channelmaps.c
+++ b/test/patest_sine_channelmaps.c
@@ -26,21 +26,21 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
/** @file patest_sine_channelmaps.c
- @ingroup test_src
- @brief Plays sine waves using sme simple channel maps.
+ @ingroup test_src
+ @brief Plays sine waves using sme simple channel maps.
Designed for use with CoreAudio, but should made to work with other APIs
- @author Bjorn Roche
+ @author Bjorn Roche
@author Ross Bencina
@author Phil Burk
*/
@@ -87,7 +87,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; isine[data->left_phase]; /* left */
@@ -97,7 +97,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
}
-
+
return paContinue;
}
@@ -115,17 +115,17 @@ int main(void)
#endif
int i;
-
+
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
printf("Output will be mapped to channels 2 and 3 instead of 0 and 1.\n");
-
+
/* initialise sinusoidal wavetable */
for( i=0; i
diff --git a/test/patest_sine_srate.c b/test/patest_sine_srate.c
index 5fd07bd..d4ce81b 100644
--- a/test/patest_sine_srate.c
+++ b/test/patest_sine_srate.c
@@ -26,22 +26,22 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
/** @file patest_sine_srate_mac.c
- @ingroup test_src
- @brief Plays sine waves at 44100 and 48000,
+ @ingroup test_src
+ @brief Plays sine waves at 44100 and 48000,
and forces the hardware to change if this is a mac.
Designed for use with CoreAudio.
- @author Bjorn Roche
+ @author Bjorn Roche
@author Ross Bencina
@author Phil Burk
*/
@@ -89,7 +89,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; isine[data->left_phase]; /* left */
@@ -99,7 +99,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
}
-
+
return paContinue;
}
@@ -146,32 +146,32 @@ int main(void)
outputParameters.hostApiSpecificStreamInfo = NULL;
#endif
err = Pa_OpenStream(
- &stream,
- NULL, /* no input */
- &outputParameters,
- sr,
- FRAMES_PER_BUFFER,
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patestCallback,
- &data );
- if( err != paNoError ) goto error;
+ &stream,
+ NULL, /* no input */
+ &outputParameters,
+ sr,
+ FRAMES_PER_BUFFER,
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ patestCallback,
+ &data );
+ if( err != paNoError ) goto error;
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
+ err = Pa_StartStream( stream );
+ if( err != paNoError ) goto error;
- printf("Play for %d seconds.\n", NUM_SECONDS );
- Pa_Sleep( NUM_SECONDS * 1000 );
+ printf("Play for %d seconds.\n", NUM_SECONDS );
+ Pa_Sleep( NUM_SECONDS * 1000 );
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
+ err = Pa_StopStream( stream );
+ if( err != paNoError ) goto error;
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
+ err = Pa_CloseStream( stream );
+ if( err != paNoError ) goto error;
}
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
diff --git a/test/patest_sine_time.c b/test/patest_sine_time.c
index 1d4f551..c1d6097 100644
--- a/test/patest_sine_time.c
+++ b/test/patest_sine_time.c
@@ -1,9 +1,9 @@
/** @file patest_sine_time.c
- @ingroup test_src
- @brief Play a sine wave for several seconds, pausing in the middle.
- Uses the Pa_GetStreamTime() call.
- @author Ross Bencina
- @author Phil Burk
+ @ingroup test_src
+ @brief Play a sine wave for several seconds, pausing in the middle.
+ Uses the Pa_GetStreamTime() call.
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
@@ -33,13 +33,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include
@@ -114,7 +114,7 @@ static void ReportStreamTime( PaStream *stream, paTestData *data );
static void ReportStreamTime( PaStream *stream, paTestData *data )
{
PaTime streamTime, latency, outTime;
-
+
streamTime = Pa_GetStreamTime( stream );
outTime = data->outTime;
if( outTime < 0.0 )
@@ -167,7 +167,7 @@ int main(void)
patestCallback,
&data );
if( err != paNoError ) goto error;
-
+
/* Watch until sound is halfway finished. */
printf("Play for %d seconds.\n", NUM_SECONDS/2 ); fflush(stdout);
@@ -182,11 +182,11 @@ int main(void)
ReportStreamTime( stream, &data );
Pa_Sleep(100);
} while( (Pa_GetStreamTime( stream ) - startTime) < (NUM_SECONDS/2) );
-
+
/* Stop sound for 2 seconds. */
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
printf("Pause for 2 seconds.\n"); fflush(stdout);
Pa_Sleep( 2000 );
@@ -195,21 +195,21 @@ int main(void)
if( err != paNoError ) goto error;
startTime = Pa_GetStreamTime( stream );
-
+
printf("Play until sound is finished.\n"); fflush(stdout);
do
{
ReportStreamTime( stream, &data );
Pa_Sleep(100);
} while( (Pa_GetStreamTime( stream ) - startTime) < (NUM_SECONDS/2) );
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
Pa_Terminate();
printf("Test finished.\n");
return err;
-
+
error:
Pa_Terminate();
fprintf( stderr, "An error occurred while using the portaudio stream\n" );
diff --git a/test/patest_start_stop.c b/test/patest_start_stop.c
index ec902cf..2470b26 100644
--- a/test/patest_start_stop.c
+++ b/test/patest_start_stop.c
@@ -1,9 +1,9 @@
/** @file patest_start_stop.c
- @ingroup test_src
- @brief Play a sine wave for several seconds. Start and stop the stream multiple times.
-
- @author Ross Bencina
- @author Phil Burk
+ @ingroup test_src
+ @brief Play a sine wave for several seconds. Start and stop the stream multiple times.
+
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
@@ -33,13 +33,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include
@@ -83,7 +83,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; isine[data->left_phase]; /* left */
@@ -93,7 +93,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
}
-
+
return paContinue;
}
@@ -107,16 +107,16 @@ int main(void)
paTestData data;
int i;
-
+
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
-
+
/* initialise sinusoidal wavetable */
for( i=0; i
+ @author Phil Burk
*/
/*
* $Id$
@@ -41,13 +41,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include
@@ -96,7 +96,7 @@ int TestStopMode( paTestData *data );
float LookupWaveform( paTestData *data, float phase );
/******************************************************
- * Convert phase between 0.0 and 1.0 to waveform value
+ * Convert phase between 0.0 and 1.0 to waveform value
* using linear interpolation.
*/
float LookupWaveform( paTestData *data, float phase )
@@ -132,7 +132,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
/* data->outTime = outTime; */
-
+
if( !data->done )
{
for( i=0; idone = 0;
data->phase = 0.0;
data->frameCounter = 0;
data->noteCounter = 0;
data->repeatCounter = 0;
data->phase_increment = data->tune[data->noteCounter];
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
@@ -257,7 +257,7 @@ int TestStopMode( paTestData *data )
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = LATENCY_SECONDS;
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
err = Pa_OpenStream(
&stream,
NULL, /* no input */
diff --git a/test/patest_stop_playout.c b/test/patest_stop_playout.c
index 17e09f3..7e6932e 100644
--- a/test/patest_stop_playout.c
+++ b/test/patest_stop_playout.c
@@ -1,9 +1,9 @@
/** @file patest_stop_playout.c
- @ingroup test_src
- @brief Test whether all queued samples are played when Pa_StopStream()
+ @ingroup test_src
+ @brief Test whether all queued samples are played when Pa_StopStream()
is used with a callback or read/write stream, or when the callback
returns paComplete.
- @author Ross Bencina
+ @author Ross Bencina
*/
/*
* $Id$
@@ -33,13 +33,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include
@@ -66,10 +66,10 @@ typedef struct
float sine[TABLE_SIZE+1];
int repeatCount;
-
+
double phase;
double lowIncrement, highIncrement;
-
+
int gap1Length, toneLength, toneFadesLength, gap2Length, blipLength;
int gap1Countdown, toneCountdown, gap2Countdown, blipCountdown;
}
@@ -105,7 +105,7 @@ static void InitTestSignalGenerator( TestData *data )
data->sine[TABLE_SIZE] = data->sine[0]; /* guard point for linear interpolation */
-
+
data->lowIncrement = (330. / SAMPLE_RATE) * TABLE_SIZE;
data->highIncrement = (1760. / SAMPLE_RATE) * TABLE_SIZE;
@@ -147,7 +147,7 @@ static void GenerateTestSignal( TestData *data, float *stereo, int frameCount )
data->gap1Countdown -= count;
framesGenerated += count;
}
-
+
if( framesGenerated < frameCount && data->toneCountdown > 0 ){
count = MIN( frameCount - framesGenerated, data->toneCountdown );
for( i=0; i < count; ++i )
@@ -168,19 +168,19 @@ static void GenerateTestSignal( TestData *data, float *stereo, int frameCount )
/* cosine-bell fade out at end */
output *= (-cos(((float)data->toneCountdown / (float)data->toneFadesLength) * M_PI) + 1.) * .5;
}
- else if( data->toneCountdown > data->toneLength - data->toneFadesLength )
+ else if( data->toneCountdown > data->toneLength - data->toneFadesLength )
{
/* cosine-bell fade in at start */
output *= (cos(((float)(data->toneCountdown - (data->toneLength - data->toneFadesLength)) / (float)data->toneFadesLength) * M_PI) + 1.) * .5;
}
output *= .5; /* play tone half as loud as blip */
-
+
*stereo++ = output;
*stereo++ = output;
data->toneCountdown--;
- }
+ }
framesGenerated += count;
}
@@ -212,7 +212,7 @@ static void GenerateTestSignal( TestData *data, float *stereo, int frameCount )
/* cosine-bell envelope over whole blip */
output *= (-cos( ((float)data->blipCountdown / (float)data->blipLength) * 2. * M_PI) + 1.) * .5;
-
+
*stereo++ = output;
*stereo++ = output;
@@ -227,7 +227,7 @@ static void GenerateTestSignal( TestData *data, float *stereo, int frameCount )
{
RetriggerTestSignalGenerator( data );
data->repeatCount++;
- }
+ }
}
if( framesGenerated < frameCount )
@@ -286,7 +286,7 @@ static int TestCallback2( const void *inputBuffer, void *outputBuffer,
if( IsTestSignalFinished( (TestData*)userData ) )
testCallback2Finished = 1;
-
+
return paContinue;
}
@@ -299,11 +299,11 @@ int main(void)
PaError err;
TestData data;
float writeBuffer[ FRAMES_PER_BUFFER * 2 ];
-
+
printf("PortAudio Test: check that stopping stream plays out all queued samples. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
InitTestSignalGenerator( &data );
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
@@ -391,7 +391,7 @@ int main(void)
ResetTestSignalGenerator( &data );
testCallback2Finished = 0;
-
+
err = Pa_OpenStream(
&stream,
NULL, /* no input */
@@ -419,7 +419,7 @@ int main(void)
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
@@ -452,23 +452,23 @@ int main(void)
GenerateTestSignal( &data, writeBuffer, FRAMES_PER_BUFFER );
err = Pa_WriteStream( stream, writeBuffer, FRAMES_PER_BUFFER );
if( err != paNoError ) goto error;
-
+
}while( !IsTestSignalFinished( &data ) );
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
/* -------------------------------------------------------------------------- */
-
+
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
-
+
error:
Pa_Terminate();
fprintf( stderr, "An error occurred while using the portaudio stream\n" );
diff --git a/test/patest_suggested_vs_streaminfo_latency.c b/test/patest_suggested_vs_streaminfo_latency.c
index 204e964..c26d871 100644
--- a/test/patest_suggested_vs_streaminfo_latency.c
+++ b/test/patest_suggested_vs_streaminfo_latency.c
@@ -1,13 +1,13 @@
/** @file patest_suggested_vs_streaminfo_latency.c
- @ingroup test_src
- @brief Print suggested vs. PaStreamInfo reported actual latency
- @author Ross Bencina
+ @ingroup test_src
+ @brief Print suggested vs. PaStreamInfo reported actual latency
+ @author Ross Bencina
- Opens streams with a sequence of suggested latency values
- from 0 to 2 seconds in .5ms intervals and gathers the resulting actual
- latency values. Output a csv file and graph suggested vs. actual. Run
- with framesPerBuffer unspecified, powers of 2 and multiples of 50 and
- prime number buffer sizes.
+ Opens streams with a sequence of suggested latency values
+ from 0 to 2 seconds in .5ms intervals and gathers the resulting actual
+ latency values. Output a csv file and graph suggested vs. actual. Run
+ with framesPerBuffer unspecified, powers of 2 and multiples of 50 and
+ prime number buffer sizes.
*/
/*
* $Id: patest_sine.c 1368 2008-03-01 00:38:27Z rossb $
@@ -37,13 +37,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include
@@ -129,8 +129,8 @@ int main( int argc, const char* argv[] )
if( inputParameters.device == -1 ){
inputParameters.device = Pa_GetDefaultInputDevice();
if (inputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default input device available.\n");
- goto error;
+ fprintf(stderr,"Error: No default input device available.\n");
+ goto error;
}
}else{
deviceInfo = Pa_GetDeviceInfo(inputParameters.device);
@@ -143,7 +143,7 @@ int main( int argc, const char* argv[] )
usage();
}
}
-
+
inputParameters.channelCount = NUM_CHANNELS;
inputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
inputParameters.hostApiSpecificStreamInfo = NULL;
@@ -158,8 +158,8 @@ int main( int argc, const char* argv[] )
if( outputParameters.device == -1 ){
outputParameters.device = Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device available.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device available.\n");
+ goto error;
}
}else{
deviceInfo = Pa_GetDeviceInfo(outputParameters.device);
@@ -214,7 +214,7 @@ int main( int argc, const char* argv[] )
err = Pa_OpenStream(
&stream,
- &inputParameters,
+ &inputParameters,
NULL, /* no output */
sampleRate,
framesPerBuffer,
@@ -234,7 +234,7 @@ int main( int argc, const char* argv[] )
err = Pa_OpenStream(
&stream,
- &inputParameters,
+ &inputParameters,
&outputParameters,
sampleRate,
framesPerBuffer,
@@ -258,7 +258,7 @@ int main( int argc, const char* argv[] )
Pa_Terminate();
printf("# Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
diff --git a/test/patest_suggested_vs_streaminfo_latency.py b/test/patest_suggested_vs_streaminfo_latency.py
index 46c7434..8026787 100644
--- a/test/patest_suggested_vs_streaminfo_latency.py
+++ b/test/patest_suggested_vs_streaminfo_latency.py
@@ -88,7 +88,7 @@ compositeTestFramesPerBufferValues.append( 882 )
individualPlotFramesPerBufferValues = [0,64,128,256,512] #output separate plots for these
-isFirst = True
+isFirst = True
for framesPerBuffer in compositeTestFramesPerBufferValues:
commandString = testExeName + " " + str(inputDeviceIndex) + " " + str(outputDeviceIndex) + " " + str(sampleRate) + " " + str(framesPerBuffer) + ' > ' + dataFileName
@@ -102,13 +102,13 @@ for framesPerBuffer in compositeTestFramesPerBufferValues:
gcf().text(0.1, 0.0,
"patest_suggested_vs_streaminfo_latency\n%s\n%s\n%s\n"%(d.inputDevice,d.outputDevice,d.sampleRate))
pdfFile.savefig()
-
-
+
+
figure(2) # composite plot, includes all compositeTestFramesPerBufferValues
if isFirst:
plot( d.suggestedLatency, d.suggestedLatency, label="Suggested latency" )
-
+
plot( d.suggestedLatency, d.halfDuplexOutputLatency )
plot( d.suggestedLatency, d.halfDuplexInputLatency )
plot( d.suggestedLatency, d.fullDuplexOutputLatency )
diff --git a/test/patest_sync.c b/test/patest_sync.c
index d3a8c0f..52df0fe 100644
--- a/test/patest_sync.c
+++ b/test/patest_sync.c
@@ -1,19 +1,19 @@
/** @file patest_sync.c
- @ingroup test_src
- @brief Test time stamping and synchronization of audio and video.
+ @ingroup test_src
+ @brief Test time stamping and synchronization of audio and video.
- A high latency is used so we can hear the difference in time.
- Random durations are used so we know we are hearing the right beep
- and not the one before or after.
+ A high latency is used so we can hear the difference in time.
+ Random durations are used so we know we are hearing the right beep
+ and not the one before or after.
- Sequence of events:
- -# Foreground requests a beep.
- -# Background randomly schedules a beep.
- -# Foreground waits for the beep to be heard based on PaUtil_GetTime().
- -# Foreground outputs video (printf) in sync with audio.
- -# Repeat.
-
- @author Phil Burk http://www.softsynth.com
+ Sequence of events:
+ -# Foreground requests a beep.
+ -# Background randomly schedules a beep.
+ -# Foreground waits for the beep to be heard based on PaUtil_GetTime().
+ -# Foreground outputs video (printf) in sync with audio.
+ -# Repeat.
+
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -43,13 +43,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -97,8 +97,8 @@ static unsigned long GenerateRandomNumber( void )
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo *timeInfo,
- PaStreamCallbackFlags statusFlags, void *userData )
+ const PaStreamCallbackTimeInfo *timeInfo,
+ PaStreamCallbackFlags statusFlags, void *userData )
{
/* Cast data passed through stream to our structure. */
paTestData *data = (paTestData*)userData;
@@ -186,7 +186,7 @@ int main(void)
/* Initialize library before making any other calls. */
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice) {
fprintf(stderr,"Error: No default output device.\n");
@@ -198,16 +198,16 @@ int main(void)
outputParameters.suggestedLatency = (double)LATENCY_MSEC / 1000;
/* Open an audio I/O stream. */
- err = Pa_OpenStream(
- &stream,
- NULL, /* no input */
- &outputParameters,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patestCallback,
- &DATA );
- if( err != paNoError ) goto error;
+ err = Pa_OpenStream(
+ &stream,
+ NULL, /* no input */
+ &outputParameters,
+ SAMPLE_RATE,
+ FRAMES_PER_BUFFER, /* frames per buffer */
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ patestCallback,
+ &DATA );
+ if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
diff --git a/test/patest_timing.c b/test/patest_timing.c
index 659ec24..2a240b4 100644
--- a/test/patest_timing.c
+++ b/test/patest_timing.c
@@ -1,8 +1,8 @@
/** @file patest_timing.c
- @ingroup test_src
- @brief Play a sine wave for several seconds, and spits out a ton of timing info while it's at it. Based on patest_sine.c
- @author Bjorn Roche
- @author Ross Bencina
+ @ingroup test_src
+ @brief Play a sine wave for several seconds, and spits out a ton of timing info while it's at it. Based on patest_sine.c
+ @author Bjorn Roche
+ @author Ross Bencina
@author Phil Burk
*/
/*
@@ -33,13 +33,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -90,7 +90,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
timeInfo->outputBufferDacTime );
printf( "getStreamTime() returns: %g\n", Pa_GetStreamTime(data->stream) - data->start );
-
+
for( i=0; isine[data->left_phase]; /* left */
@@ -100,7 +100,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
}
-
+
return paContinue;
}
@@ -114,16 +114,16 @@ int main(void)
paTestData data;
int i;
-
+
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
-
+
/* initialise sinusoidal wavetable */
for( i=0; i
- @author Phil Burk
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
@@ -33,13 +33,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -120,7 +120,7 @@ int main(void)
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
fprintf(stderr,"Error: No default output device.\n");
@@ -139,7 +139,7 @@ int main(void)
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
- &data );
+ &data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
@@ -150,44 +150,44 @@ int main(void)
load = Pa_GetStreamCpuLoad( stream );
printf("numSines = %d, CPU load = %f\n", data.numSines, load );
-
- if( load < 0.3 )
- {
- data.numSines += 10;
- }
- else if( load < 0.4 )
- {
- data.numSines += 2;
- }
- else
- {
- data.numSines += 1;
- }
-
+
+ if( load < 0.3 )
+ {
+ data.numSines += 10;
+ }
+ else if( load < 0.4 )
+ {
+ data.numSines += 2;
+ }
+ else
+ {
+ data.numSines += 1;
+ }
+
}
while( load < 0.5 );
-
+
/* Calculate target stress value then ramp up to that level*/
numStress = (int) (2.0 * data.numSines * MAX_LOAD );
if( numStress > MAX_SINES )
- numStress = MAX_SINES;
+ numStress = MAX_SINES;
for( ; data.numSines < numStress; data.numSines+=2 )
{
Pa_Sleep( 200 );
load = Pa_GetStreamCpuLoad( stream );
printf("STRESSING: numSines = %d, CPU load = %f\n", data.numSines, load );
}
-
+
printf("Suffer for 5 seconds.\n");
Pa_Sleep( 5000 );
-
+
printf("Stop stream.\n");
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
printf("Test finished.\n");
return err;
diff --git a/test/patest_two_rates.c b/test/patest_two_rates.c
index 5148fe7..2116b1e 100644
--- a/test/patest_two_rates.c
+++ b/test/patest_two_rates.c
@@ -1,7 +1,7 @@
/** @file patest_two_rates.c
- @ingroup test_src
- @brief Play two streams at different rates to make sure they don't interfere.
- @author Phil Burk
+ @ingroup test_src
+ @brief Play two streams at different rates to make sure they don't interfere.
+ @author Phil Burk
*/
/*
* $Id$
@@ -33,13 +33,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -68,10 +68,10 @@ typedef struct
** that could mess up the system like calling malloc() or free().
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData )
+ unsigned long framesPerBuffer,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
+ void *userData )
{
paTestData *data = (paTestData*)userData;
float *out = (float*)outputBuffer;
@@ -90,7 +90,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
data->phase += FREQ_INCR;
if( data->phase >= (2.0 * M_PI) ) data->phase -= (2.0 * M_PI);
}
- data->numFrames += 1;
+ data->numFrames += 1;
return 0;
}
@@ -108,28 +108,28 @@ int main(void)
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
- /* Start first stream. **********************/
+ /* Start first stream. **********************/
err = Pa_OpenStream(
- &stream1,
- NULL, /* no input */
- &outputParameters,
- SAMPLE_RATE_1,
- FRAMES_PER_BUFFER,
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patestCallback,
- &data1 );
- if( err != paNoError ) goto error;
+ &stream1,
+ NULL, /* no input */
+ &outputParameters,
+ SAMPLE_RATE_1,
+ FRAMES_PER_BUFFER,
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ patestCallback,
+ &data1 );
+ if( err != paNoError ) goto error;
err = Pa_StartStream( stream1 );
if( err != paNoError ) goto error;
@@ -138,34 +138,34 @@ int main(void)
/* Start second stream. **********************/
err = Pa_OpenStream(
- &stream2,
- NULL, /* no input */
- &outputParameters,
- SAMPLE_RATE_2,
- FRAMES_PER_BUFFER,
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patestCallback,
- &data2 );
+ &stream2,
+ NULL, /* no input */
+ &outputParameters,
+ SAMPLE_RATE_2,
+ FRAMES_PER_BUFFER,
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ patestCallback,
+ &data2 );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream2 );
if( err != paNoError ) goto error;
Pa_Sleep( 3 * 1000 );
-
+
err = Pa_StopStream( stream2 );
if( err != paNoError ) goto error;
Pa_Sleep( 3 * 1000 );
-
+
err = Pa_StopStream( stream1 );
if( err != paNoError ) goto error;
Pa_CloseStream( stream2 );
Pa_CloseStream( stream1 );
-
+
Pa_Terminate();
-
+
printf("NumFrames = %d on stream1, %d on stream2.\n", data1.numFrames, data2.numFrames );
printf("Test finished.\n");
return err;
diff --git a/test/patest_underflow.c b/test/patest_underflow.c
index 430de62..96216a6 100644
--- a/test/patest_underflow.c
+++ b/test/patest_underflow.c
@@ -1,9 +1,9 @@
/** @file patest_underflow.c
- @ingroup test_src
- @brief Simulate an output buffer underflow condition.
- Tests whether the stream can be stopped when underflowing buffers.
- @author Ross Bencina
- @author Phil Burk
+ @ingroup test_src
+ @brief Simulate an output buffer underflow condition.
+ Tests whether the stream can be stopped when underflowing buffers.
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
@@ -33,13 +33,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -116,7 +116,7 @@ int main(void)
data.left_phase = data.right_phase = data.sleepTime = 0;
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
fprintf(stderr,"Error: No default output device.\n");
diff --git a/test/patest_unplug.c b/test/patest_unplug.c
index e546921..0e4486e 100644
--- a/test/patest_unplug.c
+++ b/test/patest_unplug.c
@@ -1,7 +1,7 @@
/** @file patest_unplug.c
- @ingroup test_src
- @brief Debug a crash involving unplugging a USB device.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Debug a crash involving unplugging a USB device.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
@@ -131,10 +131,10 @@ int main(int argc, char **args)
printf("Test unplugging a USB device.\n");
if( argc > 1 ) {
- inputDevice = outputDevice = atoi( args[1] );
- printf("Using device number %d.\n\n", inputDevice );
+ inputDevice = outputDevice = atoi( args[1] );
+ printf("Using device number %d.\n\n", inputDevice );
} else {
- printf("Using default device.\n\n" );
+ printf("Using default device.\n\n" );
}
memset(&data, 0, sizeof(data));
diff --git a/test/patest_wire.c b/test/patest_wire.c
index a5f3ffc..f04e6be 100644
--- a/test/patest_wire.c
+++ b/test/patest_wire.c
@@ -1,13 +1,13 @@
/** @file patest_wire.c
- @ingroup test_src
- @brief Pass input directly to output.
+ @ingroup test_src
+ @brief Pass input directly to output.
- Note that some HW devices, for example many ISA audio cards
- on PCs, do NOT support full duplex! For a PC, you normally need
- a PCI based audio card such as the SBLive.
+ Note that some HW devices, for example many ISA audio cards
+ on PCs, do NOT support full duplex! For a PC, you normally need
+ a PCI based audio card such as the SBLive.
+
+ @author Phil Burk http://www.softsynth.com
- @author Phil Burk http://www.softsynth.com
-
While adapting to V19-API, I excluded configs with framesPerCallback=0
because of an assert in file pa_common/pa_process.c. Pieter, Oct 9, 2003.
@@ -40,13 +40,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -138,7 +138,7 @@ static int wireCallback( const void *inputBuffer, void *outputBuffer,
if( (statusFlags & paOutputOverflow) != 0 ) config->numOutputOverflows += 1;
if( (statusFlags & paPrimingOutput) != 0 ) config->numPrimingOutputs += 1;
config->numCallbacks += 1;
-
+
inChannel=0, outChannel=0;
while( !(inDone && outDone) )
{
@@ -232,7 +232,7 @@ int main(void)
}
else if( err != paNoError ) goto error;
}
- }
+ }
}
}
}
@@ -260,7 +260,7 @@ static PaError TestConfiguration( WireConfig_t *config )
PaError err = paNoError;
PaStream *stream;
PaStreamParameters inputParameters, outputParameters;
-
+
printf("input %sinterleaved!\n", (config->isInputInterleaved ? " " : "NOT ") );
printf("output %sinterleaved!\n", (config->isOutputInterleaved ? " " : "NOT ") );
printf("input channels = %d\n", config->numInputChannels );
@@ -304,13 +304,13 @@ static PaError TestConfiguration( WireConfig_t *config )
wireCallback,
config );
if( err != paNoError ) goto error;
-
+
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
-
+
printf("Now recording and playing. - Hit ENTER for next configuration, or 'q' to quit.\n"); fflush(stdout);
c = getchar();
-
+
printf("Closing stream.\n");
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
diff --git a/test/patest_wmme_find_best_latency_params.c b/test/patest_wmme_find_best_latency_params.c
index 0149f9e..860cbc6 100644
--- a/test/patest_wmme_find_best_latency_params.c
+++ b/test/patest_wmme_find_best_latency_params.c
@@ -26,13 +26,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -40,7 +40,7 @@
#include
#include
-#define _WIN32_WINNT 0x0501 /* for GetNativeSystemInfo */
+#define _WIN32_WINNT 0x0501 /* for GetNativeSystemInfo */
#include /* required when using pa_win_wmme.h */
#include /* required when using pa_win_wmme.h */
@@ -107,11 +107,11 @@ static void printWindowsVersionInfo( FILE *fp )
osVersionInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx( &osVersionInfoEx );
-
+
if( osVersionInfoEx.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ){
switch( osVersionInfoEx.dwMinorVersion ){
case 0: osName = "Windows 95"; break;
- case 10: osName = "Windows 98"; break; // could also be 98SE (I've seen code discriminate based
+ case 10: osName = "Windows 98"; break; // could also be 98SE (I've seen code discriminate based
// on osInfo.Version.Revision.ToString() == "2222A")
case 90: osName = "Windows Me"; break;
}
@@ -137,13 +137,13 @@ static void printWindowsVersionInfo( FILE *fp )
}break;
}break;
case 6:switch( osVersionInfoEx.dwMinorVersion ){
- case 0:
+ case 0:
if( osVersionInfoEx.wProductType == VER_NT_WORKSTATION )
osName = "Windows Vista";
else
osName = "Windows Server 2008";
break;
- case 1:
+ case 1:
if( osVersionInfoEx.wProductType == VER_NT_WORKSTATION )
osName = "Windows 7";
else
@@ -171,7 +171,7 @@ static void printWindowsVersionInfo( FILE *fp )
}
else if(osVersionInfoEx.wProductType == VER_NT_SERVER)
{
- if(osVersionInfoEx.dwMinorVersion == 0)
+ if(osVersionInfoEx.dwMinorVersion == 0)
{
if((osVersionInfoEx.wSuiteMask & VER_SUITE_DATACENTER) == VER_SUITE_DATACENTER)
osProductType = "Datacenter Server"; // Windows 2000 Datacenter Server
@@ -206,8 +206,8 @@ static void printWindowsVersionInfo( FILE *fp )
fprintf( fp, "OS name and edition: %s %s\n", osName, osProductType );
- fprintf( fp, "OS version: %d.%d.%d %S\n",
- osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion,
+ fprintf( fp, "OS version: %d.%d.%d %S\n",
+ osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion,
osVersionInfoEx.dwBuildNumber, osVersionInfoEx.szCSDVersion );
fprintf( fp, "Processor architecture: %s\n", processorArchitecture );
fprintf( fp, "WoW64 process: %s\n", IsWow64() ? "Yes" : "No" );
@@ -230,7 +230,7 @@ static void printTimeAndDate( FILE *fp )
typedef struct
{
float sine[TABLE_SIZE];
- double phase;
+ double phase;
double phaseIncrement;
volatile int fadeIn;
volatile int fadeOut;
@@ -257,14 +257,14 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; isine[(int)data->phase];
data->phase += data->phaseIncrement;
if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
+ data->phase -= TABLE_SIZE;
+ }
x *= data->amp;
if( data->fadeIn ){
@@ -276,11 +276,11 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
data->amp -= .001;
}
- for( j = 0; j < CHANNEL_COUNT; ++j ){
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
*out++ = x;
- }
- }
-
+ }
+ }
+
if( data->amp > 0 )
return paContinue;
else
@@ -292,7 +292,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
#define NO 0
-static int playUntilKeyPress( int deviceIndex, float sampleRate,
+static int playUntilKeyPress( int deviceIndex, float sampleRate,
int framesPerUserBuffer, int framesPerWmmeBuffer, int wmmeBufferCount )
{
PaStreamParameters outputParameters;
@@ -308,7 +308,7 @@ static int playUntilKeyPress( int deviceIndex, float sampleRate,
outputParameters.hostApiSpecificStreamInfo = NULL;
wmmeStreamInfo.size = sizeof(PaWinMmeStreamInfo);
- wmmeStreamInfo.hostApiType = paMME;
+ wmmeStreamInfo.hostApiType = paMME;
wmmeStreamInfo.version = 1;
wmmeStreamInfo.flags = paWinMmeUseLowLevelLatencyParameters | paWinMmeDontThrottleOverloadedProcessingThread;
wmmeStreamInfo.framesPerBuffer = framesPerWmmeBuffer;
@@ -379,7 +379,7 @@ static void usage( int wmmeHostApiIndex )
}
/*
- ideas:
+ ideas:
o- could be testing with 80% CPU load
o- could test with different channel counts
*/
@@ -409,15 +409,15 @@ int main(int argc, char* argv[])
if( argc > 5 )
usage(wmmeHostApiIndex);
- deviceIndex = wmmeHostApiInfo->defaultOutputDevice;
- if( argc >= 2 ){
+ deviceIndex = wmmeHostApiInfo->defaultOutputDevice;
+ if( argc >= 2 ){
deviceIndex = -1;
- if( sscanf( argv[1], "%d", &deviceIndex ) != 1 )
+ if( sscanf( argv[1], "%d", &deviceIndex ) != 1 )
usage(wmmeHostApiIndex);
if( deviceIndex < 0 || deviceIndex >= Pa_GetDeviceCount() || Pa_GetDeviceInfo(deviceIndex)->hostApi != wmmeHostApiIndex ){
usage(wmmeHostApiIndex);
}
- }
+ }
printf( "Using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
@@ -450,14 +450,14 @@ int main(int argc, char* argv[])
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
- data.phase = 0;
+ data.phase = 0;
resultsFp = fopen( "results.txt", "at" );
fprintf( resultsFp, "*** WMME smallest working output buffer sizes\n" );
printTimeAndDate( resultsFp );
printWindowsVersionInfo( resultsFp );
-
+
fprintf( resultsFp, "audio device: %s\n", Pa_GetDeviceInfo( deviceIndex )->name );
fflush( resultsFp );
@@ -465,7 +465,7 @@ int main(int argc, char* argv[])
fprintf( resultsFp, "Buffer count, Smallest working buffer size (frames), Smallest working buffering latency (frames), Smallest working buffering latency (Seconds)\n" );
for( wmmeBufferCount = wmmeMinBufferCount; wmmeBufferCount <= wmmeMaxBufferCount; ++wmmeBufferCount ){
-
+
printf( "Test %d of %d\n", (wmmeBufferCount - wmmeMinBufferCount) + 1, (wmmeMaxBufferCount-wmmeMinBufferCount) + 1 );
printf( "Testing with %d buffers...\n", wmmeBufferCount );
@@ -489,7 +489,7 @@ int main(int argc, char* argv[])
}else{
min = mid + 1;
}
-
+
}while( (min <= max) && (testResult == YES || testResult == NO) );
smallestWorkingBufferingLatencyFrames = smallestWorkingBufferSize * (wmmeBufferCount - 1);
@@ -503,10 +503,10 @@ int main(int argc, char* argv[])
fprintf( resultsFp, "###\n" );
fclose( resultsFp );
-
+
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
diff --git a/test/patest_wmme_low_level_latency_params.c b/test/patest_wmme_low_level_latency_params.c
index aa4d71e..1ac0c78 100644
--- a/test/patest_wmme_low_level_latency_params.c
+++ b/test/patest_wmme_low_level_latency_params.c
@@ -26,13 +26,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -65,7 +65,7 @@
typedef struct
{
float sine[TABLE_SIZE];
- double phase;
+ double phase;
}
paTestData;
@@ -86,20 +86,20 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; isine[(int)data->phase];
data->phase += 20;
if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
+ data->phase -= TABLE_SIZE;
+ }
- for( j = 0; j < CHANNEL_COUNT; ++j ){
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
*out++ = x;
- }
- }
-
+ }
+ }
+
return paContinue;
}
@@ -119,12 +119,12 @@ int main(int argc, char* argv[])
err = Pa_Initialize();
if( err != paNoError ) goto error;
- deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
- if( argc == 2 ){
- sscanf( argv[1], "%d", &deviceIndex );
- }
+ deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
+ if( argc == 2 ){
+ sscanf( argv[1], "%d", &deviceIndex );
+ }
- printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
+ printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
/* initialise sinusoidal wavetable */
for( i=0; i> 1;
const float framesBy2f = (float) framesBy2 ;
-
+
printf( "PortAudio Test: output silence, followed by one buffer of a ramped sine wave. SR = %d, BufSize = %d\n",
SAMPLE_RATE, FRAMES_PER_BUFFER);
-
+
/* initialise sinusoidal wavetable */
for( i=0; i
Date: Fri, 22 Jan 2021 00:00:40 +1100
Subject: [PATCH 088/157] Clean up whitespace in qa/ in preparation for
.editorconfig. (#418)
* Clean up whitespace in qa/ in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF.
---
qa/loopback/src/audio_analyzer.c | 888 ++++-----
qa/loopback/src/audio_analyzer.h | 78 +-
qa/loopback/src/biquad_filter.c | 143 +-
qa/loopback/src/biquad_filter.h | 24 +-
qa/loopback/src/paqa.c | 2442 ++++++++++++-------------
qa/loopback/src/paqa_tools.c | 222 +--
qa/loopback/src/paqa_tools.h | 6 +-
qa/loopback/src/qa_tools.h | 48 +-
qa/loopback/src/test_audio_analyzer.c | 972 +++++-----
qa/loopback/src/test_audio_analyzer.h | 6 +-
qa/loopback/src/write_wav.c | 104 +-
qa/loopback/src/write_wav.h | 14 +-
qa/paqa_devs.c | 6 +-
qa/paqa_errs.c | 34 +-
qa/paqa_latency.c | 80 +-
15 files changed, 2534 insertions(+), 2533 deletions(-)
diff --git a/qa/loopback/src/audio_analyzer.c b/qa/loopback/src/audio_analyzer.c
index 0a3dbdf..ddbd32c 100644
--- a/qa/loopback/src/audio_analyzer.c
+++ b/qa/loopback/src/audio_analyzer.c
@@ -26,13 +26,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -50,153 +50,153 @@
/*==========================================================================================*/
double PaQa_GetNthFrequency( double baseFrequency, int index )
{
- // Use 13 tone equal tempered scale because it does not generate harmonic ratios.
- return baseFrequency * pow( 2.0, index / 13.0 );
+ // Use 13 tone equal tempered scale because it does not generate harmonic ratios.
+ return baseFrequency * pow( 2.0, index / 13.0 );
}
/*==========================================================================================*/
void PaQa_EraseBuffer( float *buffer, int numFrames, int samplesPerFrame )
{
- int i;
- int numSamples = numFrames * samplesPerFrame;
- for( i=0; iphase = 0.0;
- generator->amplitude = amplitude;
- generator->frequency = frequency;
- generator->phaseIncrement = 2.0 * frequency * MATH_PI / frameRate;
+ generator->phase = 0.0;
+ generator->amplitude = amplitude;
+ generator->frequency = frequency;
+ generator->phaseIncrement = 2.0 * frequency * MATH_PI / frameRate;
}
/*==========================================================================================*/
void PaQa_MixSine( PaQaSineGenerator *generator, float *buffer, int numSamples, int stride )
{
- int i;
- for( i=0; iphase ) * generator->amplitude;
- *buffer += value; // Mix with existing value.
- buffer += stride;
- // Advance phase and wrap around.
- generator->phase += generator->phaseIncrement;
- if (generator->phase > MATH_TWO_PI)
- {
- generator->phase -= MATH_TWO_PI;
- }
- }
+ int i;
+ for( i=0; iphase ) * generator->amplitude;
+ *buffer += value; // Mix with existing value.
+ buffer += stride;
+ // Advance phase and wrap around.
+ generator->phase += generator->phaseIncrement;
+ if (generator->phase > MATH_TWO_PI)
+ {
+ generator->phase -= MATH_TWO_PI;
+ }
+ }
}
/*==========================================================================================*/
void PaQa_GenerateCrackDISABLED( float *buffer, int numSamples, int stride )
{
- int i;
- int offset = numSamples/2;
- for( i=0; ibuffer = (float*)malloc(numBytes);
- QA_ASSERT_TRUE( "Allocate recording buffer.", (recording->buffer != NULL) );
- recording->maxFrames = maxFrames; recording->sampleRate = frameRate;
- recording->numFrames = 0;
- return 0;
+ int numBytes = maxFrames * sizeof(float);
+ recording->buffer = (float*)malloc(numBytes);
+ QA_ASSERT_TRUE( "Allocate recording buffer.", (recording->buffer != NULL) );
+ recording->maxFrames = maxFrames; recording->sampleRate = frameRate;
+ recording->numFrames = 0;
+ return 0;
error:
- return 1;
+ return 1;
}
/*==========================================================================================*/
void PaQa_TerminateRecording( PaQaRecording *recording )
-{
- if (recording->buffer != NULL)
- {
- free( recording->buffer );
- recording->buffer = NULL;
- }
- recording->maxFrames = 0;
+{
+ if (recording->buffer != NULL)
+ {
+ free( recording->buffer );
+ recording->buffer = NULL;
+ }
+ recording->maxFrames = 0;
}
/*==========================================================================================*/
int PaQa_WriteRecording( PaQaRecording *recording, float *buffer, int numFrames, int stride )
{
- int i;
- int framesToWrite;
+ int i;
+ int framesToWrite;
float *data = &recording->buffer[recording->numFrames];
framesToWrite = numFrames;
- if ((framesToWrite + recording->numFrames) > recording->maxFrames)
- {
- framesToWrite = recording->maxFrames - recording->numFrames;
- }
-
- for( i=0; inumFrames += framesToWrite;
- return (recording->numFrames >= recording->maxFrames);
+ if ((framesToWrite + recording->numFrames) > recording->maxFrames)
+ {
+ framesToWrite = recording->maxFrames - recording->numFrames;
+ }
+
+ for( i=0; inumFrames += framesToWrite;
+ return (recording->numFrames >= recording->maxFrames);
}
/*==========================================================================================*/
int PaQa_WriteSilence( PaQaRecording *recording, int numFrames )
{
- int i;
- int framesToRecord;
+ int i;
+ int framesToRecord;
float *data = &recording->buffer[recording->numFrames];
framesToRecord = numFrames;
- if ((framesToRecord + recording->numFrames) > recording->maxFrames)
- {
- framesToRecord = recording->maxFrames - recording->numFrames;
- }
-
- for( i=0; inumFrames += framesToRecord;
- return (recording->numFrames >= recording->maxFrames);
+ if ((framesToRecord + recording->numFrames) > recording->maxFrames)
+ {
+ framesToRecord = recording->maxFrames - recording->numFrames;
+ }
+
+ for( i=0; inumFrames += framesToRecord;
+ return (recording->numFrames >= recording->maxFrames);
}
/*==========================================================================================*/
int PaQa_RecordFreeze( PaQaRecording *recording, int numFrames )
{
- int i;
- int framesToRecord;
+ int i;
+ int framesToRecord;
float *data = &recording->buffer[recording->numFrames];
framesToRecord = numFrames;
- if ((framesToRecord + recording->numFrames) > recording->maxFrames)
- {
- framesToRecord = recording->maxFrames - recording->numFrames;
- }
-
- for( i=0; inumFrames += framesToRecord;
- return (recording->numFrames >= recording->maxFrames);
+ if ((framesToRecord + recording->numFrames) > recording->maxFrames)
+ {
+ framesToRecord = recording->maxFrames - recording->numFrames;
+ }
+
+ for( i=0; inumFrames += framesToRecord;
+ return (recording->numFrames >= recording->maxFrames);
}
/*==========================================================================================*/
@@ -209,37 +209,37 @@ int PaQa_SaveRecordingToWaveFile( PaQaRecording *recording, const char *filename
int result = 0;
#define NUM_SAMPLES (200)
short data[NUM_SAMPLES];
- const int samplesPerFrame = 1;
+ const int samplesPerFrame = 1;
int numLeft = recording->numFrames;
- float *buffer = &recording->buffer[0];
+ float *buffer = &recording->buffer[0];
result = Audio_WAV_OpenWriter( &writer, filename, recording->sampleRate, samplesPerFrame );
if( result < 0 ) goto error;
-
- while( numLeft > 0 )
+
+ while( numLeft > 0 )
{
- int i;
+ int i;
int numToSave = (numLeft > NUM_SAMPLES) ? NUM_SAMPLES : numLeft;
- // Convert double samples to shorts.
- for( i=0; i 32767 ) ival = 32767;
- else if( ival < -32768 ) ival = -32768;
- data[i] = ival;
- }
- result = Audio_WAV_WriteShorts( &writer, data, numToSave );
+ // Convert double samples to shorts.
+ for( i=0; i 32767 ) ival = 32767;
+ else if( ival < -32768 ) ival = -32768;
+ data[i] = ival;
+ }
+ result = Audio_WAV_WriteShorts( &writer, data, numToSave );
if( result < 0 ) goto error;
- numLeft -= numToSave;
+ numLeft -= numToSave;
}
-
+
result = Audio_WAV_CloseWriter( &writer );
if( result < 0 ) goto error;
-
+
return 0;
-
+
error:
printf("ERROR: result = %d\n", result );
return result;
@@ -250,29 +250,29 @@ error:
double PaQa_MeasureCrossingSlope( float *buffer, int numFrames )
{
- int i;
- double slopeTotal = 0.0;
- int slopeCount = 0;
- float previous;
- double averageSlope = 0.0;
-
- previous = buffer[0];
- for( i=1; i 0.0) && (previous < 0.0) )
- {
- double delta = current - previous;
- slopeTotal += delta;
- slopeCount += 1;
- }
- previous = current;
- }
- if( slopeCount > 0 )
- {
- averageSlope = slopeTotal / slopeCount;
- }
- return averageSlope;
+ int i;
+ double slopeTotal = 0.0;
+ int slopeCount = 0;
+ float previous;
+ double averageSlope = 0.0;
+
+ previous = buffer[0];
+ for( i=1; i 0.0) && (previous < 0.0) )
+ {
+ double delta = current - previous;
+ slopeTotal += delta;
+ slopeCount += 1;
+ }
+ previous = current;
+ }
+ if( slopeCount > 0 )
+ {
+ averageSlope = slopeTotal / slopeCount;
+ }
+ return averageSlope;
}
/*==========================================================================================*/
@@ -285,63 +285,63 @@ double PaQa_MeasureCrossingSlope( float *buffer, int numFrames )
*
*/
double PaQa_MeasureSineAmplitudeBySlope( PaQaRecording *recording,
- double frequency, double frameRate,
- int startFrame, int numFrames )
+ double frequency, double frameRate,
+ int startFrame, int numFrames )
{
- float *buffer = &recording->buffer[startFrame];
- double measuredSlope = PaQa_MeasureCrossingSlope( buffer, numFrames );
- double unitySlope = sin( MATH_TWO_PI * frequency / frameRate );
- double estimatedAmplitude = measuredSlope / unitySlope;
- return estimatedAmplitude;
+ float *buffer = &recording->buffer[startFrame];
+ double measuredSlope = PaQa_MeasureCrossingSlope( buffer, numFrames );
+ double unitySlope = sin( MATH_TWO_PI * frequency / frameRate );
+ double estimatedAmplitude = measuredSlope / unitySlope;
+ return estimatedAmplitude;
}
/*==========================================================================================*/
double PaQa_CorrelateSine( PaQaRecording *recording, double frequency, double frameRate,
- int startFrame, int numFrames, double *phasePtr )
+ int startFrame, int numFrames, double *phasePtr )
{
- double magnitude = 0.0;
+ double magnitude = 0.0;
int numLeft = numFrames;
- double phase = 0.0;
- double phaseIncrement = 2.0 * MATH_PI * frequency / frameRate;
- double sinAccumulator = 0.0;
- double cosAccumulator = 0.0;
- float *data = &recording->buffer[startFrame];
+ double phase = 0.0;
+ double phaseIncrement = 2.0 * MATH_PI * frequency / frameRate;
+ double sinAccumulator = 0.0;
+ double cosAccumulator = 0.0;
+ float *data = &recording->buffer[startFrame];
QA_ASSERT_TRUE( "startFrame out of bounds", (startFrame < recording->numFrames) );
- QA_ASSERT_TRUE( "numFrames out of bounds", ((startFrame+numFrames) <= recording->numFrames) );
+ QA_ASSERT_TRUE( "numFrames out of bounds", ((startFrame+numFrames) <= recording->numFrames) );
- while( numLeft > 0 )
- {
- double sample = (double) *data++;
- sinAccumulator += sample * sin( phase );
- cosAccumulator += sample * cos( phase );
- phase += phaseIncrement;
- if (phase > MATH_TWO_PI)
- {
- phase -= MATH_TWO_PI;
- }
- numLeft -= 1;
- }
- sinAccumulator = sinAccumulator / numFrames;
- cosAccumulator = cosAccumulator / numFrames;
- // TODO Why do I have to multiply by 2.0? Need it to make result come out right.
- magnitude = 2.0 * sqrt( (sinAccumulator * sinAccumulator) + (cosAccumulator * cosAccumulator ));
- if( phasePtr != NULL )
- {
- double phase = atan2( cosAccumulator, sinAccumulator );
- *phasePtr = phase;
- }
- return magnitude;
+ while( numLeft > 0 )
+ {
+ double sample = (double) *data++;
+ sinAccumulator += sample * sin( phase );
+ cosAccumulator += sample * cos( phase );
+ phase += phaseIncrement;
+ if (phase > MATH_TWO_PI)
+ {
+ phase -= MATH_TWO_PI;
+ }
+ numLeft -= 1;
+ }
+ sinAccumulator = sinAccumulator / numFrames;
+ cosAccumulator = cosAccumulator / numFrames;
+ // TODO Why do I have to multiply by 2.0? Need it to make result come out right.
+ magnitude = 2.0 * sqrt( (sinAccumulator * sinAccumulator) + (cosAccumulator * cosAccumulator ));
+ if( phasePtr != NULL )
+ {
+ double phase = atan2( cosAccumulator, sinAccumulator );
+ *phasePtr = phase;
+ }
+ return magnitude;
error:
- return -1.0;
+ return -1.0;
}
/*==========================================================================================*/
void PaQa_FilterRecording( PaQaRecording *input, PaQaRecording *output, BiquadFilter *filter )
{
- int numToFilter = (input->numFrames > output->maxFrames) ? output->maxFrames : input->numFrames;
- BiquadFilter_Filter( filter, &input->buffer[0], &output->buffer[0], numToFilter );
- output->numFrames = numToFilter;
+ int numToFilter = (input->numFrames > output->maxFrames) ? output->maxFrames : input->numFrames;
+ BiquadFilter_Filter( filter, &input->buffer[0], &output->buffer[0], numToFilter );
+ output->numFrames = numToFilter;
}
/*==========================================================================================*/
@@ -351,92 +351,92 @@ void PaQa_FilterRecording( PaQaRecording *input, PaQaRecording *output, BiquadFi
*/
double PaQa_FindFirstMatch( PaQaRecording *recording, float *buffer, int numFrames, double threshold )
{
- int ic,is;
- // How many buffers will fit in the recording?
- int maxCorrelations = recording->numFrames - numFrames;
- double maxSum = 0.0;
- int peakIndex = -1;
- double inverseMaxSum = 0.0;
- int inversePeakIndex = -1;
- double location = -1.0;
+ int ic,is;
+ // How many buffers will fit in the recording?
+ int maxCorrelations = recording->numFrames - numFrames;
+ double maxSum = 0.0;
+ int peakIndex = -1;
+ double inverseMaxSum = 0.0;
+ int inversePeakIndex = -1;
+ double location = -1.0;
QA_ASSERT_TRUE( "numFrames out of bounds", (numFrames < recording->numFrames) );
- for( ic=0; icbuffer[ ic ];
- for( is=0; is maxSum) )
- {
- maxSum = sum;
- peakIndex = ic;
- }
- if( ((-sum) > inverseMaxSum) )
- {
- inverseMaxSum = -sum;
- inversePeakIndex = ic;
- }
- pastPeak = (maxSum > threshold) && (sum < 0.5*maxSum);
- inversePastPeak = (inverseMaxSum > threshold) && ((-sum) < 0.5*inverseMaxSum);
- //printf("PaQa_FindFirstMatch: ic = %4d, sum = %8f, maxSum = %8f, inverseMaxSum = %8f\n", ic, sum, maxSum, inverseMaxSum );
- if( pastPeak && inversePastPeak )
- {
- if( maxSum > inverseMaxSum )
- {
- location = peakIndex;
- }
- else
- {
- location = inversePeakIndex;
- }
- break;
- }
-
- }
- //printf("PaQa_FindFirstMatch: location = %4d\n", (int)location );
- return location;
+ for( ic=0; icbuffer[ ic ];
+ for( is=0; is maxSum) )
+ {
+ maxSum = sum;
+ peakIndex = ic;
+ }
+ if( ((-sum) > inverseMaxSum) )
+ {
+ inverseMaxSum = -sum;
+ inversePeakIndex = ic;
+ }
+ pastPeak = (maxSum > threshold) && (sum < 0.5*maxSum);
+ inversePastPeak = (inverseMaxSum > threshold) && ((-sum) < 0.5*inverseMaxSum);
+ //printf("PaQa_FindFirstMatch: ic = %4d, sum = %8f, maxSum = %8f, inverseMaxSum = %8f\n", ic, sum, maxSum, inverseMaxSum );
+ if( pastPeak && inversePastPeak )
+ {
+ if( maxSum > inverseMaxSum )
+ {
+ location = peakIndex;
+ }
+ else
+ {
+ location = inversePeakIndex;
+ }
+ break;
+ }
+
+ }
+ //printf("PaQa_FindFirstMatch: location = %4d\n", (int)location );
+ return location;
error:
- return -1.0;
+ return -1.0;
}
/*==========================================================================================*/
// Measure the area under the curve by summing absolute value of each value.
double PaQa_MeasureArea( float *buffer, int numFrames, int stride )
{
- int is;
- double area = 0.0;
- for( is=0; isnumFrames) );
+ QA_ASSERT_TRUE( "startAt+numFrames out of bounds", ((startAt+numFrames) < recording->numFrames) );
{
- double recordedArea = PaQa_MeasureArea( &recording->buffer[startAt], numFrames, 1 );
- double bufferArea = PaQa_MeasureArea( buffer, numFrames, 1 );
- if( bufferArea == 0.0 ) return 100000000.0;
- return recordedArea / bufferArea;
+ double recordedArea = PaQa_MeasureArea( &recording->buffer[startAt], numFrames, 1 );
+ double bufferArea = PaQa_MeasureArea( buffer, numFrames, 1 );
+ if( bufferArea == 0.0 ) return 100000000.0;
+ return recordedArea / bufferArea;
}
error:
- return -1.0;
+ return -1.0;
}
/*==========================================================================================*/
double PaQa_ComputePhaseDifference( double phase1, double phase2 )
{
- double delta = phase1 - phase2;
- while( delta > MATH_PI )
- {
- delta -= MATH_TWO_PI;
- }
- while( delta < -MATH_PI )
- {
- delta += MATH_TWO_PI;
- }
- return delta;
+ double delta = phase1 - phase2;
+ while( delta > MATH_PI )
+ {
+ delta -= MATH_TWO_PI;
+ }
+ while( delta < -MATH_PI )
+ {
+ delta += MATH_TWO_PI;
+ }
+ return delta;
}
/*==========================================================================================*/
int PaQa_MeasureLatency( PaQaRecording *recording, PaQaTestTone *testTone, PaQaAnalysisResult *analysisResult )
{
- double threshold;
- PaQaSineGenerator generator;
+ double threshold;
+ PaQaSineGenerator generator;
#define MAX_BUFFER_SIZE 2048
- float buffer[MAX_BUFFER_SIZE];
- double period = testTone->sampleRate / testTone->frequency;
- int cycleSize = (int) (period + 0.5);
- //printf("PaQa_AnalyseRecording: frequency = %8f, frameRate = %8f, period = %8f, cycleSize = %8d\n",
- // testTone->frequency, testTone->sampleRate, period, cycleSize );
- analysisResult->latency = -1;
- analysisResult->valid = (0);
-
- // Set up generator to find matching first cycle.
- QA_ASSERT_TRUE( "cycleSize out of bounds", (cycleSize < MAX_BUFFER_SIZE) );
- PaQa_SetupSineGenerator( &generator, testTone->frequency, testTone->amplitude, testTone->sampleRate );
- PaQa_EraseBuffer( buffer, cycleSize, testTone->samplesPerFrame );
- PaQa_MixSine( &generator, buffer, cycleSize, testTone->samplesPerFrame );
+ float buffer[MAX_BUFFER_SIZE];
+ double period = testTone->sampleRate / testTone->frequency;
+ int cycleSize = (int) (period + 0.5);
+ //printf("PaQa_AnalyseRecording: frequency = %8f, frameRate = %8f, period = %8f, cycleSize = %8d\n",
+ // testTone->frequency, testTone->sampleRate, period, cycleSize );
+ analysisResult->latency = -1;
+ analysisResult->valid = (0);
- threshold = cycleSize * 0.02;
- analysisResult->latency = PaQa_FindFirstMatch( recording, buffer, cycleSize, threshold );
- QA_ASSERT_TRUE( "Could not find the start of the signal.", (analysisResult->latency >= 0) );
- analysisResult->amplitudeRatio = PaQa_CompareAmplitudes( recording, analysisResult->latency, buffer, cycleSize );
- return 0;
+ // Set up generator to find matching first cycle.
+ QA_ASSERT_TRUE( "cycleSize out of bounds", (cycleSize < MAX_BUFFER_SIZE) );
+ PaQa_SetupSineGenerator( &generator, testTone->frequency, testTone->amplitude, testTone->sampleRate );
+ PaQa_EraseBuffer( buffer, cycleSize, testTone->samplesPerFrame );
+ PaQa_MixSine( &generator, buffer, cycleSize, testTone->samplesPerFrame );
+
+ threshold = cycleSize * 0.02;
+ analysisResult->latency = PaQa_FindFirstMatch( recording, buffer, cycleSize, threshold );
+ QA_ASSERT_TRUE( "Could not find the start of the signal.", (analysisResult->latency >= 0) );
+ analysisResult->amplitudeRatio = PaQa_CompareAmplitudes( recording, analysisResult->latency, buffer, cycleSize );
+ return 0;
error:
- return -1;
+ return -1;
}
/*==========================================================================================*/
// Apply cosine squared window.
void PaQa_FadeInRecording( PaQaRecording *recording, int startFrame, int count )
{
- int is;
- double phase = 0.5 * MATH_PI;
- // Advance a quarter wave
- double phaseIncrement = 0.25 * 2.0 * MATH_PI / count;
-
+ int is;
+ double phase = 0.5 * MATH_PI;
+ // Advance a quarter wave
+ double phaseIncrement = 0.25 * 2.0 * MATH_PI / count;
+
assert( startFrame >= 0 );
- assert( count > 0 );
-
+ assert( count > 0 );
+
/* Zero out initial part of the recording. */
- for( is=0; is