]> git.sesse.net Git - vlc/commitdiff
Merge branch 1.0-bugfix into master
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 23 May 2009 14:01:32 +0000 (17:01 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 23 May 2009 14:01:32 +0000 (17:01 +0300)
Conflicts:
modules/video_output/drawable.c
src/control/libvlc_internal.h

1  2 
modules/codec/fluidsynth.c
modules/video_output/xcb/x11.c
modules/video_output/xcb/xvideo.c
src/control/libvlc_internal.h
src/control/media_list_player.c

index ae08aeff7cdc04587158a9511fb8ed7545dfe921,26bc6e95888390bce660d68fa88c5b27bc79b3e6..74c44fa3ee7c54d5f42ae110ff546d2139636261
@@@ -66,7 -66,7 +66,7 @@@ static int Open (vlc_object_t *p_this
      decoder_t *p_dec = (decoder_t *)p_this;
      decoder_sys_t *p_sys;
  
 -    if (p_dec->fmt_in.i_codec != VLC_FOURCC ('M', 'I', 'D', 'I'))
 +    if (p_dec->fmt_in.i_codec != VLC_CODEC_MIDI)
          return VLC_EGENERIC;
  
      char *font_path = var_CreateGetNonEmptyString (p_this, "soundfont");
@@@ -82,7 -82,7 +82,7 @@@
      p_dec->fmt_out.audio.i_original_channels =
      p_dec->fmt_out.audio.i_physical_channels =
          AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
 -    p_dec->fmt_out.i_codec = VLC_FOURCC('f', 'l', '3', '2');
 +    p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
      p_dec->fmt_out.audio.i_bitspersample = 32;
  
      p_dec->pf_decode_audio = DecodeBlock;
@@@ -128,12 -128,14 +128,14 @@@ static aout_buffer_t *DecodeBlock (deco
  {
      block_t *p_block;
      decoder_sys_t *p_sys = p_dec->p_sys;
+     aout_buffer_t *p_out = NULL;
  
      if (pp_block == NULL)
          return NULL;
      p_block = *pp_block;
      if (p_block == NULL)
          return NULL;
+     *pp_block = NULL;
  
      if (p_block->i_pts && !aout_DateGet (&p_sys->end_date))
          aout_DateSet (&p_sys->end_date, p_block->i_pts);
      if (p_block->i_pts < aout_DateGet (&p_sys->end_date))
      {
          msg_Warn (p_dec, "MIDI message in the past?");
-         block_Release (p_block);
-         return NULL;
+         goto drop;
      }
  
      if (p_block->i_buffer < 1)
-         return NULL;
+         goto drop;
  
      uint8_t channel = p_block->p_buffer[0] & 0xf;
      uint8_t p1 = (p_block->i_buffer > 1) ? (p_block->p_buffer[1] & 0x7f) : 0;
              fluid_synth_pitch_bend (p_sys->synth, channel, (p1 << 7) | p2);
              break;
      }
-     p_block->p_buffer += p_block->i_buffer;
-     p_block->i_buffer = 0;
  
      unsigned samples =
          (p_block->i_pts - aout_DateGet (&p_sys->end_date)) * 441 / 10000;
      if (samples == 0)
          return NULL;
  
-     aout_buffer_t *p_out = decoder_NewAudioBuffer (p_dec, samples);
+     p_out = decoder_NewAudioBuffer (p_dec, samples);
      if (p_out == NULL)
-     {
-         block_Release (p_block);
-         return NULL;
-     }
+         goto drop;
  
      p_out->start_date = aout_DateGet (&p_sys->end_date );
      p_out->end_date   = aout_DateIncrement (&p_sys->end_date, samples);
      fluid_synth_write_float (p_sys->synth, samples,
                               p_out->p_buffer, 0, 2,
                               p_out->p_buffer, 1, 2);
+ drop:
+     block_Release (p_block);
      return p_out;
  }
index 2196fb26438141e040ad596e0a060d7f3d70c2a2,659ce37c12e569666895b117fe6a59196801112c..455b31179379b5bb5208b830b14726cb7ae4d31b
@@@ -115,7 -115,10 +115,10 @@@ static int Open (vlc_object_t *obj
      /* Connect to X */
      p_sys->conn = Connect (obj);
      if (p_sys->conn == NULL)
+     {
+         free (p_sys);
          return VLC_EGENERIC;
+     }
  
      /* Get window */
      const xcb_screen_t *scr;
      if (p_sys->embed == NULL)
      {
          xcb_disconnect (p_sys->conn);
+         free (p_sys);
          return VLC_EGENERIC;
      }
  
          {
            case 24:
              if (fmt->bits_per_pixel == 32)
 -                chroma = VLC_FOURCC ('R', 'V', '3', '2');
 +                chroma = VLC_CODEC_RGB32;
              else if (fmt->bits_per_pixel == 24)
 -                chroma = VLC_FOURCC ('R', 'V', '2', '4');
 +                chroma = VLC_CODEC_RGB24;
              else
                  continue;
              break;
            case 16:
              if (fmt->bits_per_pixel != 16)
                  continue;
 -            chroma = VLC_FOURCC ('R', 'V', '1', '6');
 +            chroma = VLC_CODEC_RGB16;
              break;
            case 15:
              if (fmt->bits_per_pixel != 16)
                  continue;
 -            chroma = VLC_FOURCC ('R', 'V', '1', '5');
 +            chroma = VLC_CODEC_RGB15;
              break;
            case 8:
              if (fmt->bits_per_pixel != 8)
                  continue;
 -            chroma = VLC_FOURCC ('R', 'G', 'B', '2');
 +            chroma = VLC_CODEC_RGB8;
              break;
            default:
              continue;
                  if (!gray)
                      continue; /* Prefer color over gray scale */
                  vid = vt->visual_id;
 -                chroma = VLC_FOURCC ('G', 'R', 'E', 'Y');
 +                chroma = VLC_CODEC_GREY;
              }
          }
  
@@@ -346,9 -350,9 +350,9 @@@ static int Init (vout_thread_t *vout
          if (pic->i_status != FREE_PICTURE)
              continue;
  
 -        vout_InitPicture (vout, pic, vout->output.i_chroma,
 -                          vout->output.i_width, vout->output.i_height,
 -                          vout->output.i_aspect);
 +        picture_Setup (pic, vout->output.i_chroma,
 +                       vout->output.i_width, vout->output.i_height,
 +                       vout->output.i_aspect);
          if (PictureAlloc (vout, pic, pic->p->i_pitch * pic->p->i_lines,
                            p_sys->shm ? p_sys->conn : NULL))
              break;
index 11ea8b586957ce0cc2ed3a4999995e96db8c1895,5b32ad14197c341ff459c191970cab1f6656f132..38d8862d66c6c8d858af941ad737b5fef4d3d98c
@@@ -159,12 -159,16 +159,16 @@@ static int Open (vlc_object_t *obj
      /* Connect to X */
      p_sys->conn = Connect (obj);
      if (p_sys->conn == NULL)
+     {
+         free (p_sys);
          return VLC_EGENERIC;
+     }
  
      if (!CheckXVideo (vout, p_sys->conn))
      {
          msg_Warn (vout, "Please enable XVideo 2.2 for faster video display");
          xcb_disconnect (p_sys->conn);
+         free (p_sys);
          return VLC_EGENERIC;
      }
  
      if (p_sys->embed == NULL)
      {
          xcb_disconnect (p_sys->conn);
+         free (p_sys);
          return VLC_EGENERIC;
      }
  
@@@ -249,21 -254,21 +254,21 @@@ static vlc_fourcc_t ParseFormat (vout_t
              {
                case 32:
                  if (f->depth == 24)
 -                    return VLC_FOURCC ('R', 'V', '3', '2');
 +                    return VLC_CODEC_RGB32;
                  break;
                case 24:
                  if (f->depth == 24)
 -                    return VLC_FOURCC ('R', 'V', '2', '4');
 +                    return VLC_CODEC_RGB24;
                  break;
                case 16:
                  if (f->depth == 16)
 -                    return VLC_FOURCC ('R', 'V', '1', '6');
 +                    return VLC_CODEC_RGB16;
                  if (f->depth == 15)
 -                    return VLC_FOURCC ('R', 'V', '1', '5');
 +                    return VLC_CODEC_RGB15;
                  break;
                case 8:
                  if (f->depth == 8)
 -                    return VLC_FOURCC ('R', 'G', 'B', '2');
 +                    return VLC_CODEC_RGB8;
                  break;
              }
              break;
              {
                /*untested: case 24:
                  if (f->vhorz_u_period == 1 && f->vvert_u_period == 1)
 -                    return VLC_FOURCC ('I', '4', '4', '4');
 +                    return VLC_CODEC_I444;
                  break;*/
                case 16:
                  if (f->vhorz_u_period == 2 && f->vvert_u_period == 1)
                  {
                      if (!strcmp ((const char *)f->vcomp_order, "YUYV"))
 -                        return VLC_FOURCC ('Y', 'U', 'Y', '2');
 +                        return VLC_CODEC_YUYV;
                      if (!strcmp ((const char *)f->vcomp_order, "UYVY"))
 -                        return VLC_FOURCC ('U', 'Y', 'V', 'Y');
 +                        return VLC_CODEC_UYVY;
                  }
                  break;
              }
                  if (f->vhorz_u_period == 2 && f->vvert_u_period == 2)
                  {
                      if (!strcmp ((const char *)f->vcomp_order, "YVU"))
 -                        return VLC_FOURCC ('Y', 'V', '1', '2');
 +                        return VLC_CODEC_YV12;
                      if (!strcmp ((const char *)f->vcomp_order, "YUV"))
 -                        return VLC_FOURCC ('I', '4', '2', '0');
 +                        return VLC_CODEC_I420;
                  }
              }
              break;
@@@ -340,11 -345,7 +345,11 @@@ FindFormat (vout_thread_t *vout, vlc_fo
      xcb_connection_t *conn = vout->p_sys->conn;
      const xcb_xv_image_format_info_t *f, *end;
  
 +#ifndef XCB_XV_OLD
      f = xcb_xv_list_image_formats_format (list);
 +#else
 +    f = (xcb_xv_image_format_info_t *) (list + 1);
 +#endif
      end = f + xcb_xv_list_image_formats_format_length (list);
      for (; f < end; f++)
      {
@@@ -405,9 -406,9 +410,9 @@@ static int Init (vout_thread_t *vout
          /* Video chroma in preference order */
          const vlc_fourcc_t chromas[] = {
              vout->fmt_in.i_chroma,
 -            VLC_FOURCC ('Y', 'U', 'Y', '2'),
 -            VLC_FOURCC ('R', 'V', '2', '4'),
 -            VLC_FOURCC ('R', 'V', '1', '5'),
 +            VLC_CODEC_YUYV,
 +            VLC_CODEC_RGB24,
 +            VLC_CODEC_RGB15,
          };
          for (size_t i = 0; i < sizeof (chromas) / sizeof (chromas[0]); i++)
          {
@@@ -460,9 -461,9 +465,9 @@@ found_adaptor
          if (pic->i_status != FREE_PICTURE)
              continue;
  
 -        vout_InitPicture (vout, pic, vout->output.i_chroma,
 -                          att->width, att->height,
 -                          vout->fmt_in.i_aspect);
 +        picture_Setup (pic, vout->output.i_chroma,
 +                       att->width, att->height,
 +                       vout->fmt_in.i_aspect);
          if (PictureAlloc (vout, pic, att->data_size,
                            p_sys->shm ? p_sys->conn : NULL))
              break;
index 58d43972dc04722c489b2c20cd31e96a0533eb6d,417d38e01f11f7048b2c8e7ef50a1d05e8bf66d3..311a859cd71c0a4b44158083ab1e2c0ede829bfc
@@@ -90,7 -90,6 +90,7 @@@ struct libvlc_media_list_
      libvlc_instance_t *         p_libvlc_instance;
      int                         i_refcount;
      vlc_mutex_t                 object_lock;
 +    vlc_mutex_t                 refcount_lock;
      libvlc_media_t * p_md; /* The media from which the
                                         * mlist comes, if any. */
      vlc_array_t                items;
@@@ -162,20 -161,10 +162,8 @@@ struct libvlc_media_player_
          uint32_t xid;
          uint32_t agl;
      } drawable;
 -
 -    bool        b_own_its_input_thread;
  };
  
- struct libvlc_media_list_player_t
- {
-     libvlc_event_manager_t *    p_event_manager;
-     libvlc_instance_t *         p_libvlc_instance;
-     unsigned                    i_refcount;
-     vlc_mutex_t                 object_lock;
-     libvlc_media_list_path_t    current_playing_item_path;
-     libvlc_media_t *            p_current_playing_item;
-     libvlc_media_list_t *       p_mlist;
-     libvlc_media_player_t *     p_mi;
- };
  struct libvlc_media_library_t
  {
      libvlc_event_manager_t * p_event_manager;
@@@ -263,6 -252,15 +251,6 @@@ typedef struct libvlc_event_manager_
  input_thread_t *libvlc_get_input_thread(
       libvlc_media_player_t *,
      libvlc_exception_t * );
 -
 -/* Media instance */
 -libvlc_media_player_t *
 -libvlc_media_player_new_from_input_thread( libvlc_instance_t *,
 -                                           input_thread_t *,
 -                                           libvlc_exception_t * );
 -
 -void libvlc_media_player_destroy(
 -        libvlc_media_player_t * );
  
  /* Media Descriptor */
  libvlc_media_t * libvlc_media_new_from_input_item(
index fd9f2c2722b87a9e520617086cafa42435f59c6c,2981907b2bde22621b086f6d63bdd9ced4b6f41d..19c029eb9a86fda7fbf8d9f1c99268fd4128f88b
  #include <vlc/libvlc.h>
  #include "media_list_path.h"
  
+ struct libvlc_media_list_player_t
+ {
+     libvlc_event_manager_t *    p_event_manager;
+     libvlc_instance_t *         p_libvlc_instance;
+     int                         i_refcount;
+     vlc_mutex_t                 object_lock;
+     libvlc_media_list_path_t    current_playing_item_path;
+     libvlc_media_t *            p_current_playing_item;
+     libvlc_media_list_t *       p_mlist;
+     libvlc_media_player_t *     p_mi;
+ };
  /*
   * Private functions
   */
@@@ -64,23 -77,23 +77,23 @@@ get_next_path( libvlc_media_list_player
                              p_mlp->p_mlist,
                              p_mlp->current_playing_item_path );
  
 -    int deepness = libvlc_media_list_path_deepness( p_mlp->current_playing_item_path );
 -    if( deepness < 1 || !p_parent_of_playing_item )
 +    int depth = libvlc_media_list_path_depth( p_mlp->current_playing_item_path );
 +    if( depth < 1 || !p_parent_of_playing_item )
          return NULL;
  
      ret = libvlc_media_list_path_copy( p_mlp->current_playing_item_path );
  
 -    while( ret[deepness-1] >= libvlc_media_list_count( p_parent_of_playing_item, NULL ) )
 +    while( ret[depth-1] >= libvlc_media_list_count( p_parent_of_playing_item, NULL ) )
      {
 -        deepness--;
 -        if( deepness <= 0 )
 +        depth--;
 +        if( depth <= 0 )
          {
              free( ret );
              libvlc_media_list_release( p_parent_of_playing_item );
              return NULL;
          }
 -        ret[deepness] = -1;
 -        ret[deepness-1]++;
 +        ret[depth] = -1;
 +        ret[depth-1]++;
          p_parent_of_playing_item  = libvlc_media_list_parentlist_at_path(
                                          p_mlp->p_mlist,
                                          ret );
@@@ -264,13 -277,10 +277,13 @@@ libvlc_media_list_player_new( libvlc_in
      if( !p_mlp )
          return NULL;
  
 +    libvlc_retain( p_instance );
 +    p_mlp->p_libvlc_instance = p_instance;
 +    p_mlp->i_refcount = 0;
 +    vlc_mutex_init( &p_mlp->object_lock );
      p_mlp->current_playing_item_path = NULL;
 -    p_mlp->p_mi = NULL;
      p_mlp->p_mlist = NULL;
 -    vlc_mutex_init( &p_mlp->object_lock );
 +    p_mlp->p_mi = NULL;
      p_mlp->p_event_manager = libvlc_event_manager_new( p_mlp,
                                                         p_instance,
                                                         p_e );
   **************************************************************************/
  void libvlc_media_list_player_release( libvlc_media_list_player_t * p_mlp )
  {
 -    free(p_mlp);
 +    if( !p_mlp )
 +        return;
 +
 +    vlc_mutex_lock( &p_mlp->object_lock );
 +
 +    p_mlp->i_refcount--;
 +    if( p_mlp->i_refcount > 0 )
 +    {
 +        vlc_mutex_unlock( &p_mlp->object_lock );
 +        return;
 +    }
 +    vlc_mutex_unlock( &p_mlp->object_lock );
 +    vlc_mutex_destroy( &p_mlp->object_lock );
 +
 +    libvlc_event_manager_release( p_mlp->p_event_manager );
 +    libvlc_media_player_release( p_mlp->p_mi );
 +
 +    if( p_mlp->p_mlist )
 +    {
 +        uninstall_playlist_observer( p_mlp );
 +        libvlc_media_list_release( p_mlp->p_mlist );
 +    }
 +
 +    free( p_mlp->current_playing_item_path );
 +    libvlc_release( p_mlp->p_libvlc_instance );
 +    free( p_mlp );
  }
  
  /**************************************************************************