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
45aba72f
Commit
45aba72f
authored
Jun 18, 2009
by
JP Dinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor spatializer initialisation and teardown to use a table and a loop.
parent
9ff188c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
39 deletions
+45
-39
modules/audio_filter/spatializer/spatializer.cpp
modules/audio_filter/spatializer/spatializer.cpp
+45
-39
No files found.
modules/audio_filter/spatializer/spatializer.cpp
View file @
45aba72f
...
@@ -19,9 +19,9 @@
...
@@ -19,9 +19,9 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License
along
*
along with this program; if not, write to the Free Software
*
with this program; if not, write to the Free Software Foundation, Inc.,
*
Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
*****************************************************************************/
/*****************************************************************************
/*****************************************************************************
...
@@ -49,7 +49,7 @@ static void Close( vlc_object_t * );
...
@@ -49,7 +49,7 @@ static void Close( vlc_object_t * );
#define ROOMSIZE_TEXT N_("Room size")
#define ROOMSIZE_TEXT N_("Room size")
#define ROOMSIZE_LONGTEXT N_("Defines the virtual surface of the room" \
#define ROOMSIZE_LONGTEXT N_("Defines the virtual surface of the room" \
"
emulated by the filter." )
"
emulated by the filter." )
#define WIDTH_TEXT N_("Room width")
#define WIDTH_TEXT N_("Room width")
#define WIDTH_LONGTEXT N_("Width of the virtual room")
#define WIDTH_LONGTEXT N_("Width of the virtual room")
...
@@ -97,7 +97,7 @@ public:
...
@@ -97,7 +97,7 @@ public:
{
{
vlc_mutex_lock
(
p_lock
);
vlc_mutex_lock
(
p_lock
);
}
}
virtual
~
CLocker
()
~
CLocker
()
{
{
vlc_mutex_unlock
(
p_lock
);
vlc_mutex_unlock
(
p_lock
);
}
}
...
@@ -105,28 +105,37 @@ private:
...
@@ -105,28 +105,37 @@ private:
vlc_mutex_t
*
p_lock
;
vlc_mutex_t
*
p_lock
;
};
};
static
const
char
*
psz_control_names
[]
=
#define DECLARECB(fn) static int fn (vlc_object_t *,char const *, \
{
vlc_value_t, vlc_value_t, void *)
"spatializer-roomsize"
,
"spatializer-width"
,
DECLARECB
(
RoomCallback
);
"spatializer-wet"
,
"spatializer-dry"
,
"spatializer-damp"
DECLARECB
(
WetCallback
);
DECLARECB
(
DryCallback
);
DECLARECB
(
DampCallback
);
DECLARECB
(
WidthCallback
);
#undef DECLARECB
struct
callback_s
{
const
char
*
psz_name
;
int
(
*
fp_callback
)(
vlc_object_t
*
,
const
char
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
void
(
revmodel
::*
fp_set
)(
float
);
};
};
static
const
callback_s
callbacks
[]
=
{
{
"spatializer-roomsize"
,
RoomCallback
,
&
revmodel
::
setroomsize
},
{
"spatializer-width"
,
WidthCallback
,
&
revmodel
::
setwidth
},
{
"spatializer-wet"
,
WetCallback
,
&
revmodel
::
setwet
},
{
"spatializer-dry"
,
DryCallback
,
&
revmodel
::
setdry
},
{
"spatializer-damp"
,
DampCallback
,
&
revmodel
::
setdamp
}
};
enum
{
num_callbacks
=
sizeof
(
callbacks
)
/
sizeof
(
callback_s
)
};
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
aout_buffer_t
*
,
aout_buffer_t
*
);
static
void
SpatFilter
(
aout_instance_t
*
,
aout_filter_t
*
,
float
*
,
float
*
,
static
void
SpatFilter
(
aout_instance_t
*
,
aout_filter_t
*
,
float
*
,
float
*
,
int
,
int
);
int
,
int
);
static
int
RoomCallback
(
vlc_object_t
*
,
char
const
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
static
int
WetCallback
(
vlc_object_t
*
,
char
const
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
static
int
DryCallback
(
vlc_object_t
*
,
char
const
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
static
int
DampCallback
(
vlc_object_t
*
,
char
const
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
static
int
WidthCallback
(
vlc_object_t
*
,
char
const
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
/*****************************************************************************
/*****************************************************************************
* Open:
* Open:
...
@@ -135,8 +144,8 @@ static int Open( vlc_object_t *p_this )
...
@@ -135,8 +144,8 @@ static int Open( vlc_object_t *p_this )
{
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
aout_filter_sys_t
*
p_sys
;
aout_filter_sys_t
*
p_sys
;
aout_instance_t
*
p_aout
=
(
aout_instance_t
*
)
p_filter
->
p_parent
;
aout_instance_t
*
p_aout
=
(
aout_instance_t
*
)
p_filter
->
p_parent
;
bool
b_fit
=
true
;
bool
b_fit
=
true
;
msg_Dbg
(
p_this
,
"Opening filter spatializer"
);
msg_Dbg
(
p_this
,
"Opening filter spatializer"
);
if
(
p_filter
->
input
.
i_format
!=
VLC_CODEC_FL32
||
if
(
p_filter
->
input
.
i_format
!=
VLC_CODEC_FL32
||
...
@@ -170,20 +179,17 @@ static int Open( vlc_object_t *p_this )
...
@@ -170,20 +179,17 @@ static int Open( vlc_object_t *p_this )
vlc_mutex_init
(
&
p_sys
->
lock
);
vlc_mutex_init
(
&
p_sys
->
lock
);
/* Init the variables */
/* Init the variables */
/* Add the callbacks */
p_sys
->
p_reverbm
=
new
revmodel
();
p_sys
->
p_reverbm
=
new
revmodel
();
p_sys
->
p_reverbm
->
setroomsize
(
var_CreateGetFloatCommand
(
p_aout
,
psz_control_names
[
0
]
)
);
p_sys
->
p_reverbm
->
setwidth
(
var_CreateGetFloatCommand
(
p_aout
,
psz_control_names
[
1
]
)
);
for
(
unsigned
i
=
0
;
i
<
num_callbacks
;
++
i
)
p_sys
->
p_reverbm
->
setwet
(
var_CreateGetFloatCommand
(
p_aout
,
psz_control_names
[
2
]
)
);
{
p_sys
->
p_reverbm
->
setdry
(
var_CreateGetFloatCommand
(
p_aout
,
psz_control_names
[
3
]
)
);
/* NOTE: C++ pointer-to-member function call from table lookup. */
p_sys
->
p_reverbm
->
setdamp
(
var_CreateGetFloatCommand
(
p_aout
,
psz_control_names
[
4
]
));
(
p_sys
->
p_reverbm
->*
(
callbacks
[
i
].
fp_set
))
(
var_CreateGetFloatCommand
(
p_aout
,
callbacks
[
i
].
psz_name
));
/* Add the callbacks */
var_AddCallback
(
p_aout
,
callbacks
[
i
].
psz_name
,
var_AddCallback
(
p_aout
,
psz_control_names
[
0
],
RoomCallback
,
p_sys
);
callbacks
[
i
].
fp_callback
,
p_sys
);
var_AddCallback
(
p_aout
,
psz_control_names
[
1
],
WidthCallback
,
p_sys
);
}
var_AddCallback
(
p_aout
,
psz_control_names
[
2
],
WetCallback
,
p_sys
);
var_AddCallback
(
p_aout
,
psz_control_names
[
3
],
DryCallback
,
p_sys
);
var_AddCallback
(
p_aout
,
psz_control_names
[
4
],
DampCallback
,
p_sys
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -198,11 +204,11 @@ static void Close( vlc_object_t *p_this )
...
@@ -198,11 +204,11 @@ static void Close( vlc_object_t *p_this )
aout_instance_t
*
p_aout
=
(
aout_instance_t
*
)
p_filter
->
p_parent
;
aout_instance_t
*
p_aout
=
(
aout_instance_t
*
)
p_filter
->
p_parent
;
/* Delete the callbacks */
/* Delete the callbacks */
var_DelCallback
(
p_aout
,
psz_control_names
[
0
],
RoomCallback
,
p_sys
);
for
(
unsigned
i
=
0
;
i
<
num_callbacks
;
++
i
)
var_DelCallback
(
p_aout
,
psz_control_names
[
1
],
WidthCallback
,
p_sys
);
{
var_DelCallback
(
p_aout
,
psz_control_names
[
2
],
WetCallback
,
p_sys
);
var_DelCallback
(
p_aout
,
callbacks
[
i
].
psz_name
,
var_DelCallback
(
p_aout
,
psz_control_names
[
3
],
DryC
allback
,
p_sys
);
callbacks
[
i
].
fp_c
allback
,
p_sys
);
var_DelCallback
(
p_aout
,
psz_control_names
[
4
],
DampCallback
,
p_sys
);
}
delete
p_sys
->
p_reverbm
;
delete
p_sys
->
p_reverbm
;
vlc_mutex_destroy
(
&
p_sys
->
lock
);
vlc_mutex_destroy
(
&
p_sys
->
lock
);
...
...
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