LCOV - code coverage report
Current view: top level - gst-plugins-bad/ext/sndfile - gstsf.c (source / functions) Hit Total Coverage
Test: GStreamer Lines: 42 44 95.5 %
Date: 2011-03-25 Functions: 3 3 100.0 %
Branches: 13 18 72.2 %

           Branch data     Line data    Source code
       1                 :            : /* GStreamer libsndfile plugin
       2                 :            :  * Copyright (C) 2003 Andy Wingo <wingo at pobox dot com>
       3                 :            :  *
       4                 :            :  * This library is free software; you can redistribute it and/or
       5                 :            :  * modify it under the terms of the GNU Library General Public
       6                 :            :  * License as published by the Free Software Foundation; either
       7                 :            :  * version 2 of the License, or (at your option) any later version.
       8                 :            :  *
       9                 :            :  * This library is distributed in the hope that it will be useful,
      10                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12                 :            :  * Library General Public License for more details.
      13                 :            :  *
      14                 :            :  * You should have received a copy of the GNU Library General Public
      15                 :            :  * License along with this library; if not, write to the
      16                 :            :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      17                 :            :  * Boston, MA 02111-1307, USA.
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #ifdef HAVE_CONFIG_H
      22                 :            : #include "config.h"
      23                 :            : #endif
      24                 :            : 
      25                 :            : #include <gst/gst-i18n-plugin.h>
      26                 :            : #include <string.h>
      27                 :            : 
      28                 :            : #include "gstsf.h"
      29                 :            : 
      30                 :            : 
      31                 :            : GType
      32                 :          6 : gst_sf_major_types_get_type (void)
      33                 :            : {
      34                 :            :   static GType sf_major_types_type = 0;
      35                 :            :   static GEnumValue *sf_major_types = NULL;
      36                 :            : 
      37         [ +  - ]:          6 :   if (!sf_major_types_type) {
      38                 :            :     SF_FORMAT_INFO format_info;
      39                 :            :     int k, count;
      40                 :            : 
      41                 :          6 :     sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int));
      42                 :            : 
      43                 :          6 :     sf_major_types = g_new0 (GEnumValue, count + 1);
      44                 :            : 
      45         [ +  + ]:        156 :     for (k = 0; k < count; k++) {
      46                 :        150 :       format_info.format = k;
      47                 :        150 :       sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info,
      48                 :            :           sizeof (format_info));
      49                 :        150 :       sf_major_types[k].value = format_info.format;
      50                 :        150 :       sf_major_types[k].value_name = g_strdup (format_info.name);
      51                 :        150 :       sf_major_types[k].value_nick = g_strdup (format_info.extension);
      52                 :            : 
      53                 :            :       /* Irritatingly enough, there exist major_types with the same extension. Let's
      54                 :            :          just hope that sndfile gives us the list in alphabetical order, as it
      55                 :            :          currently does. */
      56         [ +  + ]:        150 :       if (k > 0
      57         [ +  + ]:        144 :           && strcmp (sf_major_types[k].value_nick,
      58                 :        144 :               sf_major_types[k - 1].value_nick) == 0) {
      59                 :         12 :         g_free ((gchar *) sf_major_types[k].value_nick);
      60                 :         24 :         sf_major_types[k].value_nick =
      61                 :         12 :             g_strconcat (sf_major_types[k - 1].value_nick, "-",
      62                 :         12 :             sf_major_types[k].value_name, NULL);
      63                 :         12 :         g_strcanon ((gchar *) sf_major_types[k].value_nick,
      64                 :            :             G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
      65                 :            :       }
      66                 :            :     }
      67                 :            : 
      68                 :          6 :     sf_major_types_type =
      69                 :          6 :         g_enum_register_static ("GstSndfileMajorTypes", sf_major_types);
      70                 :            :   }
      71                 :          6 :   return sf_major_types_type;
      72                 :            : }
      73                 :            : 
      74                 :            : GType
      75                 :          6 : gst_sf_minor_types_get_type (void)
      76                 :            : {
      77                 :            :   static GType sf_minor_types_type = 0;
      78                 :            :   static GEnumValue *sf_minor_types = NULL;
      79                 :            : 
      80         [ +  - ]:          6 :   if (!sf_minor_types_type) {
      81                 :            :     SF_FORMAT_INFO format_info;
      82                 :            :     int k, count;
      83                 :            : 
      84                 :          6 :     sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int));
      85                 :            : 
      86                 :          6 :     sf_minor_types = g_new0 (GEnumValue, count + 1);
      87                 :            : 
      88         [ +  + ]:        132 :     for (k = 0; k < count; k++) {
      89                 :        126 :       format_info.format = k;
      90                 :        126 :       sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info,
      91                 :            :           sizeof (format_info));
      92                 :        126 :       sf_minor_types[k].value = format_info.format;
      93                 :        126 :       sf_minor_types[k].value_name = g_strdup (format_info.name);
      94                 :        126 :       sf_minor_types[k].value_nick = g_ascii_strdown (format_info.name, -1);
      95                 :        126 :       g_strcanon ((gchar *) sf_minor_types[k].value_nick,
      96                 :            :           G_CSET_a_2_z G_CSET_DIGITS "-", '-');
      97                 :            :     }
      98                 :            : 
      99                 :          6 :     sf_minor_types_type =
     100                 :          6 :         g_enum_register_static ("GstSndfileMinorTypes", sf_minor_types);
     101                 :            :   }
     102                 :          6 :   return sf_minor_types_type;
     103                 :            : }
     104                 :            : 
     105                 :            : static gboolean
     106                 :          7 : plugin_init (GstPlugin * plugin)
     107                 :            : {
     108                 :            : #ifdef ENABLE_NLS
     109         [ -  + ]:          7 :   GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
     110                 :            :       LOCALEDIR);
     111                 :          7 :   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
     112                 :          7 :   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
     113                 :            : #endif /* ENABLE_NLS */
     114                 :            : 
     115         [ -  + ]:          7 :   if (!gst_element_register (plugin, "sfsink", GST_RANK_NONE,
     116                 :            :           gst_sf_sink_get_type ()))
     117                 :          0 :     return FALSE;
     118                 :            : 
     119         [ -  + ]:          7 :   if (!gst_element_register (plugin, "sfsrc", GST_RANK_NONE,
     120                 :            :           gst_sf_src_get_type ()))
     121                 :          0 :     return FALSE;
     122                 :            : 
     123                 :          7 :   return TRUE;
     124                 :            : }
     125                 :            : 
     126                 :            : GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
     127                 :            :     GST_VERSION_MINOR,
     128                 :            :     "sndfile",
     129                 :            :     "use libsndfile to read and write audio from and to files",
     130                 :            :     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

Generated by: LCOV version 1.9