2047 wav->dataleft = upstream_size - wav->offset - wav->datastart;
2048 wav->end_offset = upstream_size;
2049
2050 /* Get the next n bytes and output them, if we can */
2051 if (wav->dataleft == 0 || wav->dataleft < wav->blockalign)
2052 goto found_eos;
2053 } else {
2054 goto found_eos;
2055 }
2056 }
2057
2058 /* scale the amount of data by the segment rate so we get equal
2059 * amounts of data regardless of the playback rate */
2060 desired =
2061 MIN (gst_guint64_to_gdouble (wav->dataleft),
2062 wav->max_buf_size * ABS (wav->segment.rate));
2063
2064 if (desired >= wav->blockalign && wav->blockalign > 0)
2065 desired -= (desired % wav->blockalign);
2066
2067 GST_LOG_OBJECT (wav, "Fetching %" G_GINT64_FORMAT " bytes of data "
2068 "from the sinkpad", desired);
2069
2070 if (wav->streaming) {
2071 guint avail = gst_adapter_available (wav->adapter);
2072 guint extra;
2073
2074 /* flush some bytes if evil upstream sends segment that starts
2075 * before data or does is not send sample aligned segment */
2076 if (G_LIKELY (wav->offset >= wav->datastart)) {
2077 extra = (wav->offset - wav->datastart) % wav->bytes_per_sample;
2078 } else {
2079 extra = wav->datastart - wav->offset;
2080 }
2081
2082 if (G_UNLIKELY (extra)) {
2083 extra = wav->bytes_per_sample - extra;
2084 if (extra <= avail) {
2085 GST_DEBUG_OBJECT (wav, "flushing %u bytes to sample boundary", extra);
2086 gst_adapter_flush (wav->adapter, extra);
|
2047 wav->dataleft = upstream_size - wav->offset - wav->datastart;
2048 wav->end_offset = upstream_size;
2049
2050 /* Get the next n bytes and output them, if we can */
2051 if (wav->dataleft == 0 || wav->dataleft < wav->blockalign)
2052 goto found_eos;
2053 } else {
2054 goto found_eos;
2055 }
2056 }
2057
2058 /* scale the amount of data by the segment rate so we get equal
2059 * amounts of data regardless of the playback rate */
2060 desired =
2061 MIN (gst_guint64_to_gdouble (wav->dataleft),
2062 wav->max_buf_size * ABS (wav->segment.rate));
2063
2064 if (desired >= wav->blockalign && wav->blockalign > 0)
2065 desired -= (desired % wav->blockalign);
2066
2067 #ifdef GSTREAMER_LITE
2068 if (desired == 0) {
2069 GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL),
2070 ("Invalid stream"));
2071 return GST_FLOW_ERROR;
2072 }
2073 #endif // GSTREAMER_LITE
2074
2075 GST_LOG_OBJECT (wav, "Fetching %" G_GINT64_FORMAT " bytes of data "
2076 "from the sinkpad", desired);
2077
2078 if (wav->streaming) {
2079 guint avail = gst_adapter_available (wav->adapter);
2080 guint extra;
2081
2082 /* flush some bytes if evil upstream sends segment that starts
2083 * before data or does is not send sample aligned segment */
2084 if (G_LIKELY (wav->offset >= wav->datastart)) {
2085 extra = (wav->offset - wav->datastart) % wav->bytes_per_sample;
2086 } else {
2087 extra = wav->datastart - wav->offset;
2088 }
2089
2090 if (G_UNLIKELY (extra)) {
2091 extra = wav->bytes_per_sample - extra;
2092 if (extra <= avail) {
2093 GST_DEBUG_OBJECT (wav, "flushing %u bytes to sample boundary", extra);
2094 gst_adapter_flush (wav->adapter, extra);
|