GNOME Bugzilla – Bug 485462
alsaspdifsink uses wrong sample rate
Last modified: 2007-11-15 18:41:47 UTC
When using the following pipeline: gst-launch-0.10 filesrc location=ac3-sample.avi ! decodebin2 caps=audio/x-ac3 ! ac3iec958 ! alsaspdifsink the output on the S/PDIF is using a wrong sample rate of 44100 Hz (should be 48000). All pads show the correct rate 48KHz, but the AVR shows 44.1KHz and sound is slowed down. On the same system I can play the file using xine or mplayer without problems.
Created attachment 97013 [details] output of gst-launch with GST_DEBUG=*sink*:5
sorry, can you make a log with: GST_DEBUG=*sink*:5,*ring*:5 please. This one does not show the samplerate as negotiated with the sink.
Created attachment 97056 [details] output of gst-launch with GST_DEBUG=*sink*:5,*ring*:5 sure, here it is - although I'm not sure if it is what you need, from looking at it I can't find additional info?
I just looked at alsaspdifsink.c and discovered that the ALSA PCM sample rate is only set in alsaspdifsink_open, which happens very early (you can see that in the log when it prints "Generated device string..."). Perhaps the caps containing the actual sample rate get set later, but the ALSA PCM sample rate never gets updated? I'll try to verify this once I'm home.
Created attachment 97060 [details] output of gst-launch with GST_DEBUG=*sink*:5,*ring*:5 GST_DEBUG_NO_COLOR=1 just found out about the GST_DEBUG_NO_COLOR flag :)
Created attachment 97081 [details] [review] sets the correct rate This works for me, it sets all ALSA parameters (incl. rate) when the caps have changed.
Created attachment 97211 [details] [review] set correct sample rate, fix clock issues, remove some hw params In addition to the sample rate fix, this is an attempt to fix the clock. It should now at least return reasonable values. Also, I removed some hardware params (buffer_time, period_time). These broke output on my Audiophile 24/96 (ICE1712) - without them, it works. Tested with ICE1712 and AD198x (Intel HDA).
Created attachment 97213 [details] output of a simple pyGst player (audio/video) with GST_DEBUG=*sink*:5 Log from a simple pyGst test player. One issue remaining: video has some kind of "micro-stutter", it looks like every 20th video frame or so gets dropped or delayed.
Created attachment 97214 [details] output of a simple pyGst player, with fakesink for audio
Patch by: Michael Kötter <m dot koetter at oraise dot de> * ext/alsaspdif/alsaspdifsink.c: (alsaspdifsink_set_caps), (alsaspdifsink_get_time), (alsaspdifsink_open), (alsaspdifsink_set_params), (alsaspdifsink_delay), (plugin_init): Fix sample rate and clocking. Remove buffer_time and period_time as this seems to break on some hardware. Fixes #485462.