ext/alsa/gstalsamixer.c: Update mixer (to sync with other sessions) if we try to obtain a new value. This makes alsam...

Original commit message from CVS:
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_update),
(gst_alsa_mixer_get_volume), (gst_alsa_mixer_set_volume),
(gst_alsa_mixer_set_mute), (gst_alsa_mixer_set_record),
(gst_alsa_mixer_set_option), (gst_alsa_mixer_get_option):
Update mixer (to sync with other sessions) if we try to obtain
a new value. This makes alsamixer work accross applications.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_get_time):
Only call sync functions if we're running, else alsalib asserts.
* ext/ogg/gstoggdemux.c: (gst_ogg_demux_src_query):
Sometimes fails to compile. Possibly a gcc bug.
* gst/playback/gstplaybin.c: (gen_video_element),
(gen_audio_element):
Add a reference to an application-provided object, because we lose
this same reference if we add it to the bin. If we don't do this,
we can only use this object once and thus crash if we go from
ready to playing, back to ready and back to playing again.
Also add an audioscale element because several cheap soundcards -
like mine - don't support all samplerates.
* sys/ximage/ximagesink.c: (gst_ximagesink_xcontext_get),
(gst_ximagesink_xcontext_clear), (gst_ximagesink_change_state):
Fix wrong order or PAR calls. Makes automatically obtained PAR
from the X server atually being used.
This commit is contained in:
Ronald S. Bultje 2004-09-13 09:24:00 +00:00
parent 6579f69d30
commit b709c6844b
6 changed files with 66 additions and 19 deletions

View file

@ -1,3 +1,28 @@
2004-09-13 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_update),
(gst_alsa_mixer_get_volume), (gst_alsa_mixer_set_volume),
(gst_alsa_mixer_set_mute), (gst_alsa_mixer_set_record),
(gst_alsa_mixer_set_option), (gst_alsa_mixer_get_option):
Update mixer (to sync with other sessions) if we try to obtain
a new value. This makes alsamixer work accross applications.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_get_time):
Only call sync functions if we're running, else alsalib asserts.
* ext/ogg/gstoggdemux.c: (gst_ogg_demux_src_query):
Sometimes fails to compile. Possibly a gcc bug.
* gst/playback/gstplaybin.c: (gen_video_element),
(gen_audio_element):
Add a reference to an application-provided object, because we lose
this same reference if we add it to the bin. If we don't do this,
we can only use this object once and thus crash if we go from
ready to playing, back to ready and back to playing again.
Also add an audioscale element because several cheap soundcards -
like mine - don't support all samplerates.
* sys/ximage/ximagesink.c: (gst_ximagesink_xcontext_get),
(gst_ximagesink_xcontext_clear), (gst_ximagesink_change_state):
Fix wrong order or PAR calls. Makes automatically obtained PAR
from the X server atually being used.
2004-09-12 David Schleef <ds@schleef.org>
Fixes: #151879, #151881, #151882, #151883, #151884, #151886,

View file

@ -373,6 +373,12 @@ gst_alsa_mixer_list_tracks (GstMixer * mixer)
return (const GList *) alsa_mixer->tracklist;
}
static void
gst_alsa_mixer_update (GstAlsaMixer * alsa_mixer)
{
snd_mixer_handle_events (alsa_mixer->mixer_handle);
}
static void
gst_alsa_mixer_get_volume (GstMixer * mixer,
GstMixerTrack * track, gint * volumes)
@ -382,6 +388,8 @@ gst_alsa_mixer_get_volume (GstMixer * mixer,
g_return_if_fail (GST_ALSA_MIXER (mixer)->mixer_handle != NULL);
gst_alsa_mixer_update (GST_ALSA_MIXER (mixer));
if (track->flags & GST_MIXER_TRACK_MUTE &&
!snd_mixer_selem_has_playback_switch (alsa_track->element)) {
for (i = 0; i < track->num_channels; i++)
@ -409,6 +417,8 @@ gst_alsa_mixer_set_volume (GstMixer * mixer,
g_return_if_fail (GST_ALSA_MIXER (mixer)->mixer_handle != NULL);
gst_alsa_mixer_update (GST_ALSA_MIXER (mixer));
/* only set the volume with ALSA lib if the track isn't muted. */
for (i = 0; i < track->num_channels; i++) {
alsa_track->volumes[i] = volumes[i];
@ -434,6 +444,8 @@ gst_alsa_mixer_set_mute (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
g_return_if_fail (GST_ALSA_MIXER (mixer)->mixer_handle != NULL);
gst_alsa_mixer_update (GST_ALSA_MIXER (mixer));
if (mute) {
track->flags |= GST_MIXER_TRACK_MUTE;
} else {
@ -463,6 +475,8 @@ gst_alsa_mixer_set_record (GstMixer * mixer,
g_return_if_fail (GST_ALSA_MIXER (mixer)->mixer_handle != NULL);
gst_alsa_mixer_update (GST_ALSA_MIXER (mixer));
if (record) {
track->flags |= GST_MIXER_TRACK_RECORD;
} else {
@ -482,6 +496,8 @@ gst_alsa_mixer_set_option (GstMixer * mixer,
g_return_if_fail (GST_ALSA_MIXER (mixer)->mixer_handle != NULL);
gst_alsa_mixer_update (GST_ALSA_MIXER (mixer));
for (item = opts->values; item != NULL; item = item->next, n++) {
if (!strcmp (item->data, value)) {
idx = n;
@ -502,6 +518,8 @@ gst_alsa_mixer_get_option (GstMixer * mixer, GstMixerOptions * opts)
g_return_val_if_fail (GST_ALSA_MIXER (mixer)->mixer_handle != NULL, NULL);
gst_alsa_mixer_update (GST_ALSA_MIXER (mixer));
snd_mixer_selem_get_enum_item (alsa_opts->element, 0, &idx);
return g_list_nth_data (opts->values, idx);

View file

@ -564,7 +564,9 @@ gst_alsa_sink_get_time (GstAlsa * this)
if (!this->format)
return 0;
if (snd_pcm_delay (this->handle, &delay) != 0) {
if (!GST_FLAG_IS_SET (this, GST_ALSA_RUNNING)) {
delay = 0;
} else if (snd_pcm_delay (this->handle, &delay) != 0) {
return this->played / this->format->rate;
}
if (this->played <= delay) {

View file

@ -396,7 +396,7 @@ gst_ogg_demux_src_query (GstPad * pad, GstQueryType type,
gboolean res = FALSE;
GstOggDemux *ogg;
GstOggPad *cur;
guint64 granulepos;
guint64 granulepos = 0;
ogg = GST_OGG_DEMUX (gst_pad_get_parent (pad));
@ -533,8 +533,7 @@ gst_ogg_demux_src_event (GstPad * pad, GstEvent * event)
GST_OGG_SET_STATE (ogg, GST_OGG_STATE_SEEK);
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad,
pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;
);
pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;);
GST_DEBUG_OBJECT (ogg,
"initiating seeking to format %d, offset %" G_GUINT64_FORMAT, format,
offset);
@ -607,8 +606,7 @@ gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event)
gst_event_unref (event);
GST_FLAG_UNSET (ogg, GST_OGG_FLAG_WAIT_FOR_DISCONT);
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad,
pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;
);
pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;);
break;
default:
gst_pad_event_default (pad, event);
@ -878,8 +876,7 @@ _find_chain_get_unknown_part (GstOggDemux * ogg, gint64 * start, gint64 * end)
*end = G_MAXINT64;
g_assert (ogg->current_chain >= 0);
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad, *start = MAX (*start, pad->end_offset);
);
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad, *start = MAX (*start, pad->end_offset););
if (ogg->setup_state == SETUP_FIND_LAST_CHAIN) {
*end = gst_file_pad_get_length (ogg->sinkpad);
@ -1008,8 +1005,7 @@ _find_streams_check (GstOggDemux * ogg)
} else {
endpos = G_MAXINT64;
FOR_PAD_IN_CHAIN (ogg, pad, ogg->chains->len - 1,
endpos = MIN (endpos, pad->start_offset);
);
endpos = MIN (endpos, pad->start_offset););
}
if (!ogg->seek_skipped || gst_ogg_demux_position (ogg) >= endpos) {
/* have we found the endposition for all streams yet? */

View file

@ -285,6 +285,7 @@ gen_video_element (GstPlayBin * play_bin)
conv = gst_element_factory_make ("ffmpegcolorspace", "vconv");
scale = gst_element_factory_make ("videoscale", "vscale");
if (play_bin->video_sink) {
gst_object_ref (GST_OBJECT (play_bin->video_sink));
sink = play_bin->video_sink;
} else {
sink = gst_element_factory_make ("ximagesink", "sink");
@ -311,15 +312,18 @@ gen_audio_element (GstPlayBin * play_bin)
GstElement *conv;
GstElement *sink;
GstElement *volume;
GstElement *scale;
element = gst_bin_new ("abin");
conv = gst_element_factory_make ("audioconvert", "aconv");
scale = gst_element_factory_make ("audioscale", "ascale");
volume = gst_element_factory_make ("volume", "volume");
g_object_set (G_OBJECT (volume), "volume", play_bin->volume, NULL);
play_bin->volume_element = volume;
if (play_bin->audio_sink) {
gst_object_ref (GST_OBJECT (play_bin->audio_sink));
sink = play_bin->audio_sink;
} else {
sink = gst_element_factory_make ("osssink", "sink");
@ -328,10 +332,12 @@ gen_audio_element (GstPlayBin * play_bin)
play_bin->seekables = g_list_prepend (play_bin->seekables, sink);
gst_bin_add (GST_BIN (element), conv);
gst_bin_add (GST_BIN (element), scale);
gst_bin_add (GST_BIN (element), volume);
gst_bin_add (GST_BIN (element), sink);
gst_element_link_pads (conv, "src", volume, "sink");
gst_element_link_pads (conv, "src", scale, "sink");
gst_element_link_pads (scale, "src", volume, "sink");
gst_element_link_pads (volume, "src", sink, "sink");
gst_element_add_ghost_pad (element,

View file

@ -817,6 +817,12 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
}
}
/* update object's par with calculated one if not set yet */
if (!ximagesink->par) {
ximagesink->par = g_new0 (GValue, 1);
gst_value_init_and_copy (ximagesink->par, xcontext->par);
GST_DEBUG_OBJECT (ximagesink, "set calculated PAR on object's PAR");
}
xcontext->caps = gst_caps_new_simple ("video/x-raw-rgb",
"bpp", G_TYPE_INT, xcontext->bpp,
"depth", G_TYPE_INT, xcontext->depth,
@ -850,6 +856,8 @@ gst_ximagesink_xcontext_clear (GstXImageSink * ximagesink)
gst_caps_free (ximagesink->xcontext->caps);
g_free (ximagesink->xcontext->par);
g_free (ximagesink->par);
ximagesink->par = NULL;
g_mutex_lock (ximagesink->x_lock);
@ -1015,12 +1023,6 @@ gst_ximagesink_change_state (GstElement * element)
ximagesink->xcontext = gst_ximagesink_xcontext_get (ximagesink);
if (!ximagesink->xcontext)
return GST_STATE_FAILURE;
/* update object's par with calculated one if not set yet */
if (!ximagesink->par) {
ximagesink->par = g_new0 (GValue, 1);
gst_value_init_and_copy (ximagesink->par, ximagesink->xcontext->par);
GST_DEBUG_OBJECT (ximagesink, "set calculated PAR on object's PAR");
}
/* call XSynchronize with the current value of synchronous */
GST_DEBUG_OBJECT (ximagesink, "XSynchronize called with %s",
ximagesink->synchronous ? "TRUE" : "FALSE");
@ -1059,8 +1061,6 @@ gst_ximagesink_change_state (GstElement * element)
gst_ximagesink_xcontext_clear (ximagesink);
ximagesink->xcontext = NULL;
}
g_free (ximagesink->par);
ximagesink->par = NULL;
break;
}