Hi,
I like to change the playback speed of an audio pipeline. For that, I wrote an example which should change the playback speed to the ratio to 0.5 in the segment (T=11s => T=16s) The audio samples are generated from an app source. This generates a 300Hz sine tone with a tick every 500ms. My seek event: { gboolean update = TRUE; GstSegment segment; gst_segment_init (&segment, GST_FORMAT_TIME); printf("gst_segment_do_seek ...\n"); if( gst_segment_do_seek (&segment, 0.5, GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, GST_SEEK_TYPE_SET, pos + 1*GST_SECOND, GST_SEEK_TYPE_SET, pos + 1*GST_SECOND + 5*GST_SECOND, &update)) { GstEvent *ev = gst_event_new_segment (&segment); if( ev != NULL ) { if( !gst_element_send_event(data->audio_scaletempo,ev) ) { } } } } Instead of a changed playback speed, I get a complete mute. I don't know why? Any hint? Maik My test: gcc -o gstseektest gstseektest.c `pkg-config --cflags --libs gstreamer-1.0 gstreamer-app-1.0 gstreamer-audio-1.0` -lm ./gstseektest 0:00:00.017054010 32199 0xbd6430 INFO GST_EVENT gstevent.c:1511:gst_event_new_reconfigure: creating reconfigure event 0:00:00.017461765 32199 0xbd6430 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbbd2e0 reconfigure 61441 0:00:00.017503466 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<sink:proxypad0> have event type reconfigure event: 0xbbd2e0, time 99:99:99.999999999, seq-num 0, (NULL) 0:00:00.017778341 32199 0xbd6430 INFO GST_EVENT gstevent.c:1511:gst_event_new_reconfigure: creating reconfigure event 0:00:00.017830456 32199 0xbd6430 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbbd350 reconfigure 61441 0:00:00.017843365 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_source:src> have event type reconfigure event: 0xbbd350, time 99:99:99.999999999, seq-num 2, (NULL) 0:00:00.017855729 32199 0xbd6430 INFO GST_EVENT gstpad.c:5652:gst_pad_send_event_unchecked:<audio_source:src> Received event on flushing pad. Discarding 0:00:00.017984762 32199 0xbd6430 INFO GST_EVENT gstevent.c:1511:gst_event_new_reconfigure: creating reconfigure event 0:00:00.018048776 32199 0xbd6430 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbcb000 reconfigure 61441 0:00:00.018061161 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_queue:src> have event type reconfigure event: 0xbcb000, time 99:99:99.999999999, seq-num 5, (NULL) 0:00:00.018094548 32199 0xbd6430 INFO GST_EVENT gstpad.c:5652:gst_pad_send_event_unchecked:<audio_queue:src> Received event on flushing pad. Discarding 0:00:00.018698948 32199 0xbd6430 INFO GST_EVENT gstevent.c:1511:gst_event_new_reconfigure: creating reconfigure event 0:00:00.018768177 32199 0xbd6430 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbcb070 reconfigure 61441 0:00:00.018781683 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_scaletempo:src> have event type reconfigure event: 0xbcb070, time 99:99:99.999999999, seq-num 8, (NULL) 0:00:00.018813472 32199 0xbd6430 INFO GST_EVENT gstpad.c:5652:gst_pad_send_event_unchecked:<audio_scaletempo:src> Received event on flushing pad. Discarding 0:00:00.019507583 32199 0xbd6430 INFO GST_EVENT gstevent.c:1511:gst_event_new_reconfigure: creating reconfigure event 0:00:00.019554719 32199 0xbd6430 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbcb0e0 reconfigure 61441 0:00:00.019623702 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_convert1:src> have event type reconfigure event: 0xbcb0e0, time 99:99:99.999999999, seq-num 11, (NULL) 0:00:00.019655183 32199 0xbd6430 INFO GST_EVENT gstpad.c:5652:gst_pad_send_event_unchecked:<audio_convert1:src> Received event on flushing pad. Discarding 0:00:00.019702936 32199 0xbd6430 INFO GST_EVENT gstevent.c:1511:gst_event_new_reconfigure: creating reconfigure event 0:00:00.019729220 32199 0xbd6430 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbcb150 reconfigure 61441 0:00:00.019778134 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_resample:src> have event type reconfigure event: 0xbcb150, time 99:99:99.999999999, seq-num 14, (NULL) 0:00:00.019789796 32199 0xbd6430 INFO GST_EVENT gstpad.c:5652:gst_pad_send_event_unchecked:<audio_resample:src> Received event on flushing pad. Discarding 0:00:00.039213483 32199 0xbd6430 INFO GST_EVENT gstevent.c:1511:gst_event_new_reconfigure: creating reconfigure event 0:00:00.039277891 32199 0xbd6430 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbcb2a0 reconfigure 61441 0:00:00.039295173 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<sink:proxypad0> have event type reconfigure event: 0xbcb2a0, time 99:99:99.999999999, seq-num 18, (NULL) 0:00:00.039957859 32199 0xbcf320 FIXME default gstutils.c:3826:gst_pad_create_stream_id_internal:<audio_source:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:00.040056874 32199 0xbcf320 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbde0f0 stream-start 10254 0:00:00.040167590 32199 0xbcf320 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_queue:sink> have event type stream-start event: 0xbde0f0, time 99:99:99.999999999, seq-num 40, GstEventStreamStart, stream-id=(string)964c8ceeaaf0f109aecdf3a51767d017, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE, group-id=(uint)0; 0:00:00.040282212 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_scaletempo:sink> have event type stream-start event: 0xbde0f0, time 99:99:99.999999999, seq-num 40, GstEventStreamStart, stream-id=(string)964c8ceeaaf0f109aecdf3a51767d017, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE, group-id=(uint)0; 0:00:00.040360015 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_convert1:sink> have event type stream-start event: 0xbde0f0, time 99:99:99.999999999, seq-num 40, GstEventStreamStart, stream-id=(string)964c8ceeaaf0f109aecdf3a51767d017, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE, group-id=(uint)0; 0:00:00.040377651 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_resample:sink> have event type stream-start event: 0xbde0f0, time 99:99:99.999999999, seq-num 40, GstEventStreamStart, stream-id=(string)964c8ceeaaf0f109aecdf3a51767d017, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE, group-id=(uint)0; 0:00:00.040414557 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_sink:sink> have event type stream-start event: 0xbde0f0, time 99:99:99.999999999, seq-num 40, GstEventStreamStart, stream-id=(string)964c8ceeaaf0f109aecdf3a51767d017, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE, group-id=(uint)0; 0:00:00.040442030 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_sink-actual-sink-alsa:sink> have event type stream-start event: 0xbde0f0, time 99:99:99.999999999, seq-num 40, GstEventStreamStart, stream-id=(string)964c8ceeaaf0f109aecdf3a51767d017, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE, group-id=(uint)0; 0:00:00.040535589 32199 0xbcf320 INFO GST_EVENT gstevent.c:808:gst_event_new_caps: creating caps event audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)44100, channels=(int)1 0:00:00.040553150 32199 0xbcf320 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbde160 caps 12814 0:00:00.040568920 32199 0xbcf320 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_queue:sink> have event type caps event: 0xbde160, time 99:99:99.999999999, seq-num 44, GstEventCaps, caps=(GstCaps)"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)44100\,\ channels\=\(int\)1"; 0:00:00.040749803 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_scaletempo:sink> have event type caps event: 0xbde160, time 99:99:99.999999999, seq-num 44, GstEventCaps, caps=(GstCaps)"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)44100\,\ channels\=\(int\)1"; 0:00:00.040906240 32199 0xbcf4a0 DEBUG scaletempo gstscaletempo.c:679:gst_scaletempo_set_caps: caps: audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)44100, channels=(int)1, 2 bps 0:00:00.040950315 32199 0xbcf4a0 INFO GST_EVENT gstevent.c:808:gst_event_new_caps: creating caps event audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)44100, channels=(int)1 0:00:00.040971495 32199 0xbcf4a0 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0x7fad54004410 caps 12814 0:00:00.040990706 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_convert1:sink> have event type caps event: 0x7fad54004410, time 99:99:99.999999999, seq-num 45, GstEventCaps, caps=(GstCaps)"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)44100\,\ channels\=\(int\)1"; 0:00:00.041585263 32199 0xbcf4a0 WARN alsa conf.c:4694:snd_config_expand: alsalib error: Unknown parameters {AES0 0x02 AES1 0x82 AES2 0x00 AES3 0x02} 0:00:00.041608410 32199 0xbcf4a0 WARN alsa pcm.c:2239:snd_pcm_open_noupdate: alsalib error: Unknown PCM default:{AES0 0x02 AES1 0x82 AES2 0x00 AES3 0x02} 0:00:00.040931204 32199 0xbcf320 INFO GST_EVENT gstevent.c:889:gst_event_new_segment: creating segment event time segment start=0:00:00.000000000, offset=0:00:00.000000000, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 0:00:00.000000000, duration 99:99:99.999999999 0:00:00.042804712 32199 0xbcf320 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbde1d0 segment 17934 0:00:00.042823820 32199 0xbcf320 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_queue:sink> have event type segment event: 0xbde1d0, time 99:99:99.999999999, seq-num 35, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)1, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)0, stop=(guint64)18446744073709551615, time=(guint64)0, position=(guint64)0, duration=(guint64)18446744073709551615;"; 0:00:00.049389403 32199 0xbcf4a0 INFO GST_EVENT gstevent.c:808:gst_event_new_caps: creating caps event audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)44100, channels=(int)1 0:00:00.049533091 32199 0xbcf4a0 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0x7fad540044f0 caps 12814 0:00:00.049624092 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_resample:sink> have event type caps event: 0x7fad540044f0, time 99:99:99.999999999, seq-num 48, GstEventCaps, caps=(GstCaps)"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)44100\,\ channels\=\(int\)1"; 0:00:00.052439365 32199 0xbcf4a0 WARN audio-resampler audio-resampler.c:273:convert_taps_gint16_c: can't find exact taps 0:00:00.052530887 32199 0xbcf4a0 INFO GST_EVENT gstevent.c:808:gst_event_new_caps: creating caps event audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)44100, channels=(int)1 0:00:00.052554080 32199 0xbcf4a0 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0x7fad54004640 caps 12814 0:00:00.052610405 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_sink:sink> have event type caps event: 0x7fad54004640, time 99:99:99.999999999, seq-num 49, GstEventCaps, caps=(GstCaps)"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)44100\,\ channels\=\(int\)1"; 0:00:00.052702883 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_sink-actual-sink-alsa:sink> have event type caps event: 0x7fad54004640, time 99:99:99.999999999, seq-num 49, GstEventCaps, caps=(GstCaps)"audio/x-raw\,\ format\=\(string\)S16LE\,\ layout\=\(string\)interleaved\,\ rate\=\(int\)44100\,\ channels\=\(int\)1"; 0:00:00.062901170 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_scaletempo:sink> have event type segment event: 0xbde1d0, time 99:99:99.999999999, seq-num 35, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)1, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)0, stop=(guint64)18446744073709551615, time=(guint64)0, position=(guint64)0, duration=(guint64)18446744073709551615;"; 0:00:00.062966702 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_convert1:sink> have event type segment event: 0xbde1d0, time 99:99:99.999999999, seq-num 35, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)1, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)0, stop=(guint64)18446744073709551615, time=(guint64)0, position=(guint64)0, duration=(guint64)18446744073709551615;"; 0:00:00.063005484 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_resample:sink> have event type segment event: 0xbde1d0, time 99:99:99.999999999, seq-num 35, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)1, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)0, stop=(guint64)18446744073709551615, time=(guint64)0, position=(guint64)0, duration=(guint64)18446744073709551615;"; 0:00:00.063042013 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_sink:sink> have event type segment event: 0xbde1d0, time 99:99:99.999999999, seq-num 35, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)1, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)0, stop=(guint64)18446744073709551615, time=(guint64)0, position=(guint64)0, duration=(guint64)18446744073709551615;"; 0:00:00.063078654 32199 0xbcf4a0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_sink-actual-sink-alsa:sink> have event type segment event: 0xbde1d0, time 99:99:99.999999999, seq-num 35, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)1, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)0, stop=(guint64)18446744073709551615, time=(guint64)0, position=(guint64)0, duration=(guint64)18446744073709551615;"; 0:00:00.063479840 32199 0x7fad54003cf0 DEBUG scaletempo gstscaletempo.c:747:gst_scaletempo_query:<audio_scaletempo> Peer latency: min 0:00:00.000000000 max 0:01:40.000000000 0:00:00.063503013 32199 0x7fad54003cf0 DEBUG scaletempo gstscaletempo.c:751:gst_scaletempo_query:<audio_scaletempo> Our latency: 0:00:00.000000000 0:00:00.063515248 32199 0x7fad54003cf0 DEBUG scaletempo gstscaletempo.c:758:gst_scaletempo_query:<audio_scaletempo> Calculated total latency : min 0:00:00.000000000 max 0:01:40.000000000 0:00:00.063547392 32199 0x7fad54003cf0 INFO GST_EVENT gstevent.c:1382:gst_event_new_latency: creating latency event 0:00:00.000000000 0:00:00.063564230 32199 0x7fad54003cf0 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0x7fad54004ac0 latency 56321 0:00:00.063587530 32199 0x7fad54003cf0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<sink:proxypad0> have event type latency event: 0x7fad54004ac0, time 99:99:99.999999999, seq-num 59, GstEventLatency, latency=(guint64)0; 0:00:00.063626992 32199 0x7fad54003cf0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_resample:src> have event type latency event: 0x7fad54004ac0, time 99:99:99.999999999, seq-num 59, GstEventLatency, latency=(guint64)0; 0:00:00.063642462 32199 0x7fad54003cf0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_convert1:src> have event type latency event: 0x7fad54004ac0, time 99:99:99.999999999, seq-num 59, GstEventLatency, latency=(guint64)0; 0:00:00.063656774 32199 0x7fad54003cf0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_scaletempo:src> have event type latency event: 0x7fad54004ac0, time 99:99:99.999999999, seq-num 59, GstEventLatency, latency=(guint64)0; 0:00:00.063670622 32199 0x7fad54003cf0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_queue:src> have event type latency event: 0x7fad54004ac0, time 99:99:99.999999999, seq-num 59, GstEventLatency, latency=(guint64)0; 0:00:00.063686127 32199 0x7fad54003cf0 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_source:src> have event type latency event: 0x7fad54004ac0, time 99:99:99.999999999, seq-num 59, GstEventLatency, latency=(guint64)0; gst_segment_do_seek ... 0:00:10.022508572 32199 0xbd6430 INFO GST_EVENT gstevent.c:889:gst_event_new_segment: creating segment event time segment start=0:00:11.134149659, offset=0:00:00.000000000, stop=0:00:16.134149659, rate=0.500000, applied_rate=1.000000, flags=0x00, time=0:00:11.134149659, base=0:00:00.000000000, position 0:00:11.134149659, duration 99:99:99.999999999 0:00:10.022536518 32199 0xbd6430 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbcb310 segment 17934 0:00:10.022549032 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_scaletempo:sink> have event type segment event: 0xbcb310, time 99:99:99.999999999, seq-num 68, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)0.5, applied-rate=(double)1, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)11134149659, stop=(guint64)16134149659, time=(guint64)11134149659, position=(guint64)11134149659, duration=(guint64)18446744073709551615;"; 0:00:10.131871256 32199 0xbd6430 DEBUG scaletempo gstscaletempo.c:620:gst_scaletempo_sink_event: 0.500 scale, 0.000 stride_in, 0 stride_out 0:00:10.131914177 32199 0xbd6430 INFO GST_EVENT gstevent.c:889:gst_event_new_segment: creating segment event time segment start=0:00:11.134149659, offset=0:00:00.000000000, stop=0:00:21.134149659, rate=1.000000, applied_rate=0.500000, flags=0x00, time=0:00:11.134149659, base=0:00:00.000000000, position 0:00:11.134149659, duration 99:99:99.999999999 0:00:10.131942226 32199 0xbd6430 DEBUG GST_EVENT gstevent.c:305:gst_event_new_custom: creating new event 0xbde010 segment 17934 0:00:10.131959883 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_convert1:sink> have event type segment event: 0xbde010, time 99:99:99.999999999, seq-num 68, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)0.5, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)11134149659, stop=(guint64)21134149659, time=(guint64)11134149659, position=(guint64)11134149659, duration=(guint64)18446744073709551615;"; 0:00:10.132050951 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_resample:sink> have event type segment event: 0xbde010, time 99:99:99.999999999, seq-num 68, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)0.5, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)11134149659, stop=(guint64)21134149659, time=(guint64)11134149659, position=(guint64)11134149659, duration=(guint64)18446744073709551615;"; 0:00:10.132102178 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_sink:sink> have event type segment event: 0xbde010, time 99:99:99.999999999, seq-num 68, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)0.5, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)11134149659, stop=(guint64)21134149659, time=(guint64)11134149659, position=(guint64)11134149659, duration=(guint64)18446744073709551615;"; 0:00:10.132149719 32199 0xbd6430 DEBUG GST_EVENT gstpad.c:5546:gst_pad_send_event_unchecked:<audio_sink-actual-sink-alsa:sink> have event type segment event: 0xbde010, time 99:99:99.999999999, seq-num 68, GstEventSegment, segment=(GstSegment)"GstSegment, flags=(GstSegmentFlags)GST_SEGMENT_FLAG_NONE, rate=(double)1, applied-rate=(double)0.5, format=(GstFormat)GST_FORMAT_TIME, base=(guint64)0, offset=(guint64)0, start=(guint64)11134149659, stop=(guint64)21134149659, time=(guint64)11134149659, position=(guint64)11134149659, duration=(guint64)18446744073709551615;"; 0:00:10.133330285 32199 0xbcf4a0 DEBUG scaletempo gstscaletempo.c:424:reinit_buffers: 0.500 scale, 661.500 stride_in, 1323 stride_out, 1059 standing, 264 overlap, 617 search, 2204 queue, S16LE mode 0:00:11.095553961 32199 0xbcf4a0 WARN audiobasesink gstaudiobasesink.c:1807:gst_audio_base_sink_get_alignment:<audio_sink-actual-sink-alsa> Unexpected discontinuity in audio timestamps of -0:00:10.698526077, resyncing 0:00:11.096069902 32199 0xbcf4a0 WARN audiobasesink gstaudiobasesink.c:1807:gst_audio_base_sink_get_alignment:<audio_sink-actual-sink-alsa> Unexpected discontinuity in audio timestamps of +0:00:00.002879818, resyncing 0:00:11.097452921 32199 0xbcf4a0 WARN audiobasesink gstaudiobasesink.c:1807:gst_audio_base_sink_get_alignment:<audio_sink-actual-sink-alsa> Unexpected discontinuity in audio timestamps of +0:00:00.001859410, resyncing 0:00:11.100180015 32199 0xbcf4a0 WARN audiobasesink gstaudiobasesink.c:1807:gst_audio_base_sink_get_alignment:<audio_sink-actual-sink-alsa> Unexpected discontinuity in audio timestamps of +0:00:00.000839002, resyncing 0:00:11.120734946 32199 0xbcf4a0 WARN audiobasesink gstaudiobasesink.c:1807:gst_audio_base_sink_get_alignment:<audio_sink-actual-sink-alsa> Unexpected discontinuity in audio timestamps of +0:00:00.000113378, resyncing => audio is muted? My example code: /* compile with: * gcc -o gstseektest gstseektest.c `pkg-config --cflags --libs gstreamer-1.0 gstreamer-app-1.0 gstreamer-audio-1.0` -lm */ #include <gst/gst.h> #include <gst/audio/audio.h> #include <stdio.h> #include <string.h> #include <math.h> #define CHUNK_SIZE 1024 /* Amount of bytes we are sending in each buffer */ #define SAMPLE_RATE 44100 /* Samples per second we are sending */ /* Structure to contain all our information, so we can pass it to callbacks */ typedef struct _CustomData { GstElement *pipeline, *app_source, *audio_queue, *audio_scaletempo, *audio_convert1, *audio_resample, *audio_sink; guint64 num_samples; /* Number of samples generated so far (for timestamp generation) */ guint sourceid; /* To control the GSource */ guint timeoutid; GMainLoop *main_loop; /* GLib's Main Loop */ FILE* sink_pad_dumpfile; } CustomData; /* PAD probe for sink data capturing */ GstPadProbeReturn sink_pad_probe (GstPad *pad, GstPadProbeInfo *info, gpointer user_data) { CustomData *data = (CustomData*)user_data; if(((info->type&GST_PAD_PROBE_TYPE_BUFFER)!=0)&&(info->data != NULL)) { GstMapInfo buf_info; gst_buffer_map(GST_BUFFER(info->data), &buf_info, GST_MAP_READ); if( data->sink_pad_dumpfile != NULL ) { fwrite(buf_info.data,1,buf_info.size,data->sink_pad_dumpfile); } gst_buffer_unmap(GST_BUFFER(info->data), &buf_info); } return GST_PAD_PROBE_OK; } /* This method is called by the idle GSource in the mainloop, to feed CHUNK_SIZE bytes into appsrc. * The ide handler is added to the mainloop when appsrc requests us to start sending data (need-data signal) * and is removed when appsrc has enough data (enough-data signal). */ static gboolean push_data (CustomData *data) { GstBuffer *buffer; GstFlowReturn ret; int i; GstMapInfo map; gint16 *raw; gint num_samples = CHUNK_SIZE / 2; /* Because each sample is 16 bits */ gfloat freq; /* Create a new empty buffer */ buffer = gst_buffer_new_and_alloc (CHUNK_SIZE); /* Set its timestamp and duration */ GST_BUFFER_TIMESTAMP (buffer) = gst_util_uint64_scale (data->num_samples, GST_SECOND, SAMPLE_RATE); GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale (num_samples, GST_SECOND, SAMPLE_RATE); /* Generate some psychodelic waveforms */ gst_buffer_map (buffer, &map, GST_MAP_WRITE); raw = (gint16 *)map.data; for (i = 0; i < num_samples; i++) { raw[i] = (gint16)2000*sin((300.0*3.14*2.0*(1.0*i+data->num_samples))/(SAMPLE_RATE)); /* * generate a click every 500ms for later tempo measurement */ if( ((i+data->num_samples+1)%(SAMPLE_RATE/2)) == 0 ) { raw[i] = -30000; } else if( ((i+data->num_samples)%(SAMPLE_RATE/2)) == 0 ) { raw[i] = 30000; } } gst_buffer_unmap (buffer, &map); data->num_samples += num_samples; /* Push the buffer into the appsrc */ g_signal_emit_by_name (data->app_source, "push-buffer", buffer, &ret); /* Free the buffer now that we are done with it */ gst_buffer_unref (buffer); if (ret != GST_FLOW_OK) { /* We got some error, stop sending data */ return FALSE; } return TRUE; } /* timer for scaletempo changes */ static gboolean timeout_10000ms (CustomData *data) { GstClockTime pos; gst_element_query_position(data->pipeline,GST_FORMAT_TIME,&pos); /* * install a scaletempo segment with custom ratio */ { gboolean update = TRUE; GstSegment segment; gst_segment_init (&segment, GST_FORMAT_TIME); printf("gst_segment_do_seek ...\n"); if( gst_segment_do_seek (&segment, 0.5, GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, GST_SEEK_TYPE_SET, pos + 1*GST_SECOND, GST_SEEK_TYPE_SET, pos + 1*GST_SECOND + 5*GST_SECOND, &update)) { GstEvent *ev = gst_event_new_segment (&segment); if( ev != NULL ) { if( !gst_element_send_event(data->audio_scaletempo,ev) ) { } } } } return FALSE; } /* This signal callback triggers when appsrc needs data. Here, we add an idle handler * to the mainloop to start pushing data into the appsrc */ static void start_feed (GstElement *source, guint size, CustomData *data) { if (data->sourceid == 0) { //g_print ("Start feeding\n"); data->sourceid = g_idle_add ((GSourceFunc) push_data, data); } } /* This callback triggers when appsrc has enough data and we can stop sending. * We remove the idle handler from the mainloop */ static void stop_feed (GstElement *source, CustomData *data) { if (data->sourceid != 0) { //g_print ("Stop feeding\n"); g_source_remove (data->sourceid); data->sourceid = 0; } } /* This function is called when an error message is posted on the bus */ static void error_cb (GstBus *bus, GstMessage *msg, CustomData *data) { GError *err; gchar *debug_info; /* Print error details on the screen */ gst_message_parse_error (msg, &err, &debug_info); g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error (&err); g_free (debug_info); g_main_loop_quit (data->main_loop); } int main(int argc, char *argv[]) { CustomData data; GstAudioInfo info; GstCaps *audio_caps; GstBus *bus; /* Initialize cumstom data structure */ memset (&data, 0, sizeof (data)); /* Initialize GStreamer */ gst_init (&argc, &argv); /* Create the elements */ data.app_source = gst_element_factory_make ("appsrc", "audio_source"); data.audio_queue = gst_element_factory_make ("queue", "audio_queue"); g_object_set (data.audio_queue, "max-size-time", 100*GST_SECOND, NULL); data.audio_scaletempo = gst_element_factory_make ("scaletempo", "audio_scaletempo"); data.audio_convert1 = gst_element_factory_make ("audioconvert", "audio_convert1"); data.audio_resample = gst_element_factory_make ("audioresample", "audio_resample"); #if 1 data.audio_sink = gst_element_factory_make ("autoaudiosink", "audio_sink"); #else data.audio_sink = gst_element_factory_make ("alsasink", "audio_sink"); g_object_set (data.audio_sink, "sync", TRUE, "slave-method", 1, NULL); #endif /* Create the empty pipeline */ data.pipeline = gst_pipeline_new ("test-pipeline"); if (!data.pipeline || !data.app_source || !data.audio_queue || !data.audio_scaletempo || !data.audio_convert1 || !data.audio_resample || !data.audio_sink ) { g_printerr ("Not all elements could be created.\n"); return -1; } /* Configure appsrc */ gst_audio_info_set_format (&info, GST_AUDIO_FORMAT_S16, SAMPLE_RATE, 1, NULL); audio_caps = gst_audio_info_to_caps (&info); g_object_set (data.app_source, "is-live", FALSE, "caps", audio_caps, "format", GST_FORMAT_TIME, NULL); g_signal_connect (data.app_source, "need-data", G_CALLBACK (start_feed), &data); g_signal_connect (data.app_source, "enough-data", G_CALLBACK (stop_feed), &data); /* Link all elements that can be automatically linked because they have "Always" pads */ gst_bin_add_many (GST_BIN (data.pipeline), data.app_source, data.audio_queue, data.audio_scaletempo, data.audio_convert1, data.audio_resample, data.audio_sink, NULL); if (gst_element_link_many (data.app_source, data.audio_queue, data.audio_scaletempo, data.audio_convert1, data.audio_resample, data.audio_sink, NULL) != TRUE ) { g_printerr ("Elements could not be linked.\n"); gst_object_unref (data.pipeline); return -1; } /* * pad probe for offline analysis */ data.sink_pad_dumpfile = fopen("gstseektest.raw","wb"); gst_pad_add_probe( gst_element_get_static_pad(data.audio_sink, "sink"), GST_PAD_PROBE_TYPE_BUFFER, sink_pad_probe, &data, NULL); /* Instruct the bus to emit signals for each received message, and connect to the interesting signals */ bus = gst_element_get_bus (data.pipeline); gst_bus_add_signal_watch (bus); g_signal_connect (G_OBJECT (bus), "message::error", (GCallback)error_cb, &data); gst_object_unref (bus); /* * timer for scaletempo changes */ data.timeoutid = g_timeout_add ( 10000, (GSourceFunc) timeout_10000ms, &data); /* Start playing the pipeline */ gst_element_set_state (data.pipeline, GST_STATE_PLAYING); /* Create a GLib Main Loop and set it to run */ data.main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (data.main_loop); /* Free resources */ gst_element_set_state (data.pipeline, GST_STATE_NULL); gst_object_unref (data.pipeline); return 0; } -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |