Subversion Repositories mdb

Rev

Rev 35 | Rev 56 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35 Rev 40
Line 117... Line 117...
117
 
117
 
118
	if (!FLAC__stream_decoder_process_until_end_of_stream(fsd))
118
	if (!FLAC__stream_decoder_process_until_end_of_stream(fsd))
119
	{
119
	{
120
		if (last_todo != PLAY_STATUS_STOP)
120
		if (last_todo != PLAY_STATUS_STOP)
121
		{
121
		{
-
 
122
			syslog(LOG_WARNING, "Error playing file %s", file);
122
			syslog(LOG_DAEMON, "Error processing stream: %s", FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(fsd)]);
123
			syslog(LOG_WARNING, "Error processing stream: %s", FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(fsd)]);
-
 
124
			ao_close(dev);
123
			FLAC__stream_decoder_finish(fsd);
125
			FLAC__stream_decoder_finish(fsd);
124
			FLAC__stream_decoder_delete(fsd);
126
			FLAC__stream_decoder_delete(fsd);
125
			ao_shutdown();
127
			ao_shutdown();
126
			last_todo = 0;
128
			last_todo = 0;
127
			return;
129
			return;
Line 142... Line 144...
142
FLAC__StreamDecoderWriteStatus sdWriteCallback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
144
FLAC__StreamDecoderWriteStatus sdWriteCallback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
143
{
145
{
144
struct st_params *params = (struct st_params *)client_data;
146
struct st_params *params = (struct st_params *)client_data;
145
int driver = params->driver;
147
int driver = params->driver;
146
int s1 = params->s1;
148
int s1 = params->s1;
147
//const FLAC__uint32 total_size = (FLAC__uint32)(total_samples * channels * (bps / 8));
-
 
148
uint_32 samples = frame->header.blocksize;
149
uint_32 samples = frame->header.blocksize;
149
uint_32 decoded_size = frame->header.blocksize * frame->header.channels * (bps / 8);
150
uint_32 decoded_size = frame->header.blocksize * frame->header.channels * (bps / 8);
150
static uint_8 aobuf[FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(uint_32)]; /*oink!*/
151
static uint_8 aobuf[FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(uint_32)]; /*oink!*/
-
 
152
uint_32 *u32aobuf = (uint_32 *) aobuf;
151
uint_16 *u16aobuf = (uint_16 *) aobuf;
153
uint_16 *u16aobuf = (uint_16 *) aobuf;
152
uint_8   *u8aobuf = (uint_8  *) aobuf;
154
uint_8   *u8aobuf = (uint_8  *) aobuf;
153
size_t i, j;
155
size_t i, j;
154
uint_32 sample, channel;
156
uint_32 sample, channel;
155
int todo;
157
int todo;
Line 158... Line 160...
158
	{
160
	{
159
		syslog(LOG_DAEMON, "ERROR: FLAC file have to have a total_samples count in STREAMINFO");
161
		syslog(LOG_DAEMON, "ERROR: FLAC file have to have a total_samples count in STREAMINFO");
160
		return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
162
		return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
161
	}
163
	}
162
 
164
 
163
	if (channels != 2 || (bps != 16 && bps != 8)) 
165
	if (channels <= 0 || (bps != 32 && bps != 16 && bps != 8))
164
	{
166
	{
165
		syslog(LOG_DAEMON, "ERROR: Currently only 8bit or 16bit streams supported!");
167
		syslog(LOG_DAEMON, "ERROR: Currently only 8bit, 16bit or 32bit streams supported!");
166
		return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
168
		return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
167
	}
169
	}
168
 
170
 
169
	if (buffer[0] == NULL) 
171
	if (buffer[0] == NULL) 
170
	{
172
	{
Line 268... Line 270...
268
		{
270
		{
269
			for(channel = 0; channel < frame->header.channels; channel++,i++)
271
			for(channel = 0; channel < frame->header.channels; channel++,i++)
270
				u16aobuf[i] = (uint_16)(buffer[channel][sample]);
272
				u16aobuf[i] = (uint_16)(buffer[channel][sample]);
271
		} 
273
		} 
272
	}
274
	}
-
 
275
	else if (bps == 32)
-
 
276
	{
-
 
277
		for (sample = i = 0; sample < samples; sample++)
-
 
278
		{
-
 
279
			for(channel = 0; channel < frame->header.channels; channel++,i++)
-
 
280
				u32aobuf[i] = (uint_32)(buffer[channel][sample]);
-
 
281
		} 
-
 
282
	}
273
 
283
	
274
	ao_play(dev, (char *)aobuf, decoded_size);
284
	ao_play(dev, (char *)aobuf, decoded_size);
275
 
285
 
276
	if (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER)
286
	if (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER)
277
	{
287
	{
278
		char hv0[255], hv1[32], hv2[32], hv3[32];
288
		char hv0[255], hv1[32], hv2[32], hv3[32];
Line 308... Line 318...
308
	}
318
	}
309
}
319
}
310
 
320
 
311
static void sdErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void * client_data)
321
static void sdErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void * client_data)
312
{
322
{
313
	syslog(LOG_DAEMON, "Got error callback: %s", FLAC__StreamDecoderErrorStatusString[status]);
323
	syslog(LOG_WARNING, "Got error callback: %s", FLAC__StreamDecoderErrorStatusString[status]);
314
}
324
}