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
21f3ef76
Commit
21f3ef76
authored
Oct 31, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input: simplify/inline aout resource handling
parent
1925313d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
78 deletions
+57
-78
src/input/decoder.c
src/input/decoder.c
+4
-4
src/input/resource.c
src/input/resource.c
+46
-72
src/input/resource.h
src/input/resource.h
+7
-2
No files found.
src/input/decoder.c
View file @
21f3ef76
...
...
@@ -2075,7 +2075,7 @@ static void DeleteDecoder( decoder_t * p_dec )
/* TODO: REVISIT gap-less audio */
aout_DecFlush
(
p_owner
->
p_aout
);
aout_DecDelete
(
p_owner
->
p_aout
);
input_resource_
Reques
tAout
(
p_owner
->
p_resource
,
p_owner
->
p_aout
);
input_resource_
Pu
tAout
(
p_owner
->
p_resource
,
p_owner
->
p_aout
);
if
(
p_owner
->
p_input
!=
NULL
)
input_SendEventAout
(
p_owner
->
p_input
);
}
...
...
@@ -2196,7 +2196,7 @@ static block_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
p_owner
->
p_aout
=
NULL
;
vlc_mutex_unlock
(
&
p_owner
->
lock
);
input_resource_
Reques
tAout
(
p_owner
->
p_resource
,
p_aout
);
input_resource_
Pu
tAout
(
p_owner
->
p_resource
,
p_aout
);
}
if
(
p_owner
->
p_aout
==
NULL
)
...
...
@@ -2230,7 +2230,7 @@ static block_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
request_vout
.
p_private
=
p_dec
;
assert
(
p_owner
->
p_aout
==
NULL
);
p_aout
=
input_resource_
RequestAout
(
p_owner
->
p_resource
,
NULL
);
p_aout
=
input_resource_
GetAout
(
p_owner
->
p_resource
);
if
(
p_aout
)
{
aout_FormatPrepare
(
&
format
);
...
...
@@ -2238,7 +2238,7 @@ static block_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
&
p_dec
->
fmt_out
.
audio_replay_gain
,
&
request_vout
)
)
{
input_resource_
Reques
tAout
(
p_owner
->
p_resource
,
p_aout
);
input_resource_
Pu
tAout
(
p_owner
->
p_resource
,
p_aout
);
p_aout
=
NULL
;
}
}
...
...
src/input/resource.c
View file @
21f3ef76
...
...
@@ -325,39 +325,15 @@ exit:
vlc_mutex_unlock
(
&
p_resource
->
lock_hold
);
}
/* */
static
void
DestroyAout
(
input_resource_t
*
p_resource
)
{
if
(
p_resource
->
p_aout
)
{
aout_Destroy
(
p_resource
->
p_aout
);
p_resource
->
p_aout
=
NULL
;
}
}
static
void
ReleaseAout
(
input_resource_t
*
p_resource
,
audio_output_t
*
p_aout
)
{
if
(
likely
(
p_aout
==
p_resource
->
p_aout
)
)
{
assert
(
p_resource
->
b_aout_busy
);
p_resource
->
b_aout_busy
=
false
;
msg_Dbg
(
p_resource
->
p_parent
,
"releasing audio output"
);
vlc_object_release
(
p_aout
);
}
else
{
msg_Dbg
(
p_resource
->
p_parent
,
"destroying extra audio output"
);
aout_Destroy
(
p_aout
);
}
}
static
audio_output_t
*
AllocateAout
(
input_resource_t
*
p_resource
)
/* Audio output */
audio_output_t
*
input_resource_GetAout
(
input_resource_t
*
p_resource
)
{
audio_output_t
*
p_aout
;
if
(
unlikely
(
p_resource
->
b_aout_busy
)
)
vlc_mutex_lock
(
&
p_resource
->
lock
);
if
(
p_resource
->
b_aout_busy
)
{
vlc_mutex_unlock
(
&
p_resource
->
lock
);
msg_Dbg
(
p_resource
->
p_parent
,
"creating extra audio output"
);
return
aout_New
(
p_resource
->
p_parent
);
}
...
...
@@ -367,61 +343,76 @@ static audio_output_t *AllocateAout( input_resource_t *p_resource )
{
msg_Dbg
(
p_resource
->
p_parent
,
"creating audio output"
);
p_aout
=
aout_New
(
p_resource
->
p_parent
);
if
(
unlikely
(
p_aout
==
NULL
)
)
return
NULL
;
}
else
msg_Dbg
(
p_resource
->
p_parent
,
"reusing audio output"
);
if
(
p_aout
!=
NULL
)
{
vlc_mutex_lock
(
&
p_resource
->
lock_hold
);
assert
(
p_resource
->
p_aout
==
NULL
);
p_resource
->
p_aout
=
p_aout
;
vlc_mutex_unlock
(
&
p_resource
->
lock_hold
);
}
else
msg_Dbg
(
p_resource
->
p_parent
,
"recycling audio output"
);
p_resource
->
b_aout_busy
=
true
;
vlc_object_hold
(
p_aout
);
p_resource
->
b_aout_busy
=
true
;
vlc_object_hold
(
p_aout
);
}
vlc_mutex_unlock
(
&
p_resource
->
lock
);
return
p_aout
;
}
static
audio_output_t
*
RequestAout
(
input_resource_t
*
p_resource
,
audio_output_t
*
p_aout
)
void
input_resource_PutAout
(
input_resource_t
*
p_resource
,
audio_output_t
*
p_aout
)
{
vlc_assert_locked
(
&
p_resource
->
lock
);
assert
(
p_aout
!=
NULL
);
if
(
p_aout
)
vlc_mutex_lock
(
&
p_resource
->
lock
);
if
(
p_aout
==
p_resource
->
p_aout
)
{
ReleaseAout
(
p_resource
,
p_aout
);
return
NULL
;
assert
(
p_resource
->
b_aout_busy
);
p_resource
->
b_aout_busy
=
false
;
msg_Dbg
(
p_resource
->
p_parent
,
"keeping audio output"
);
vlc_object_release
(
p_aout
);
p_aout
=
NULL
;
}
return
AllocateAout
(
p_resource
);
else
msg_Dbg
(
p_resource
->
p_parent
,
"destroying extra audio output"
);
vlc_mutex_unlock
(
&
p_resource
->
lock
);
if
(
p_aout
!=
NULL
)
aout_Destroy
(
p_aout
);
}
static
audio_output_t
*
HoldAout
(
input_resource_t
*
p_resource
)
audio_output_t
*
input_resource_
HoldAout
(
input_resource_t
*
p_resource
)
{
vlc_mutex_lock
(
&
p_resource
->
lock_hold
)
;
audio_output_t
*
p_aout
;
audio_output_t
*
p_aout
=
p_resource
->
p_aout
;
vlc_mutex_lock
(
&
p_resource
->
lock_hold
);
p_aout
=
p_resource
->
p_aout
;
if
(
p_aout
)
vlc_object_hold
(
p_aout
);
vlc_mutex_unlock
(
&
p_resource
->
lock_hold
);
return
p_aout
;
}
static
void
TerminateAout
(
input_resource_t
*
p_resource
)
static
void
input_resource_
TerminateAout
(
input_resource_t
*
p_resource
)
{
vlc_mutex_lock
(
&
p_resource
->
lock_hold
)
;
audio_output_t
*
p_aout
;
audio_output_t
*
p_aout
=
p_resource
->
p_aout
;
vlc_mutex_lock
(
&
p_resource
->
lock
);
vlc_mutex_lock
(
&
p_resource
->
lock_hold
);
p_aout
=
p_resource
->
p_aout
;
p_resource
->
p_aout
=
NULL
;
vlc_mutex_unlock
(
&
p_resource
->
lock_hold
);
p_resource
->
b_aout_busy
=
false
;
vlc_mutex_unlock
(
&
p_resource
->
lock
);
if
(
p_aout
)
if
(
p_aout
!=
NULL
)
aout_Destroy
(
p_aout
);
}
/* */
/*
Common
*/
input_resource_t
*
input_resource_New
(
vlc_object_t
*
p_parent
)
{
input_resource_t
*
p_resource
=
calloc
(
1
,
sizeof
(
*
p_resource
)
);
...
...
@@ -442,7 +433,8 @@ void input_resource_Release( input_resource_t *p_resource )
DestroySout
(
p_resource
);
DestroyVout
(
p_resource
);
DestroyAout
(
p_resource
);
if
(
p_resource
->
p_aout
!=
NULL
)
aout_Destroy
(
p_resource
->
p_aout
);
vlc_mutex_destroy
(
&
p_resource
->
lock_hold
);
vlc_mutex_destroy
(
&
p_resource
->
lock
);
...
...
@@ -504,20 +496,6 @@ bool input_resource_HasVout( input_resource_t *p_resource )
return
b_vout
;
}
/* */
audio_output_t
*
input_resource_RequestAout
(
input_resource_t
*
p_resource
,
audio_output_t
*
p_aout
)
{
vlc_mutex_lock
(
&
p_resource
->
lock
);
audio_output_t
*
p_ret
=
RequestAout
(
p_resource
,
p_aout
);
vlc_mutex_unlock
(
&
p_resource
->
lock
);
return
p_ret
;
}
audio_output_t
*
input_resource_HoldAout
(
input_resource_t
*
p_resource
)
{
return
HoldAout
(
p_resource
);
}
/* */
sout_instance_t
*
input_resource_RequestSout
(
input_resource_t
*
p_resource
,
sout_instance_t
*
p_sout
,
const
char
*
psz_sout
)
{
...
...
@@ -535,11 +513,7 @@ void input_resource_TerminateSout( input_resource_t *p_resource )
void
input_resource_Terminate
(
input_resource_t
*
p_resource
)
{
input_resource_TerminateSout
(
p_resource
);
vlc_mutex_lock
(
&
p_resource
->
lock
);
TerminateAout
(
p_resource
);
vlc_mutex_unlock
(
&
p_resource
->
lock
);
input_resource_TerminateAout
(
p_resource
);
input_resource_TerminateVout
(
p_resource
);
}
src/input/resource.h
View file @
21f3ef76
...
...
@@ -37,9 +37,14 @@ void input_resource_SetInput( input_resource_t *, input_thread_t * );
sout_instance_t
*
input_resource_RequestSout
(
input_resource_t
*
,
sout_instance_t
*
,
const
char
*
psz_sout
);
/**
* This function
handles aout reques
t.
* This function
creates or recycles an audio outpu
t.
*/
audio_output_t
*
input_resource_RequestAout
(
input_resource_t
*
,
audio_output_t
*
);
audio_output_t
*
input_resource_GetAout
(
input_resource_t
*
);
/**
* This function retains or destroys an audio output.
*/
void
input_resource_PutAout
(
input_resource_t
*
,
audio_output_t
*
);
/**
* This function returns the current aout if any.
...
...
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