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
3a71b317
Commit
3a71b317
authored
Dec 10, 2014
by
Thomas Guillem
Committed by
Jean-Baptiste Kempf
Dec 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsm/sd: discover in a separate thread
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
91b638cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
25 deletions
+54
-25
modules/access/dsm/sd.c
modules/access/dsm/sd.c
+54
-25
No files found.
modules/access/dsm/sd.c
View file @
3a71b317
...
@@ -30,11 +30,18 @@
...
@@ -30,11 +30,18 @@
# include "config.h"
# include "config.h"
#endif
#endif
#include <vlc_common.h>
#include <vlc_atomic.h>
#include <bdsm/bdsm.h>
#include "common.h"
#include "common.h"
struct
services_discovery_sys_t
struct
services_discovery_sys_t
{
{
netbios_ns
*
ns
;
netbios_ns
*
p_ns
;
vlc_thread_t
thread
;
atomic_bool
stop
;
};
};
int
bdsm_sd_probe_Open
(
vlc_object_t
*
p_this
)
int
bdsm_sd_probe_Open
(
vlc_object_t
*
p_this
)
...
@@ -47,26 +54,20 @@ int bdsm_sd_probe_Open (vlc_object_t *p_this)
...
@@ -47,26 +54,20 @@ int bdsm_sd_probe_Open (vlc_object_t *p_this)
return
VLC_PROBE_CONTINUE
;
return
VLC_PROBE_CONTINUE
;
}
}
int
bdsm_SdOpen
(
vlc_object_t
*
p_this
)
static
void
*
Run
(
void
*
data
)
{
{
services_discovery_t
*
p_sd
=
(
services_discovery_t
*
)
p_this
;
services_discovery_t
*
p_sd
=
data
;
services_discovery_sys_t
*
p_sys
=
malloc
(
sizeof
(
*
p_sys
));
services_discovery_sys_t
*
p_sys
=
p_sd
->
p_sys
;
if
(
p_sys
==
NULL
)
return
VLC_ENOMEM
;
p_sd
->
p_sys
=
p_sys
;
/* Let's create a NETBIOS name service object */
if
(
!
netbios_ns_discover
(
p_sys
->
p_ns
)
)
p_sys
->
ns
=
netbios_ns_new
();
return
NULL
;
if
(
p_sys
->
ns
==
NULL
)
goto
error
;
if
(
!
netbios_ns_discover
(
p_sys
->
ns
)
)
if
(
atomic_load
(
&
p_sys
->
stop
)
)
goto
error
;
return
NULL
;
for
(
ssize_t
i
=
0
;
i
<
netbios_ns_entry_count
(
p_sys
->
ns
);
i
++
)
for
(
ssize_t
i
=
0
;
i
<
netbios_ns_entry_count
(
p_sys
->
p_
ns
);
i
++
)
{
{
netbios_ns_entry
*
p_entry
=
netbios_ns_entry_at
(
p_sys
->
ns
,
i
);
netbios_ns_entry
*
p_entry
=
netbios_ns_entry_at
(
p_sys
->
p_
ns
,
i
);
char
type
=
netbios_ns_entry_type
(
p_entry
);
char
type
=
netbios_ns_entry_type
(
p_entry
);
if
(
type
==
0x20
)
if
(
type
==
0x20
)
...
@@ -76,7 +77,7 @@ int bdsm_SdOpen (vlc_object_t *p_this)
...
@@ -76,7 +77,7 @@ int bdsm_SdOpen (vlc_object_t *p_this)
const
char
*
name
=
netbios_ns_entry_name
(
p_entry
);
const
char
*
name
=
netbios_ns_entry_name
(
p_entry
);
if
(
asprintf
(
&
psz_mrl
,
"smb://%s"
,
name
)
<
0
)
if
(
asprintf
(
&
psz_mrl
,
"smb://%s"
,
name
)
<
0
)
goto
error
;
return
NULL
;
p_item
=
input_item_NewWithType
(
psz_mrl
,
name
,
0
,
NULL
,
p_item
=
input_item_NewWithType
(
psz_mrl
,
name
,
0
,
NULL
,
0
,
-
1
,
ITEM_TYPE_NODE
);
0
,
-
1
,
ITEM_TYPE_NODE
);
...
@@ -84,18 +85,37 @@ int bdsm_SdOpen (vlc_object_t *p_this)
...
@@ -84,18 +85,37 @@ int bdsm_SdOpen (vlc_object_t *p_this)
services_discovery_AddItem
(
p_sd
,
p_item
,
NULL
);
services_discovery_AddItem
(
p_sd
,
p_item
,
NULL
);
free
(
psz_mrl
);
}
}
}
}
return
NULL
;
}
int
bdsm_SdOpen
(
vlc_object_t
*
p_this
)
{
services_discovery_t
*
p_sd
=
(
services_discovery_t
*
)
p_this
;
services_discovery_sys_t
*
p_sys
=
calloc
(
1
,
sizeof
(
*
p_sys
));
if
(
p_sys
==
NULL
)
return
VLC_ENOMEM
;
p_sd
->
p_sys
=
p_sys
;
p_sys
->
p_ns
=
netbios_ns_new
();
if
(
p_sys
->
p_ns
==
NULL
)
goto
error
;
atomic_store
(
&
p_sys
->
stop
,
false
);
if
(
vlc_clone
(
&
p_sys
->
thread
,
Run
,
p_sd
,
VLC_THREAD_PRIORITY_LOW
)
)
{
p_sys
->
thread
=
0
;
goto
error
;
}
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
error:
error:
if
(
p_sys
->
ns
!=
NULL
)
bdsm_SdClose
(
p_this
);
netbios_ns_destroy
(
p_sys
->
ns
);
free
(
p_sys
);
p_sd
->
p_sys
=
NULL
;
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -107,7 +127,16 @@ void bdsm_SdClose (vlc_object_t *p_this)
...
@@ -107,7 +127,16 @@ void bdsm_SdClose (vlc_object_t *p_this)
if
(
p_sys
==
NULL
)
if
(
p_sys
==
NULL
)
return
;
return
;
if
(
p_sys
->
ns
!=
NULL
)
if
(
p_sys
->
thread
)
{
netbios_ns_destroy
(
p_sys
->
ns
);
atomic_store
(
&
p_sys
->
stop
,
true
);
if
(
p_sys
->
p_ns
)
netbios_ns_abort
(
p_sys
->
p_ns
);
vlc_join
(
p_sys
->
thread
,
NULL
);
}
if
(
p_sys
->
p_ns
)
netbios_ns_destroy
(
p_sys
->
p_ns
);
free
(
p_sys
);
}
}
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