Commit b5f3c4ea authored by Ronald S. Bultje's avatar Ronald S. Bultje
Browse files

Add SIGUSR1/SIGUSR2 as play/stop signals. Also add these to the documentation. Fixes #120065

Original commit message from CVS:
Add SIGUSR1/SIGUSR2 as play/stop signals. Also add these to the documentation. Fixes #120065
parent 7cd75b0a
...@@ -192,6 +192,15 @@ Ranges are in this format: [ PROPERTY, PROPERTY ] ...@@ -192,6 +192,15 @@ Ranges are in this format: [ PROPERTY, PROPERTY ]
.br .br
Lists use this format: ( PROPERTY \fI[, PROPERTY ...]\fR ) Lists use this format: ( PROPERTY \fI[, PROPERTY ...]\fR )
.SH "PIPELINE CONTROL"
A pipeline can be controlled by signals. SIGUSR2 will stop the pipeline
(GST_STATE_NULL); SIGUSR1 will put it back to play (GST_STATE_PLAYING).
By default, the pipeline will start in the playing state.
.br
There are currently no signals defined to go into the ready or pause
(GST_STATE_READY and GST_STATE_PAUSED) state explicitely.
.SH "PIPELINE EXAMPLES" .SH "PIPELINE EXAMPLES"
The examples below assume that you have the correct plug-ins available. The examples below assume that you have the correct plug-ins available.
......
...@@ -133,14 +133,16 @@ fault_handler_sighandler (int signum) ...@@ -133,14 +133,16 @@ fault_handler_sighandler (int signum)
{ {
fault_restore (); fault_restore ();
if (signum == SIGSEGV) { switch (signum) {
g_print ("Caught SIGSEGV\n"); case SIGSEGV:
} g_print ("Caught SIGSEGV\n");
else if (signum == SIGQUIT){ break;
g_print ("Caught SIGQUIT\n"); case SIGQUIT:
} g_print ("Caught SIGQUIT\n");
else { break;
g_print ("signo: %d\n", signum); default:
g_print ("signo: %d\n", signum);
break;
} }
fault_spin(); fault_spin();
...@@ -153,16 +155,18 @@ fault_handler_sigaction (int signum, siginfo_t *si, void *misc) ...@@ -153,16 +155,18 @@ fault_handler_sigaction (int signum, siginfo_t *si, void *misc)
{ {
fault_restore (); fault_restore ();
if (si->si_signo == SIGSEGV) { switch (si->si_signo) {
g_print ("Caught SIGSEGV accessing address %p\n", si->si_addr); case SIGSEGV:
} g_print ("Caught SIGSEGV accessing address %p\n", si->si_addr);
else if (si->si_signo == SIGQUIT){ break;
g_print ("Caught SIGQUIT\n"); case SIGQUIT:
} g_print ("Caught SIGQUIT\n");
else { break;
g_print ("signo: %d\n", si->si_signo); default:
g_print ("errno: %d\n", si->si_errno); g_print ("signo: %d\n", si->si_signo);
g_print ("code: %d\n", si->si_code); g_print ("errno: %d\n", si->si_errno);
g_print ("code: %d\n", si->si_code);
break;
} }
fault_spin(); fault_spin();
...@@ -194,8 +198,8 @@ fault_restore (void) ...@@ -194,8 +198,8 @@ fault_restore (void)
memset (&action, 0, sizeof (action)); memset (&action, 0, sizeof (action));
action.sa_handler = SIG_DFL; action.sa_handler = SIG_DFL;
sigaction(SIGSEGV, &action, NULL); sigaction (SIGSEGV, &action, NULL);
sigaction(SIGQUIT, &action, NULL); sigaction (SIGQUIT, &action, NULL);
} }
static void static void
...@@ -245,7 +249,33 @@ sigint_restore (void) ...@@ -245,7 +249,33 @@ sigint_restore (void)
memset (&action, 0, sizeof (action)); memset (&action, 0, sizeof (action));
action.sa_handler = SIG_DFL; action.sa_handler = SIG_DFL;
sigaction(SIGINT, &action, NULL); sigaction (SIGINT, &action, NULL);
}
static void
play_handler (int signum)
{
switch (signum) {
case SIGUSR1:
g_print ("Caught SIGUSR1 - Play request\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
break;
case SIGUSR2:
g_print ("Caught SIGUSR2 - Stop request\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
break;
}
}
static void
play_signal_setup(void)
{
struct sigaction action;
memset (&action, 0, sizeof (action));
action.sa_handler = play_handler;
sigaction (SIGUSR1, &action, NULL);
sigaction (SIGUSR2, &action, NULL);
} }
int int
...@@ -308,6 +338,7 @@ main(int argc, char *argv[]) ...@@ -308,6 +338,7 @@ main(int argc, char *argv[])
fault_setup(); fault_setup();
sigint_setup(); sigint_setup();
play_signal_setup();
if (trace) { if (trace) {
if (!gst_alloc_trace_available()) { if (!gst_alloc_trace_available()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment