mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
ext/alsaspdif/alsaspdifsink.*: Use sampling rate from set_caps. Comment out some more unused code.
Original commit message from CVS: * 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.
This commit is contained in:
parent
957ad05fa6
commit
c21a6c3ece
4 changed files with 39 additions and 7 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
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>
|
2006-05-18 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
* configure.ac:
|
* configure.ac:
|
||||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit 6811863fce665ce0a466bc03ee2ac5e2d5f47d28
|
Subproject commit 764c5f25101d20da7f26942c36ba840ba65c63d7
|
|
@ -37,7 +37,6 @@ GST_DEBUG_CATEGORY_STATIC (alsaspdifsink_debug);
|
||||||
|
|
||||||
/* The magic audio-type we pretend to be for AC3 output */
|
/* The magic audio-type we pretend to be for AC3 output */
|
||||||
#define AC3_CHANNELS 2
|
#define AC3_CHANNELS 2
|
||||||
#define AC3_RATE 48000
|
|
||||||
#define AC3_BITS 16
|
#define AC3_BITS 16
|
||||||
|
|
||||||
/* Define AC3 FORMAT as big endian. Fall back to swapping
|
/* Define AC3 FORMAT as big endian. Fall back to swapping
|
||||||
|
@ -48,6 +47,10 @@ GST_DEBUG_CATEGORY_STATIC (alsaspdifsink_debug);
|
||||||
/* The size in bytes of an IEC958 frame. */
|
/* The size in bytes of an IEC958 frame. */
|
||||||
#define IEC958_FRAME_SIZE 6144
|
#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. */
|
/* The duration of a single IEC958 frame. */
|
||||||
#define IEC958_FRAME_DURATION (32 * GST_MSECOND)
|
#define IEC958_FRAME_DURATION (32 * GST_MSECOND)
|
||||||
|
|
||||||
|
@ -56,9 +59,6 @@ GST_DEBUG_CATEGORY_STATIC (alsaspdifsink_debug);
|
||||||
value. */
|
value. */
|
||||||
#define MAX_SYNC_DIFF (IEC958_FRAME_DURATION * 0.8)
|
#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. */
|
/* Playing time for the given number of ALSA PCM frames. */
|
||||||
#define ALSASPDIFSINK_TIME_PER_FRAMES(sink, frames) \
|
#define ALSASPDIFSINK_TIME_PER_FRAMES(sink, frames) \
|
||||||
(((GstClockTime) (frames) * GST_SECOND) / AC3_RATE)
|
(((GstClockTime) (frames) * GST_SECOND) / AC3_RATE)
|
||||||
|
@ -66,6 +66,7 @@ GST_DEBUG_CATEGORY_STATIC (alsaspdifsink_debug);
|
||||||
/* Number of ALSA PCM frames for the given playing time. */
|
/* Number of ALSA PCM frames for the given playing time. */
|
||||||
#define ALSASPDIFSINK_FRAMES_PER_TIME(sink, time) \
|
#define ALSASPDIFSINK_FRAMES_PER_TIME(sink, time) \
|
||||||
(((GstClockTime) AC3_RATE * (time)) / GST_SECOND)
|
(((GstClockTime) AC3_RATE * (time)) / GST_SECOND)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ElementFactory information. */
|
/* ElementFactory information. */
|
||||||
static GstElementDetails alsaspdifsink_details = {
|
static GstElementDetails alsaspdifsink_details = {
|
||||||
|
@ -112,6 +113,7 @@ static GstFlowReturn alsaspdifsink_render (GstBaseSink * bsink,
|
||||||
GstBuffer * buf);
|
GstBuffer * buf);
|
||||||
static void alsaspdifsink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
|
static void alsaspdifsink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
|
||||||
GstClockTime * start, GstClockTime * end);
|
GstClockTime * start, GstClockTime * end);
|
||||||
|
static gboolean alsaspdifsink_set_caps (GstBaseSink * bsink, GstCaps * caps);
|
||||||
|
|
||||||
static gboolean alsaspdifsink_open (AlsaSPDIFSink * sink);
|
static gboolean alsaspdifsink_open (AlsaSPDIFSink * sink);
|
||||||
static void alsaspdifsink_close (AlsaSPDIFSink * sink);
|
static void alsaspdifsink_close (AlsaSPDIFSink * sink);
|
||||||
|
@ -160,6 +162,7 @@ alsaspdifsink_class_init (AlsaSPDIFSinkClass * klass)
|
||||||
gstbasesink_class->event = alsaspdifsink_event;
|
gstbasesink_class->event = alsaspdifsink_event;
|
||||||
gstbasesink_class->render = alsaspdifsink_render;
|
gstbasesink_class->render = alsaspdifsink_render;
|
||||||
gstbasesink_class->get_times = alsaspdifsink_get_times;
|
gstbasesink_class->get_times = alsaspdifsink_get_times;
|
||||||
|
gstbasesink_class->set_caps = alsaspdifsink_set_caps;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* We ignore the device property anyway, so don't install it
|
/* We ignore the device property anyway, so don't install it
|
||||||
|
@ -250,6 +253,18 @@ alsaspdifsink_get_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 *
|
static GstClock *
|
||||||
alsaspdifsink_provide_clock (GstElement * elem)
|
alsaspdifsink_provide_clock (GstElement * elem)
|
||||||
{
|
{
|
||||||
|
@ -263,7 +278,7 @@ alsaspdifsink_get_time (GstClock * clock, gpointer user_data)
|
||||||
{
|
{
|
||||||
AlsaSPDIFSink *sink = ALSASPDIFSINK (user_data);
|
AlsaSPDIFSink *sink = ALSASPDIFSINK (user_data);
|
||||||
|
|
||||||
return sink->frames * IEC958_FRAME_DURATION;
|
return sink->frames * sink->rate / 1536;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -359,7 +374,7 @@ alsaspdifsink_open (AlsaSPDIFSink * sink)
|
||||||
goto __close;
|
goto __close;
|
||||||
}
|
}
|
||||||
|
|
||||||
rate = AC3_RATE;
|
rate = sink->rate;
|
||||||
err = snd_pcm_hw_params_set_rate_near (sink->pcm, params, &rate, 0);
|
err = snd_pcm_hw_params_set_rate_near (sink->pcm, params, &rate, 0);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
|
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
|
||||||
|
|
|
@ -71,6 +71,8 @@ struct _AlsaSPDIFSink {
|
||||||
|
|
||||||
guint64 frames; /* Number of complete frames written */
|
guint64 frames; /* Number of complete frames written */
|
||||||
gboolean need_swap; /* Whether to byte swap outgoing data */
|
gboolean need_swap; /* Whether to byte swap outgoing data */
|
||||||
|
|
||||||
|
gint rate; /* Sampling rate of data */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _AlsaSPDIFSinkClass {
|
struct _AlsaSPDIFSinkClass {
|
||||||
|
|
Loading…
Reference in a new issue