Changeset 112
- Timestamp:
- 09/04/06 20:29:59 (5 years ago)
- Location:
- fm_server/trunk/src
- Files:
-
- 10 modified
-
Makefile.am (modified) (1 diff)
-
Makefile.in (modified) (4 diffs)
-
fm_element.c (modified) (1 diff)
-
fm_element.h (modified) (1 diff)
-
fm_input_gst/fm_input_gst.c (modified) (2 diffs)
-
fm_input_gst/fm_input_gst_common.h (modified) (1 diff)
-
fm_output_alsa.c (modified) (3 diffs)
-
fm_pipeline.c (modified) (8 diffs)
-
fm_pipeline.h (modified) (3 diffs)
-
main.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fm_server/trunk/src/Makefile.am
r111 r112 16 16 fm_utils.c\ 17 17 fm_utils.h\ 18 src_type_conv.c\ 19 src_type_conv.h\ 18 20 fm_input.c\ 19 21 fm_input.h\ -
fm_server/trunk/src/Makefile.in
r111 r112 61 61 PROGRAMS = $(bin_PROGRAMS) 62 62 am__fm_server_SOURCES_DIST = main.c types.h fm_utils.c fm_utils.h \ 63 fm_input.c fm_input.h fm_output.c fm_output.h fm_effect.c \ 64 fm_effect.h fm_element.c fm_element.h fm_pipeline.c \ 65 fm_pipeline.h fm_input_test.c fm_input_test.h fm_input_cdj.c \ 66 fm_input_cdj.h fm_marshal.c fm_marshal.h fm_effect_gain.c \ 67 fm_effect_gain.h fm_effect_rate.c fm_effect_rate.h fm_mixer.c \ 68 fm_mixer.h fm_djmixer.c fm_djmixer.h fm_buffer.c fm_buffer.h \ 63 src_type_conv.c src_type_conv.h fm_input.c fm_input.h \ 64 fm_output.c fm_output.h fm_effect.c fm_effect.h fm_element.c \ 65 fm_element.h fm_pipeline.c fm_pipeline.h fm_input_test.c \ 66 fm_input_test.h fm_input_cdj.c fm_input_cdj.h fm_marshal.c \ 67 fm_marshal.h fm_effect_gain.c fm_effect_gain.h \ 68 fm_effect_rate.c fm_effect_rate.h fm_mixer.c fm_mixer.h \ 69 fm_djmixer.c fm_djmixer.h fm_buffer.c fm_buffer.h \ 69 70 fm_effect_pan.c fm_effect_pan.h fm_output_alsa.c \ 70 71 fm_output_alsa.h fm_output_jack.c fm_output_jack.h … … 72 73 @HAVE_JACK_TRUE@am__objects_2 = fm_output_jack.$(OBJEXT) 73 74 am_fm_server_OBJECTS = main.$(OBJEXT) fm_utils.$(OBJEXT) \ 74 fm_input.$(OBJEXT) fm_output.$(OBJEXT) fm_effect.$(OBJEXT) \75 fm_e lement.$(OBJEXT) fm_pipeline.$(OBJEXT) \75 src_type_conv.$(OBJEXT) fm_input.$(OBJEXT) fm_output.$(OBJEXT) \ 76 fm_effect.$(OBJEXT) fm_element.$(OBJEXT) fm_pipeline.$(OBJEXT) \ 76 77 fm_input_test.$(OBJEXT) fm_input_cdj.$(OBJEXT) \ 77 78 fm_marshal.$(OBJEXT) fm_effect_gain.$(OBJEXT) \ … … 257 258 SUBDIRS = fm_input_gst 258 259 INCLUDES = $(FM_SERVER_CFLAGS) 259 fm_server_SOURCES = main.c types.h fm_utils.c fm_utils.h fm_input.c \ 260 fm_input.h fm_output.c fm_output.h fm_effect.c fm_effect.h \ 261 fm_element.c fm_element.h fm_pipeline.c fm_pipeline.h \ 262 fm_input_test.c fm_input_test.h fm_input_cdj.c fm_input_cdj.h \ 263 fm_marshal.c fm_marshal.h fm_effect_gain.c fm_effect_gain.h \ 260 fm_server_SOURCES = main.c types.h fm_utils.c fm_utils.h \ 261 src_type_conv.c src_type_conv.h fm_input.c fm_input.h \ 262 fm_output.c fm_output.h fm_effect.c fm_effect.h fm_element.c \ 263 fm_element.h fm_pipeline.c fm_pipeline.h fm_input_test.c \ 264 fm_input_test.h fm_input_cdj.c fm_input_cdj.h fm_marshal.c \ 265 fm_marshal.h fm_effect_gain.c fm_effect_gain.h \ 264 266 fm_effect_rate.c fm_effect_rate.h fm_mixer.c fm_mixer.h \ 265 267 fm_djmixer.c fm_djmixer.h fm_buffer.c fm_buffer.h \ … … 357 359 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fm_utils.Po@am__quote@ 358 360 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ 361 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/src_type_conv.Po@am__quote@ 359 362 360 363 .c.o: -
fm_server/trunk/src/fm_element.c
r61 r112 135 135 { 136 136 element->name = NULL; 137 // element->src_pads = PAD_NONE;138 137 element->src_ports = NULL; 139 // element->sink_pads = PAD_NONE;140 138 element->sink_ports = NULL; 141 139 142 140 element->active = FALSE; 143 141 element->dispose_has_run = FALSE; 142 143 element->pipeline = NULL; 144 144 } 145 145 -
fm_server/trunk/src/fm_element.h
r58 r112 81 81 gboolean active; 82 82 gboolean dispose_has_run; 83 84 // yes, I know this is an hack 85 gpointer pipeline; 83 86 }; 84 87 -
fm_server/trunk/src/fm_input_gst/fm_input_gst.c
r109 r112 11 11 #include "../fm_element.h" 12 12 #include "../fm_input.h" 13 #include "../fm_output.h" 14 #include "../fm_pipeline.h" 13 15 14 16 #include "fm_input_gst_common.h" … … 350 352 common->sem = fm_sem_new (1); 351 353 common->gst_seek_to_sample = -1; 354 // common->sample_rate = fm_pipeline_get_sample_rate (FM_PIPELINE (element->pipeline)); 355 352 356 353 357 /* setup */ -
fm_server/trunk/src/fm_input_gst/fm_input_gst_common.h
r107 r112 31 31 { 32 32 gpointer input_gst; 33 guint sample_rate; 33 34 34 35 GstElement *pipeline; -
fm_server/trunk/src/fm_output_alsa.c
r111 r112 7 7 #include <alsa/asoundlib.h> 8 8 9 #include "src_type_conv.h" 9 10 #include "fm_buffer.h" 10 11 #include "fm_element.h" … … 14 15 15 16 #define ALSA_DEFAULT_DEVICE "default" 17 #define ALSA_DEFAULT_SAMPLE_RATE 44100 16 18 #define ALSA_DEFAULT_BUFFER_TIME 22000 17 19 #define ALSA_DEFAULT_PERIOD_TIME 10000 … … 407 409 fm_element_get_buffer_from_src(element, output_alsa->main_buffer); 408 410 409 guint i; 410 gint16 *ptr = output_alsa->buffer_int; 411 for (i = 0; i < output_alsa->buffer_size_samples; i++) { 412 *(ptr++) = FLOAT_TO_INT (output_alsa->main_buffer->channel_data[0][i]); 413 *(ptr++) = FLOAT_TO_INT (output_alsa->main_buffer->channel_data[1][i]); 414 } 415 411 src_float_to_short_array_stereo (output_alsa->main_buffer->channel_data[0], 412 output_alsa->main_buffer->channel_data[1], 413 output_alsa->buffer_int, output_alsa->buffer_size_samples); 414 416 415 gint err = 0; 417 416 -
fm_server/trunk/src/fm_pipeline.c
r109 r112 87 87 rgc_marshal_VOID__ELEMENT, 88 88 1, G_TYPE_STRING); 89 90 rgc_method_register ("add_element", 91 FM_TYPE_PIPELINE, 92 G_CALLBACK (fm_pipeline_add_element), 93 rgc_marshal_VOID__ELEMENT, 94 1, G_TYPE_STRING); 89 95 90 96 rgc_method_register ("activate", … … 112 118 fm_pipeline_class_init (FmPipelineClass *klass) 113 119 { 114 /*GObjectClass *gobject_class = G_OBJECT_CLASS (klass); 115 116 gobject_class->set_property = fm_pipeline_set_property; 117 gobject_class->get_property = fm_pipeline_get_property;*/ 120 //GObjectClass *gobject_class = G_OBJECT_CLASS (klass); 118 121 } 119 122 … … 122 125 fm_pipeline_init (FmPipeline *pipeline) 123 126 { 124 GError *err = NULL;125 126 g_print ("a1");127 128 pipeline->start = g_mutex_new ();129 g_mutex_lock (pipeline->start);130 131 g_print ("a2");132 133 pipeline->pipe_thread = g_thread_create ((GThreadFunc) fm_pipeline_thread_entry,134 (gpointer) pipeline, FALSE, &err);135 136 127 g_print ("new pipeline created\n"); 137 128 138 129 /* Start with a reasonable default, the output element will alter this if it needs to */ 139 130 pipeline->sample_rate = 48000; 140 141 return;142 131 } 143 132 … … 156 145 fm_pipeline_activate (FmPipeline *pipeline) 157 146 { 158 //gint samples_per_buffer;159 147 g_assert (FM_IS_PIPELINE (pipeline)); 160 148 g_return_if_fail (FM_IS_ELEMENT (pipeline->sink)); … … 164 152 pipeline->sample_rate = fm_output_get_sample_rate(pipeline->sink); 165 153 fm_element_activate(FM_ELEMENT(pipeline->sink)); 166 167 // OSS uses 4096 samples_per_buffer168 /* samples_per_buffer = 0fm_output_get_spb (FM_OUTPUT (pipeline->sink));169 g_print ("output set a %d samples per buffer\n", samples_per_buffer);*/170 171 //g_assert_not_reached ();172 173 /* pipeline->buffer = fm_buffer_new (MAX_SAMPLES, FM_SAMPLES_FLOAT,174 FM_INTERLEAVING_NORMAL, FM_CHANNELS_STEREO);175 FM_BUFFER_REQUESTED (pipeline->buffer) = samples_per_buffer;*/176 177 return;178 154 } 179 155 … … 183 159 FmElement *sink) 184 160 { 185 g_ assert(FM_IS_PIPELINE (pipeline));161 g_return_if_fail (FM_IS_PIPELINE (pipeline)); 186 162 FmOutput *out = FM_OUTPUT(sink); 187 g_ assert(FM_IS_OUTPUT (out));163 g_return_if_fail (FM_IS_OUTPUT (out)); 188 164 189 165 pipeline->sink = FM_OUTPUT(sink); 190 166 191 167 return; 168 } 169 170 171 void 172 fm_pipeline_add_element (FmPipeline *pipeline, 173 FmElement *element) 174 { 175 g_return_if_fail (FM_IS_PIPELINE (pipeline)); 176 g_return_if_fail (FM_IS_ELEMENT (element)); 177 178 element->pipeline = pipeline; 192 179 } 193 180 … … 201 188 g_debug("Starting pipeline..."); 202 189 fm_output_start(pipeline->sink); 203 204 /*g_assert (pipeline);205 206 if (pipeline->sink == NULL)207 g_print ("Audiodevice is not set!\n");208 209 pipeline->running = TRUE;210 211 // Let the thread start212 g_print ("MAIN - Unlocking mutex\n");213 g_mutex_unlock (pipeline->start);*/214 215 return;216 190 } 217 191 … … 225 199 g_debug("Stopping pipeline..."); 226 200 fm_output_stop(pipeline->sink); 227 /*g_mutex_unlock (pipeline->start);228 g_print ("MAIN - Locking again mutex\n");229 g_mutex_lock (pipeline->start);230 g_print ("MAIN - Locked mutex\n");231 pipeline->running = FALSE;*/232 233 return;234 }235 236 237 GThreadFunc238 fm_pipeline_thread_entry (gpointer data)239 {240 /*g_print ("in new thread\n");241 242 FmPipeline *pipeline = FM_PIPELINE (data);243 244 fm_pipeline_loop (pipeline);*/245 246 return (NULL);247 }248 249 250 void251 fm_pipeline_loop (FmPipeline *pipeline)252 {253 /*g_print ("Waiting...\n");254 g_mutex_lock (pipeline->start);255 g_print ("Go!\n");256 fm_output_start(pipeline->sink);*/257 258 /*buffer_elems = samples_per_buffer;259 buffer_int_size = (sizeof (int16_t) * buffer_elems);260 buffer_fp_size = (sizeof (gfloat) * buffer_elems);*/261 262 // guint samples_per_buffer = fm_output_get_spb (FM_OUTPUT (pipeline->sink));263 264 /*while (TRUE) {265 if (pipeline->running == FALSE) {266 g_print ("ENGINE - Locking mutex\n");267 fm_output_stop(pipeline->sink);268 g_mutex_lock (pipeline->start);269 g_print ("ENGINE - Mutex was unlocked\n");270 fm_output_start(pipeline->sink);271 }272 g_thread_yield();*/273 /* fm_element_get_buffer (pipeline->sink, pipeline->buffer);274 fm_output_play (FM_OUTPUT (pipeline->sink), pipeline->buffer);275 g_print ("iterating...\n");*/276 /*}*/277 201 } 278 202 -
fm_server/trunk/src/fm_pipeline.h
r29 r112 45 45 FmOutput *sink; 46 46 47 FmBuffer *buffer;48 49 GMutex *start;50 GThread *pipe_thread;51 52 gboolean running;53 gboolean working;54 55 47 guint sample_rate; 56 48 }; … … 79 71 80 72 void 73 fm_pipeline_add_element (FmPipeline *pipeline, 74 FmElement *element); 75 76 void 81 77 fm_pipeline_run (FmPipeline *pipeline); 82 78 … … 84 80 fm_pipeline_stop (FmPipeline *pipeline); 85 81 86 GThreadFunc 87 fm_pipeline_thread_entry (gpointer data); 88 89 void 90 fm_pipeline_loop (FmPipeline *pipeline); 82 guint 83 fm_pipeline_get_sample_rate (FmPipeline *pipeline); 91 84 92 85 -
fm_server/trunk/src/main.c
r111 r112 86 86 87 87 88 89 //gint buffer_elems = 0; // element = 1 * channels_n90 //gint buffer_int_size = 0; // buffer_int_size = sizeof (int16_t) * buffer_elems91 //gint buffer_fp_size = 0; // buffer_int_size = sizeof (gfloat) * buffer_elems92 93 gboolean94 timeout (gpointer user_data)95 {96 /*g_print ("Timeout!\n");97 98 FmEngine *data = (FmEngine *) user_data;99 100 if (fm_engine_is_running (data))101 fm_engine_stop (data);102 else103 fm_engine_start (data);104 */105 106 exit (0);107 return (TRUE);108 }109 110 111 88 gint 112 89 main (gint argc, … … 152 129 fm_mixer_class_register (); 153 130 fm_djmixer_class_register (); 154 /* fm_effect_pan_class_register (); 155 156 fm_mixer_dj_class_register ();*/ 131 fm_effect_pan_class_register (); 157 132 #if HAVE_ALSA_ASOUNDLIB_H 158 133 fm_output_alsa_class_register (); 159 134 #endif 160 //fm_output_oss_class_register ();161 135 162 // test_case ();163 164 /*RgcMessageNew *mess1;165 mess1 = rgc_message_new_create ("cdj1", "FmInputCDJ");166 rgc_message_execute_new (mess1)*/167 168 136 GMainLoop *main_loop; 169 137 main_loop = g_main_loop_new (NULL, FALSE); 170 138 171 139 /*unlink ("/tmp/fmraw.raw"); 172 temp_fd = open ("/tmp/fmraw.raw", (O_WRONLY && O_SYNC)); */173 g_assert (temp_fd != -1); 140 temp_fd = open ("/tmp/fmraw.raw", (O_WRONLY && O_SYNC)); 141 g_assert (temp_fd != -1);*/ 174 142 175 /*main_conn = fm_connection_unix_new ("/tmp/fm");176 main_connection = FM_CONNECTION (main_conn);177 g_idle_add ((GSourceFunc) fm_connection_start, main_conn);*/178 179 //g_timeout_add (100000, timeout, NULL);180 181 143 g_main_loop_run (main_loop); 182 144 … … 195 157 196 158 197 /*void198 test_case (void)199 {200 FmPipeline *pipeline;201 FmElement *input;202 FmElement *output;203 204 pipeline = fm_pipeline_new ();205 input = FM_ELEMENT (fm_input_cdj_new ());206 output = FM_ELEMENT (fm_output_oss_new ());207 208 fm_element_connect_src (output, input);209 210 fm_pipeline_set_sink (pipeline, output);211 212 fm_pipeline_activate (pipeline);213 214 fm_pipeline_run (pipeline);215 216 g_object_set (G_OBJECT (input), "filename", "/tmp/b.mp3", NULL);217 218 fm_input_cdj_load (FM_INPUT_CDJ (input));219 }*/220 221 222 /*void223 test_case (void)224 {225 FmElement *input;226 227 input = FM_ELEMENT (fm_input_cdj_new ());228 229 fm_element_activate (input);230 231 g_object_set (G_OBJECT (input), "filename", "/tmp/b.mp3", NULL);232 fm_input_cdj_load (FM_INPUT_CDJ (input));233 234 FmBuffer *buffer = fm_buffer_new (MAX_SAMPLES, FM_SAMPLES_FLOAT,235 FM_INTERLEAVING_NORMAL, FM_CHANNELS_STEREO);236 FM_BUFFER_REQUESTED (buffer) = 32;237 238 FmBuffer *out_buffer = fm_buffer_new (MAX_SAMPLES, FM_SAMPLES_INT16,239 FM_INTERLEAVING_NORMAL, FM_CHANNELS_STEREO);240 241 while (TRUE) {242 fm_element_get_buffer (input, buffer);243 244 fm_buffer_convert (buffer, out_buffer);245 246 fm_buffer_dump_to_file (out_buffer, temp_fd);247 }248 249 fm_buffer_destroy (buffer);250 fm_buffer_destroy (out_buffer);251 }*/252 253 #define SEGMENT_SIZE 64254 255 /*void256 test_case (void)257 {258 FmGstThread *thread;259 260 thread = fm_gst_thread_new ();261 262 fm_gst_thread_load (thread, "/tmp/b.mp3");263 264 265 FmBuffer *buffer = NULL;266 buffer = fm_buffer_new (SEGMENT_SIZE, FM_SAMPLES_INT16,267 FM_INTERLEAVING_NORMAL, FM_CHANNELS_STEREO);268 269 FmBuffer *float_buffer = NULL;270 float_buffer = fm_buffer_new (SEGMENT_SIZE, FM_SAMPLES_FLOAT,271 FM_INTERLEAVING_NORMAL, FM_CHANNELS_STEREO);272 273 FmBuffer *out_buffer = NULL;//g_print ("%d\n", BUF_READ);274 out_buffer = fm_buffer_new (SEGMENT_SIZE, FM_SAMPLES_INT16,275 FM_INTERLEAVING_NORMAL, FM_CHANNELS_STEREO);276 277 while (TRUE) {278 fm_gst_thread_get_buffer (thread, buffer);279 280 fm_buffer_convert (buffer, float_buffer);281 fm_buffer_convert (float_buffer, out_buffer);282 283 fm_buffer_dump_to_file (out_buffer, temp_fd);284 }285 286 fm_buffer_destroy (buffer);287 fm_buffer_destroy (float_buffer);288 fm_buffer_destroy (out_buffer);289 }*/
