1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/* GSL - Generic Sound Layer
* Copyright (C) 2001 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GSL_DATA_HANDLE_H__
#define __GSL_DATA_HANDLE_H__
#include <gsl/gsldefs.h>
#include <gsl/gslcommon.h> /* GslErrorType */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* --- macros --- */
#define GSL_DATA_HANDLE_OPENED(handle) (((GslDataHandle*) (handle))->open_count > 0)
#define GSL_DATA_HANDLE_READ_LINEAR(handle) (((GslDataHandle*) (handle))->vtable->coarse_seek != NULL)
/* --- typedefs & structures --- */
typedef struct {
GslLong n_values;
guint n_channels;
guint bit_depth;
} GslDataHandleSetup;
struct _GslDataHandle
{
/* constant members */
GslDataHandleFuncs *vtable;
gchar *name;
/* common members */
GslMutex mutex;
guint ref_count;
guint open_count;
/* opened data handle setup (open_count > 0) */
GslDataHandleSetup setup;
};
struct _GslDataHandleFuncs
{
GslErrorType (*open) (GslDataHandle *data_handle,
GslDataHandleSetup *setup);
GslLong (*read) (GslDataHandle *data_handle,
GslLong voffset, /* in values */
GslLong n_values,
gfloat *values);
void (*close) (GslDataHandle *data_handle);
void (*destroy) (GslDataHandle *data_handle);
/* optional (for codecs) */
GslLong (*coarse_seek) (GslDataHandle *data_handle,
GslLong position);
};
/* --- standard functions --- */
GslDataHandle* gsl_data_handle_ref (GslDataHandle *dhandle);
void gsl_data_handle_unref (GslDataHandle *dhandle);
GslErrorType gsl_data_handle_open (GslDataHandle *dhandle);
void gsl_data_handle_close (GslDataHandle *dhandle);
GslLong gsl_data_handle_length (GslDataHandle *data_handle);
#define gsl_data_handle_n_values( dh) \
gsl_data_handle_length (dh)
guint gsl_data_handle_n_channels (GslDataHandle *data_handle);
guint gsl_data_handle_bit_depth (GslDataHandle *data_handle);
const gchar* gsl_data_handle_name (GslDataHandle *data_handle);
GslLong gsl_data_handle_read (GslDataHandle *data_handle,
GslLong value_offset,
GslLong n_values,
gfloat *values);
GslDataHandle* gsl_data_handle_new_cut (GslDataHandle *src_handle,
GslLong cut_offset,
GslLong n_cut_values);
GslDataHandle* gsl_data_handle_new_crop (GslDataHandle *src_handle,
GslLong n_head_cut,
GslLong n_tail_cut);
GslDataHandle* gsl_data_handle_new_reverse (GslDataHandle *src_handle);
GslDataHandle* gsl_data_handle_new_insert (GslDataHandle *src_handle,
guint paste_bit_depth,
GslLong insertion_offset,
GslLong n_paste_values,
const gfloat *paste_values,
void (*free) (gpointer values));
GslDataHandle* gsl_data_handle_new_mem (guint n_channels,
guint bit_depth,
GslLong n_values,
const gfloat *values,
void (*free) (gpointer values));
GslDataHandle* gsl_data_handle_new_dcached (GslDataCache *dcache);
/* cheap and inefficient, testpurpose only */
GslDataHandle* gsl_data_handle_new_looped (GslDataHandle *src_handle,
GslLong loop_first,
GslLong loop_last);
/* --- wave specific functions --- */
typedef enum /*< skip >*/
{
GSL_WAVE_FORMAT_NONE,
GSL_WAVE_FORMAT_UNSIGNED_8,
GSL_WAVE_FORMAT_SIGNED_8,
GSL_WAVE_FORMAT_UNSIGNED_12,
GSL_WAVE_FORMAT_SIGNED_12,
GSL_WAVE_FORMAT_UNSIGNED_16,
GSL_WAVE_FORMAT_SIGNED_16,
GSL_WAVE_FORMAT_FLOAT,
GSL_WAVE_FORMAT_LAST
} GslWaveFormatType;
const gchar* gsl_wave_format_to_string (GslWaveFormatType format);
GslWaveFormatType gsl_wave_format_from_string (const gchar *string);
GslDataHandle* gsl_wave_handle_new (const gchar *file_name,
guint n_channels,
GslWaveFormatType format,
guint byte_order,
GslLong byte_offset,
GslLong n_values);
/* --- auxillary functions --- */
gboolean gsl_data_handle_common_init (GslDataHandle *dhandle,
const gchar *file_name);
void gsl_data_handle_common_free (GslDataHandle *dhandle);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GSL_DATA_HANDLE_H__ */
|