Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
2685a8b2
Commit
2685a8b2
authored
Jun 09, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mixer: cleanup packetization
parent
789f1724
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
44 deletions
+36
-44
src/audio_output/mixer.c
src/audio_output/mixer.c
+36
-44
No files found.
src/audio_output/mixer.c
View file @
2685a8b2
...
@@ -194,18 +194,11 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
...
@@ -194,18 +194,11 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
/* Additionally check that p_first_byte_to_mix is well located. */
/* Additionally check that p_first_byte_to_mix is well located. */
const
unsigned
framesize
=
p_mixer
->
fmt
.
i_bytes_per_frame
;
const
unsigned
framesize
=
p_mixer
->
fmt
.
i_bytes_per_frame
;
mtime_t
i_buffer
=
(
start_date
-
p_buffer
->
i_pts
)
ssize_t
delta
=
(
start_date
-
p_buffer
->
i_pts
)
*
framesize
*
p_mixer
->
fmt
.
i_rate
/
CLOCK_FREQ
;
*
p_mixer
->
fmt
.
i_rate
/
CLOCK_FREQ
;
if
(
delta
!=
0
)
if
(
!
((
i_buffer
+
framesize
>
0
)
&&
(
i_buffer
<
framesize
))
)
msg_Warn
(
p_mixer
,
"mixer start is not output end (%zd)"
,
delta
);
{
if
(
delta
<
0
)
msg_Warn
(
p_mixer
,
"mixer start is not output start (%"
PRId64
")"
,
i_buffer
);
/* Round to the nearest multiple */
i_buffer
/=
p_mixer
->
fmt
.
i_bytes_per_frame
;
i_buffer
*=
p_mixer
->
fmt
.
i_bytes_per_frame
;
if
(
i_buffer
<
0
)
{
{
/* Is it really the best way to do it ? */
/* Is it really the best way to do it ? */
aout_lock_output_fifo
(
p_aout
);
aout_lock_output_fifo
(
p_aout
);
...
@@ -214,12 +207,14 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
...
@@ -214,12 +207,14 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
aout_unlock_output_fifo
(
p_aout
);
aout_unlock_output_fifo
(
p_aout
);
goto
giveup
;
goto
giveup
;
}
}
p_buffer
->
p_buffer
+=
i_buffer
;
if
(
delta
>
0
)
p_buffer
->
i_buffer
-=
i_buffer
;
{
i_buffer
/=
framesize
;
p_buffer
->
i_nb_samples
-=
delta
;
p_buffer
->
i_nb_samples
-=
i_buffer
;
p_buffer
->
i_pts
+=
delta
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
p_buffer
->
i_pts
+=
i_buffer
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
p_buffer
->
i_length
-=
delta
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
p_buffer
->
i_length
-=
i_buffer
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
delta
*=
framesize
;
p_buffer
->
p_buffer
+=
delta
;
p_buffer
->
i_buffer
-=
delta
;
}
}
/* Build packet with adequate number of samples */
/* Build packet with adequate number of samples */
...
@@ -231,28 +226,19 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
...
@@ -231,28 +226,19 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
goto
giveup
;
goto
giveup
;
p_buffer
->
i_nb_samples
=
samples
;
p_buffer
->
i_nb_samples
=
samples
;
for
(
uint8_t
*
p_out
=
p_buffer
->
p_buffer
;;
)
for
(
uint8_t
*
p_out
=
p_buffer
->
p_buffer
;
needed
>
0
;
)
{
{
uint8_t
*
p_in
=
p_fifo
->
p_first
->
p_buffer
;
aout_buffer_t
*
p_inbuf
=
p_fifo
->
p_first
;
size_t
avail
=
p_fifo
->
p_first
->
i_nb_samples
*
framesize
;
if
(
unlikely
(
p_inbuf
==
NULL
)
)
if
(
avail
<
needed
)
{
vlc_memcpy
(
p_out
,
p_in
,
avail
);
needed
-=
avail
;
p_out
+=
avail
;
/* Next buffer */
aout_BufferFree
(
aout_FifoPop
(
p_fifo
)
);
if
(
p_input
->
fifo
.
p_first
==
NULL
)
{
{
msg_Err
(
p_mixer
,
"internal amix error"
);
msg_Err
(
p_mixer
,
"internal amix error"
);
vlc_memset
(
p_out
,
0
,
needed
);
vlc_memset
(
p_out
,
0
,
needed
);
break
;
break
;
}
}
p_in
=
p_fifo
->
p_first
->
p_buffer
;
}
const
uint8_t
*
p_in
=
p_inbuf
->
p_buffer
;
else
size_t
avail
=
p_inbuf
->
i_nb_samples
*
framesize
;
if
(
avail
>
needed
)
{
{
vlc_memcpy
(
p_out
,
p_in
,
needed
);
vlc_memcpy
(
p_out
,
p_in
,
needed
);
p_fifo
->
p_first
->
p_buffer
+=
needed
;
p_fifo
->
p_first
->
p_buffer
+=
needed
;
...
@@ -263,6 +249,12 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
...
@@ -263,6 +249,12 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
p_fifo
->
p_first
->
i_length
-=
needed
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
p_fifo
->
p_first
->
i_length
-=
needed
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
break
;
break
;
}
}
vlc_memcpy
(
p_out
,
p_in
,
avail
);
needed
-=
avail
;
p_out
+=
avail
;
/* Next buffer */
aout_BufferFree
(
aout_FifoPop
(
p_fifo
)
);
}
}
}
}
else
else
...
...
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