Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
6809bd99
Commit
6809bd99
authored
Jul 24, 2013
by
Ludovic Fauvet
Committed by
Jean-Baptiste Kempf
Jul 25, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directsound: clear the ring buffer ahead of the write pointer (fix #8860)
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
a80fee5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
4 deletions
+27
-4
modules/audio_output/directx.c
modules/audio_output/directx.c
+27
-4
No files found.
modules/audio_output/directx.c
View file @
6809bd99
...
...
@@ -669,13 +669,26 @@ static int FillBuffer( audio_output_t *p_aout, block_t *p_buffer )
size_t
towrite
=
(
p_buffer
)
?
p_buffer
->
i_buffer
:
DS_BUF_SIZE
;
void
*
p_write_position
,
*
p_wrap_around
;
unsigned
long
l_bytes1
,
l_bytes2
;
uint32_t
i_read
;
size_t
i_size
;
mtime_t
i_buf
;
HRESULT
dsresult
;
if
(
IDirectSoundBuffer_GetCurrentPosition
(
p_aout
->
sys
->
p_dsbuffer
,
(
LPDWORD
)
&
i_read
,
NULL
)
==
DS_OK
)
{
/* Compute the outer interval between the write and read pointers within the ring buffer */
i_buf
=
(
mtime_t
)
p_aout
->
sys
->
i_write
-
(
mtime_t
)
i_read
;
if
(
i_buf
<=
0
)
i_buf
+=
DS_BUF_SIZE
;
}
else
i_buf
=
towrite
;
/* Before copying anything, we have to lock the buffer */
dsresult
=
IDirectSoundBuffer_Lock
(
p_sys
->
p_dsbuffer
,
/* DS buffer */
p_aout
->
sys
->
i_write
,
/* Start offset */
towrite
,
/* Number of bytes */
i_buf
,
/* Number of bytes */
&
p_write_position
,
/* Address of lock start */
&
l_bytes1
,
/* Count of bytes locked before wrap around */
&
p_wrap_around
,
/* Buffer address (if wrap around) */
...
...
@@ -687,7 +700,7 @@ static int FillBuffer( audio_output_t *p_aout, block_t *p_buffer )
dsresult
=
IDirectSoundBuffer_Lock
(
p_sys
->
p_dsbuffer
,
p_aout
->
sys
->
i_write
,
towrite
,
i_buf
,
&
p_write_position
,
&
l_bytes1
,
&
p_wrap_around
,
...
...
@@ -714,9 +727,19 @@ static int FillBuffer( audio_output_t *p_aout, block_t *p_buffer )
p_sys
->
chans_to_reorder
,
p_sys
->
chan_table
,
p_sys
->
format
);
memcpy
(
p_write_position
,
p_buffer
->
p_buffer
,
l_bytes1
);
i_size
=
(
p_buffer
->
i_buffer
<
l_bytes1
)
?
p_buffer
->
i_buffer
:
l_bytes1
;
memcpy
(
p_write_position
,
p_buffer
->
p_buffer
,
i_size
);
memset
(
(
uint8_t
*
)
p_write_position
+
i_size
,
0
,
l_bytes1
-
i_size
);
if
(
l_bytes1
<
p_buffer
->
i_buffer
)
memcpy
(
p_wrap_around
,
p_buffer
->
p_buffer
+
l_bytes1
,
l_bytes2
);
{
/* Compute the remaining buffer space to be written */
i_buf
=
i_buf
-
i_size
-
(
l_bytes1
-
i_size
);
i_size
=
(
p_buffer
->
i_buffer
-
l_bytes1
<
l_bytes2
)
?
p_buffer
->
i_buffer
-
l_bytes1
:
l_bytes2
;
memcpy
(
p_wrap_around
,
p_buffer
->
p_buffer
+
l_bytes1
,
i_size
);
memset
(
(
uint8_t
*
)
p_wrap_around
+
i_size
,
0
,
i_buf
-
i_size
);
}
block_Release
(
p_buffer
);
}
...
...
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