diff src/flac113/plugin.c @ 561:914c96de3244 trunk

[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
author iabervon
date Sun, 28 Jan 2007 21:09:12 -0800
parents 221086196f89
children ca3de84e2288
line wrap: on
line diff
--- a/src/flac113/plugin.c	Sun Jan 28 17:41:50 2007 -0800
+++ b/src/flac113/plugin.c	Sun Jan 28 21:09:12 2007 -0800
@@ -274,8 +274,9 @@
 	return result;
 }
 
-void FLAC_XMMS__play_file(char *filename)
+void FLAC_XMMS__play_file(InputPlayback *playback)
 {
+        char *filename = playback->filename;
 	sample_buffer_first_ = sample_buffer_last_ = 0;
 	audio_error_ = false;
 	stream_data_.abort_flag = false;
@@ -325,7 +326,7 @@
 	FLAC__replaygain_synthesis__init_dither_context(&stream_data_.dither_context, stream_data_.sample_format_bytes_per_sample * 8, flac_cfg.output.resolution.replaygain.noise_shaping);
 	stream_data_.is_playing = true;
 
-	if(flac_ip.output->open_audio(stream_data_.sample_format, stream_data_.sample_rate, stream_data_.channels) == 0) {
+	if(playback->output->open_audio(stream_data_.sample_format, stream_data_.sample_rate, stream_data_.channels) == 0) {
 		audio_error_ = true;
 		safe_decoder_finish_(decoder_);
 		return;
@@ -339,7 +340,7 @@
 	decode_thread_ = g_thread_create((GThreadFunc)play_loop_, NULL, TRUE, NULL);
 }
 
-void FLAC_XMMS__stop()
+void FLAC_XMMS__stop(InputPlayback *playback)
 {
 	if(stream_data_.is_playing) {
 		stream_data_.is_playing = false;
@@ -347,17 +348,17 @@
 			stream_data_.play_thread_open = false;
 			g_thread_join(decode_thread_);
 		}
-		flac_ip.output->close_audio();
+		playback->output->close_audio();
 		safe_decoder_finish_(decoder_);
 	}
 }
 
-void FLAC_XMMS__pause(short p)
+void FLAC_XMMS__pause(InputPlayback *playback, short p)
 {
-	flac_ip.output->pause(p);
+	playback->output->pause(p);
 }
 
-void FLAC_XMMS__seek(int time)
+void FLAC_XMMS__seek(InputPlayback *playback, int time)
 {
 	stream_data_.seek_to_in_sec = time;
 	stream_data_.eof = false;
@@ -366,14 +367,14 @@
 		xmms_usleep(10000);
 }
 
-int FLAC_XMMS__get_time()
+int FLAC_XMMS__get_time(InputPlayback *playback)
 {
 	if(audio_error_)
 		return -2;
-	if(!stream_data_.is_playing || (stream_data_.eof && !flac_ip.output->buffer_playing()))
+	if(!stream_data_.is_playing || (stream_data_.eof && !playback->output->buffer_playing()))
 		return -1;
 	else
-		return flac_ip.output->output_time();
+		return playback->output->output_time();
 }
 
 void FLAC_XMMS__cleanup()
@@ -437,11 +438,10 @@
 
 static void *play_loop_(void *arg)
 {
+        InputPlayback *playback = arg;
 	unsigned written_time_last = 0, bh_index_last_w = 0, bh_index_last_o = BITRATE_HIST_SIZE, blocksize = 1;
 	FLAC__uint64 decode_position_last = 0, decode_position_frame_last = 0, decode_position_frame = 0;
 
-	(void)arg;
-
 	while(stream_data_.is_playing) {
 		if(!stream_data_.eof) {
 			while(sample_buffer_last_ - sample_buffer_first_ < SAMPLES_PER_WRITE) {
@@ -471,15 +471,15 @@
 				FLAC__uint64 decode_position;
 
 				sample_buffer_first_ += n;
-				while(flac_ip.output->buffer_free() < (int)bytes && stream_data_.is_playing && stream_data_.seek_to_in_sec == -1)
+				while(playback->output->buffer_free() < (int)bytes && stream_data_.is_playing && stream_data_.seek_to_in_sec == -1)
 					xmms_usleep(10000);
 				if(stream_data_.is_playing && stream_data_.seek_to_in_sec == -1)
-					produce_audio(flac_ip.output->written_time(), stream_data_.sample_format,
+					produce_audio(playback->output->written_time(), stream_data_.sample_format,
 						stream_data_.channels, bytes, sample_buffer_start, NULL);
 
 				/* compute current bitrate */
 
-				written_time = flac_ip.output->written_time();
+				written_time = playback->output->written_time();
 				bh_index_w = written_time / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE;
 				if(bh_index_w != bh_index_last_w) {
 					bh_index_last_w = bh_index_w;
@@ -505,8 +505,8 @@
 			if(stream_data_.total_samples > 0 && target_sample >= stream_data_.total_samples)
 				target_sample = stream_data_.total_samples - 1;
 			if(FLAC__stream_decoder_seek_absolute(decoder_, target_sample)) {
-				flac_ip.output->flush(stream_data_.seek_to_in_sec * 1000);
-				bh_index_last_w = bh_index_last_o = flac_ip.output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE;
+				playback->output->flush(stream_data_.seek_to_in_sec * 1000);
+				bh_index_last_w = bh_index_last_o = playback->output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE;
 				if(!FLAC__stream_decoder_get_decode_position(decoder_, &decode_position_frame))
 					decode_position_frame = 0;
 				stream_data_.eof = false;
@@ -524,7 +524,7 @@
 		else if ( !flac_cfg.title.disable_bitrate_update )
 		{
 			/* display the right bitrate from history */
-			unsigned bh_index_o = flac_ip.output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE;
+			unsigned bh_index_o = playback->output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE;
 			if(bh_index_o != bh_index_last_o && bh_index_o != bh_index_last_w && bh_index_o != (bh_index_last_w + 1) % BITRATE_HIST_SIZE) {
 				bh_index_last_o = bh_index_o;
 				flac_ip.set_info(stream_data_.title, stream_data_.length_in_msec, bitrate_history_[bh_index_o], stream_data_.sample_rate, stream_data_.channels);
@@ -535,8 +535,8 @@
 	safe_decoder_finish_(decoder_);
 
 	/* are these two calls necessary? */
-	flac_ip.output->buffer_free();
-	flac_ip.output->buffer_free();
+	playback->output->buffer_free();
+	playback->output->buffer_free();
 
 	g_free(stream_data_.title);