Update of /cvsroot/freevo/kaa/xine/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11138/src

Modified Files:
        __init__.py audio_port.c stream.c video_port.c video_port.h 
        xine.c 
Log Message:
Move x11 driver initialization code into drivers/x11.c.  Add callbacks for
frame_output_callback and dest_size_callback so that they can be 
implemented in Python.  Add BEGIN_ALLOW_THREADS and END_ALLOW_THREADS in
various places so the global interpreter lock can be acquired in the above
callbacks.


Index: stream.c
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/stream.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** stream.c    18 Jul 2005 19:36:50 -0000      1.3
--- stream.c    19 Jul 2005 02:07:24 -0000      1.4
***************
*** 115,120 ****
--- 115,122 ----
      printf("DEalloc Stream: %x\n", self->stream);
      if (self->stream && self->xine_object_owner) {
+         Py_BEGIN_ALLOW_THREADS
          xine_close(self->stream);
          xine_dispose(self->stream);
+         Py_END_ALLOW_THREADS
      }
      Py_DECREF(self->wrapper);
***************
*** 150,159 ****
          return NULL;
  
      result = xine_play(self->stream, pos, time);
      if (!result) {
          PyErr_Format(xine_error, "Failed to play stream (FIXME: add useful 
error).");
          return NULL;
      }
! 
      return Py_INCREF(Py_None), Py_None;
  }
--- 152,163 ----
          return NULL;
  
+     Py_BEGIN_ALLOW_THREADS
      result = xine_play(self->stream, pos, time);
+     Py_END_ALLOW_THREADS
      if (!result) {
          PyErr_Format(xine_error, "Failed to play stream (FIXME: add useful 
error).");
          return NULL;
      }
!     
      return Py_INCREF(Py_None), Py_None;
  }

Index: video_port.h
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/video_port.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** video_port.h        18 Jul 2005 03:40:21 -0000      1.2
--- video_port.h        19 Jul 2005 02:07:24 -0000      1.3
***************
*** 17,20 ****
--- 17,23 ----
  
      PyObject *wrapper;
+ 
+     void (*driver_dealloc_cb)(void *);
+     void *driver_dealloc_data;
  } Xine_Video_Port_PyObject;
  

Index: video_port.c
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/video_port.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** video_port.c        18 Jul 2005 19:36:50 -0000      1.3
--- video_port.c        19 Jul 2005 02:07:24 -0000      1.4
***************
*** 95,103 ****
--- 95,109 ----
      printf("DEalloc Video Port: %x\n", self->vo);
      if (self->vo && self->xine_object_owner) {
+         Py_BEGIN_ALLOW_THREADS
          xine_close_video_driver(self->xine, self->vo);
+         Py_END_ALLOW_THREADS
      }
      Py_DECREF(self->wrapper);
      Xine_Video_Port_PyObject__clear(self);
      xine_object_to_pyobject_unregister(self->vo);
+ 
+     if (self->driver_dealloc_cb)
+         self->driver_dealloc_cb(self->driver_dealloc_data);
+ 
      self->ob_type->tp_free((PyObject *) self);
  }

Index: audio_port.c
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/audio_port.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** audio_port.c        18 Jul 2005 19:36:49 -0000      1.3
--- audio_port.c        19 Jul 2005 02:07:24 -0000      1.4
***************
*** 85,89 ****
--- 85,91 ----
      printf("DEalloc Audio Port: %x\n", self->ao);
      if (self->ao && self->xine_object_owner) {
+         Py_BEGIN_ALLOW_THREADS
          xine_close_audio_driver(self->xine, self->ao);
+         Py_END_ALLOW_THREADS
      }
      Py_DECREF(self->wrapper);

Index: __init__.py
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/__init__.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** __init__.py 18 Jul 2005 19:36:49 -0000      1.3
--- __init__.py 19 Jul 2005 02:07:24 -0000      1.4
***************
*** 1,5 ****
  import weakref
  import _xine
! from kaa import display
  
  XineError = _xine.XineError
--- 1,5 ----
  import weakref
  import _xine
! from kaa import display, notifier
  
  XineError = _xine.XineError
***************
*** 30,38 ****
          self._xine = _xine.Xine()
  
      def open_video_driver(self, driver = "auto", **kwargs):
          if "window" in kwargs:
!             assert(type(kwargs["window"]) == display.X11Window)
!             kwargs["window"] = kwargs["window"]._window
!             self._xine.dependencies.append(kwargs["window"])
          
          vo = self._xine.open_video_driver(driver, **kwargs)
--- 30,57 ----
          self._xine = _xine.Xine()
  
+     def _default_frame_output_cb(self, width, height, aspect, window):
+         #print "FRAME CALLBACK", width, height, aspect, window.get_geometry()
+         if window:
+             win_w, win_h = window.get_geometry()[1]
+         else:
+             win_w, win_h = 640, 480
+         # Return order: dst_pos, win_pos, dst_size, aspect
+         aspect = width / height
+         w = win_w
+         h = w / aspect
+         y = (win_h-h)/2
+         return (0, y), (0, 0), (w, h), 1
+ 
      def open_video_driver(self, driver = "auto", **kwargs):
          if "window" in kwargs:
!             window = kwargs["window"]
!             assert(type(window) == display.X11Window)
!             if "frame_output_cb" not in kwargs:
!                 kwargs["frame_output_cb"] = 
notifier.WeakCallback(self._default_frame_output_cb, window)
!             if "dest_size_cb" not in kwargs:
!                 kwargs["dest_size_cb"] = self._default_frame_output_cb
!             kwargs["window"] = window._window
!             self._xine.dependencies.append(window._window)
! 
          
          vo = self._xine.open_video_driver(driver, **kwargs)
***************
*** 95,100 ****
          return self._stream.open(mrl)
  
!     def play(self, pos = 0, time = 0):
!         return self._stream.play(pos, time)
  
      def get_video_source(self):
--- 114,119 ----
          return self._stream.open(mrl)
  
!     def play(self, pos = 0, time = 0.0):
!         return self._stream.play(pos, int(time*1000))
  
      def get_video_source(self):

Index: xine.c
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/xine.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** xine.c      18 Jul 2005 19:36:50 -0000      1.3
--- xine.c      19 Jul 2005 02:07:24 -0000      1.4
***************
*** 166,190 ****
  }
  
- // XXX Temporary.  Obviously. :)
- static void frame_output_cb(void *data, int video_width, int video_height,
-                 double video_pixel_aspect, int *dest_x, int *dest_y,
-                 int *dest_width, int *dest_height,
-                 double *dest_pixel_aspect, int *win_x, int *win_y) {
-   *dest_x            = 0;
-   *dest_y            = 0;
-   *win_x             = 0;
-   *win_y             = 0;
-   *dest_width        = 640;//width;
-   *dest_height       = 480;//height;
-   *dest_pixel_aspect = 1;
-   //printf("frame_output_cb: Video width: %d, heigh: %d, pixel aspect: %f 
%x\n", video_width, video_height, video_pixel_aspect, data);
- }
- 
- 
  PyObject *
  Xine_PyObject_open_video_driver(Xine_PyObject *self, PyObject *args, PyObject 
*kwargs)
  {
-     char *driver;
      xine_video_port_t *vo_port = NULL;
  
      if (!PyArg_ParseTuple(args, "s", &driver))
--- 166,176 ----
  }
  
  PyObject *
  Xine_PyObject_open_video_driver(Xine_PyObject *self, PyObject *args, PyObject 
*kwargs)
  {
      xine_video_port_t *vo_port = NULL;
+     Xine_Video_Port_PyObject *vo;
+     char *driver;
+     void *finalize_data = NULL;
  
      if (!PyArg_ParseTuple(args, "s", &driver))
***************
*** 192,215 ****
  
      if (!strcmp(driver, "xv") || !strcmp(driver, "auto")) {
!         PyObject *window;
!         x11_visual_t vis;
! 
!         window = PyDict_GetItemString(kwargs, "window");
!         if (!x11window_object_decompose(window, &vis.d, (Display 
**)&vis.display))
!             return NULL;
!         vis.screen = DefaultScreen(vis.display);
!         vis.user_data = NULL;
!         vis.frame_output_cb = frame_output_cb;
!         vis.user_data = window;
!         vo_port = xine_open_video_driver(self->xine, driver, 
XINE_VISUAL_TYPE_X11, (void *)&vis);
      } else if (!strcmp(driver, "none")) {
          vo_port = xine_open_video_driver(self->xine, driver, 
XINE_VISUAL_TYPE_NONE, 0);
      }
          
!     if (!vo_port) {
          PyErr_Format(xine_error, "Failed to open driver: %s", driver);
          return NULL;
      }
!     return (PyObject *)pyxine_new_video_port_pyobject(self, vo_port, 1);
  }
  
--- 178,197 ----
  
      if (!strcmp(driver, "xv") || !strcmp(driver, "auto")) {
!         vo_port = x11_open_video_driver(self, driver, kwargs, &finalize_data);
      } else if (!strcmp(driver, "none")) {
          vo_port = xine_open_video_driver(self->xine, driver, 
XINE_VISUAL_TYPE_NONE, 0);
      }
          
!     if (!vo_port && !PyErr_Occurred()) {
          PyErr_Format(xine_error, "Failed to open driver: %s", driver);
          return NULL;
      }
! 
!     vo = pyxine_new_video_port_pyobject(self, vo_port, 1);
! 
!     if (!strcmp(driver, "xv") || !strcmp(driver, "auto")) {
!         x11_open_video_driver_finalize(vo, finalize_data);
!     }
!     return (PyObject *)vo;
  }
  
***************
*** 290,303 ****
      }
  
-     {
-         /*
-         xine_post_in_t *input_api = (xine_post_in_t *) xine_post_input(post, 
"parameters");
-         xine_post_api_t *api = (xine_post_api_t *)input_api->data;
-         int data = 142;
-         api->set_parameters(post, &data);
-         printf("POST API: %x\n", input_api);
-         */
-     }
- 
      return (PyObject *)pyxine_new_post_pyobject(self, post, audio_targets, 
video_targets, 1);
  
--- 272,275 ----
***************
*** 447,449 ****
--- 419,422 ----
  #endif
  
+     PyEval_InitThreads();
  }



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to