Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
8b961dae
Commit
8b961dae
authored
Jul 22, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OSS: add audio-device variable, run-time device selection
parent
e4ed088f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
17 deletions
+56
-17
modules/audio_output/oss.c
modules/audio_output/oss.c
+56
-17
No files found.
modules/audio_output/oss.c
View file @
8b961dae
...
@@ -81,6 +81,17 @@ static int VolumeSync (audio_output_t *);
...
@@ -81,6 +81,17 @@ static int VolumeSync (audio_output_t *);
static
int
VolumeSet
(
audio_output_t
*
,
float
);
static
int
VolumeSet
(
audio_output_t
*
,
float
);
static
int
MuteSet
(
audio_output_t
*
,
bool
);
static
int
MuteSet
(
audio_output_t
*
,
bool
);
static
int
DeviceChanged
(
vlc_object_t
*
obj
,
const
char
*
varname
,
vlc_value_t
prev
,
vlc_value_t
cur
,
void
*
data
)
{
aout_ChannelsRestart
(
obj
,
varname
,
prev
,
cur
,
data
);
if
(
!
var_Type
(
obj
,
"oss-audio-device"
))
var_Create
(
obj
,
"oss-audio-device"
,
VLC_VAR_STRING
);
var_SetString
(
obj
,
"oss-audio-device"
,
cur
.
psz_string
);
return
VLC_SUCCESS
;
}
static
int
Open
(
vlc_object_t
*
obj
)
static
int
Open
(
vlc_object_t
*
obj
)
{
{
audio_output_t
*
aout
=
(
audio_output_t
*
)
obj
;
audio_output_t
*
aout
=
(
audio_output_t
*
)
obj
;
...
@@ -97,10 +108,10 @@ static int Open (vlc_object_t *obj)
...
@@ -97,10 +108,10 @@ static int Open (vlc_object_t *obj)
msg_Dbg
(
aout
,
"using OSS device: %s"
,
device
);
msg_Dbg
(
aout
,
"using OSS device: %s"
,
device
);
int
fd
=
vlc_open
(
device
,
O_WRONLY
);
int
fd
=
vlc_open
(
device
,
O_WRONLY
);
free
(
devicebuf
);
if
(
fd
==
-
1
)
if
(
fd
==
-
1
)
{
{
msg_Err
(
aout
,
"cannot open OSS device: %m"
);
msg_Err
(
aout
,
"cannot open OSS device %s: %m"
,
device
);
free
(
devicebuf
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -239,11 +250,51 @@ static int Open (vlc_object_t *obj)
...
@@ -239,11 +250,51 @@ static int Open (vlc_object_t *obj)
aout
->
mute_set
=
MuteSet
;
aout
->
mute_set
=
MuteSet
;
}
}
}
}
return
0
;
/* Build the devices list */
var_Create
(
aout
,
"audio-device"
,
VLC_VAR_STRING
|
VLC_VAR_HASCHOICE
);
var_SetString
(
aout
,
"audio-device"
,
device
);
var_AddCallback
(
aout
,
"audio-device"
,
DeviceChanged
,
NULL
);
oss_sysinfo
si
;
if
(
ioctl
(
fd
,
SNDCTL_SYSINFO
,
&
si
)
>=
0
)
{
vlc_value_t
val
,
text
;
text
.
psz_string
=
_
(
"Audio Device"
);
var_Change
(
aout
,
"audio-device"
,
VLC_VAR_SETTEXT
,
&
text
,
NULL
);
msg_Dbg
(
aout
,
"using %s version %s (0x%06X) under %s"
,
si
.
product
,
si
.
version
,
si
.
versionnum
,
si
.
license
);
for
(
int
i
=
0
;
i
<
si
.
numaudios
;
i
++
)
{
oss_audioinfo
ai
=
{
.
dev
=
i
};
if
(
ioctl
(
fd
,
SNDCTL_AUDIOINFO
,
&
ai
)
<
0
)
{
msg_Warn
(
aout
,
"cannot get device %d infos: %m"
,
i
);
continue
;
}
if
(
ai
.
caps
&
(
PCM_CAP_HIDDEN
|
PCM_CAP_MODEM
))
continue
;
if
(
!
(
ai
.
caps
&
PCM_CAP_OUTPUT
))
continue
;
if
(
!
ai
.
enabled
)
continue
;
val
.
psz_string
=
ai
.
devnode
;
text
.
psz_string
=
ai
.
name
;
var_Change
(
aout
,
"audio-device"
,
VLC_VAR_ADDCHOICE
,
&
val
,
&
text
);
}
}
free
(
devicebuf
);
return
0
;
error:
error:
close
(
fd
);
free
(
sys
);
free
(
sys
);
close
(
fd
);
free
(
devicebuf
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -256,20 +307,8 @@ static void Close (vlc_object_t *obj)
...
@@ -256,20 +307,8 @@ static void Close (vlc_object_t *obj)
aout_sys_t
*
sys
=
aout
->
sys
;
aout_sys_t
*
sys
=
aout
->
sys
;
int
fd
=
sys
->
fd
;
int
fd
=
sys
->
fd
;
#if 0
var_DelCallback
(
obj
,
"audio-device"
,
DeviceChanged
,
NULL
);
/* FIXME: ugly hack so selected OSS device survives restart */
char *device = var_InheritString (obj, "audio-device");
if (device != NULL)
{
if (!var_Type (obj, "oss-audio-device"))
var_Create (obj, "oss-audio-device", VLC_VAR_STRING);
var_SetString (obj, "oss-audio-device", device);
free (device);
}
var_DelCallback (obj, "audio-device", aout_ChannelsRestart, NULL);
var_Destroy
(
obj
,
"audio-device"
);
var_Destroy
(
obj
,
"audio-device"
);
#endif
ioctl
(
fd
,
SNDCTL_DSP_HALT
,
NULL
);
ioctl
(
fd
,
SNDCTL_DSP_HALT
,
NULL
);
close
(
fd
);
close
(
fd
);
...
...
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