Blame ext/alsa/gstalsaplugin.c

Packit 0652a1
/*
Packit 0652a1
 * Copyright (C) 2001 CodeFactory AB
Packit 0652a1
 * Copyright (C) 2001 Thomas Nyberg <thomas@codefactory.se>
Packit 0652a1
 * Copyright (C) 2001-2002 Andy Wingo <apwingo@eos.ncsu.edu>
Packit 0652a1
 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
Packit 0652a1
 *
Packit 0652a1
 * This library is free software; you can redistribute it and/or
Packit 0652a1
 * modify it under the terms of the GNU Library General Public
Packit 0652a1
 * License as published by the Free Software Foundation; either
Packit 0652a1
 * version 2 of the License, or (at your option) any later version.
Packit 0652a1
 *
Packit 0652a1
 * This library is distributed in the hope that it will be useful,
Packit 0652a1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 0652a1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Packit 0652a1
 * Library General Public License for more details.
Packit 0652a1
 *
Packit 0652a1
 * You should have received a copy of the GNU Library General Public
Packit 0652a1
 * License along with this library; if not, write to the Free
Packit 0652a1
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 0652a1
 */
Packit 0652a1
Packit 0652a1
#ifdef HAVE_CONFIG_H
Packit 0652a1
#include "config.h"
Packit 0652a1
#endif
Packit 0652a1
Packit 0652a1
#include "gstalsasink.h"
Packit 0652a1
#include "gstalsasrc.h"
Packit 0652a1
#include "gstalsamidisrc.h"
Packit 0652a1
Packit 0652a1
#include <gst/gst-i18n-plugin.h>
Packit 0652a1
Packit 0652a1
GST_DEBUG_CATEGORY (alsa_debug);
Packit 0652a1
Packit 0652a1
/* ALSA debugging wrapper */
Packit 0652a1
/* *INDENT-OFF* */
Packit 0652a1
G_GNUC_PRINTF (5, 6)
Packit 0652a1
/* *INDENT-ON* */
Packit 0652a1
static void
Packit 0652a1
gst_alsa_error_wrapper (const char *file, int line, const char *function,
Packit 0652a1
    int err, const char *fmt, ...)
Packit 0652a1
{
Packit 0652a1
#ifndef GST_DISABLE_GST_DEBUG
Packit 0652a1
  va_list args;
Packit 0652a1
  gchar *str;
Packit 0652a1
Packit 0652a1
  va_start (args, fmt);
Packit 0652a1
  str = g_strdup_vprintf (fmt, args);
Packit 0652a1
  va_end (args);
Packit 0652a1
  /* FIXME: use GST_LEVEL_ERROR here? Currently warning is used because we're 
Packit 0652a1
   * able to catch enough of the errors that would be printed otherwise
Packit 0652a1
   */
Packit 0652a1
  gst_debug_log (alsa_debug, GST_LEVEL_WARNING, file, function, line, NULL,
Packit 0652a1
      "alsalib error: %s%s%s", str, err ? ": " : "",
Packit 0652a1
      err ? snd_strerror (err) : "");
Packit 0652a1
  g_free (str);
Packit 0652a1
#endif
Packit 0652a1
}
Packit 0652a1
Packit 0652a1
static gboolean
Packit 0652a1
plugin_init (GstPlugin * plugin)
Packit 0652a1
{
Packit 0652a1
  int err;
Packit 0652a1
Packit 0652a1
  if (!gst_element_register (plugin, "alsasrc", GST_RANK_PRIMARY,
Packit 0652a1
          GST_TYPE_ALSA_SRC))
Packit 0652a1
    return FALSE;
Packit 0652a1
  if (!gst_element_register (plugin, "alsasink", GST_RANK_PRIMARY,
Packit 0652a1
          GST_TYPE_ALSA_SINK))
Packit 0652a1
    return FALSE;
Packit 0652a1
  if (!gst_element_register (plugin, "alsamidisrc", GST_RANK_PRIMARY,
Packit 0652a1
          GST_TYPE_ALSA_MIDI_SRC))
Packit 0652a1
    return FALSE;
Packit 0652a1
Packit 0652a1
  GST_DEBUG_CATEGORY_INIT (alsa_debug, "alsa", 0, "alsa plugins");
Packit 0652a1
Packit 0652a1
#ifdef ENABLE_NLS
Packit 0652a1
  GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
Packit 0652a1
      LOCALEDIR);
Packit 0652a1
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
Packit 0652a1
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
Packit 0652a1
#endif
Packit 0652a1
Packit 0652a1
  err = snd_lib_error_set_handler (gst_alsa_error_wrapper);
Packit 0652a1
  if (err != 0)
Packit 0652a1
    GST_WARNING ("failed to set alsa error handler");
Packit 0652a1
Packit 0652a1
  return TRUE;
Packit 0652a1
}
Packit 0652a1
Packit 0652a1
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
Packit 0652a1
    GST_VERSION_MINOR,
Packit 0652a1
    alsa,
Packit 0652a1
    "ALSA plugin library",
Packit 0652a1
    plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)