Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
4ebb43f1
Commit
4ebb43f1
authored
Jun 30, 2015
by
rogerdpack
Committed by
Michael Niedermayer
Jun 30, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ffmpeg: windows: respond to logoff and ctrl+break messages as well
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
bd0f1412
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
configure
configure
+2
-0
ffmpeg.c
ffmpeg.c
+41
-0
No files found.
configure
View file @
4ebb43f1
...
...
@@ -1787,6 +1787,7 @@ SYSTEM_FUNCS="
pthread_cancel
sched_getaffinity
SetConsoleTextAttribute
SetConsoleCtrlHandler
setmode
setrlimit
Sleep
...
...
@@ -4990,6 +4991,7 @@ check_func_headers windows.h GetSystemTimeAsFileTime
check_func_headers windows.h MapViewOfFile
check_func_headers windows.h PeekNamedPipe
check_func_headers windows.h SetConsoleTextAttribute
check_func_headers windows.h SetConsoleCtrlHandler
check_func_headers windows.h Sleep
check_func_headers windows.h VirtualAlloc
check_struct windows.h
"CONDITION_VARIABLE"
Ptr
...
...
ffmpeg.c
View file @
4ebb43f1
...
...
@@ -79,6 +79,10 @@
#include <windows.h>
#include <psapi.h>
#endif
#if HAVE_SETCONSOLECTRLHANDLER
#include <windows.h>
#endif
#if HAVE_SYS_SELECT_H
#include <sys/select.h>
...
...
@@ -313,6 +317,7 @@ void term_exit(void)
static
volatile
int
received_sigterm
=
0
;
static
volatile
int
received_nb_signals
=
0
;
static
volatile
int
transcode_init_done
=
0
;
static
volatile
int
ffmpeg_exited
=
0
;
static
int
main_return_code
=
0
;
static
void
...
...
@@ -329,6 +334,38 @@ sigterm_handler(int sig)
}
}
#if HAVE_SETCONSOLECTRLHANDLER
static
BOOL
WINAPI
CtrlHandler
(
DWORD
fdwCtrlType
)
{
av_log
(
NULL
,
AV_LOG_DEBUG
,
"
\n
Received windows signal %ld
\n
"
,
fdwCtrlType
);
switch
(
fdwCtrlType
)
{
case
CTRL_C_EVENT
:
case
CTRL_BREAK_EVENT
:
sigterm_handler
(
SIGINT
);
return
TRUE
;
case
CTRL_CLOSE_EVENT
:
case
CTRL_LOGOFF_EVENT
:
case
CTRL_SHUTDOWN_EVENT
:
sigterm_handler
(
SIGTERM
);
/* Basically, with these 3 events, when we return from this method the
process is hard terminated, so stall as long as we need to
to try and let the main thread(s) clean up and gracefully terminate
(we have at most 5 seconds, but should be done far before that). */
while
(
!
ffmpeg_exited
)
{
Sleep
(
0
);
}
return
TRUE
;
default:
av_log
(
NULL
,
AV_LOG_ERROR
,
"Received unknown windows signal %ld
\n
"
,
fdwCtrlType
);
return
FALSE
;
}
}
#endif
void
term_init
(
void
)
{
#if HAVE_TERMIOS_H
...
...
@@ -362,6 +399,9 @@ void term_init(void)
#ifdef SIGXCPU
signal
(
SIGXCPU
,
sigterm_handler
);
#endif
#if HAVE_SETCONSOLECTRLHANDLER
SetConsoleCtrlHandler
((
PHANDLER_ROUTINE
)
CtrlHandler
,
TRUE
);
#endif
}
/* read a key without blocking */
...
...
@@ -537,6 +577,7 @@ static void ffmpeg_cleanup(int ret)
av_log
(
NULL
,
AV_LOG_INFO
,
"Conversion failed!
\n
"
);
}
term_exit
();
ffmpeg_exited
=
1
;
}
void
remove_avoptions
(
AVDictionary
**
a
,
AVDictionary
*
b
)
...
...
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