27 typedef struct xmms_segment_data_St {
39 static gint64 ms_to_samples (gint rate,
42 static gint ms_to_bytes (gint rate,
46 static gint samples_to_bytes (gint64 unit,
49 static gint64 bytes_to_samples (gint64 unit,
74 ms_to_samples (gint rate,
77 return (gint64)(((gdouble) rate) * milliseconds / 1000);
81 ms_to_bytes (gint rate,
85 return (gint) ms_to_samples (rate, milliseconds) * unit;
89 samples_to_bytes (gint64 unit,
92 return (gint) samples * unit;
96 bytes_to_samples (gint64 unit,
99 return (gint64) bytes / unit;
109 methods.
init = xmms_segment_init;
110 methods.
destroy = xmms_segment_destroy;
111 methods.
read = xmms_segment_read;
112 methods.
seek = xmms_segment_seek;
131 const gchar *metakey;
137 gint sample_size_in_bytes;
140 g_return_val_if_fail (xform, FALSE);
150 startms = (gint) strtol (nptr, &endptr, 10);
151 if (*endptr !=
'\0') {
152 XMMS_DBG (
"\"startms\" has garbage!");
159 stopms = (gint) strtol (nptr, &endptr, 10);
160 if (*endptr !=
'\0') {
168 XMMS_DBG (
"\"duration\" doesnt exist, ignore stopms.");
175 if (stopms != INT_MAX) {
185 sample_size_in_bytes = xmms_sample_size_get (fmt);
189 data->unit = channels * sample_size_in_bytes;
190 data->current_bytes = data->start_bytes = ms_to_bytes (samplerate,
193 data->stop_bytes = ms_to_bytes (samplerate,
201 samples = ms_to_samples (samplerate, startms);
228 if (data && (data->current_bytes + len >= data->stop_bytes)) {
229 len = data->stop_bytes - data->current_bytes;
233 if (data && (res > 0)) {
234 data->current_bytes += res;
259 samples > bytes_to_samples (data->unit,
261 - data->start_bytes)) {
262 xmms_error_set (error,
264 "Seeking out of range");
268 tmp = bytes_to_samples (data->unit,
274 data->current_bytes = samples_to_bytes (data->unit,
282 "Handling segment information specified by startms/stopms",
283 xmms_segment_plugin_setup);
XMMS_XFORM_BUILTIN(segment, "Segment Effect", XMMS_VERSION, "Handling segment information specified by startms/stopms", xmms_segment_plugin_setup)
#define xmms_log_info(fmt,...)
#define XMMS_DBG(fmt,...)
G_BEGIN_DECLS struct xmms_error_St xmms_error_t
struct xmms_segment_data_St xmms_segment_data_t