sys/sunaudio/: Attached find a patch that fixes a number of bugs with the SunAudio mixer plugin and fixes #344101: 1....

Original commit message from CVS:
Patch by: Brian Cameron <brian dot cameron at sun dot com>
* sys/sunaudio/gstsunaudiomixerctrl.c:
(gst_sunaudiomixer_ctrl_open), (gst_sunaudiomixer_ctrl_build_list),
(gst_sunaudiomixer_ctrl_new), (gst_sunaudiomixer_ctrl_set_volume),
(gst_sunaudiomixer_ctrl_set_mute):
* sys/sunaudio/gstsunaudiosink.c: (gst_sunaudiosink_class_init),
(gst_sunaudiosink_init), (gst_sunaudiosink_prepare),
(gst_sunaudiosink_write):
Attached find a patch that fixes a number of bugs with the SunAudio mixer
plugin and fixes #344101:
1. The gst_sunaudiomixer_ctrl_build_list kept appending the same 3 tracks onto
the tracklist causing gnome-volume-control's preferences dialog to be messed
up and would core dump if you checked/unchecked any item.
2. We weren't previously setting the MUTE flag properly.  Fixing this makes
gnome-volume-control work better.
3. Now we properly define the input track to be GST_MIXER_TRACK_INPUT and
the monitor to be GST_MIXER_TRACK_OUTPUT, so that makes gnome-volume-control
look better.
Also some minor cleanup in gstsunaudiosink.c.
This commit is contained in:
Brian Cameron 2006-06-09 17:29:08 +00:00 committed by Wim Taymans
parent 78d078e986
commit 6052579ae4
3 changed files with 67 additions and 32 deletions

View file

@ -1,3 +1,27 @@
2006-06-09 Wim Taymans <wim@fluendo.com>
Patch by: Brian Cameron <brian dot cameron at sun dot com>
* sys/sunaudio/gstsunaudiomixerctrl.c:
(gst_sunaudiomixer_ctrl_open), (gst_sunaudiomixer_ctrl_build_list),
(gst_sunaudiomixer_ctrl_new), (gst_sunaudiomixer_ctrl_set_volume),
(gst_sunaudiomixer_ctrl_set_mute):
* sys/sunaudio/gstsunaudiosink.c: (gst_sunaudiosink_class_init),
(gst_sunaudiosink_init), (gst_sunaudiosink_prepare),
(gst_sunaudiosink_write):
Attached find a patch that fixes a number of bugs with the SunAudio mixer
plugin and fixes #344101:
1. The gst_sunaudiomixer_ctrl_build_list kept appending the same 3 tracks onto
the tracklist causing gnome-volume-control's preferences dialog to be messed
up and would core dump if you checked/unchecked any item.
2. We weren't previously setting the MUTE flag properly. Fixing this makes
gnome-volume-control work better.
3. Now we properly define the input track to be GST_MIXER_TRACK_INPUT and
the monitor to be GST_MIXER_TRACK_OUTPUT, so that makes gnome-volume-control
look better.
Also some minor cleanup in gstsunaudiosink.c.
2006-06-09 Wim Taymans <wim@fluendo.com>
* ext/jpeg/gstjpegdec.c: (gst_idct_method_get_type),

View file

@ -38,43 +38,48 @@
#define SCALE_FACTOR 2.55 /* 255/100 */
static gboolean
gst_sunaudiomixer_ctrl_open (GstSunAudioMixerCtrl * sunaudio)
gst_sunaudiomixer_ctrl_open (GstSunAudioMixerCtrl * mixer)
{
int fd;
/* First try to open non-blocking */
fd = open (sunaudio->device, O_RDWR | O_NONBLOCK);
fd = open (mixer->device, O_RDWR | O_NONBLOCK);
if (fd >= 0) {
close (fd);
fd = open (sunaudio->device, O_WRONLY);
fd = open (mixer->device, O_WRONLY);
}
if (fd == -1) {
GST_DEBUG_OBJECT (sunaudio,
"Failed to open mixer device %s, mixing disabled: %s", sunaudio->device,
GST_DEBUG_OBJECT (mixer,
"Failed to open mixer device %s, mixing disabled: %s", mixer->device,
strerror (errno));
return FALSE;
}
sunaudio->mixer_fd = fd;
mixer->mixer_fd = fd;
return TRUE;
}
void
gst_sunaudiomixer_ctrl_build_list (GstSunAudioMixerCtrl * sunaudio)
gst_sunaudiomixer_ctrl_build_list (GstSunAudioMixerCtrl * mixer)
{
GstMixerTrack *track;
g_return_if_fail (sunaudio->mixer_fd != -1);
g_return_if_fail (mixer->mixer_fd != -1);
/*
* Do not continue appending the same 3 static tracks onto the list
*/
if (mixer->tracklist == NULL) {
track = gst_sunaudiomixer_track_new (0, 1, GST_MIXER_TRACK_OUTPUT);
sunaudio->tracklist = g_list_append (sunaudio->tracklist, track);
track = gst_sunaudiomixer_track_new (1, 1, 0);
sunaudio->tracklist = g_list_append (sunaudio->tracklist, track);
track = gst_sunaudiomixer_track_new (2, 1, 0);
sunaudio->tracklist = g_list_append (sunaudio->tracklist, track);
mixer->tracklist = g_list_append (mixer->tracklist, track);
track = gst_sunaudiomixer_track_new (1, 1, GST_MIXER_TRACK_INPUT);
mixer->tracklist = g_list_append (mixer->tracklist, track);
track = gst_sunaudiomixer_track_new (2, 1, GST_MIXER_TRACK_OUTPUT);
mixer->tracklist = g_list_append (mixer->tracklist, track);
}
}
GstSunAudioMixerCtrl *
@ -88,6 +93,7 @@ gst_sunaudiomixer_ctrl_new (const char *device)
ret->device = g_strdup (device);
ret->mixer_fd = -1;
ret->tracklist = NULL;
if (!gst_sunaudiomixer_ctrl_open (ret))
goto error;
@ -172,7 +178,10 @@ gst_sunaudiomixer_ctrl_set_volume (GstSunAudioMixerCtrl * mixer,
g_return_if_fail (mixer->mixer_fd != -1);
volume = volumes[0] * SCALE_FACTOR + 0.5;
if (volume < 0)
volume = 0;
volume = volumes[0] * SCALE_FACTOR;
/* Set the volume */
AUDIO_INITINFO (&audioinfo);
@ -198,29 +207,33 @@ gst_sunaudiomixer_ctrl_set_volume (GstSunAudioMixerCtrl * mixer,
}
void
gst_sunaudiomixer_ctrl_set_mute (GstSunAudioMixerCtrl * sunaudio,
gst_sunaudiomixer_ctrl_set_mute (GstSunAudioMixerCtrl * mixer,
GstMixerTrack * track, gboolean mute)
{
struct audio_info audioinfo;
GstSunAudioMixerTrack *sunaudiotrack = GST_SUNAUDIO_MIXER_TRACK (track);
gint volume;
g_return_if_fail (sunaudio->mixer_fd != -1);
if (sunaudiotrack->track_num != 0)
return;
g_return_if_fail (mixer->mixer_fd != -1);
AUDIO_INITINFO (&audioinfo);
if (mute) {
audioinfo.output_muted = 1;
volume = 0;
track->flags |= GST_MIXER_TRACK_MUTE;
} else {
audioinfo.output_muted = 0;
volume = sunaudiotrack->vol;
track->flags &= ~GST_MIXER_TRACK_MUTE;
}
switch (sunaudiotrack->track_num) {
case 0:
if (mute)
audioinfo.output_muted = 1;
else
audioinfo.output_muted = 0;
audioinfo.play.gain = volume;
break;
case 1:
@ -231,7 +244,7 @@ gst_sunaudiomixer_ctrl_set_mute (GstSunAudioMixerCtrl * sunaudio,
break;
}
if (ioctl (sunaudio->mixer_fd, AUDIO_SETINFO, &audioinfo) < 0) {
if (ioctl (mixer->mixer_fd, AUDIO_SETINFO, &audioinfo) < 0) {
g_warning ("Error setting audio device volume");
return;
}

View file

@ -160,10 +160,6 @@ gst_sunaudiosink_class_init (GstSunAudioSinkClass * klass)
gobject_class->get_property =
GST_DEBUG_FUNCPTR (gst_sunaudiosink_get_property);
g_object_class_install_property (gobject_class, PROP_DEVICE,
g_param_spec_string ("device", "Device", "Audio Device (/dev/audio)",
DEFAULT_DEVICE, G_PARAM_READWRITE));
gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_sunaudiosink_getcaps);
gstaudiosink_class->open = GST_DEBUG_FUNCPTR (gst_sunaudiosink_open);
@ -174,17 +170,22 @@ gst_sunaudiosink_class_init (GstSunAudioSinkClass * klass)
gstaudiosink_class->write = GST_DEBUG_FUNCPTR (gst_sunaudiosink_write);
gstaudiosink_class->delay = GST_DEBUG_FUNCPTR (gst_sunaudiosink_delay);
gstaudiosink_class->reset = GST_DEBUG_FUNCPTR (gst_sunaudiosink_reset);
g_object_class_install_property (gobject_class, PROP_DEVICE,
g_param_spec_string ("device", "Device", "Audio Device (/dev/audio)",
DEFAULT_DEVICE, G_PARAM_READWRITE));
}
static void
gst_sunaudiosink_init (GstSunAudioSink * sunaudiosink)
{
const char *audiodev;
GstClockTime buffer_time;
GValue gvalue = { 0, };
GST_DEBUG_OBJECT (sunaudiosink, "initializing sunaudiosink");
sunaudiosink->fd = -1;
audiodev = g_getenv ("AUDIODEV");
if (audiodev == NULL)
audiodev = DEFAULT_DEVICE;
@ -340,7 +341,6 @@ gst_sunaudiosink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
ainfo.play.precision = spec->width;
ainfo.play.encoding = AUDIO_ENCODING_LINEAR;
ainfo.play.port = ports;
ainfo.output_muted = 0;
/*
* SunAudio doesn't really give access to buffer size, these values work. Setting
@ -376,9 +376,7 @@ gst_sunaudiosink_unprepare (GstAudioSink * asink)
static guint
gst_sunaudiosink_write (GstAudioSink * asink, gpointer data, guint length)
{
GstSunAudioSink *sunaudiosink = GST_SUNAUDIO_SINK (asink);
return write (sunaudiosink->fd, data, length);
return write (GST_SUNAUDIO_SINK (asink)->fd, data, length);
}
/*