handle_keyboard not working well

Dudi.r dudi017 at gmail.com
Tue Apr 8 23:31:58 PDT 2014


Hi!

I have code that play video and every time I press 'p' the pipeline moves to
PAUSED state. and 'o' to PLAYING state.

this is part of the program:

 

.....
io_stdin = g_io_channel_win32_new_fd (fileno (stdin));
g_io_add_watch (io_stdin, G_IO_IN, (GIOFunc)handle_keyboard, app);

gst_element_set_state (pipeline, GST_STATE_PLAYING);

.....


static gboolean handle_keyboard (GIOChannel *source, GIOCondition cond,
CustomData *data) {
  gchar *str = NULL;
  if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) !=
G_IO_STATUS_NORMAL) {
      return TRUE;
     }
  
switch (g_ascii_tolower (str[0])) 
    {
       case 'p':
	    data->playing =FALSE;
	    gst_element_set_state (data->pipeline, GST_STATE_PAUSED);
            g_print ("Setting state to %s\n", data->playing ? "PLAYING" :
"PAUSE");
          break;

       case 'o':   
	   app->playing =TRUE;
           gst_element_set_state (data->pipeline, GST_STATE_PLAYING);	
           g_print ("Setting state to %s\n", app->playing ? "PLAYING" :
"PAUSE");
         break;
    }
  g_free (str);

return TRUE;
}


I don't know why, but when I press the keyboard (any button not just p and
o) is freezes before I press the enter button.

I tried to put a break point inside the "handle_keyboard" and when I press
any button, the video still get stuck and not getting the break point.
but if I press enter after that I pressed the button, the program get to the
break point (and it still stuck)

if I press 'o' (for PLAYING state) nothing happen.....

It works fine in 0.10 project but with 1.0 project, I get these problems.

I don't know how to add keyboard listener on gstreamer otherwise...
if someone know what to do it will be great!

Dudi.




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/handle-keyboard-not-working-well-tp4666372.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list