Changeset 230
- Timestamp:
- 02/15/08 17:21:47 (4 years ago)
- Location:
- trunk/fm_server/src
- Files:
-
- 10 modified
-
fm_buffer.c (modified) (1 diff)
-
fm_element.c (modified) (5 diffs)
-
fm_element.h (modified) (1 diff)
-
fm_input.c (modified) (3 diffs)
-
fm_input_test.c (modified) (2 diffs)
-
fm_output.c (modified) (2 diffs)
-
fm_output.h (modified) (1 diff)
-
fm_output_alsa.c (modified) (16 diffs)
-
fm_pipeline.c (modified) (3 diffs)
-
fm_pipeline.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fm_server/src/fm_buffer.c
r229 r230 41 41 42 42 size_bytes = samples_to_bytes(n_samples, n_channels); 43 g_print ("Allocated a new buffer of %d samples, %d bytes\n", n_samples, size_bytes);43 g_print ("Allocated a new buffer of %d bytes\n", size_bytes); 44 44 45 45 -
trunk/fm_server/src/fm_element.c
r229 r230 207 207 g_return_if_fail (FM_IS_ELEMENT (element)); 208 208 g_return_if_fail (name); 209 209 210 210 element->name = g_strdup (name); 211 211 } … … 217 217 g_return_val_if_fail (FM_IS_ELEMENT (element), NULL); 218 218 219 return (gchar *) g_object_get_data (G_OBJECT (element), "name"); 220 //return (element->name); 219 return (element->name); 221 220 } 222 221 … … 283 282 FmElementClass *klass = FM_ELEMENT_GET_CLASS (element); 284 283 285 g_print("fm_element_activate, %p - %s\n", element, fm_element_get_name (element)); 286 287 if (element->active) { 288 g_warning ("Element \"%s\" was active!", fm_element_get_name (element)); 289 return FALSE; 290 } 284 // g_print("fm_element_activate, %p\n", element); 285 286 g_return_val_if_fail (!element->active, FALSE); 291 287 292 288 if (!element->pipeline) { … … 316 312 g_return_val_if_fail (FM_IS_ELEMENT (element), FALSE); 317 313 FmElementClass *class = FM_ELEMENT_GET_CLASS (element); 318 319 g_print("fm_element_deactivate, %p - %s\n", element, fm_element_get_name (element)); 320 321 if (!element->active) { 322 g_warning ("Element \"%s\" was not active!", fm_element_get_name (element)); 323 return FALSE; 324 } 314 315 g_return_val_if_fail (element->active, FALSE); 325 316 326 317 gboolean ret; … … 399 390 400 391 401 gboolean402 fm_element_deactivate_connected (FmElement *element)403 {404 g_return_val_if_fail (element->sink_ports, FALSE);405 406 // g_print("fm_element_activate_connected, %p\n", element);407 408 GList *tmp = element->sink_ports;409 while (tmp) {410 FmElementSinkPort *our_port = (FmElementSinkPort *) tmp->data;411 FmElementSrcPort *peer_port = our_port->peer;412 413 if (peer_port == NULL)414 return TRUE;415 416 if (!fm_element_deactivate (FM_ELEMENT (peer_port->owner)))417 return FALSE;418 tmp = tmp->next;419 }420 421 return TRUE;422 }423 424 425 392 void 426 393 fm_element_get_buffer_from_src (FmElement *element, -
trunk/fm_server/src/fm_element.h
r229 r230 167 167 fm_element_activate_connected (FmElement *element); 168 168 169 gboolean170 fm_element_deactivate_connected (FmElement *element);171 172 169 void 173 170 fm_element_get_buffer_from_src (FmElement *element, -
trunk/fm_server/src/fm_input.c
r229 r230 95 95 fm_input_class_init (FmInputClass *class) 96 96 { 97 //GObjectClass *gobject_class = G_OBJECT_CLASS (class);97 GObjectClass *gobject_class = G_OBJECT_CLASS (class); 98 98 //FmElementClass *element_class = FM_ELEMENT_CLASS (class); 99 99 FmInputClass *input_class = FM_INPUT_CLASS (class); … … 106 106 input_class->set_position = NULL; 107 107 108 /*g_object_class_install_property (gobject_class,108 g_object_class_install_property (gobject_class, 109 109 PROP_STATE, 110 110 g_param_spec_int ("state", … … 112 112 "Input state", 113 113 FM_INPUT_STOP, FM_INPUT_PLAY, FM_INPUT_PLAY, 114 G_PARAM_READWRITE)); */114 G_PARAM_READWRITE)); 115 115 } 116 116 -
trunk/fm_server/src/fm_input_test.c
r229 r230 207 207 FmInputTest *input_test = FM_INPUT_TEST (object); 208 208 g_return_if_fail (FM_IS_INPUT_TEST (input_test)); 209 210 G_OBJECT_CLASS (parent_class)->dispose (object); 209 /* Nothing to do here */ 211 210 } 212 211 … … 217 216 FmInputTest *input_test = FM_INPUT_TEST (object); 218 217 g_return_if_fail (FM_IS_INPUT_TEST (input_test)); 219 220 G_OBJECT_CLASS (parent_class)->finalize (object); 218 g_free (input_test); 219 220 g_print ("aaaaaaaaalllllllllrrrrrrriiiiggggghhhhhhhhtttttttt!!!!!!!\n"); 221 221 } 222 222 -
trunk/fm_server/src/fm_output.c
r229 r230 105 105 106 106 107 /*guint 108 fm_output_get_max_buffer_size (FmOutput *output) 109 { 110 return 0; 111 }*/ 112 113 107 114 gboolean 108 115 fm_output_start (FmOutput *output) … … 118 125 } 119 126 } 120 121 127 122 128 gboolean -
trunk/fm_server/src/fm_output.h
r229 r230 53 53 FmElementClass parent; 54 54 55 /* Let the output element start and allow it to call get_buffer() on its connected elements. 56 It will be called after activate() */ 55 /*guint (*get_max_buffer_size) (FmOutput *output);*/ 57 56 gboolean (*start) (FmOutput *output); 58 59 /* Signal the output element to stop (it isn't allowed to call get_buffer() again. */60 57 gboolean (*stop) (FmOutput *output); 61 58 }; -
trunk/fm_server/src/fm_output_alsa.c
r229 r230 75 75 static gboolean fm_output_alsa_activate (FmElement *element); 76 76 static gboolean fm_output_alsa_deactivate (FmElement *element); 77 static void fm_output_alsa_dispose (GObject *object);78 77 static void fm_output_alsa_finalize (GObject *object); 79 78 static gint xrun_recovery (snd_pcm_t *handle, … … 81 80 static gpointer fm_output_alsa_play (gpointer data); 82 81 static gboolean fm_output_alsa_start (FmOutput *output); 83 static gboolean fm_output_alsa_stop (FmOutput *output);84 82 85 83 … … 131 129 gobject_class->set_property = fm_output_alsa_set_property; 132 130 gobject_class->get_property = fm_output_alsa_get_property; 133 134 gobject_class->dispose = fm_output_alsa_dispose; 131 135 132 gobject_class->finalize = fm_output_alsa_finalize; 136 133 … … 139 136 140 137 output_class->start = fm_output_alsa_start; 141 output_class->stop = fm_output_alsa_stop;138 142 139 143 140 g_object_class_install_property (gobject_class, … … 251 248 gint err; 252 249 253 //g_print ("Activating FmOutputAlsa\n");250 g_print ("Activating FmOutputAlsa\n"); 254 251 255 252 // Open the device … … 307 304 } 308 305 309 //g_print ("ALSA sample rate: %d\n", output->sample_rate);306 g_print ("ALSA sample rate: %d\n", output->sample_rate); 310 307 311 308 guint n_channels = FM_CHANNELS_STEREO; … … 337 334 } 338 335 336 g_print ("ALSA: buffer size is %lu\n", output_alsa->buffer_size); 337 339 338 err = snd_pcm_hw_params_set_period_time_near (output_alsa->sound_handle, 340 339 output_alsa->hwparams, … … 361 360 return FALSE; 362 361 } 363 364 /* g_print ("ALSA: buffer size is %lu frames\n", output_alsa->buffer_size);365 g_print ("ALSA: period size is %lu frames\n", output_alsa->period_size);*/366 362 367 363 output_alsa->buffer_size_samples = output_alsa->period_size; … … 382 378 fm_output_alsa_deactivate (FmElement *element) 383 379 { 384 // g_print ("ALSA: deactivate\n"); 385 FmOutputAlsa *output_alsa = FM_OUTPUT_ALSA (element); 380 /*FmOutputAlsa *output_alsa = FM_OUTPUT_ALSA (element); 386 381 gint err; 387 382 388 383 g_free (output_alsa->device_name); 389 384 390 snd_pcm_hw_free (output_alsa->sound_handle);391 385 err = snd_pcm_close (output_alsa->sound_handle); 392 386 if (err < 0) { … … 403 397 output_alsa->buffer_size = 0; 404 398 output_alsa->period_size = 0; 405 output_alsa->thread = NULL; 406 output_alsa->stop_processing = FALSE; 407 408 g_free (output_alsa->buffer_int); 409 fm_buffer_destroy (output_alsa->main_buffer); 410 411 if (!fm_element_deactivate_connected (element)) 412 return FALSE; 399 output_alsa->engine_buffer = NULL;*/ 413 400 414 401 return TRUE; … … 417 404 418 405 static void 419 fm_output_alsa_ dispose (GObject *object)406 fm_output_alsa_finalize (GObject *object) 420 407 { 421 408 FmOutputAlsa *output_alsa = FM_OUTPUT_ALSA (object); 422 409 g_assert (!output_alsa->sound_handle); 423 410 424 G_OBJECT_CLASS (parent_class)->dispose (object);425 }426 427 428 static void429 fm_output_alsa_finalize (GObject *object)430 {431 FmOutputAlsa *output_alsa = FM_OUTPUT_ALSA (object);432 g_assert (!output_alsa->sound_handle);433 434 411 g_free (output_alsa->device_name); 435 436 G_OBJECT_CLASS (parent_class)->finalize (object); 412 g_free (output_alsa); 437 413 } 438 414 … … 445 421 446 422 output_alsa->thread = g_thread_create (fm_output_alsa_play, output_alsa, 447 TRUE, &error);423 FALSE, &error); 448 424 if (output_alsa->thread) { 449 //g_print("ALSA output started!\n");425 g_print("ALSA output started!\n"); 450 426 return TRUE; 451 427 } else { … … 456 432 457 433 458 static gboolean459 fm_output_alsa_stop (FmOutput *output)460 {461 FmOutputAlsa *output_alsa = FM_OUTPUT_ALSA(output);462 463 output_alsa->stop_processing = TRUE;464 465 // g_print ("joining\n");466 g_thread_join (output_alsa->thread);467 468 return TRUE;469 }470 471 472 434 #define FLOAT_TO_INT(x) ((gint16) ((x) * 32768.0)) 473 435 … … 490 452 output_alsa->main_buffer->channel_data[1], 491 453 output_alsa->buffer_int, output_alsa->buffer_size_samples); 454 492 455 gint err = 0; 493 456 … … 495 458 output_alsa->buffer_int, 496 459 output_alsa->buffer_size_samples); 497 498 // g_print ("ALSA: written %u frames\n", output_alsa->buffer_size_samples);499 460 500 461 if (err < 0) { … … 517 478 } 518 479 519 //g_print ("output_alsa->stop_processing == TRUE!\n");480 g_print ("output_alsa->stop_processing == TRUE!\n"); 520 481 521 482 return NULL; -
trunk/fm_server/src/fm_pipeline.c
r229 r230 108 108 0); 109 109 110 rgc_method_register ("deactivate",111 FM_TYPE_PIPELINE,112 G_CALLBACK (fm_pipeline_deactivate),113 rgc_marshal_VOID__VOID,114 0);115 116 110 rgc_method_register ("run", 117 111 FM_TYPE_PIPELINE, … … 161 155 fm_pipeline_activate (FmPipeline *pipeline) 162 156 { 163 FmElement *element = FM_ELEMENT (pipeline);164 g_assert (FM_IS_PIPELINE (pipeline));165 g_return_if_fail (FM_IS_ELEMENT (pipeline->sink));166 g_return_if_fail (!element->active);167 168 g_print ("Activating pipeline...\n");169 170 pipeline->sample_rate = fm_output_get_sample_rate(pipeline->sink);171 fm_element_activate(FM_ELEMENT(pipeline->sink));172 }173 174 175 void176 fm_pipeline_deactivate (FmPipeline *pipeline)177 {178 157 g_assert (FM_IS_PIPELINE (pipeline)); 179 158 g_return_if_fail (FM_IS_ELEMENT (pipeline->sink)); 180 159 181 g_print ("Deactivating pipeline...\n"); 182 183 fm_element_deactivate(FM_ELEMENT(pipeline->sink)); 160 g_print ("Activating pipeline...\n"); 161 162 pipeline->sample_rate = fm_output_get_sample_rate(pipeline->sink); 163 fm_element_activate(FM_ELEMENT(pipeline->sink)); 184 164 } 185 165 … … 245 225 g_return_if_fail (FM_IS_PIPELINE (pipeline)); 246 226 g_return_if_fail (FM_IS_OUTPUT(pipeline->sink)); 247 227 248 228 g_debug("Stopping pipeline..."); 249 229 fm_output_stop(pipeline->sink); -
trunk/fm_server/src/fm_pipeline.h
r229 r230 69 69 70 70 void 71 fm_pipeline_deactivate (FmPipeline *pipeline);72 73 void74 71 fm_pipeline_set_sink (FmPipeline *pipeline, 75 72 FmElement *sink);
