Subversion Repositories mdb

Rev

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

Rev 40 Rev 56
Line 24... Line 24...
24
 
24
 
25
#include "config.h"
25
#include "config.h"
26
#include "helplib.h"
26
#include "helplib.h"
27
#include "play.h"
27
#include "play.h"
28
#include "user.h"
28
#include "user.h"
-
 
29
#include "mdb.h"
29
 
30
 
30
static FLAC__StreamDecoderWriteStatus sdWriteCallback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
31
static FLAC__StreamDecoderWriteStatus sdWriteCallback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
31
static void sdMetadataCallback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
32
static void sdMetadataCallback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
32
static void sdErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void * client_data);
33
static void sdErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void * client_data);
33
 
34
 
Line 52... Line 53...
52
 
53
 
53
void playFlac(int s1, char *file)
54
void playFlac(int s1, char *file)
54
{
55
{
55
int i, flag;
56
int i, flag;
56
int driver;
57
int driver;
57
char hv0[64];
58
/* char hv0[64]; */
58
struct st_params params;
59
struct st_params params;
59
 
60
 
60
	/* Check if we've a valid sound driver defined */
61
	/* Check if we've a valid sound driver defined */
61
	flag = FALSE;
62
	flag = FALSE;
62
	i = 0;
63
	i = 0;
Line 129... Line 130...
129
			return;
130
			return;
130
		}
131
		}
131
	}
132
	}
132
 
133
 
133
	/* clean up */
134
	/* clean up */
134
	strcpy(hv0, "PLAYER:STOP;");
135
	handleWrite("PLAYER:STOP;");
135
	write (s1, hv0, strlen(hv0));
136
/*	write (s1, hv0, strlen(hv0)); */
136
	last_todo = 0;
137
	last_todo = 0;
137
 
138
 
138
	ao_close(dev);
139
	ao_close(dev);
139
	FLAC__stream_decoder_finish(fsd);
140
	FLAC__stream_decoder_finish(fsd);
140
	FLAC__stream_decoder_delete(fsd);
141
	FLAC__stream_decoder_delete(fsd);
Line 150... Line 151...
150
uint_32 decoded_size = frame->header.blocksize * frame->header.channels * (bps / 8);
151
uint_32 decoded_size = frame->header.blocksize * frame->header.channels * (bps / 8);
151
static uint_8 aobuf[FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(uint_32)]; /*oink!*/
152
static uint_8 aobuf[FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(uint_32)]; /*oink!*/
152
uint_32 *u32aobuf = (uint_32 *) aobuf;
153
uint_32 *u32aobuf = (uint_32 *) aobuf;
153
uint_16 *u16aobuf = (uint_16 *) aobuf;
154
uint_16 *u16aobuf = (uint_16 *) aobuf;
154
uint_8   *u8aobuf = (uint_8  *) aobuf;
155
uint_8   *u8aobuf = (uint_8  *) aobuf;
155
size_t i, j;
156
size_t i;
156
uint_32 sample, channel;
157
uint_32 sample, channel;
157
int todo;
158
int todo;
158
 
159
 
159
	if (total_samples == 0) 
160
	if (total_samples == 0) 
160
	{
161
	{
Line 247... Line 248...
247
			syslog(LOG_DAEMON, "Error opening live playback device: %s", hv0);
248
			syslog(LOG_DAEMON, "Error opening live playback device: %s", hv0);
248
			return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
249
			return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
249
		}
250
		}
250
 
251
 
251
		playStatus = PLAY_STATUS_PLAY;
252
		playStatus = PLAY_STATUS_PLAY;
252
		strcpy (hv0, "PLAYER:PLAY;");
253
		handleWrite("PLAYER:PLAY;");
253
		write(s1, hv0, strlen(hv0));
254
/*		write(s1, hv0, strlen(hv0)); */
254
	}
255
	}
255
 
256
 
256
	if (bps == 8)
257
	if (bps == 8)
257
	{
258
	{
258
		for (sample = i = 0; sample < samples; sample++) 
259
		for (sample = i = 0; sample < samples; sample++) 
Line 293... Line 294...
293
		f_el_time += f_tm;
294
		f_el_time += f_tm;
294
		elapsed_seconds = (unsigned)f_el_time;
295
		elapsed_seconds = (unsigned)f_el_time;
295
 
296
 
296
		if (elapsed_seconds != old_second)
297
		if (elapsed_seconds != old_second)
297
		{
298
		{
-
 
299
			if (!playQuiet)
-
 
300
			{
298
			sprintf(hv0, "POSITION:%s:%s:%s;", secondsToString(elapsed_seconds, &hv1[0]), secondsToString(total_seconds - elapsed_seconds, &hv2[0]), secondsToString(total_seconds, &hv3[0]));
301
				sprintf(hv0, "POSITION:%s:%s:%s;", secondsToString(elapsed_seconds, &hv1[0]), secondsToString(total_seconds - elapsed_seconds, &hv2[0]), secondsToString(total_seconds, &hv3[0]));
-
 
302
				handleWrite(hv0);
299
			write(s1, hv0, strlen(hv0));
303
			/*	write(s1, hv0, strlen(hv0)); */
-
 
304
			}
-
 
305
 
300
			old_second = elapsed_seconds;
306
			old_second = elapsed_seconds;
301
		}
307
		}
302
	}
308
	}
303
 
309
 
304
	return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
310
	return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;