Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
eb7da3f0
Commit
eb7da3f0
authored
Sep 03, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wasapi: do not assume mdate() returns the performance counter
parent
92e270eb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
3 deletions
+35
-3
modules/audio_output/wasapi.c
modules/audio_output/wasapi.c
+35
-3
No files found.
modules/audio_output/wasapi.c
View file @
eb7da3f0
...
...
@@ -26,6 +26,7 @@
#define COBJMACROS
#define CONST_VTABLE
#include <stdlib.h>
#include <assert.h>
#include <audioclient.h>
#include <audiopolicy.h>
...
...
@@ -55,6 +56,36 @@ vlc_module_begin()
set_callbacks
(
Open
,
Close
)
vlc_module_end
()
static
LARGE_INTEGER
freq
;
/* performance counters frequency */
BOOL
WINAPI
DllMain
(
HINSTANCE
,
DWORD
,
LPVOID
);
/* avoid warning */
BOOL
WINAPI
DllMain
(
HINSTANCE
dll
,
DWORD
reason
,
LPVOID
reserved
)
{
(
void
)
dll
;
(
void
)
reserved
;
switch
(
reason
)
{
case
DLL_PROCESS_ATTACH
:
if
(
!
QueryPerformanceFrequency
(
&
freq
))
return
FALSE
;
break
;
}
return
TRUE
;
}
static
UINT64
GetQPC
(
void
)
{
LARGE_INTEGER
counter
;
if
(
!
QueryPerformanceCounter
(
&
counter
))
abort
();
lldiv_t
d
=
lldiv
(
counter
.
QuadPart
,
freq
.
QuadPart
);
return
(
d
.
quot
*
10000000
)
+
((
d
.
rem
*
10000000
)
/
freq
.
QuadPart
);
}
static
int
TryEnter
(
vlc_object_t
*
obj
)
{
HRESULT
hr
=
CoInitializeEx
(
NULL
,
COINIT_MULTITHREADED
);
...
...
@@ -107,12 +138,13 @@ static void Play(audio_output_t *aout, block_t *block, mtime_t *restrict drift)
{
UINT64
pos
,
qpcpos
;
/* NOTE: this assumes mdate() uses QPC() (which it currently does). */
hr
=
IAudioClock_GetPosition
(
sys
->
clock
,
&
pos
,
&
qpcpos
);
if
(
SUCCEEDED
(
hr
))
{
qpcpos
=
(
qpcpos
+
5
)
/
10
;
/* 100ns -> 1µs */
*
drift
=
mdate
()
-
qpcpos
;
qpcpos
=
GetQPC
()
-
qpcpos
;
static_assert
((
10000000
%
CLOCK_FREQ
)
==
0
,
"Frequency conversion broken"
);
*
drift
=
qpcpos
/
(
10000000
/
CLOCK_FREQ
);
}
else
msg_Warn
(
aout
,
"cannot get position (error 0x%lx)"
,
hr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment