Added an audioscale element to the GStreamer pipeline;

this may fix #1840.
Added audioconvert, too -- not sure what that does, but it seems to be
the thing to do.
This commit is contained in:
fgerlits 2006-10-11 15:17:25 +00:00
parent 56f1593247
commit 03acf0d17a
2 changed files with 58 additions and 14 deletions

View File

@ -291,15 +291,29 @@ GstreamerPlayer :: open(const std::string fileUrl)
gst_element_unlink(decoder, fakesink); gst_element_unlink(decoder, fakesink);
gst_object_unref(GST_OBJECT(pipe)); gst_object_unref(GST_OBJECT(pipe));
// not sure what this does, but it seems important
audioconvert = gst_element_factory_make("audioconvert", NULL);
// reduce the volume to 80% // reduce the volume to 80%
volume = gst_element_factory_make("volume", NULL); volume = gst_element_factory_make("volume", NULL);
g_object_set(G_OBJECT(volume), "volume", gdouble(0.8), NULL); g_object_set(G_OBJECT(volume), "volume", gdouble(0.8), NULL);
gst_element_link_many(decoder, volume, audiosink, NULL); // scale the sampling rate, if necessary
gst_bin_add_many(GST_BIN(pipeline), filesrc, audioscale = gst_element_factory_make("audioscale", NULL);
decoder,
volume, gst_element_link_many(decoder,
audiosink, NULL); audioconvert,
volume,
audioscale,
audiosink,
NULL);
gst_bin_add_many(GST_BIN(pipeline), filesrc,
decoder,
audioconvert,
volume,
audioscale,
audiosink,
NULL);
// connect the eos signal handler // connect the eos signal handler
g_signal_connect(decoder, "eos", G_CALLBACK(eosEventHandler), this); g_signal_connect(decoder, "eos", G_CALLBACK(eosEventHandler), this);
@ -445,14 +459,31 @@ GstreamerPlayer :: close(void) throw ()
} }
gst_element_set_state(pipeline, GST_STATE_NULL); gst_element_set_state(pipeline, GST_STATE_NULL);
if (filesrc && decoder) { if (filesrc && decoder) {
gst_element_unlink(filesrc, decoder); gst_element_unlink(filesrc, decoder);
} }
if (decoder && volume) { if (decoder && audioconvert) {
gst_element_unlink(decoder, volume); gst_element_unlink(decoder, audioconvert);
} }
if (volume && audiosink) { if (audioconvert && volume) {
gst_element_unlink(volume, audiosink); gst_element_unlink(audioconvert, volume);
}
if (volume && audioscale) {
gst_element_unlink(volume, audioscale);
}
if (audioscale && audiosink) {
gst_element_unlink(audioscale, audiosink);
}
if (audioscale) {
gst_bin_remove(GST_BIN(pipeline), audioscale);
}
if (volume) {
gst_bin_remove(GST_BIN(pipeline), volume);
}
if (audioconvert) {
gst_bin_remove(GST_BIN(pipeline), audioconvert);
} }
if (decoder) { if (decoder) {
gst_bin_remove(GST_BIN(pipeline), decoder); gst_bin_remove(GST_BIN(pipeline), decoder);
@ -460,9 +491,12 @@ GstreamerPlayer :: close(void) throw ()
if (filesrc) { if (filesrc) {
gst_bin_remove(GST_BIN(pipeline), filesrc); gst_bin_remove(GST_BIN(pipeline), filesrc);
} }
filesrc = 0;
decoder = 0; filesrc = 0;
volume = 0; decoder = 0;
audioconvert = 0;
volume = 0;
audioscale = 0;
} }

View File

@ -112,11 +112,21 @@ class GstreamerPlayer : virtual public Configurable,
*/ */
GstElement * decoder; GstElement * decoder;
/**
* The audioconvert element.
*/
GstElement * audioconvert;
/** /**
* The volume element. * The volume element.
*/ */
GstElement * volume; GstElement * volume;
/**
* The audioscale element.
*/
GstElement * audioscale;
/** /**
* The desired capabilities of the audio sink. * The desired capabilities of the audio sink.
*/ */