Show
Ignore:
Timestamp:
09/02/06 23:16:15 (6 years ago)
Author:
ath
Message:

End-of-file and misc fixes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • fm_server/trunk/src/fm_input_gst/fm_input_gst.c

    r108 r109  
    1515#include "gstfmsink.h" 
    1616#include "fm_input_gst.h" 
     17 
     18//#define USE_AUDIORESAMPLE 
    1719 
    1820extern int temp_fd; 
     
    369371 
    370372        common->converter = gst_element_factory_make ("audioconvert", "converter"); 
    371 //      common->resampler = gst_element_factory_make ("audioresample", "resampler"); 
     373#ifdef USE_AUDIORESAMPLE 
     374        common->resampler = gst_element_factory_make ("audioresample", "resampler"); 
     375#endif 
    372376        common->output_pad = gst_element_get_pad (common->converter, "sink"); 
    373377        common->sink = gst_element_factory_make ("fm_sink", "sink"); 
    374378 
    375379        gst_bin_add_many (GST_BIN (common->output_bin), common->converter, 
    376                           /*common->resampler,*/ common->sink, NULL); 
    377  
    378         gst_element_link_many (common->converter, /*common->resampler,*/ common->sink, NULL); 
     380#ifdef USE_AUDIORESAMPLE 
     381                          common->resampler, 
     382#endif 
     383                          common->sink, NULL); 
     384 
     385        gst_element_link_many (common->converter, 
     386#ifdef USE_AUDIORESAMPLE 
     387                               common->resampler, 
     388#endif 
     389                               common->sink, NULL); 
    379390 
    380391        gst_element_add_pad (common->output_bin, gst_ghost_pad_new ("sink", common->output_pad)); 
     
    450461        } 
    451462 
    452         if (input_gst->seek_at_sample > -1) { 
     463        if ((input_gst->seek_at_sample > -1) && chk){ 
     464                 
    453465                glong first_avail_sample = input_gst->current_pos_samples - BYTES_TO_SAMPLES(chk->bytes_behind_us); 
    454466                glong last_avail_sample = input_gst->current_pos_samples + BYTES_TO_SAMPLES(jack_ringbuffer_read_space(chk->ring));  // we need an offset 
     
    485497        // bytes da scartare 
    486498        guint bytes_from_ring = chk->bytes_behind_us + SAMPLES_TO_BYTES(FM_BUFFER_REQUESTED(buffer)); 
     499        if ((chk->eos_offset_samples > 0) && 
     500            ((input_gst->current_pos_samples + FM_BUFFER_REQUESTED (buffer)) > chk->eos_offset_samples)) 
     501                bytes_from_ring = SAMPLES_TO_BYTES (chk->eos_offset_samples - input_gst->current_pos_samples); 
     502 
    487503        size_t read_bytes = jack_ringbuffer_peek(chk->ring, (gchar *) input_gst->interleaved_buffer, bytes_from_ring); 
    488504 
     
    503519 
    504520        if ((chk->eos_offset_samples) && (input_gst->current_pos_samples >= chk->eos_offset_samples)) { 
    505                 g_print ("We're at %d samples - end of file!\n", input_gst->current_pos_samples); 
     521                g_print ("We're at %lld samples - end of file!\n", input_gst->current_pos_samples); 
    506522                common->read_chunk = NULL; 
    507523        }