* gst-libs/gst/audio/gstringbuffer.c: (build_linear_format):
Make gcc-4.1 happy (part of #327357).
+2006-01-28 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * ext/alsa/gstalsasink.c: (gst_alsasink_init), (set_hwparams),
+ (set_swparams), (gst_alsasink_prepare), (gst_alsasink_unprepare),
+ (gst_alsasink_close), (gst_alsasink_write), (gst_alsasink_reset):
+ * ext/alsa/gstalsasrc.c: (gst_alsasrc_init), (set_hwparams),
+ (set_swparams), (gst_alsasrc_open), (gst_alsasrc_prepare),
+ (gst_alsasrc_unprepare), (gst_alsasrc_read):
+ Update all error messages. All of them should either use
+ the default translated message, or actually provide a
+ translatable string.
+ Make the string for channel count problems meaningful.
+
2006-01-28 Thomas Vander Stichele <thomas at apestaart dot org>
* sys/v4l/v4l_calls.c: (gst_v4l_open):
#include "gstalsa.h"
#include "gstalsasink.h"
+#include <gst/gst-i18n-plugin.h>
+
/* elementfactory information */
static GstElementDetails gst_alsasink_details =
GST_ELEMENT_DETAILS ("Audio Sink (ALSA)",
static void
gst_alsasink_init (GstAlsaSink * alsasink)
{
- GST_DEBUG ("initializing alsasink");
+ GST_DEBUG_OBJECT (alsasink, "initializing alsasink");
alsasink->device = g_strdup ("default");
alsasink->handle = NULL;
snd_pcm_hw_params_alloca (¶ms);
- GST_DEBUG ("Negotiating to %d channels @ %d Hz", alsa->channels, alsa->rate);
+ GST_DEBUG_OBJECT (alsa, "Negotiating to %d channels @ %d Hz", alsa->channels,
+ alsa->rate);
/* choose all parameters */
CHECK (snd_pcm_hw_params_any (alsa->handle, params), no_config);
/* ERRORS */
no_config:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Broken configuration for playback: no configurations available: %s",
- snd_strerror (err)), (NULL));
+ snd_strerror (err)));
return err;
}
wrong_access:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Access type not available for playback: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Access type not available for playback: %s", snd_strerror (err)));
return err;
}
no_sample_format:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Sample format not available for playback: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Sample format not available for playback: %s", snd_strerror (err)));
return err;
}
no_channels:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Channels count (%i) not available for playbacks: %s",
- alsa->channels, snd_strerror (err)), (NULL));
+ gchar *msg = NULL;
+
+ if ((alsa->channels) == 1)
+ msg = g_strdup (_("Could not open device for playback in mono mode."));
+ if ((alsa->channels) == 2)
+ msg = g_strdup (_("Could not open device for playback in stereo mode."));
+ if ((alsa->channels) > 2)
+ msg =
+ g_strdup_printf (_
+ ("Could not open device for playback in %d-channel mode."),
+ alsa->channels);
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (msg), (snd_strerror (err)));
+ g_free (msg);
return err;
}
no_rate:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Rate %iHz not available for playback: %s",
- alsa->rate, snd_strerror (err)), (NULL));
+ alsa->rate, snd_strerror (err)));
return err;
}
rate_match:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Rate doesn't match (requested %iHz, get %iHz)",
- alsa->rate, err), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Rate doesn't match (requested %iHz, get %iHz)", alsa->rate, err));
return -EINVAL;
}
buffer_time:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Unable to set buffer time %i for playback: %s",
- alsa->buffer_time, snd_strerror (err)), (NULL));
+ alsa->buffer_time, snd_strerror (err)));
return err;
}
buffer_size:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to get buffer size for playback: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to get buffer size for playback: %s", snd_strerror (err)));
return err;
}
period_time:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Unable to set period time %i for playback: %s", alsa->period_time,
- snd_strerror (err)), (NULL));
+ snd_strerror (err)));
return err;
}
period_size:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to get period size for playback: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to get period size for playback: %s", snd_strerror (err)));
return err;
}
set_hw_params:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to set hw params for playback: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to set hw params for playback: %s", snd_strerror (err)));
return err;
}
}
/* ERRORS */
no_config:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Unable to determine current swparams for playback: %s",
- snd_strerror (err)), (NULL));
+ snd_strerror (err)));
return err;
}
start_threshold:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Unable to set start threshold mode for playback: %s",
- snd_strerror (err)), (NULL));
+ snd_strerror (err)));
return err;
}
set_avail:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to set avail min for playback: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to set avail min for playback: %s", snd_strerror (err)));
return err;
}
set_align:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to set transfer align for playback: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to set transfer align for playback: %s", snd_strerror (err)));
return err;
}
set_sw_params:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to set sw params for playback: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to set sw params for playback: %s", snd_strerror (err)));
return err;
}
}
/* ERRORS */
spec_parse:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Error parsing spec"), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Error parsing spec"));
return FALSE;
}
non_block:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Could not set device to blocking: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Could not set device to blocking: %s", snd_strerror (err)));
return FALSE;
}
hw_params_failed:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Setting of hwparams failed: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Setting of hwparams failed: %s", snd_strerror (err)));
return FALSE;
}
sw_params_failed:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Setting of swparams failed: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Setting of swparams failed: %s", snd_strerror (err)));
return FALSE;
}
}
/* ERRORS */
drop:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Could not drop samples: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Could not drop samples: %s", snd_strerror (err)));
return FALSE;
}
hw_free:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Could not free hw params: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Could not free hw params: %s", snd_strerror (err)));
return FALSE;
}
non_block:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Could not set device to nonblocking: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Could not set device to nonblocking: %s", snd_strerror (err)));
return FALSE;
}
}
/* ERRORS */
close_error:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, CLOSE,
- ("Playback close error: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, CLOSE, (NULL),
+ ("Playback close error: %s", snd_strerror (err)));
return FALSE;
}
}
if (err < 0) {
if (err == -EAGAIN) {
- GST_DEBUG ("Write error: %s", snd_strerror (err));
+ GST_DEBUG_OBJECT (asink, "Write error: %s", snd_strerror (err));
continue;
} else if (xrun_recovery (alsa->handle, err) < 0) {
goto write_error;
/* ERRORS */
drop_error:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS,
("alsa-reset: pcm drop error: %s", snd_strerror (err)), (NULL));
return;
}
prepare_error:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS,
("alsa-reset: pcm prepare error: %s", snd_strerror (err)), (NULL));
return;
}
#include <getopt.h>
#include <alsa/asoundlib.h>
-
#include "gstalsasrc.h"
+#include <gst/gst-i18n-plugin.h>
+
/* elementfactory information */
static GstElementDetails gst_alsasrc_details =
GST_ELEMENT_DETAILS ("Audio Src (ALSA)",
static void
gst_alsasrc_init (GstAlsaSrc * alsasrc, GstAlsaSrcClass * g_class)
{
- GST_DEBUG ("initializing alsasrc");
+ GST_DEBUG_OBJECT (alsasrc, "initializing");
alsasrc->device = g_strdup ("default");
}
/* ERRORS */
no_config:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Broken configuration for recording: no configurations available: %s",
- snd_strerror (err)), (NULL));
+ snd_strerror (err)));
return err;
}
wrong_access:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Access type not available for recording: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Access type not available for recording: %s", snd_strerror (err)));
return err;
}
no_sample_format:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Sample format not available for recording: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Sample format not available for recording: %s", snd_strerror (err)));
return err;
}
no_channels:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Channels count (%i) not available for recording: %s",
- alsa->channels, snd_strerror (err)), (NULL));
+ gchar *msg = NULL;
+
+ if ((alsa->channels) == 1)
+ msg = g_strdup (_("Could not open device for recording in mono mode."));
+ if ((alsa->channels) == 2)
+ msg = g_strdup (_("Could not open device for recording in stereo mode."));
+ if ((alsa->channels) > 2)
+ msg =
+ g_strdup_printf (_
+ ("Could not open device for recording in %d-channel mode"),
+ alsa->channels);
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (msg), (snd_strerror (err)));
+ g_free (msg);
return err;
}
no_rate:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Rate %iHz not available for recording: %s",
- alsa->rate, snd_strerror (err)), (NULL));
+ alsa->rate, snd_strerror (err)));
return err;
}
rate_match:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Rate doesn't match (requested %iHz, get %iHz)",
- alsa->rate, err), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Rate doesn't match (requested %iHz, get %iHz)", alsa->rate, err));
return -EINVAL;
}
buffer_time:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Unable to set buffer time %i for recording: %s",
- alsa->buffer_time, snd_strerror (err)), (NULL));
+ alsa->buffer_time, snd_strerror (err)));
return err;
}
buffer_size:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to get buffer size for recording: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to get buffer size for recording: %s", snd_strerror (err)));
return err;
}
period_time:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Unable to set period time %i for recording: %s", alsa->period_time,
- snd_strerror (err)), (NULL));
+ snd_strerror (err)));
return err;
}
period_size:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to get period size for recording: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to get period size for recording: %s", snd_strerror (err)));
return err;
}
set_hw_params:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to set hw params for recording: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to set hw params for recording: %s", snd_strerror (err)));
return err;
}
}
/* ERRORS */
no_config:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to determine current swparams for recording: %s",
- snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to determine current swparams for playback: %s",
+ snd_strerror (err)));
return err;
}
#if 0
start_threshold:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to set start threshold mode for recording: %s",
- snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to set start threshold mode for playback: %s",
+ snd_strerror (err)));
return err;
}
set_avail:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to set avail min for recording: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to set avail min for playback: %s", snd_strerror (err)));
return err;
}
#endif
set_align:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to set transfer align for recording: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to set transfer align for playback: %s", snd_strerror (err)));
return err;
}
set_sw_params:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Unable to set sw params for recording: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Unable to set sw params for playback: %s", snd_strerror (err)));
return err;
}
}
/* ERRORS */
open_error:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Capture open error: %s", snd_strerror (err)), (NULL));
+ if (err == -EBUSY) {
+ GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY, (NULL), (NULL));
+ } else {
+ GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
+ (NULL), ("Recording open error: %s", snd_strerror (err)));
+ }
return FALSE;
}
}
/* ERRORS */
spec_parse:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Error parsing spec"), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Error parsing spec"));
return FALSE;
}
non_block:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Could not set device to blocking: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Could not set device to blocking: %s", snd_strerror (err)));
return FALSE;
}
hw_params_failed:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Setting of hwparams failed: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Setting of hwparams failed: %s", snd_strerror (err)));
return FALSE;
}
sw_params_failed:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Setting of swparams failed: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Setting of swparams failed: %s", snd_strerror (err)));
return FALSE;
}
prepare_failed:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Prepare failed: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Prepare failed: %s", snd_strerror (err)));
return FALSE;
}
}
/* ERRORS */
drop:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Could not drop samples: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Could not drop samples: %s", snd_strerror (err)));
return FALSE;
}
hw_free:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Could not free hw params: %s", snd_strerror (err)), (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Could not free hw params: %s", snd_strerror (err)));
return FALSE;
}
non_block:
{
- GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,
- ("Could not set device to nonblocking: %s", snd_strerror (err)),
- (NULL));
+ GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
+ ("Could not set device to nonblocking: %s", snd_strerror (err)));
return FALSE;
}
}
while (cptr > 0) {
if ((err = snd_pcm_readi (alsa->handle, ptr, cptr)) < 0) {
if (err == -EAGAIN) {
- GST_DEBUG ("Read error: %s", snd_strerror (err));
+ GST_DEBUG_OBJECT (asrc, "Read error: %s", snd_strerror (err));
continue;
} else if (xrun_recovery (alsa->handle, err) < 0) {
goto read_error;