+2006-05-19 Michael Smith <msmith@fluendo.com>
+
+ * ext/alsaspdif/alsaspdifsink.c: (alsaspdifsink_base_init),
+ (alsaspdifsink_class_init), (alsaspdifsink_init),
+ (alsaspdifsink_dispose), (alsaspdifsink_set_property),
+ (alsaspdifsink_get_property), (alsaspdifsink_set_caps),
+ (alsaspdifsink_get_time), (alsaspdifsink_open),
+ (alsaspdifsink_close), (alsaspdifsink_find_pcm_device),
+ (alsaspdifsink_write_frame), (alsaspdifsink_event),
+ (alsaspdifsink_get_times), (alsaspdifsink_current_delay),
+ (generate_iec958_zero_frame), (alsaspdifsink_render),
+ (ignore_alsa_err), (alsaspdifsink_change_state), (plugin_init):
+ * ext/alsaspdif/alsaspdifsink.h:
+ Use sampling rate from set_caps. Comment out some more unused code.
+
2006-05-18 Stefan Kost <ensonic@users.sf.net>
* configure.ac:
/* The magic audio-type we pretend to be for AC3 output */
#define AC3_CHANNELS 2
-#define AC3_RATE 48000
#define AC3_BITS 16
/* Define AC3 FORMAT as big endian. Fall back to swapping
/* The size in bytes of an IEC958 frame. */
#define IEC958_FRAME_SIZE 6144
+/* Size in bytes of an ALSA PCM frame (4, for this case). */
+#define ALSASPDIFSINK_BYTES_PER_FRAME ((AC3_BITS / 8) * AC3_CHANNELS)
+
+#if 0
/* The duration of a single IEC958 frame. */
#define IEC958_FRAME_DURATION (32 * GST_MSECOND)
value. */
#define MAX_SYNC_DIFF (IEC958_FRAME_DURATION * 0.8)
-/* Size in bytes of an ALSA PCM frame (4, for this case). */
-#define ALSASPDIFSINK_BYTES_PER_FRAME ((AC3_BITS / 8) * AC3_CHANNELS)
-
/* Playing time for the given number of ALSA PCM frames. */
#define ALSASPDIFSINK_TIME_PER_FRAMES(sink, frames) \
(((GstClockTime) (frames) * GST_SECOND) / AC3_RATE)
/* Number of ALSA PCM frames for the given playing time. */
#define ALSASPDIFSINK_FRAMES_PER_TIME(sink, time) \
(((GstClockTime) AC3_RATE * (time)) / GST_SECOND)
+#endif
/* ElementFactory information. */
static GstElementDetails alsaspdifsink_details = {
GstBuffer * buf);
static void alsaspdifsink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
GstClockTime * start, GstClockTime * end);
+static gboolean alsaspdifsink_set_caps (GstBaseSink * bsink, GstCaps * caps);
static gboolean alsaspdifsink_open (AlsaSPDIFSink * sink);
static void alsaspdifsink_close (AlsaSPDIFSink * sink);
gstbasesink_class->event = alsaspdifsink_event;
gstbasesink_class->render = alsaspdifsink_render;
gstbasesink_class->get_times = alsaspdifsink_get_times;
+ gstbasesink_class->set_caps = alsaspdifsink_set_caps;
#if 0
/* We ignore the device property anyway, so don't install it
}
}
+static gboolean
+alsaspdifsink_set_caps (GstBaseSink * bsink, GstCaps * caps)
+{
+ AlsaSPDIFSink *sink = ALSASPDIFSINK (bsink);
+
+ if (!gst_structure_get_int (gst_caps_get_structure (caps, 0), "rate",
+ &sink->rate))
+ sink->rate = 48000;
+
+ return TRUE;
+}
+
static GstClock *
alsaspdifsink_provide_clock (GstElement * elem)
{
{
AlsaSPDIFSink *sink = ALSASPDIFSINK (user_data);
- return sink->frames * IEC958_FRAME_DURATION;
+ return sink->frames * sink->rate / 1536;
}
static gboolean
goto __close;
}
- rate = AC3_RATE;
+ rate = sink->rate;
err = snd_pcm_hw_params_set_rate_near (sink->pcm, params, &rate, 0);
if (err < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,