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
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 )
...
@@ -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. */
/* 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
")"
,
/* Is it really the best way to do it ? */
i_buffer
);
aout_lock_output_fifo
(
p_aout
);
aout_FifoSet
(
&
p_aout
->
output
.
fifo
,
0
);
/* Round to the nearest multiple */
date_Set
(
&
exact_start_date
,
0
);
i_buffer
/=
p_mixer
->
fmt
.
i_bytes_per_frame
;
aout_unlock_output_fifo
(
p_aout
);
i_buffer
*=
p_mixer
->
fmt
.
i_bytes_per_frame
;
goto
giveup
;
if
(
i_buffer
<
0
)
}
{
if
(
delta
>
0
)
/* Is it really the best way to do it ? */
{
aout_lock_output_fifo
(
p_aout
);
p_buffer
->
i_nb_samples
-=
delta
;
aout_FifoSet
(
&
p_aout
->
output
.
fifo
,
0
);
p_buffer
->
i_pts
+=
delta
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
date_Set
(
&
exact_start_date
,
0
);
p_buffer
->
i_length
-=
delta
*
CLOCK_FREQ
/
p_mixer
->
fmt
.
i_rate
;
aout_unlock_output_fifo
(
p_aout
);
delta
*=
framesize
;
goto
giveup
;
p_buffer
->
p_buffer
+=
delta
;
}
p_buffer
->
i_buffer
-=
delta
;
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
;
}
}
/* 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
);
msg_Err
(
p_mixer
,
"internal amix error"
);
needed
-=
avail
;
vlc_memset
(
p_out
,
0
,
needed
);
p_out
+=
avail
;
break
;
/* 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
;
}
}
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
);
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