Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
de5be62d
Commit
de5be62d
authored
Oct 18, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter/route: allocate "sources" statically
Worst-case allocation using MAX_CHANNELS.
parent
b5f608d0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
14 deletions
+6
-14
RouteFilterPlugin.cxx
src/filter/RouteFilterPlugin.cxx
+6
-14
No files found.
src/filter/RouteFilterPlugin.cxx
View file @
de5be62d
...
...
@@ -52,6 +52,8 @@
#include <glib.h>
#include <algorithm>
#include <assert.h>
#include <string.h>
#include <stdint.h>
...
...
@@ -77,7 +79,7 @@ class RouteFilter final : public Filter {
* a corresponding input channel from which to take the
* data. A -1 means "no source"
*/
int8_t
*
sources
;
int8_t
sources
[
MAX_CHANNELS
]
;
/**
* The actual input format of our signal, once opened
...
...
@@ -107,11 +109,6 @@ class RouteFilter final : public Filter {
PcmBuffer
output_buffer
;
public
:
RouteFilter
()
:
sources
(
nullptr
)
{}
~
RouteFilter
()
{
g_free
(
sources
);
}
/**
* Parse the "routes" section, a string on the form
* a>b, c>d, e>f, ...
...
...
@@ -135,7 +132,7 @@ RouteFilter::Configure(const config_param ¶m, Error &error) {
/* TODO:
* With a more clever way of marking "don't copy to output N",
* This could easily be merged into a single loop with some
* dynamic
g_realloc() instead of one count run and one g_
malloc().
* dynamic
realloc() instead of one count run and one
malloc().
*/
gchar
**
tokens
;
...
...
@@ -144,6 +141,8 @@ RouteFilter::Configure(const config_param ¶m, Error &error) {
// A cowardly default, just passthrough stereo
const
char
*
const
routes
=
param
.
GetBlockValue
(
"routes"
,
"0>0, 1>1"
);
std
::
fill_n
(
sources
,
MAX_CHANNELS
,
-
1
);
min_input_channels
=
0
;
min_output_channels
=
0
;
...
...
@@ -191,13 +190,6 @@ RouteFilter::Configure(const config_param ¶m, Error &error) {
return
false
;
}
// Allocate a map of "copy nothing to me"
sources
=
(
int8_t
*
)
g_malloc
(
min_output_channels
*
sizeof
(
*
sources
));
for
(
unsigned
i
=
0
;
i
<
min_output_channels
;
++
i
)
sources
[
i
]
=
-
1
;
// Run through the spec again, and save the
// actual mapping output <- input
for
(
int
c
=
0
;
c
<
number_of_copies
;
++
c
)
{
...
...
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