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
f41e5f46
Commit
f41e5f46
authored
Dec 15, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ALSA: deduplicate devices enumeration
parent
35dda100
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
48 deletions
+9
-48
modules/audio_output/alsa.c
modules/audio_output/alsa.c
+9
-48
No files found.
modules/audio_output/alsa.c
View file @
f41e5f46
...
@@ -742,56 +742,11 @@ static void Stop (audio_output_t *aout)
...
@@ -742,56 +742,11 @@ static void Stop (audio_output_t *aout)
* Enumerates ALSA output devices.
* Enumerates ALSA output devices.
*/
*/
static
int
EnumDevices
(
vlc_object_t
*
obj
,
char
const
*
varname
,
static
int
EnumDevices
(
vlc_object_t
*
obj
,
char
const
*
varname
,
char
***
restrict
vp
,
char
***
restrict
t
p
)
char
***
restrict
idp
,
char
***
restrict
name
p
)
{
{
unsigned
n
=
0
;
char
**
names
=
xmalloc
(
sizeof
(
*
names
));
char
**
descs
=
xmalloc
(
sizeof
(
*
names
));
names
[
0
]
=
strdup
(
"default"
);
descs
[
0
]
=
strdup
(
N_
(
"Default"
));
n
++
;
if
(
unlikely
(
names
[
0
]
==
NULL
||
descs
[
0
]
==
NULL
))
abort
();
void
**
hints
;
void
**
hints
;
if
(
snd_device_name_hint
(
-
1
,
"pcm"
,
&
hints
)
<
0
)
return
n
;
for
(
size_t
i
=
0
;
hints
[
i
]
!=
NULL
;
i
++
)
{
void
*
hint
=
hints
[
i
];
char
*
name
=
snd_device_name_get_hint
(
hint
,
"NAME"
);
if
(
unlikely
(
name
==
NULL
))
continue
;
char
*
desc
=
snd_device_name_get_hint
(
hint
,
"DESC"
);
if
(
desc
==
NULL
)
{
free
(
name
);
continue
;
}
names
=
xrealloc
(
names
,
(
n
+
1
)
*
sizeof
(
*
names
));
msg_Dbg
(
obj
,
"Available ALSA PCM devices:"
);
descs
=
xrealloc
(
descs
,
(
n
+
1
)
*
sizeof
(
*
descs
));
names
[
n
]
=
name
;
descs
[
n
]
=
desc
;
n
++
;
}
snd_device_name_free_hint
(
hints
);
(
void
)
obj
;
(
void
)
varname
;
*
vp
=
names
;
*
tp
=
descs
;
return
n
;
}
static
int
DevicesEnum
(
audio_output_t
*
aout
,
char
***
idp
,
char
***
namep
)
{
void
**
hints
;
msg_Dbg
(
aout
,
"Available ALSA PCM devices:"
);
if
(
snd_device_name_hint
(
-
1
,
"pcm"
,
&
hints
)
<
0
)
if
(
snd_device_name_hint
(
-
1
,
"pcm"
,
&
hints
)
<
0
)
return
-
1
;
return
-
1
;
...
@@ -810,7 +765,7 @@ static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep)
...
@@ -810,7 +765,7 @@ static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep)
if
(
desc
!=
NULL
)
if
(
desc
!=
NULL
)
for
(
char
*
lf
=
strchr
(
desc
,
'\n'
);
lf
;
lf
=
strchr
(
lf
,
'\n'
))
for
(
char
*
lf
=
strchr
(
desc
,
'\n'
);
lf
;
lf
=
strchr
(
lf
,
'\n'
))
*
lf
=
' '
;
*
lf
=
' '
;
msg_Dbg
(
aout
,
"%s (%s)"
,
(
desc
!=
NULL
)
?
desc
:
name
,
name
);
msg_Dbg
(
obj
,
"%s (%s)"
,
(
desc
!=
NULL
)
?
desc
:
name
,
name
);
ids
=
xrealloc
(
ids
,
(
n
+
1
)
*
sizeof
(
*
ids
));
ids
=
xrealloc
(
ids
,
(
n
+
1
)
*
sizeof
(
*
ids
));
names
=
xrealloc
(
names
,
(
n
+
1
)
*
sizeof
(
*
names
));
names
=
xrealloc
(
names
,
(
n
+
1
)
*
sizeof
(
*
names
));
...
@@ -822,9 +777,15 @@ static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep)
...
@@ -822,9 +777,15 @@ static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep)
snd_device_name_free_hint
(
hints
);
snd_device_name_free_hint
(
hints
);
*
idp
=
ids
;
*
idp
=
ids
;
*
namep
=
names
;
*
namep
=
names
;
(
void
)
varname
;
return
n
;
return
n
;
}
}
static
int
DevicesEnum
(
audio_output_t
*
aout
,
char
***
idp
,
char
***
namep
)
{
return
EnumDevices
(
VLC_OBJECT
(
aout
),
NULL
,
idp
,
namep
);
}
static
int
DeviceSelect
(
audio_output_t
*
aout
,
const
char
*
id
)
static
int
DeviceSelect
(
audio_output_t
*
aout
,
const
char
*
id
)
{
{
if
(
!
var_Type
(
aout
,
"alsa-audio-device"
))
if
(
!
var_Type
(
aout
,
"alsa-audio-device"
))
...
...
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