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
a8ca319f
Commit
a8ca319f
authored
Jul 19, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sndio: allocate sys structure
parent
c84a18eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 deletions
+26
-17
modules/audio_output/sndio.c
modules/audio_output/sndio.c
+26
-17
No files found.
modules/audio_output/sndio.c
View file @
a8ca319f
...
...
@@ -45,17 +45,27 @@ vlc_module_end ()
static
void
Play
(
audio_output_t
*
,
block_t
*
);
static
void
Pause
(
audio_output_t
*
,
bool
,
mtime_t
);
struct
aout_sys_t
{
struct
sio_hdl
*
hdl
;
};
/** Initializes an sndio playback stream */
static
int
Open
(
vlc_object_t
*
obj
)
{
audio_output_t
*
aout
=
(
audio_output_t
*
)
obj
;
aout_sys_t
*
sys
=
malloc
(
sizeof
(
*
sys
));
if
(
unlikely
(
sys
==
NULL
))
return
VLC_EGENERIC
;
s
truct
sio_hdl
*
sio
=
sio_open
(
NULL
,
SIO_PLAY
,
0
/* blocking */
);
if
(
s
io
==
NULL
)
s
ys
->
hdl
=
sio_open
(
NULL
,
SIO_PLAY
,
0
/* blocking */
);
if
(
s
ys
->
hdl
==
NULL
)
{
msg_Err
(
obj
,
"cannot create audio playback stream"
);
free
(
sys
);
return
VLC_EGENERIC
;
}
aout
->
sys
=
sys
;
struct
sio_par
par
;
sio_initpar
(
&
par
);
...
...
@@ -67,7 +77,7 @@ static int Open (vlc_object_t *obj)
par
.
rate
=
aout
->
format
.
i_rate
;
par
.
xrun
=
SIO_SYNC
;
if
(
!
sio_setpar
(
s
io
,
&
par
)
||
!
sio_getpar
(
sio
,
&
par
))
if
(
!
sio_setpar
(
s
ys
->
hdl
,
&
par
)
||
!
sio_getpar
(
sys
->
hdl
,
&
par
))
{
msg_Err
(
obj
,
"cannot negotiate audio playback parameters"
);
goto
error
;
...
...
@@ -135,36 +145,35 @@ static int Open (vlc_object_t *obj)
aout_FormatPrepare
(
&
f
);
aout
->
format
=
f
;
aout
->
sys
=
(
void
*
)
sio
;
aout
->
sys
=
sys
;
aout
->
pf_play
=
Play
;
aout
->
pf_pause
=
Pause
;
aout
->
pf_flush
=
NULL
;
/* sndio sucks! */
/* TODO: sio_setvol()/sio_onvol() */
aout
->
volume_set
=
NULL
;
aout
->
mute_set
=
NULL
;
sio_start
(
s
io
);
sio_start
(
s
ys
->
hdl
);
return
VLC_SUCCESS
;
error:
sio_close
(
sio
);
Close
(
obj
);
return
VLC_EGENERIC
;
}
static
void
Close
(
vlc_object_t
*
obj
)
{
audio_output_t
*
aout
=
(
audio_output_t
*
)
obj
;
struct
sio_hdl
*
sio
=
(
void
*
)
aout
->
sys
;
aout_sys_t
*
sys
=
aout
->
sys
;
sio_close
(
sio
);
sio_close
(
sys
->
hdl
);
free
(
sys
);
}
static
void
Play
(
audio_output_t
*
aout
,
block_t
*
block
)
{
struct
sio_hdl
*
sio
=
(
void
*
)
aout
->
sys
;
aout_sys_t
*
sys
=
aout
->
sys
;
struct
sio_par
par
;
if
(
sio_getpar
(
s
io
,
&
par
)
==
0
)
if
(
sio_getpar
(
s
ys
->
hdl
,
&
par
)
==
0
)
{
mtime_t
delay
=
par
.
bufsz
*
CLOCK_FREQ
/
aout
->
format
.
i_rate
;
...
...
@@ -172,9 +181,9 @@ static void Play (audio_output_t *aout, block_t *block)
aout_TimeReport
(
aout
,
block
->
i_pts
-
delay
);
}
while
(
block
->
i_buffer
>
0
&&
!
sio_eof
(
s
io
))
while
(
block
->
i_buffer
>
0
&&
!
sio_eof
(
s
ys
->
hdl
))
{
size_t
bytes
=
sio_write
(
s
io
,
block
->
p_buffer
,
block
->
i_buffer
);
size_t
bytes
=
sio_write
(
s
ys
->
hdl
,
block
->
p_buffer
,
block
->
i_buffer
);
block
->
p_buffer
+=
bytes
;
block
->
i_buffer
-=
bytes
;
...
...
@@ -185,11 +194,11 @@ static void Play (audio_output_t *aout, block_t *block)
static
void
Pause
(
audio_output_t
*
aout
,
bool
pause
,
mtime_t
date
)
{
struct
sio_hdl
*
sio
=
(
void
*
)
aout
->
sys
;
aout_sys_t
*
sys
=
aout
->
sys
;
if
(
pause
)
sio_stop
(
s
io
);
sio_stop
(
s
ys
->
hdl
);
else
sio_start
(
s
io
);
sio_start
(
s
ys
->
hdl
);
(
void
)
date
;
}
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