Commit 14d7abc2 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵
Browse files

ext/wavpack/gstwavpackparse.c: Use G_GINT64_CONSTANT, this fixes the duration...

ext/wavpack/gstwavpackparse.c: Use G_GINT64_CONSTANT, this fixes the duration query on files without known length.

Original commit message from CVS:
* ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_reset),
(gst_wavpack_parse_src_query), (gst_wavpack_parse_create_src_pad):
Use G_GINT64_CONSTANT, this fixes the duration query on files without
known length.
parent 96da5200
2008-06-19 Sebastian Dröge <slomo@circular-chaos.org>
* ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_reset),
(gst_wavpack_parse_src_query), (gst_wavpack_parse_create_src_pad):
Use G_GINT64_CONSTANT, this fixes the duration query on files without
known length.
2008-06-19 Sebastian Dröge <slomo@circular-chaos.org>
 
* gst/matroska/matroska-demux.c:
......
......@@ -93,14 +93,18 @@ static GstStaticPadTemplate wvc_src_factory = GST_STATIC_PAD_TEMPLATE ("wvcsrc",
);
static gboolean gst_wavpack_parse_sink_activate (GstPad * sinkpad);
static gboolean
gst_wavpack_parse_sink_activate_pull (GstPad * sinkpad, gboolean active);
static void gst_wavpack_parse_loop (GstElement * element);
static GstStateChangeReturn gst_wavpack_parse_change_state (GstElement *
element, GstStateChange transition);
static void gst_wavpack_parse_reset (GstWavpackParse * parse);
static gint64 gst_wavpack_parse_get_upstream_length (GstWavpackParse * wvparse);
static GstBuffer *gst_wavpack_parse_pull_buffer (GstWavpackParse * wvparse,
gint64 offset, guint size, GstFlowReturn * flow);
static GstFlowReturn gst_wavpack_parse_chain (GstPad * pad, GstBuffer * buf);
......@@ -139,6 +143,7 @@ static void
gst_wavpack_parse_class_init (GstWavpackParseClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
......@@ -162,6 +167,7 @@ gst_wavpack_parse_index_get_entry_from_sample (GstWavpackParse * wvparse,
gint64 sample_offset)
{
gint i;
GSList *node;
if (wvparse->entries == NULL)
......@@ -220,7 +226,7 @@ gst_wavpack_parse_index_append_entry (GstWavpackParse * wvparse,
static void
gst_wavpack_parse_reset (GstWavpackParse * parse)
{
parse->total_samples = -1;
parse->total_samples = G_GINT64_CONSTANT (-1);
parse->samplerate = 0;
parse->channels = 0;
......@@ -282,12 +288,15 @@ static gboolean
gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
{
GstWavpackParse *parse = GST_WAVPACK_PARSE (gst_pad_get_parent (pad));
GstFormat format;
gboolean ret = FALSE;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:{
gint64 cur;
guint rate;
GST_OBJECT_LOCK (parse);
......@@ -322,6 +331,7 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
}
case GST_QUERY_DURATION:{
gint64 len;
guint rate;
GST_OBJECT_LOCK (parse);
......@@ -338,7 +348,7 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
switch (format) {
case GST_FORMAT_TIME:
if (len != -1)
if (len != G_GINT64_CONSTANT (-1))
len = gst_util_uint64_scale_int (len, GST_SECOND, rate);
gst_query_set_duration (query, GST_FORMAT_TIME, len);
ret = TRUE;
......@@ -359,6 +369,7 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
if (format == GST_FORMAT_TIME || format == GST_FORMAT_DEFAULT) {
gboolean seekable;
gint64 duration = -1;
/* only fails if we didn't read the headers yet and can't say
......@@ -399,7 +410,9 @@ gst_wavpack_parse_scan_to_find_sample (GstWavpackParse * parse,
gint64 sample, gint64 * byte_offset, gint64 * start_sample)
{
GstWavpackParseIndexEntry *entry;
GstFlowReturn ret;
gint64 off = 0;
/* first, check if we have to scan at all */
......@@ -427,6 +440,7 @@ gst_wavpack_parse_scan_to_find_sample (GstWavpackParse * parse,
/* now scan forward until we find the chunk we're looking for or hit EOS */
do {
WavpackHeader header;
GstBuffer *buf;
buf = gst_wavpack_parse_pull_buffer (parse, off, sizeof (WavpackHeader),
......@@ -464,10 +478,15 @@ static gboolean
gst_wavpack_parse_send_newsegment (GstWavpackParse * wvparse, gboolean update)
{
GstSegment *s = &wvparse->segment;
gboolean ret;
gint64 stop_time = -1;
gint64 start_time = 0;
gint64 cur_pos_time;
gint64 diff;
/* segment is in DEFAULT format, but we want to send a TIME newsegment */
......@@ -504,18 +523,31 @@ gst_wavpack_parse_handle_seek_event (GstWavpackParse * wvparse,
GstEvent * event)
{
GstSeekFlags seek_flags;
GstSeekType start_type;
GstSeekType stop_type;
GstSegment segment;
GstFormat format;
gboolean only_update;
gboolean flush, ret;
gdouble speed;
gint64 stop;
gint64 start; /* sample we want to seek to */
gint64 byte_offset; /* byte offset the chunk we seek to starts at */
gint64 chunk_start; /* first sample in chunk we seek to */
guint rate;
gint64 last_stop;
if (wvparse->adapter) {
......@@ -641,6 +673,7 @@ static gboolean
gst_wavpack_parse_sink_event (GstPad * pad, GstEvent * event)
{
GstWavpackParse *parse;
gboolean ret = TRUE;
parse = GST_WAVPACK_PARSE (gst_pad_get_parent (pad));
......@@ -699,6 +732,7 @@ static gboolean
gst_wavpack_parse_src_event (GstPad * pad, GstEvent * event)
{
GstWavpackParse *parse;
gboolean ret;
parse = GST_WAVPACK_PARSE (gst_pad_get_parent (pad));
......@@ -720,6 +754,7 @@ static void
gst_wavpack_parse_init (GstWavpackParse * parse, GstWavpackParseClass * gclass)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (parse);
GstPadTemplate *tmpl;
tmpl = gst_element_class_get_pad_template (klass, "sink");
......@@ -760,6 +795,7 @@ gst_wavpack_parse_pull_buffer (GstWavpackParse * wvparse, gint64 offset,
guint size, GstFlowReturn * flow)
{
GstFlowReturn flow_ret;
GstBuffer *buf = NULL;
if (offset + size >= wvparse->upstream_length) {
......@@ -800,7 +836,9 @@ gst_wavpack_parse_create_src_pad (GstWavpackParse * wvparse, GstBuffer * buf,
WavpackHeader * header)
{
GstWavpackMetadata meta;
GstCaps *caps = NULL;
guchar *bufptr;
g_assert (wvparse->srcpad == NULL);
......@@ -820,9 +858,13 @@ gst_wavpack_parse_create_src_pad (GstWavpackParse * wvparse, GstBuffer * buf,
case ID_WV_BITSTREAM:
case ID_WVX_BITSTREAM:{
WavpackStreamReader *stream_reader = gst_wavpack_stream_reader_new ();
WavpackContext *wpc;
gchar error_msg[80];
read_id rid;
gint channel_mask;
rid.buffer = GST_BUFFER_DATA (buf);
......@@ -837,8 +879,9 @@ gst_wavpack_parse_create_src_pad (GstWavpackParse * wvparse, GstBuffer * buf,
wvparse->samplerate = WavpackGetSampleRate (wpc);
wvparse->channels = WavpackGetNumChannels (wpc);
wvparse->total_samples = (header->total_samples == (int32_t) - 1) ?
-1 : header->total_samples;
wvparse->total_samples =
(header->total_samples ==
0xffffffff) ? G_GINT64_CONSTANT (-1) : header->total_samples;
caps = gst_caps_new_simple ("audio/x-wavpack",
"width", G_TYPE_INT, WavpackGetBitsPerSample (wpc),
......@@ -973,6 +1016,7 @@ static guint8 *
gst_wavpack_parse_find_marker (guint8 * buf, guint size)
{
int i;
guint8 *ret = NULL;
if (G_UNLIKELY (size < 4))
......@@ -991,11 +1035,13 @@ static GstFlowReturn
gst_wavpack_parse_resync_loop (GstWavpackParse * parse, WavpackHeader * header)
{
GstFlowReturn flow_ret = GST_FLOW_UNEXPECTED;
GstBuffer *buf = NULL;
/* loop until we have a frame header or reach the end of the stream */
while (1) {
guint8 *data, *marker;
guint len, size;
if (buf) {
......@@ -1056,6 +1102,7 @@ static void
gst_wavpack_parse_loop (GstElement * element)
{
GstWavpackParse *parse = GST_WAVPACK_PARSE (element);
GstFlowReturn flow_ret;
WavpackHeader header = { {0,}, 0, };
GstBuffer *buf = NULL;
......@@ -1131,6 +1178,7 @@ static gboolean
gst_wavpack_parse_resync_adapter (GstAdapter * adapter)
{
const guint8 *buf, *marker;
guint avail = gst_adapter_available (adapter);
if (avail < 4)
......@@ -1162,8 +1210,11 @@ static GstFlowReturn
gst_wavpack_parse_chain (GstPad * pad, GstBuffer * buf)
{
GstWavpackParse *wvparse = GST_WAVPACK_PARSE (GST_PAD_PARENT (pad));
GstFlowReturn ret = GST_FLOW_OK;
WavpackHeader wph;
const guint8 *tmp_buf;
if (!wvparse->adapter) {
......@@ -1223,6 +1274,7 @@ static GstStateChangeReturn
gst_wavpack_parse_change_state (GstElement * element, GstStateChange transition)
{
GstWavpackParse *wvparse = GST_WAVPACK_PARSE (element);
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
switch (transition) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment