~jcowgill/ubuntu/trusty/easytag/bug-1295882

« back to all changes in this revision

Viewing changes to src/flac_header.c

  • Committer: Package Import Robot
  • Author(s): James Cowgill, James Cowgill, Alessio Treglia
  • Date: 2014-02-28 15:50:09 UTC
  • mfrom: (8.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20140228155009-o7quqdw3qlldw98q
Tags: 2.1.10-1
* Team upload.

[ James Cowgill ]
* New upstream release (Closes: #560813, #500051, #518955, #727811).
* Add myself to the list of uploaders.
* Use debhelper v9.
* debian/control:
  - Build depend on desktop-file-utils and yelp-tools.
  - Recommend on gnome-icon-theme, gvfs and yelp (thanks David King)
  - Update homepage location.
  - Bump standards to 3.9.5 (no changes required).
* debian/copyright:
  - Rewritten to use DEP-5
* debian/rules:
  - Enable all hardening flags.
  - Remove unnecessary dh overrides.
* debian/patches:
  - Remove 1001-c90_style.patch, applied upstream.
  - Add patch to remove appdata from buildsystem.
    Can't use until appdata-tools is introduced into Debian.

[ Alessio Treglia ]
* Improve package description (Closes: #691687)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 *  You should have received a copy of the GNU General Public License
17
17
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
 */
20
20
 
21
21
/*
25
25
 *
26
26
 */
27
27
 
28
 
#include <config.h> // For definition of ENABLE_FLAC
 
28
#include "config.h" /* For definition of ENABLE_FLAC. */
29
29
 
30
30
#ifdef ENABLE_FLAC
31
31
 
32
32
#include <gtk/gtk.h>
33
 
#include <glib/gi18n-lib.h>
34
 
#include <stdio.h>
35
 
#include <errno.h>
36
 
#include <string.h>    // 20030519 <tmancill@debian.org> for compiliation on ia64 arch
 
33
#include <glib/gi18n.h>
37
34
#include <FLAC/all.h>
38
35
 
39
36
#include "easytag.h"
40
37
#include "et_core.h"
41
38
#include "flac_header.h"
42
 
#include "log.h"
43
39
#include "misc.h"
44
 
#include "charset.h"
45
40
 
46
41
 
47
42
/****************
48
43
 * Declarations *
49
44
 ****************/
50
 
/* Taken in "xmms/plugin.h" */
51
 
typedef enum
52
 
{
53
 
    FMT_U8, FMT_S8, FMT_U16_LE, FMT_U16_BE, FMT_U16_NE, FMT_S16_LE, FMT_S16_BE, FMT_S16_NE
54
 
}
55
 
AFormat;
56
 
 
57
45
typedef struct {
58
46
    FLAC__bool abort_flag;
59
47
    FLAC__bool is_playing;
64
52
    unsigned channels;
65
53
    unsigned sample_rate;
66
54
    unsigned length_in_msec;
67
 
    AFormat sample_format; // Note : defined in XMMS devel
68
55
    int seek_to_in_sec;
69
56
} file_info_struct;
70
57
 
92
79
 
93
80
gboolean Flac_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo)
94
81
{
95
 
    FILE *file;
96
 
    gdouble duration = 0;
 
82
    gint duration = 0;
97
83
    gulong filesize;
98
84
    FLAC__StreamDecoder *tmp_decoder;
99
85
 
100
86
    file_info_struct tmp_file_info;
101
87
 
102
 
    if (!filename || !ETFileInfo)
103
 
        return FALSE;
104
 
 
105
 
    if ( (file=fopen(filename,"r"))==NULL )
106
 
    {
107
 
        gchar *filename_utf8 = filename_to_display(filename);
108
 
        Log_Print(LOG_ERROR,_("Error while opening file: '%s' (%s)."),filename_utf8,g_strerror(errno));
109
 
        g_free(filename_utf8);
110
 
        return FALSE;
111
 
    }
112
 
    fclose(file);
 
88
    g_return_val_if_fail (filename != NULL && ETFileInfo != NULL, FALSE);
113
89
 
114
90
    /* Decoding FLAC file */
115
91
    tmp_decoder = FLAC__stream_decoder_new();
116
 
    if (tmp_decoder == 0)
 
92
    if (tmp_decoder == NULL)
117
93
    {
118
94
        return FALSE;
119
95
    }
134
110
    /* End of decoding FLAC file */
135
111
 
136
112
 
137
 
    filesize = Get_File_Size(filename);
 
113
    filesize = et_get_file_size (filename);
138
114
    duration = (gint)tmp_file_info.length_in_msec/1000;
139
115
 
140
116
    ETFileInfo->version     = 0; // Not defined in FLAC file
195
171
        file_info->channels = metadata->data.stream_info.channels;
196
172
        file_info->sample_rate = metadata->data.stream_info.sample_rate;
197
173
 
198
 
        if (file_info->bits_per_sample == 8)
199
 
        {
200
 
            file_info->sample_format = FMT_S8;
201
 
        } else if (file_info->bits_per_sample == 16)
202
 
        {
203
 
            file_info->sample_format = FMT_S16_NE;
204
 
        } else
205
 
        {
206
 
            file_info->abort_flag = true;
207
 
            return;
208
 
        }
209
174
        if (file_info->sample_rate != 0 && (file_info->sample_rate / 100) != 0) // To prevent crash...
210
175
            file_info->length_in_msec = file_info->total_samples * 10 / (file_info->sample_rate / 100);
211
176
    }
253
218
    g_free(text);
254
219
 
255
220
    /* Size */
256
 
    size  = Convert_Size(ETFileInfo->size);
257
 
    size1 = Convert_Size(ETCore->ETFileDisplayedList_TotalSize);
 
221
    size  = g_format_size (ETFileInfo->size);
 
222
    size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
258
223
    text  = g_strdup_printf("%s (%s)",size,size1);
259
224
    gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
260
225
    g_free(size);