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
22aae046
Commit
22aae046
authored
Sep 02, 2004
by
Gildas Bazin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* src/input/demux.c: ignore STREAM_CONTROL_ACCESS control query + coding style changes.
parent
d07df552
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
52 deletions
+41
-52
src/input/demux.c
src/input/demux.c
+41
-52
No files found.
src/input/demux.c
View file @
22aae046
...
@@ -119,13 +119,15 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
...
@@ -119,13 +119,15 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
{
{
p_demux
->
p_module
=
p_demux
->
p_module
=
module_Need
(
p_demux
,
"demux2"
,
psz_module
,
module_Need
(
p_demux
,
"demux2"
,
psz_module
,
!
strcmp
(
psz_module
,
p_demux
->
psz_demux
)
?
VLC_TRUE
:
VLC_FALSE
);
!
strcmp
(
psz_module
,
p_demux
->
psz_demux
)
?
VLC_TRUE
:
VLC_FALSE
);
}
}
else
else
{
{
p_demux
->
p_module
=
p_demux
->
p_module
=
module_Need
(
p_demux
,
"access_demux"
,
psz_module
,
module_Need
(
p_demux
,
"access_demux"
,
psz_module
,
!
strcmp
(
psz_module
,
p_demux
->
psz_access
)
?
VLC_TRUE
:
VLC_FALSE
);
!
strcmp
(
psz_module
,
p_demux
->
psz_access
)
?
VLC_TRUE
:
VLC_FALSE
);
}
}
if
(
p_demux
->
p_module
==
NULL
)
if
(
p_demux
->
p_module
==
NULL
)
...
@@ -261,6 +263,7 @@ typedef struct
...
@@ -261,6 +263,7 @@ typedef struct
char
*
psz_name
;
char
*
psz_name
;
es_out_t
*
out
;
es_out_t
*
out
;
demux_t
*
p_demux
;
demux_t
*
p_demux
;
}
d_stream_sys_t
;
}
d_stream_sys_t
;
static
int
DStreamRead
(
stream_t
*
,
void
*
p_read
,
int
i_read
);
static
int
DStreamRead
(
stream_t
*
,
void
*
p_read
,
int
i_read
);
...
@@ -269,16 +272,14 @@ static int DStreamControl( stream_t *, int i_query, va_list );
...
@@ -269,16 +272,14 @@ static int DStreamControl( stream_t *, int i_query, va_list );
static
int
DStreamThread
(
stream_t
*
);
static
int
DStreamThread
(
stream_t
*
);
stream_t
*
__stream_DemuxNew
(
vlc_object_t
*
p_obj
,
char
*
psz_demux
,
es_out_t
*
out
)
stream_t
*
__stream_DemuxNew
(
vlc_object_t
*
p_obj
,
char
*
psz_demux
,
es_out_t
*
out
)
{
{
/* We create a stream reader, and launch a thread */
/* We create a stream reader, and launch a thread */
stream_t
*
s
;
stream_t
*
s
;
d_stream_sys_t
*
p_sys
;
d_stream_sys_t
*
p_sys
;
if
(
psz_demux
==
NULL
||
*
psz_demux
==
'\0'
)
if
(
psz_demux
==
NULL
||
*
psz_demux
==
'\0'
)
return
NULL
;
{
return
NULL
;
}
s
=
vlc_object_create
(
p_obj
,
VLC_OBJECT_STREAM
);
s
=
vlc_object_create
(
p_obj
,
VLC_OBJECT_STREAM
);
s
->
pf_block
=
NULL
;
s
->
pf_block
=
NULL
;
...
@@ -298,7 +299,8 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, char *psz_demux, es_out_t *out
...
@@ -298,7 +299,8 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, char *psz_demux, es_out_t *out
p_sys
->
out
=
out
;
p_sys
->
out
=
out
;
p_sys
->
p_demux
=
NULL
;
p_sys
->
p_demux
=
NULL
;
if
(
vlc_thread_create
(
s
,
"stream out"
,
DStreamThread
,
VLC_THREAD_PRIORITY_INPUT
,
VLC_FALSE
)
)
if
(
vlc_thread_create
(
s
,
"stream out"
,
DStreamThread
,
VLC_THREAD_PRIORITY_INPUT
,
VLC_FALSE
)
)
{
{
vlc_mutex_destroy
(
&
p_sys
->
lock
);
vlc_mutex_destroy
(
&
p_sys
->
lock
);
vlc_object_destroy
(
s
);
vlc_object_destroy
(
s
);
...
@@ -309,13 +311,14 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, char *psz_demux, es_out_t *out
...
@@ -309,13 +311,14 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, char *psz_demux, es_out_t *out
return
s
;
return
s
;
}
}
void
stream_DemuxSend
(
stream_t
*
s
,
block_t
*
p_block
)
void
stream_DemuxSend
(
stream_t
*
s
,
block_t
*
p_block
)
{
{
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
if
(
p_block
->
i_buffer
>
0
)
if
(
p_block
->
i_buffer
>
0
)
{
{
vlc_mutex_lock
(
&
p_sys
->
lock
);
vlc_mutex_lock
(
&
p_sys
->
lock
);
/* Realloc if needed */
/* Realloc if needed */
if
(
p_sys
->
i_buffer
+
p_block
->
i_buffer
>
p_sys
->
i_buffer_size
)
if
(
p_sys
->
i_buffer
+
p_block
->
i_buffer
>
p_sys
->
i_buffer_size
)
{
{
...
@@ -330,11 +333,13 @@ void stream_DemuxSend( stream_t *s, block_t *p_block )
...
@@ -330,11 +333,13 @@ void stream_DemuxSend( stream_t *s, block_t *p_block )
p_sys
->
i_buffer_size
+=
p_block
->
i_buffer
;
p_sys
->
i_buffer_size
+=
p_block
->
i_buffer
;
/* FIXME won't work with PEEK -> segfault */
/* FIXME won't work with PEEK -> segfault */
p_sys
->
p_buffer
=
realloc
(
p_sys
->
p_buffer
,
p_sys
->
i_buffer_size
);
p_sys
->
p_buffer
=
realloc
(
p_sys
->
p_buffer
,
p_sys
->
i_buffer_size
);
msg_Dbg
(
s
,
"stream_DemuxSend: realloc to %d"
,
p_sys
->
i_buffer_size
);
msg_Dbg
(
s
,
"stream_DemuxSend: realloc to %d"
,
p_sys
->
i_buffer_size
);
}
}
/* copy data */
/* copy data */
memcpy
(
&
p_sys
->
p_buffer
[
p_sys
->
i_buffer
],
p_block
->
p_buffer
,
p_block
->
i_buffer
);
memcpy
(
&
p_sys
->
p_buffer
[
p_sys
->
i_buffer
],
p_block
->
p_buffer
,
p_block
->
i_buffer
);
p_sys
->
i_buffer
+=
p_block
->
i_buffer
;
p_sys
->
i_buffer
+=
p_block
->
i_buffer
;
vlc_mutex_unlock
(
&
p_sys
->
lock
);
vlc_mutex_unlock
(
&
p_sys
->
lock
);
...
@@ -343,25 +348,19 @@ void stream_DemuxSend( stream_t *s, block_t *p_block )
...
@@ -343,25 +348,19 @@ void stream_DemuxSend( stream_t *s, block_t *p_block )
block_Release
(
p_block
);
block_Release
(
p_block
);
}
}
void
stream_DemuxDelete
(
stream_t
*
s
)
void
stream_DemuxDelete
(
stream_t
*
s
)
{
{
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
s
->
b_die
=
VLC_TRUE
;
s
->
b_die
=
VLC_TRUE
;
vlc_mutex_lock
(
&
p_sys
->
lock
);
vlc_mutex_lock
(
&
p_sys
->
lock
);
if
(
p_sys
->
p_demux
)
if
(
p_sys
->
p_demux
)
p_sys
->
p_demux
->
b_die
=
VLC_TRUE
;
{
p_sys
->
p_demux
->
b_die
=
VLC_TRUE
;
}
vlc_mutex_unlock
(
&
p_sys
->
lock
);
vlc_mutex_unlock
(
&
p_sys
->
lock
);
vlc_thread_join
(
s
);
vlc_thread_join
(
s
);
if
(
p_sys
->
p_demux
)
if
(
p_sys
->
p_demux
)
demux2_Delete
(
p_sys
->
p_demux
);
{
demux2_Delete
(
p_sys
->
p_demux
);
}
vlc_mutex_destroy
(
&
p_sys
->
lock
);
vlc_mutex_destroy
(
&
p_sys
->
lock
);
free
(
p_sys
->
psz_name
);
free
(
p_sys
->
psz_name
);
free
(
p_sys
->
p_buffer
);
free
(
p_sys
->
p_buffer
);
...
@@ -370,20 +369,17 @@ void stream_DemuxDelete( stream_t *s )
...
@@ -370,20 +369,17 @@ void stream_DemuxDelete( stream_t *s )
}
}
static
int
DStreamRead
(
stream_t
*
s
,
void
*
p_read
,
int
i_read
)
static
int
DStreamRead
(
stream_t
*
s
,
void
*
p_read
,
int
i_read
)
{
{
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
int
i_copy
;
int
i_copy
;
//msg_Dbg( s, "DStreamRead: wanted %d bytes", i_read );
//msg_Dbg( s, "DStreamRead: wanted %d bytes", i_read );
for
(
;;
)
for
(
;;
)
{
{
vlc_mutex_lock
(
&
p_sys
->
lock
);
vlc_mutex_lock
(
&
p_sys
->
lock
);
//msg_Dbg( s, "DStreamRead: buffer %d", p_sys->i_buffer );
//msg_Dbg( s, "DStreamRead: buffer %d", p_sys->i_buffer );
if
(
p_sys
->
i_buffer
>=
i_read
||
s
->
b_die
)
if
(
p_sys
->
i_buffer
>=
i_read
||
s
->
b_die
)
break
;
{
break
;
}
vlc_mutex_unlock
(
&
p_sys
->
lock
);
vlc_mutex_unlock
(
&
p_sys
->
lock
);
msleep
(
10000
);
msleep
(
10000
);
}
}
...
@@ -393,37 +389,33 @@ static int DStreamRead ( stream_t *s, void *p_read, int i_read )
...
@@ -393,37 +389,33 @@ static int DStreamRead ( stream_t *s, void *p_read, int i_read )
i_copy
=
__MIN
(
i_read
,
p_sys
->
i_buffer
);
i_copy
=
__MIN
(
i_read
,
p_sys
->
i_buffer
);
if
(
i_copy
>
0
)
if
(
i_copy
>
0
)
{
{
if
(
p_read
)
if
(
p_read
)
memcpy
(
p_read
,
p_sys
->
p_buffer
,
i_copy
);
{
memcpy
(
p_read
,
p_sys
->
p_buffer
,
i_copy
);
}
p_sys
->
i_buffer
-=
i_copy
;
p_sys
->
i_buffer
-=
i_copy
;
p_sys
->
i_pos
+=
i_copy
;
p_sys
->
i_pos
+=
i_copy
;
if
(
p_sys
->
i_buffer
>
0
)
if
(
p_sys
->
i_buffer
>
0
)
{
{
memmove
(
p_sys
->
p_buffer
,
&
p_sys
->
p_buffer
[
i_copy
],
p_sys
->
i_buffer
);
memmove
(
p_sys
->
p_buffer
,
&
p_sys
->
p_buffer
[
i_copy
],
p_sys
->
i_buffer
);
}
}
}
}
vlc_mutex_unlock
(
&
p_sys
->
lock
);
vlc_mutex_unlock
(
&
p_sys
->
lock
);
return
i_copy
;
return
i_copy
;
}
}
static
int
DStreamPeek
(
stream_t
*
s
,
uint8_t
**
pp_peek
,
int
i_peek
)
static
int
DStreamPeek
(
stream_t
*
s
,
uint8_t
**
pp_peek
,
int
i_peek
)
{
{
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
int
i_copy
;
int
i_copy
;
//msg_Dbg( s, "DStreamPeek: wanted %d bytes", i_peek );
//msg_Dbg( s, "DStreamPeek: wanted %d bytes", i_peek );
for
(
;;
)
for
(
;;
)
{
{
vlc_mutex_lock
(
&
p_sys
->
lock
);
vlc_mutex_lock
(
&
p_sys
->
lock
);
//msg_Dbg( s, "DStreamPeek: buffer %d", p_sys->i_buffer );
//msg_Dbg( s, "DStreamPeek: buffer %d", p_sys->i_buffer );
if
(
p_sys
->
i_buffer
>=
i_peek
||
s
->
b_die
)
if
(
p_sys
->
i_buffer
>=
i_peek
||
s
->
b_die
)
break
;
{
break
;
}
vlc_mutex_unlock
(
&
p_sys
->
lock
);
vlc_mutex_unlock
(
&
p_sys
->
lock
);
msleep
(
10000
);
msleep
(
10000
);
}
}
...
@@ -435,12 +427,13 @@ static int DStreamPeek ( stream_t *s, uint8_t **pp_peek, int i_peek )
...
@@ -435,12 +427,13 @@ static int DStreamPeek ( stream_t *s, uint8_t **pp_peek, int i_peek )
return
i_copy
;
return
i_copy
;
}
}
static
int
DStreamControl
(
stream_t
*
s
,
int
i_query
,
va_list
args
)
static
int
DStreamControl
(
stream_t
*
s
,
int
i_query
,
va_list
args
)
{
{
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
int64_t
*
p_i64
;
int64_t
*
p_i64
;
vlc_bool_t
*
p_b
;
vlc_bool_t
*
p_b
;
int
*
p_int
;
int
*
p_int
;
switch
(
i_query
)
switch
(
i_query
)
{
{
case
STREAM_GET_SIZE
:
case
STREAM_GET_SIZE
:
...
@@ -467,17 +460,13 @@ static int DStreamControl( stream_t *s, int i_query, va_list args )
...
@@ -467,17 +460,13 @@ static int DStreamControl( stream_t *s, int i_query, va_list args )
{
{
int64_t
i64
=
(
int64_t
)
va_arg
(
args
,
int64_t
);
int64_t
i64
=
(
int64_t
)
va_arg
(
args
,
int64_t
);
int
i_skip
;
int
i_skip
;
if
(
i64
<
p_sys
->
i_pos
)
if
(
i64
<
p_sys
->
i_pos
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
i_skip
=
i64
-
p_sys
->
i_pos
;
i_skip
=
i64
-
p_sys
->
i_pos
;
while
(
i_skip
>
0
)
while
(
i_skip
>
0
)
{
{
int
i_read
=
DStreamRead
(
s
,
NULL
,
i_skip
);
int
i_read
=
DStreamRead
(
s
,
NULL
,
i_skip
);
if
(
i_read
<=
0
)
return
VLC_EGENERIC
;
if
(
i_read
<=
0
)
return
VLC_EGENERIC
;
i_skip
-=
i_read
;
i_skip
-=
i_read
;
}
}
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
...
@@ -488,20 +477,22 @@ static int DStreamControl( stream_t *s, int i_query, va_list args )
...
@@ -488,20 +477,22 @@ static int DStreamControl( stream_t *s, int i_query, va_list args )
*
p_int
=
0
;
*
p_int
=
0
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
case
STREAM_CONTROL_ACCESS
:
return
VLC_EGENERIC
;
default:
default:
msg_Err
(
s
,
"invalid DStreamControl query=0x%x"
,
i_query
);
msg_Err
(
s
,
"invalid DStreamControl query=0x%x"
,
i_query
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
}
}
static
int
DStreamThread
(
stream_t
*
s
)
static
int
DStreamThread
(
stream_t
*
s
)
{
{
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
demux_t
*
p_demux
;
demux_t
*
p_demux
;
/* Create the demuxer */
/* Create the demuxer */
if
(
!
(
p_demux
=
demux2_New
(
s
,
""
,
p_sys
->
psz_name
,
""
,
s
,
p_sys
->
out
))
)
if
(
(
p_demux
=
demux2_New
(
s
,
""
,
p_sys
->
psz_name
,
""
,
s
,
p_sys
->
out
)
)
==
NULL
)
{
{
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -513,11 +504,9 @@ static int DStreamThread ( stream_t *s )
...
@@ -513,11 +504,9 @@ static int DStreamThread ( stream_t *s )
/* Main loop */
/* Main loop */
while
(
!
s
->
b_die
&&
!
p_demux
->
b_die
)
while
(
!
s
->
b_die
&&
!
p_demux
->
b_die
)
{
{
if
(
p_demux
->
pf_demux
(
p_demux
)
<=
0
)
if
(
p_demux
->
pf_demux
(
p_demux
)
<=
0
)
break
;
{
break
;
}
}
}
p_demux
->
b_die
=
VLC_TRUE
;
p_demux
->
b_die
=
VLC_TRUE
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
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