gst-gmyth/mythsrc/gstmythtvsrc.c
branchtrunk
changeset 774 366b0fd1eead
parent 754 cb885ee44618
child 812 cf7e02ee3db4
     1.1 --- a/gst-gmyth/mythsrc/gstmythtvsrc.c	Thu Jun 14 20:40:47 2007 +0100
     1.2 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c	Wed Jul 04 08:38:36 2007 +0100
     1.3 @@ -383,7 +383,7 @@
     1.4      G_OBJECT_CLASS(parent_class)->finalize(gobject);
     1.5  }
     1.6  
     1.7 -static          GMythFileReadResult
     1.8 +static GMythFileReadResult
     1.9  do_read_request_response(GstMythtvSrc * src, guint size,
    1.10                           GByteArray * data_ptr)
    1.11  {
    1.12 @@ -457,7 +457,7 @@
    1.13      return result;
    1.14  }
    1.15  
    1.16 -static          GstFlowReturn
    1.17 +static GstFlowReturn
    1.18  gst_mythtv_src_create(GstPushSrc * psrc, GstBuffer ** outbuf)
    1.19  {
    1.20      GstMythtvSrc   *src;
    1.21 @@ -498,8 +498,8 @@
    1.22          /*
    1.23           * got the next program info? 
    1.24           */
    1.25 -        if (G_UNLIKELY(src->update_prog_chain)
    1.26 -            || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)) {
    1.27 +        if (G_UNLIKELY(src->update_prog_chain) || 
    1.28 +            (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)) {
    1.29              GST_DEBUG_OBJECT(src,
    1.30                               "Update PROGRAM CHAIN!!! buffer_size = %d.",
    1.31                               src->bytes_queue->len);
    1.32 @@ -543,14 +543,13 @@
    1.33          /*
    1.34           */
    1.35          if (G_UNLIKELY(buffer->len < 0)) {
    1.36 -
    1.37              if (buffer != NULL) {
    1.38                  g_byte_array_free(buffer, TRUE);
    1.39                  buffer = NULL;
    1.40              }
    1.41  
    1.42 -            if (src->live_tv
    1.43 -                || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN))
    1.44 +            if (src->live_tv || 
    1.45 +                (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN))
    1.46                  goto change_progchain;
    1.47              else
    1.48                  goto read_error;
    1.49 @@ -561,8 +560,12 @@
    1.50                  buffer = NULL;
    1.51              }
    1.52  
    1.53 -            if (!src->live_tv)
    1.54 -                goto done;
    1.55 +            if (!src->live_tv) {
    1.56 +                if (src->eos)
    1.57 +                    goto eos;
    1.58 +                else 
    1.59 +                    goto done;
    1.60 +            }
    1.61              else
    1.62                  goto program_chain_changed;
    1.63          }
    1.64 @@ -589,9 +592,10 @@
    1.65           */
    1.66      }
    1.67  
    1.68 -    guint           buffer_size =
    1.69 -        (src->buffer_remain <
    1.70 -         MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
    1.71 +    guint buffer_size;
    1.72 +    buffer_size = (src->buffer_remain <  MAX_READ_SIZE) ? 
    1.73 +                   src->buffer_remain : 
    1.74 +                   MAX_READ_SIZE;
    1.75  
    1.76      *outbuf = gst_buffer_new();
    1.77  
    1.78 @@ -623,21 +627,17 @@
    1.79      src->bytes_queue =
    1.80          g_byte_array_remove_range(src->bytes_queue, 0, buffer_size);
    1.81  
    1.82 -    if (G_UNLIKELY(src->eos) || (!src->live_tv
    1.83 -                                 && (src->bytes_read >=
    1.84 -                                     src->content_size)))
    1.85 +    if (src->eos  || 
    1.86 +        (!src->live_tv && (src->bytes_read >= src->content_size))
    1.87 +       )
    1.88          goto eos;
    1.89  
    1.90    done:
    1.91      {
    1.92 -        const gchar    *reason = gst_flow_get_name(ret);
    1.93          return ret;
    1.94      }
    1.95    eos:
    1.96      {
    1.97 -        const gchar    *reason = gst_flow_get_name(ret);
    1.98 -
    1.99 -        GST_DEBUG_OBJECT(src, "pausing task, reason %s", reason);
   1.100          return GST_FLOW_UNEXPECTED;
   1.101      }
   1.102      /*
   1.103 @@ -700,7 +700,7 @@
   1.104  
   1.105  }
   1.106  
   1.107 -static          gboolean
   1.108 +static gboolean
   1.109  gst_mythtv_src_do_seek(GstBaseSrc * base, GstSegment * segment)
   1.110  {
   1.111      GstMythtvSrc   *src = GST_MYTHTV_SRC(base);
   1.112 @@ -764,7 +764,7 @@
   1.113  /*
   1.114   * create a socket for connecting to remote server 
   1.115   */
   1.116 -static          gboolean
   1.117 +static gboolean
   1.118  gst_mythtv_src_start(GstBaseSrc * bsrc)
   1.119  {
   1.120      GstMythtvSrc   *src = GST_MYTHTV_SRC(bsrc);
   1.121 @@ -972,7 +972,7 @@
   1.122  
   1.123  }
   1.124  
   1.125 -static          gboolean
   1.126 +static gboolean
   1.127  gst_mythtv_src_get_size(GstBaseSrc * bsrc, guint64 * size)
   1.128  {
   1.129      GstMythtvSrc   *src = GST_MYTHTV_SRC(bsrc);
   1.130 @@ -1010,7 +1010,7 @@
   1.131   * close the socket and associated resources used both to recover from
   1.132   * errors and go to NULL state 
   1.133   */
   1.134 -static          gboolean
   1.135 +static gboolean
   1.136  gst_mythtv_src_stop(GstBaseSrc * bsrc)
   1.137  {
   1.138      GstMythtvSrc   *src = GST_MYTHTV_SRC(bsrc);
   1.139 @@ -1024,17 +1024,15 @@
   1.140      return TRUE;
   1.141  }
   1.142  
   1.143 -static          gboolean
   1.144 +static gboolean
   1.145  gst_mythtv_src_handle_event(GstPad * pad, GstEvent * event)
   1.146  {
   1.147      GstMythtvSrc   *src = GST_MYTHTV_SRC(GST_PAD_PARENT(pad));
   1.148      gint64          cont_size = 0;
   1.149 -    gboolean        ret = FALSE;
   1.150 +    gboolean        ret = TRUE;
   1.151  
   1.152      switch (GST_EVENT_TYPE(event)) {
   1.153      case GST_EVENT_EOS:
   1.154 -        GST_WARNING_OBJECT(src, "Got EOS event");
   1.155 -
   1.156          if (src->live_tv) {
   1.157              cont_size = gst_mythtv_src_get_position(src);
   1.158              if (cont_size > src->content_size) {
   1.159 @@ -1051,16 +1049,17 @@
   1.160          ret = gst_pad_event_default(pad, event);
   1.161      }
   1.162  
   1.163 +    GST_DEBUG_OBJECT (src, "HANDLE EVENT %d", ret);
   1.164      return ret;
   1.165  }
   1.166  
   1.167 -static          gboolean
   1.168 +static gboolean
   1.169  gst_mythtv_src_is_seekable(GstBaseSrc * push_src)
   1.170  {
   1.171      return TRUE;
   1.172  }
   1.173  
   1.174 -static          gboolean
   1.175 +static gboolean
   1.176  gst_mythtv_src_handle_query(GstPad * pad, GstQuery * query)
   1.177  {
   1.178      gboolean        res = FALSE;
   1.179 @@ -1107,12 +1106,12 @@
   1.180      return res;
   1.181  }
   1.182  
   1.183 -static          GstStateChangeReturn
   1.184 +static GstStateChangeReturn
   1.185  gst_mythtv_src_change_state(GstElement * element,
   1.186                              GstStateChange transition)
   1.187  {
   1.188      GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
   1.189 -    GstMythtvSrc   *src = GST_MYTHTV_SRC(element);
   1.190 +    GstMythtvSrc  *src = GST_MYTHTV_SRC(element);
   1.191  
   1.192      switch (transition) {
   1.193      case GST_STATE_CHANGE_NULL_TO_READY:
   1.194 @@ -1133,11 +1132,10 @@
   1.195          break;
   1.196      }
   1.197  
   1.198 -
   1.199 -    ret =
   1.200 -        GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
   1.201 -    if (ret == GST_STATE_CHANGE_FAILURE)
   1.202 +    ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
   1.203 +    if (ret == GST_STATE_CHANGE_FAILURE) {
   1.204          return ret;
   1.205 +    }
   1.206  
   1.207  
   1.208      switch (transition) {
   1.209 @@ -1293,7 +1291,7 @@
   1.210      GST_OBJECT_UNLOCK(mythtvsrc);
   1.211  }
   1.212  
   1.213 -static          gboolean
   1.214 +static gboolean
   1.215  plugin_init(GstPlugin * plugin)
   1.216  {
   1.217      return gst_element_register(plugin, "mythtvsrc", GST_RANK_NONE,
   1.218 @@ -1309,7 +1307,7 @@
   1.219  
   1.220  
   1.221  /*** GSTURIHANDLER INTERFACE *************************************************/
   1.222 -static          guint
   1.223 +static guint
   1.224  gst_mythtv_src_uri_get_type(void)
   1.225  {
   1.226      return GST_URI_SRC;
   1.227 @@ -1331,7 +1329,7 @@
   1.228      return src->uri_name;
   1.229  }
   1.230  
   1.231 -static          gboolean
   1.232 +static gboolean
   1.233  gst_mythtv_src_uri_set_uri(GstURIHandler * handler, const gchar * uri)
   1.234  {
   1.235      GstMythtvSrc   *src = GST_MYTHTV_SRC(handler);