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
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
Hide 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,32 +194,27 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
/* Additionally check that p_first_byte_to_mix is well located. */
const
unsigned
framesize
=
p_mixer
->
fmt
.
i_bytes_per_frame
;
mtime_t
i_buffer
=
(
start_date
-
p_buffer
->
i_pts
)
*
framesize
*
p_mixer
->
fmt
.
i_rate
/
CLOCK_FREQ
;
if
(
!
((
i_buffer
+
framesize
>
0
)
&&
(
i_buffer
<
framesize
))
)
ssize_t
delta
=
(
start_date
-
p_buffer
->
i_pts
)
*
p_mixer
->
fmt
.
i_rate
/
CLOCK_FREQ
;
if
(
delta
!=
0
)
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 ? */
aout_lock_output_fifo
(
p_aout
);
aout_FifoSet
(
&
p_aout
->
output
.
fifo
,
0
);
date_Set
(
&
exact_start_date
,
0
);
aout_unlock_output_fifo
(
p_aout
);
goto
giveup
;
}
p_buffer
->
p_buffer
+=
i_buffer
;
p_buffer
->
i_buffer
-=
i_buffer
;
i_buffer
/=
framesize
;
p_buffer
->
i_nb_samples
-=
i_buffer
;
p_buffer
->
i_pts
+=
i_buffer
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
p_buffer
->
i_length
-=
i_buffer
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
/* Is it really the best way to do it ? */
aout_lock_output_fifo
(
p_aout
);
aout_FifoSet
(
&
p_aout
->
output
.
fifo
,
0
);
date_Set
(
&
exact_start_date
,
0
);
aout_unlock_output_fifo
(
p_aout
);
goto
giveup
;
}
if
(
delta
>
0
)
{
p_buffer
->
i_nb_samples
-=
delta
;
p_buffer
->
i_pts
+=
delta
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
p_buffer
->
i_length
-=
delta
*
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 */
...
...
@@ -231,28 +226,19 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
goto
giveup
;
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
;
size_t
avail
=
p_fifo
->
p_first
->
i_nb_samples
*
framesize
;
if
(
avail
<
needed
)
aout_buffer_t
*
p_inbuf
=
p_fifo
->
p_first
;
if
(
unlikely
(
p_inbuf
==
NULL
)
)
{
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"
);
vlc_memset
(
p_out
,
0
,
needed
);
break
;
}
p_in
=
p_fifo
->
p_first
->
p_buffer
;
msg_Err
(
p_mixer
,
"internal amix error"
);
vlc_memset
(
p_out
,
0
,
needed
);
break
;
}
else
const
uint8_t
*
p_in
=
p_inbuf
->
p_buffer
;
size_t
avail
=
p_inbuf
->
i_nb_samples
*
framesize
;
if
(
avail
>
needed
)
{
vlc_memcpy
(
p_out
,
p_in
,
needed
);
p_fifo
->
p_first
->
p_buffer
+=
needed
;
...
...
@@ -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
;
break
;
}
vlc_memcpy
(
p_out
,
p_in
,
avail
);
needed
-=
avail
;
p_out
+=
avail
;
/* Next buffer */
aout_BufferFree
(
aout_FifoPop
(
p_fifo
)
);
}
}
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