Revert commits towards #152864 made so far. We'll pick it up again after the 0.10.13 release.

Original commit message from CVS:
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_ensure_track_list),
(gst_alsa_mixer_free), (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):
* ext/alsa/gstalsamixer.h:
* ext/alsa/gstalsamixerelement.c:
(gst_alsa_mixer_element_interface_supported),
(gst_alsa_mixer_element_finalize), (gst_alsa_mixer_element_init),
(gst_alsa_mixer_element_set_property),
(gst_alsa_mixer_element_get_property),
(gst_alsa_mixer_element_change_state):
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_update):
* gst-libs/gst/interfaces/mixer.c: (gst_mixer_volume_changed),
(gst_mixer_option_changed):
* gst-libs/gst/interfaces/mixer.h:
Revert commits towards #152864 made so far. We'll pick it up again
after the 0.10.13 release.
This commit is contained in:
Jan Schmidt 2007-05-25 10:07:26 +00:00
parent b2fdf703c9
commit 588bc09c33
7 changed files with 93 additions and 340 deletions

View file

@ -1,3 +1,24 @@
2007-05-25 Jan Schmidt <thaytan@mad.scientist.com>
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_ensure_track_list),
(gst_alsa_mixer_free), (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):
* ext/alsa/gstalsamixer.h:
* ext/alsa/gstalsamixerelement.c:
(gst_alsa_mixer_element_interface_supported),
(gst_alsa_mixer_element_finalize), (gst_alsa_mixer_element_init),
(gst_alsa_mixer_element_set_property),
(gst_alsa_mixer_element_get_property),
(gst_alsa_mixer_element_change_state):
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_update):
* gst-libs/gst/interfaces/mixer.c: (gst_mixer_volume_changed),
(gst_mixer_option_changed):
* gst-libs/gst/interfaces/mixer.h:
Revert commits towards #152864 made so far. We'll pick it up again
after the 0.10.13 release.
2007-05-24 Wim Taymans <wim@fluendo.com> 2007-05-24 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/audio/gstbaseaudiosink.c: * gst-libs/gst/audio/gstbaseaudiosink.c:

View file

@ -42,82 +42,6 @@
#include "gstalsamixer.h" #include "gstalsamixer.h"
static void gst_alsa_mixer_update_option (GstAlsaMixer * mixer,
GstAlsaMixerOptions * alsa_opts);
static void gst_alsa_mixer_update_track (GstAlsaMixer * mixer,
GstAlsaMixerTrack * alsa_track);
static gboolean gst_alsa_mixer_prepare (GSource * source, gint * timeout);
static gboolean gst_alsa_mixer_check (GSource * source);
static gboolean gst_alsa_mixer_dispatch (GSource * source, GSourceFunc callback,
gpointer user_data);
static void gst_alsa_mixer_finalize (GSource * source);
static GMainContext *main_context;
typedef struct _GstAlsaMixerWatch GstAlsaMixerWatch;
struct _GstAlsaMixerWatch
{
GSource source;
gint n_poll_fds;
GPollFD *poll_fds;
};
GSourceFuncs gst_alsa_mixer_watch_funcs = {
gst_alsa_mixer_prepare,
gst_alsa_mixer_check,
gst_alsa_mixer_dispatch,
gst_alsa_mixer_finalize
};
static gboolean
gst_alsa_mixer_prepare (GSource * source, gint * timeout)
{
*timeout = -1;
return FALSE;
}
static gboolean
gst_alsa_mixer_check (GSource * source)
{
GstAlsaMixerWatch *watch = (GstAlsaMixerWatch *) source;
gint i;
gushort revents;
/* Code based on snd_mixer_poll_descriptors_revents() adapted for glib */
revents = 0;
for (i = 0; i < watch->n_poll_fds; ++i) {
revents |= watch->poll_fds[i].revents & (G_IO_IN | G_IO_ERR | G_IO_HUP);
}
if (revents & G_IO_ERR || revents & G_IO_HUP) {
GST_DEBUG ("ALSA poll fds returned ERR or HUP");
return FALSE;
}
return (revents & G_IO_IN);
}
static gboolean
gst_alsa_mixer_dispatch (GSource * source, GSourceFunc callback,
gpointer user_data)
{
g_return_val_if_fail (callback, FALSE);
return (*callback) (user_data);
}
static void
gst_alsa_mixer_finalize (GSource * source)
{
GstAlsaMixerWatch *watch = (GstAlsaMixerWatch *) source;
if (watch->poll_fds != NULL) {
g_free (watch->poll_fds);
watch->poll_fds = NULL;
}
watch->n_poll_fds = 0;
}
/* First some utils, then the mixer implementation */ /* First some utils, then the mixer implementation */
static gboolean static gboolean
@ -245,77 +169,11 @@ gst_alsa_mixer_find_master_mixer (GstAlsaMixer * mixer, snd_mixer_t * handle)
return NULL; return NULL;
} }
static gboolean
gst_alsa_mixer_handle_source_callback (gpointer data)
{
GstAlsaMixer *mixer = (GstAlsaMixer *) data;
GST_LOG ("Source cb");
snd_mixer_handle_events (mixer->handle);
return TRUE;
}
static int
gst_alsa_mixer_handle_callback (snd_mixer_t * handle, unsigned int mask,
snd_mixer_elem_t * elem)
{
GstAlsaMixer *mixer =
(GstAlsaMixer *) snd_mixer_get_callback_private (handle);
GList *item;
GST_LOG ("ALSA cb");
snd_mixer_handle_events (mixer->handle);
for (item = mixer->tracklist; item != NULL; item = item->next) {
if (GST_IS_ALSA_MIXER_TRACK (item->data)) {
GstAlsaMixerTrack *item_alsa_track = GST_ALSA_MIXER_TRACK (item->data);
gst_alsa_mixer_update_track (mixer, item_alsa_track);
} else {
GstAlsaMixerOptions *item_alsa_options =
GST_ALSA_MIXER_OPTIONS (item->data);
gst_alsa_mixer_update_option (mixer, item_alsa_options);
}
}
return 0;
}
int
gst_alsa_mixer_elem_handle_callback (snd_mixer_elem_t * elem, unsigned int mask)
{
GstAlsaMixer *mixer =
(GstAlsaMixer *) snd_mixer_elem_get_callback_private (elem);
GList *item;
GST_LOG ("ALSA elem cb");
for (item = mixer->tracklist; item != NULL; item = item->next) {
if (GST_IS_ALSA_MIXER_TRACK (item->data)) {
if (GST_ALSA_MIXER_TRACK (item->data)->element != elem)
continue;
gst_alsa_mixer_update_track (mixer, GST_ALSA_MIXER_TRACK (item->data));
} else if (GST_IS_ALSA_MIXER_OPTIONS (item->data)) {
if (GST_ALSA_MIXER_OPTIONS (item->data)->element != elem)
continue;
gst_alsa_mixer_update_option (mixer, GST_ALSA_MIXER_OPTIONS (item->data));
}
}
return 0;
}
static void static void
gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer) gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer)
{ {
gint i, count; gint i, count;
snd_mixer_elem_t *element, *master; snd_mixer_elem_t *element, *master;
struct pollfd *pfds;
GstAlsaMixerWatch *watch;
GList *item;
g_return_if_fail (mixer->handle != NULL); g_return_if_fail (mixer->handle != NULL);
@ -337,6 +195,7 @@ gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer)
GstMixerTrack *play_track = NULL; GstMixerTrack *play_track = NULL;
GstMixerTrack *cap_track = NULL; GstMixerTrack *cap_track = NULL;
const gchar *name; const gchar *name;
GList *item;
gint samename = 0; gint samename = 0;
name = snd_mixer_selem_get_name (element); name = snd_mixer_selem_get_name (element);
@ -412,6 +271,7 @@ gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer)
} }
} }
if (play_track && cap_track) { if (play_track && cap_track) {
GST_ALSA_MIXER_TRACK (play_track)->shared_mute = GST_ALSA_MIXER_TRACK (play_track)->shared_mute =
GST_ALSA_MIXER_TRACK (cap_track); GST_ALSA_MIXER_TRACK (cap_track);
@ -427,62 +287,6 @@ gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer)
element = snd_mixer_elem_next (element); element = snd_mixer_elem_next (element);
} }
if (mixer->handle_source != NULL)
return;
snd_mixer_set_callback_private (mixer->handle, mixer);
snd_mixer_set_callback (mixer->handle, gst_alsa_mixer_handle_callback);
main_context = g_main_context_default ();
mixer->handle_source =
g_source_new (&gst_alsa_mixer_watch_funcs, sizeof (GstAlsaMixerWatch));
g_return_if_fail (main_context != NULL && mixer->handle_source != NULL);
count = snd_mixer_poll_descriptors_count (mixer->handle);
if (count < 1) {
GST_WARNING ("Poll descriptors count < 0: %d", count);
g_source_destroy (mixer->handle_source);
mixer->handle_source = NULL;
return;
}
pfds = g_newa (struct pollfd, count);
watch = (GstAlsaMixerWatch *) mixer->handle_source;
watch->n_poll_fds = snd_mixer_poll_descriptors (mixer->handle, pfds, count);;
watch->poll_fds = g_new0 (GPollFD, count);
for (i = 0; i < watch->n_poll_fds; ++i) {
watch->poll_fds[i].fd = pfds[i].fd;
if (pfds[i].events & POLLIN)
watch->poll_fds[i].events |= G_IO_IN;
if (pfds[i].events & POLLOUT)
watch->poll_fds[i].events |= G_IO_OUT;
if (pfds[i].events & POLLPRI)
watch->poll_fds[i].events |= G_IO_PRI;
g_source_add_poll (mixer->handle_source, &watch->poll_fds[i]);
}
/* FIXME mixer has to be protected, since cb could be made from different thread ? */
g_source_set_callback (mixer->handle_source,
gst_alsa_mixer_handle_source_callback, mixer, NULL);
g_source_attach (mixer->handle_source, main_context);
for (item = mixer->tracklist; item != NULL; item = item->next) {
snd_mixer_elem_t *temp;
if (GST_IS_ALSA_MIXER_OPTIONS (item->data))
temp = GST_ALSA_MIXER_OPTIONS (item->data)->element;
else
temp = GST_ALSA_MIXER_TRACK (item->data)->element;
snd_mixer_elem_set_callback (temp, gst_alsa_mixer_elem_handle_callback);
snd_mixer_elem_set_callback_private (temp, mixer);
}
} }
@ -518,16 +322,6 @@ gst_alsa_mixer_free (GstAlsaMixer * mixer)
{ {
g_return_if_fail (mixer != NULL); g_return_if_fail (mixer != NULL);
if (mixer->interface) {
g_object_unref (G_OBJECT (mixer->interface));
mixer->interface = NULL;
}
if (mixer->handle_source) {
g_source_destroy (mixer->handle_source);
mixer->handle_source = NULL;
}
if (mixer->device) { if (mixer->device) {
g_free (mixer->device); g_free (mixer->device);
mixer->device = NULL; mixer->device = NULL;
@ -562,6 +356,16 @@ gst_alsa_mixer_list_tracks (GstAlsaMixer * mixer)
return (const GList *) mixer->tracklist; return (const GList *) mixer->tracklist;
} }
static void
gst_alsa_mixer_update (GstAlsaMixer * mixer, GstAlsaMixerTrack * alsa_track)
{
snd_mixer_handle_events (mixer->handle);
if (alsa_track)
gst_alsa_mixer_track_update (alsa_track);
}
void void
gst_alsa_mixer_get_volume (GstAlsaMixer * mixer, GstMixerTrack * track, gst_alsa_mixer_get_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
gint * volumes) gint * volumes)
@ -571,7 +375,7 @@ gst_alsa_mixer_get_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
g_return_if_fail (mixer->handle != NULL); g_return_if_fail (mixer->handle != NULL);
gst_alsa_mixer_track_update (alsa_track); gst_alsa_mixer_update (mixer, alsa_track);
if (track->flags & GST_MIXER_TRACK_OUTPUT) { /* return playback volume */ if (track->flags & GST_MIXER_TRACK_OUTPUT) { /* return playback volume */
@ -616,7 +420,7 @@ gst_alsa_mixer_set_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
g_return_if_fail (mixer->handle != NULL); g_return_if_fail (mixer->handle != NULL);
gst_alsa_mixer_track_update (alsa_track); gst_alsa_mixer_update (mixer, alsa_track);
if (track->flags & GST_MIXER_TRACK_OUTPUT) { if (track->flags & GST_MIXER_TRACK_OUTPUT) {
@ -657,7 +461,7 @@ gst_alsa_mixer_set_mute (GstAlsaMixer * mixer, GstMixerTrack * track,
g_return_if_fail (mixer->handle != NULL); g_return_if_fail (mixer->handle != NULL);
gst_alsa_mixer_track_update (alsa_track); gst_alsa_mixer_update (mixer, alsa_track);
if (!!(mute) == !!(track->flags & GST_MIXER_TRACK_MUTE)) if (!!(mute) == !!(track->flags & GST_MIXER_TRACK_MUTE))
return; return;
@ -705,7 +509,7 @@ gst_alsa_mixer_set_record (GstAlsaMixer * mixer,
g_return_if_fail (mixer->handle != NULL); g_return_if_fail (mixer->handle != NULL);
gst_alsa_mixer_track_update (alsa_track); gst_alsa_mixer_update (mixer, alsa_track);
if (!!(record) == !!(track->flags & GST_MIXER_TRACK_RECORD)) if (!!(record) == !!(track->flags & GST_MIXER_TRACK_RECORD))
return; return;
@ -732,7 +536,7 @@ gst_alsa_mixer_set_record (GstAlsaMixer * mixer,
if (item_alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_CSWITCH_EXCL && if (item_alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_CSWITCH_EXCL &&
item_alsa_track->capture_group == alsa_track->capture_group) { item_alsa_track->capture_group == alsa_track->capture_group) {
gst_alsa_mixer_track_update (item_alsa_track); gst_alsa_mixer_update (mixer, item_alsa_track);
} }
} }
} }
@ -758,6 +562,8 @@ gst_alsa_mixer_set_option (GstAlsaMixer * mixer,
g_return_if_fail (mixer->handle != NULL); g_return_if_fail (mixer->handle != NULL);
gst_alsa_mixer_update (mixer, NULL);
for (item = opts->values; item != NULL; item = item->next, n++) { for (item = opts->values; item != NULL; item = item->next, n++) {
if (!strcmp (item->data, value)) { if (!strcmp (item->data, value)) {
idx = n; idx = n;
@ -779,60 +585,11 @@ gst_alsa_mixer_get_option (GstAlsaMixer * mixer, GstMixerOptions * opts)
g_return_val_if_fail (mixer->handle != NULL, NULL); g_return_val_if_fail (mixer->handle != NULL, NULL);
gst_alsa_mixer_update (mixer, NULL);
ret = snd_mixer_selem_get_enum_item (alsa_opts->element, 0, &idx); ret = snd_mixer_selem_get_enum_item (alsa_opts->element, 0, &idx);
if (ret == 0) if (ret == 0)
return g_list_nth_data (opts->values, idx); return g_list_nth_data (opts->values, idx);
else else
return snd_strerror (ret); /* feeble attempt at error handling */ return snd_strerror (ret); /* feeble attempt at error handling */
} }
static void
gst_alsa_mixer_update_option (GstAlsaMixer * mixer,
GstAlsaMixerOptions * alsa_opts)
{
gint ret;
guint idx;
const gchar *option;
if (mixer->interface == NULL) {
GST_WARNING ("Cannot send update notifications, no GstMixer * given");
return;
}
ret = snd_mixer_selem_get_enum_item (alsa_opts->element, 0, &idx);
if (ret == 0) {
option = g_list_nth_data (GST_MIXER_OPTIONS (alsa_opts)->values, idx);
gst_mixer_option_changed (mixer->interface, GST_MIXER_OPTIONS (alsa_opts),
option);
}
}
static void
gst_alsa_mixer_update_track (GstAlsaMixer * mixer,
GstAlsaMixerTrack * alsa_track)
{
GstMixerTrack *track = (GstMixerTrack *) alsa_track;
if (mixer->interface == NULL) {
GST_WARNING ("Cannot send update notifications, no GstMixer * given");
return;
}
gst_alsa_mixer_track_update (alsa_track);
gst_mixer_record_toggled (mixer->interface, track,
GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_RECORD));
gst_mixer_mute_toggled (mixer->interface, track,
GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MUTE));
gst_mixer_volume_changed (mixer->interface, track, alsa_track->volumes);
}
/* utility function for gstalsamixerelement to set the interface */
void
_gst_alsa_mixer_set_interface (GstAlsaMixer * mixer, GstMixer * interface)
{
g_return_if_fail (mixer != NULL && mixer->interface == NULL);
g_return_if_fail (interface != NULL);
mixer->interface = g_object_ref (G_OBJECT (interface));
}

View file

@ -51,9 +51,7 @@ struct _GstAlsaMixer
GList * tracklist; /* list of available tracks */ GList * tracklist; /* list of available tracks */
snd_mixer_t * handle; snd_mixer_t * handle;
GSource * handle_source;
GstMixer * interface;
gchar * device; gchar * device;
gchar * cardname; gchar * cardname;
@ -63,8 +61,6 @@ struct _GstAlsaMixer
GstAlsaMixer* gst_alsa_mixer_new (const gchar *device, GstAlsaMixer* gst_alsa_mixer_new (const gchar *device,
GstAlsaMixerDirection dir); GstAlsaMixerDirection dir);
void _gst_alsa_mixer_set_interface (GstAlsaMixer * mixer,
GstMixer * interface);
void gst_alsa_mixer_free (GstAlsaMixer *mixer); void gst_alsa_mixer_free (GstAlsaMixer *mixer);
const GList* gst_alsa_mixer_list_tracks (GstAlsaMixer * mixer); const GList* gst_alsa_mixer_list_tracks (GstAlsaMixer * mixer);
@ -86,6 +82,7 @@ void gst_alsa_mixer_set_option (GstAlsaMixer * mixer,
const gchar* gst_alsa_mixer_get_option (GstAlsaMixer * mixer, const gchar* gst_alsa_mixer_get_option (GstAlsaMixer * mixer,
GstMixerOptions * opts); GstMixerOptions * opts);
#define GST_IMPLEMENT_ALSA_MIXER_METHODS(Type, interface_as_function) \ #define GST_IMPLEMENT_ALSA_MIXER_METHODS(Type, interface_as_function) \
static gboolean \ static gboolean \
interface_as_function ## _supported (Type *this, GType iface_type) \ interface_as_function ## _supported (Type *this, GType iface_type) \

View file

@ -44,7 +44,7 @@ GST_ELEMENT_DETAILS ("Alsa mixer",
static void gst_alsa_mixer_element_init_interfaces (GType type); static void gst_alsa_mixer_element_init_interfaces (GType type);
GST_BOILERPLATE_FULL (GstAlsaMixerElement, gst_alsa_mixer_element, GST_BOILERPLATE_FULL (GstAlsaMixerElement, gst_alsa_mixer_element,
GstElement, GST_TYPE_ELEMENT, gst_alsa_mixer_element_init_interfaces); GstElement, GST_TYPE_ELEMENT, gst_alsa_mixer_element_init_interfaces)
/* massive macro that takes care of all the GstMixer stuff */ /* massive macro that takes care of all the GstMixer stuff */
GST_IMPLEMENT_ALSA_MIXER_METHODS (GstAlsaMixerElement, gst_alsa_mixer_element); GST_IMPLEMENT_ALSA_MIXER_METHODS (GstAlsaMixerElement, gst_alsa_mixer_element);
@ -59,11 +59,11 @@ static GstStateChangeReturn gst_alsa_mixer_element_change_state (GstElement
* element, GstStateChange transition); * element, GstStateChange transition);
static gboolean static gboolean
gst_alsa_mixer_element_interface_supported (GstAlsaMixerElement * self, gst_alsa_mixer_element_interface_supported (GstAlsaMixerElement * this,
GType interface_type) GType interface_type)
{ {
if (interface_type == GST_TYPE_MIXER) { if (interface_type == GST_TYPE_MIXER) {
return gst_alsa_mixer_element_supported (self, interface_type); return gst_alsa_mixer_element_supported (this, interface_type);
} }
g_return_val_if_reached (FALSE); g_return_val_if_reached (FALSE);
@ -133,37 +133,37 @@ gst_alsa_mixer_element_class_init (GstAlsaMixerElementClass * klass)
static void static void
gst_alsa_mixer_element_finalize (GObject * obj) gst_alsa_mixer_element_finalize (GObject * obj)
{ {
GstAlsaMixerElement *self = GST_ALSA_MIXER_ELEMENT (obj); GstAlsaMixerElement *this = GST_ALSA_MIXER_ELEMENT (obj);
g_free (self->device); g_free (this->device);
G_OBJECT_CLASS (parent_class)->finalize (obj); G_OBJECT_CLASS (parent_class)->finalize (obj);
} }
static void static void
gst_alsa_mixer_element_init (GstAlsaMixerElement * self, gst_alsa_mixer_element_init (GstAlsaMixerElement * this,
GstAlsaMixerElementClass * klass) GstAlsaMixerElementClass * klass)
{ {
self->mixer = NULL; this->mixer = NULL;
self->device = g_strdup (DEFAULT_PROP_DEVICE); this->device = g_strdup (DEFAULT_PROP_DEVICE);
} }
static void static void
gst_alsa_mixer_element_set_property (GObject * object, guint prop_id, gst_alsa_mixer_element_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
GstAlsaMixerElement *self = GST_ALSA_MIXER_ELEMENT (object); GstAlsaMixerElement *this = GST_ALSA_MIXER_ELEMENT (object);
switch (prop_id) { switch (prop_id) {
case PROP_DEVICE:{ case PROP_DEVICE:{
GST_OBJECT_LOCK (self); GST_OBJECT_LOCK (this);
g_free (self->device); g_free (this->device);
self->device = g_value_dup_string (value); this->device = g_value_dup_string (value);
/* make sure we never set NULL, this is nice when we want to open the /* make sure we never set NULL, this is nice when we want to open the
* device. */ * device. */
if (self->device == NULL) if (this->device == NULL)
self->device = g_strdup (DEFAULT_PROP_DEVICE); this->device = g_strdup (DEFAULT_PROP_DEVICE);
GST_OBJECT_UNLOCK (self); GST_OBJECT_UNLOCK (this);
break; break;
} }
default: default:
@ -176,23 +176,23 @@ static void
gst_alsa_mixer_element_get_property (GObject * object, guint prop_id, gst_alsa_mixer_element_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec) GValue * value, GParamSpec * pspec)
{ {
GstAlsaMixerElement *self = GST_ALSA_MIXER_ELEMENT (object); GstAlsaMixerElement *this = GST_ALSA_MIXER_ELEMENT (object);
switch (prop_id) { switch (prop_id) {
case PROP_DEVICE:{ case PROP_DEVICE:{
GST_OBJECT_LOCK (self); GST_OBJECT_LOCK (this);
g_value_set_string (value, self->device); g_value_set_string (value, this->device);
GST_OBJECT_UNLOCK (self); GST_OBJECT_UNLOCK (this);
break; break;
} }
case PROP_DEVICE_NAME:{ case PROP_DEVICE_NAME:{
GST_OBJECT_LOCK (self); GST_OBJECT_LOCK (this);
if (self->mixer) { if (this->mixer) {
g_value_set_string (value, self->mixer->cardname); g_value_set_string (value, this->mixer->cardname);
} else { } else {
g_value_set_string (value, NULL); g_value_set_string (value, NULL);
} }
GST_OBJECT_UNLOCK (self); GST_OBJECT_UNLOCK (this);
break; break;
} }
default: default:
@ -206,15 +206,14 @@ gst_alsa_mixer_element_change_state (GstElement * element,
GstStateChange transition) GstStateChange transition)
{ {
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstAlsaMixerElement *self = GST_ALSA_MIXER_ELEMENT (element); GstAlsaMixerElement *this = GST_ALSA_MIXER_ELEMENT (element);
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY: case GST_STATE_CHANGE_NULL_TO_READY:
if (!self->mixer) { if (!this->mixer) {
self->mixer = gst_alsa_mixer_new (self->device, GST_ALSA_MIXER_ALL); this->mixer = gst_alsa_mixer_new (this->device, GST_ALSA_MIXER_ALL);
if (!self->mixer) if (!this->mixer)
goto open_failed; goto open_failed;
_gst_alsa_mixer_set_interface (self->mixer, GST_MIXER (element));
} }
break; break;
default: default:
@ -227,9 +226,9 @@ gst_alsa_mixer_element_change_state (GstElement * element,
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
if (self->mixer) { if (this->mixer) {
gst_alsa_mixer_free (self->mixer); gst_alsa_mixer_free (this->mixer);
self->mixer = NULL; this->mixer = NULL;
} }
break; break;
default: default:
@ -242,7 +241,7 @@ gst_alsa_mixer_element_change_state (GstElement * element,
open_failed: open_failed:
{ {
GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ_WRITE, (NULL), GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ_WRITE, (NULL),
("Failed to open alsa mixer device '%s'", self->device)); ("Failed to open alsa mixer device '%s'", this->device));
return GST_STATE_CHANGE_FAILURE; return GST_STATE_CHANGE_FAILURE;
} }
} }

View file

@ -239,26 +239,6 @@ gst_alsa_mixer_track_update (GstAlsaMixerTrack * alsa_track)
gint i; gint i;
gint audible = !(track->flags & GST_MIXER_TRACK_MUTE); gint audible = !(track->flags & GST_MIXER_TRACK_MUTE);
if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_PVOLUME)) {
/* update playback volume */
for (i = 0; i < track->num_channels; i++) {
long vol = 0;
snd_mixer_selem_get_playback_volume (alsa_track->element, i, &vol);
alsa_track->volumes[i] = (gint) vol;
}
}
if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_CVOLUME)) {
/* update capture volume */
for (i = 0; i < track->num_channels; i++) {
long vol = 0;
snd_mixer_selem_get_capture_volume (alsa_track->element, i, &vol);
alsa_track->volumes[i] = (gint) vol;
}
}
/* Any updates in flags? */ /* Any updates in flags? */
if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_PSWITCH)) { if (alsa_track_has_cap (alsa_track, GST_ALSA_MIXER_TRACK_PSWITCH)) {
int v = 0; int v = 0;

View file

@ -340,7 +340,7 @@ gst_mixer_record_toggled (GstMixer * mixer,
void void
gst_mixer_volume_changed (GstMixer * mixer, gst_mixer_volume_changed (GstMixer * mixer,
GstMixerTrack * track, const gint * volumes) GstMixerTrack * track, gint * volumes)
{ {
g_return_if_fail (mixer != NULL); g_return_if_fail (mixer != NULL);
g_return_if_fail (track != NULL); g_return_if_fail (track != NULL);
@ -353,7 +353,7 @@ gst_mixer_volume_changed (GstMixer * mixer,
void void
gst_mixer_option_changed (GstMixer * mixer, gst_mixer_option_changed (GstMixer * mixer,
GstMixerOptions * opts, const gchar * value) GstMixerOptions * opts, gchar * value)
{ {
g_return_if_fail (mixer != NULL); g_return_if_fail (mixer != NULL);
g_return_if_fail (opts != NULL); g_return_if_fail (opts != NULL);
@ -361,5 +361,5 @@ gst_mixer_option_changed (GstMixer * mixer,
g_signal_emit (G_OBJECT (mixer), g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[SIGNAL_OPTION_CHANGED], 0, opts, value); gst_mixer_signals[SIGNAL_OPTION_CHANGED], 0, opts, value);
g_signal_emit_by_name (G_OBJECT (opts), "option_changed", value); g_signal_emit_by_name (G_OBJECT (opts), "value_changed", value);
} }

View file

@ -74,6 +74,7 @@ struct _GstMixerClass {
void (* set_record) (GstMixer *mixer, void (* set_record) (GstMixer *mixer,
GstMixerTrack *track, GstMixerTrack *track,
gboolean record); gboolean record);
/* signals */ /* signals */
void (* mute_toggled) (GstMixer *mixer, void (* mute_toggled) (GstMixer *mixer,
GstMixerTrack *channel, GstMixerTrack *channel,
@ -83,19 +84,18 @@ struct _GstMixerClass {
gboolean record); gboolean record);
void (* volume_changed) (GstMixer *mixer, void (* volume_changed) (GstMixer *mixer,
GstMixerTrack *channel, GstMixerTrack *channel,
const gint *volumes); gint *volumes);
void (* option_changed) (GstMixer *mixer,
GstMixerOptions *opts,
const gchar *option);
/* FIXME 0.11: move set/get function to virtual functions part */
void (* set_option) (GstMixer *mixer, void (* set_option) (GstMixer *mixer,
GstMixerOptions *opts, GstMixerOptions *opts,
gchar *value); gchar *value);
const gchar * (* get_option) (GstMixer *mixer, const gchar * (* get_option) (GstMixer *mixer,
GstMixerOptions *opts); GstMixerOptions *opts);
void (* option_changed) (GstMixer *mixer,
GstMixerOptions *opts,
gchar *option);
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING];
}; };
@ -129,13 +129,12 @@ void gst_mixer_mute_toggled (GstMixer *mixer,
void gst_mixer_record_toggled (GstMixer *mixer, void gst_mixer_record_toggled (GstMixer *mixer,
GstMixerTrack *track, GstMixerTrack *track,
gboolean record); gboolean record);
void gst_mixer_volume_changed (GstMixer *mixer, void gst_mixer_volume_changed (GstMixer *mixer,
GstMixerTrack *track, GstMixerTrack *track,
const gint *volumes); gint *volumes);
void gst_mixer_option_changed (GstMixer *mixer, void gst_mixer_option_changed (GstMixer *mixer,
GstMixerOptions *opts, GstMixerOptions *opts,
const gchar *value); gchar *value);
G_END_DECLS G_END_DECLS