- /* get the bytestreams for each pad */
- for (i=0 ; i<numsinkpads ; i++){
- bytestreams[i] = gst_bytestream_new (ladspa->sinkpads[i]);
- }
-
- /* since this is a loop element, we just loop here til things fall apart. */
- do {
- num_empty_pads = 0;
- /* first get all the necessary data from the input ports */
- for (i=0 ; i<numsinkpads ; i++){
- GST_DEBUG (0, "pulling %u bytes through channel %d'sbytestream", bufferbytesize, i);
- got_bytes = gst_bytestream_read (bytestreams[i], buffers_in + i, bufferbytesize);
-
- if (got_bytes != bufferbytesize) {
- /* we need to check for an event. */
- gst_bytestream_get_status (bytestreams[i], &waiting, &event);
-
- if (event && GST_EVENT_TYPE(event) == GST_EVENT_EOS) {
- /* if we get an EOS event from one of our sink pads, we assume that
- pad's finished handling data. delete the bytestream, free up the
- pad, and free up the memory associated with the input channel. */
- GST_DEBUG (0, "got an EOS event on sinkpad %d", i);
- }
- /* CHECKME should maybe check for other events and try to pull more data here */
- num_empty_pads++;
- } else {
- data_in[i] = (LADSPA_Data *) GST_BUFFER_DATA(buffers_in[i]);
- GST_BUFFER_TIMESTAMP(buffers_in[i]) = ladspa->timestamp;
- }
- }
-
- if (num_empty_pads > 0){
- if (num_empty_pads < numsinkpads){
- /* only some pads have EOS, need to create some empty buffers */
- for (i=0 ; i<numsinkpads ; i++){
- if (buffers_in[i] == NULL){
- int x;
- LADSPA_Data *data;
- buffers_in[i] = gst_buffer_new_from_pool (ladspa->bufpool, 0, 0);
- GST_BUFFER_TIMESTAMP(buffers_in[i]) = ladspa->timestamp;
- data_in[i] = data = (LADSPA_Data *) GST_BUFFER_DATA(buffers_in[i]);
- for (x=0 ; x < ladspa->buffersize ; x++)
- data[x] = 0.0F;
-
- data_in[i] = (LADSPA_Data *) GST_BUFFER_DATA(buffers_in[i]);
- GST_BUFFER_TIMESTAMP(buffers_in[i]) = ladspa->timestamp;
- }
- }
- }
- else {
- /* all pads have EOS, time to quit */
- /* CHECKME do I have to push EOS events here? */
- GST_DEBUG (0, "All sink pads have EOS, finishing.");
- break;
- }
- }