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
91f0104f
Commit
91f0104f
authored
Sep 12, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use poll instead of arbitrary msleep in lirc (close #1983)
parent
47591074
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
52 deletions
+68
-52
modules/control/lirc.c
modules/control/lirc.c
+68
-52
No files found.
modules/control/lirc.c
View file @
91f0104f
...
...
@@ -36,6 +36,10 @@
#include <vlc_interface.h>
#include <vlc_osd.h>
#ifdef HAVE_POLL
# include <poll.h>
#endif
#include <lirc/lirc_client.h>
#define LIRC_TEXT N_("Change the lirc configuration file.")
...
...
@@ -44,24 +48,11 @@
"searches in the users home directory." )
/*****************************************************************************
* intf_sys_t: description and status of FB interface
*****************************************************************************/
struct
intf_sys_t
{
char
*
psz_file
;
struct
lirc_config
*
config
;
};
/*****************************************************************************
* Local prototypes
* Module descriptor
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
void
Run
(
intf_thread_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_shortname
(
N_
(
"Infrared"
)
);
set_category
(
CAT_INTERFACE
);
...
...
@@ -74,48 +65,65 @@ vlc_module_begin();
LIRC_TEXT
,
LIRC_LONGTEXT
,
true
);
vlc_module_end
();
/*****************************************************************************
* intf_sys_t: description and status of FB interface
*****************************************************************************/
struct
intf_sys_t
{
char
*
psz_file
;
struct
lirc_config
*
config
;
int
i_fd
;
};
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
void
Run
(
intf_thread_t
*
);
static
int
Process
(
intf_thread_t
*
);
/*****************************************************************************
* Open: initialize interface
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
p_this
)
{
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
int
i_fd
;
int
f_sys_t
*
p_sys
;
/* Allocate instance and initialize some members */
p_intf
->
p_sys
=
malloc
(
sizeof
(
intf_sys_t
)
);
if
(
p_intf
->
p_sys
==
NULL
)
{
msg_Err
(
p_intf
,
"out of memory"
);
return
1
;
}
p_intf
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
intf_sys_t
)
);
if
(
p_sys
==
NULL
)
return
VLC_ENOMEM
;
p_intf
->
pf_run
=
Run
;
p_intf
->
p_sys
->
psz_file
=
var_CreateGetNonEmptyString
(
p_intf
,
"lirc-file"
);
i_fd
=
lirc_init
(
"vlc"
,
1
);
if
(
i_fd
==
-
1
)
p_sys
->
psz_file
=
var_CreateGetNonEmptyString
(
p_intf
,
"lirc-file"
);
p_sys
->
i_fd
=
lirc_init
(
"vlc"
,
1
);
if
(
p_sys
->
i_fd
==
-
1
)
{
msg_Err
(
p_intf
,
"lirc initialisation failed"
);
free
(
p_intf
->
p_sys
->
psz_file
);
free
(
p_intf
->
p_sys
);
return
1
;
goto
exit
;
}
/* We want polling */
fcntl
(
i_fd
,
F_SETFL
,
fcntl
(
i_fd
,
F_GETFL
)
|
O_NONBLOCK
);
fcntl
(
p_sys
->
i_fd
,
F_SETFL
,
fcntl
(
p_sys
->
i_fd
,
F_GETFL
)
|
O_NONBLOCK
);
if
(
lirc_readconfig
(
p_intf
->
p_sys
->
psz_file
,
&
p_intf
->
p_sys
->
config
,
NULL
)
!=
0
)
/* */
if
(
lirc_readconfig
(
p_sys
->
psz_file
,
&
p_sys
->
config
,
NULL
)
!=
0
)
{
msg_Err
(
p_intf
,
"failure while reading lirc config"
);
lirc_deinit
();
free
(
p_intf
->
p_sys
->
psz_file
);
free
(
p_intf
->
p_sys
);
return
1
;
goto
exit
;
}
return
0
;
return
VLC_SUCCESS
;
exit:
if
(
p_sys
->
i_fd
!=
-
1
)
lirc_deinit
();
free
(
p_sys
->
psz_file
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
/*****************************************************************************
...
...
@@ -124,12 +132,13 @@ static int Open( vlc_object_t *p_this )
static
void
Close
(
vlc_object_t
*
p_this
)
{
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
/* Destroy structure */
free
(
p_intf
->
p_sys
->
psz_file
);
lirc_freeconfig
(
p_intf
->
p_sys
->
config
);
lirc_freeconfig
(
p_sys
->
config
);
lirc_deinit
();
free
(
p_intf
->
p_sys
);
free
(
p_sys
->
psz_file
);
free
(
p_sys
);
}
/*****************************************************************************
...
...
@@ -137,26 +146,34 @@ static void Close( vlc_object_t *p_this )
*****************************************************************************/
static
void
Run
(
intf_thread_t
*
p_intf
)
{
char
*
code
,
*
c
;
int
canc
=
vlc_savecancel
();
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
for
(
;;
)
{
/* Sleep a bit */
/* Wait for data */
struct
pollfd
ufd
=
{
.
fd
=
p_sys
->
i_fd
,
.
events
=
POLLIN
,
.
revents
=
0
};
if
(
poll
(
&
ufd
,
1
,
-
1
)
==
-
1
)
break
;
/* Process */
int
canc
=
vlc_savecancel
();
Process
(
p_intf
);
vlc_restorecancel
(
canc
);
msleep
(
INTF_IDLE_SLEEP
);
canc
=
vlc_savecancel
();
}
}
/* We poll the lircsocket */
if
(
lirc_nextcode
(
&
code
)
!=
0
)
static
int
Process
(
intf_thread_t
*
p_intf
)
{
for
(
;;
)
{
break
;
}
char
*
code
,
*
c
;
int
i_ret
=
lirc_nextcode
(
&
code
);
if
(
i_ret
)
return
i_ret
;
if
(
code
==
NULL
)
{
continue
;
}
return
0
;
while
(
!
intf_ShouldDie
(
p_intf
)
&&
(
lirc_code2char
(
p_intf
->
p_sys
->
config
,
code
,
&
c
)
==
0
)
...
...
@@ -202,5 +219,4 @@ static void Run( intf_thread_t *p_intf )
}
free
(
code
);
}
vlc_restorecancel
(
canc
);
}
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