Show
Ignore:
Timestamp:
01/16/08 13:40:36 (4 years ago)
Author:
ath
Message:

Fixes for FmElement's new API.

Files:
1 modified

Legend:

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

    r181 r196  
    6464FmInputState fm_input_cdj_get_state     (FmInput        *input); 
    6565static void fm_input_cdj_update_bpm     (FmInputCDJ     *input_cdj); 
    66 static void fm_input_cdj_become_sync_master (FmElement  *element); 
     66static void fm_input_cdj_become_sync_master (FmElement  *element, 
     67                                         FmSync         *sync); 
    6768static void fm_input_cdj_get_buffer     (FmElement      *element, 
    68                                          FmBuffer       *buffer); 
     69                                         FmBuffer       *buffer, 
     70                                         FmSync         *sync); 
    6971static void fm_input_cdj_input_state_changed_cb (FmInput *input, 
    7072                                         FmInputState   state, 
     
    277279 
    278280static void 
    279 fm_input_cdj_become_sync_master         (FmElement      *element) 
    280 { 
    281 #define BPM 120 
     281fm_input_cdj_become_sync_master         (FmElement      *element, 
     282                                         FmSync         *sync) 
     283{ 
    282284        g_print ("FmInputCDJ has become sync master!\n"); 
    283285 
    284         FmSync *sync = fm_element_pipeline_get_sync_info (element); 
    285  
    286         sync->bpm = BPM; 
     286        sync->in_use = TRUE; 
     287 
     288        sync->bpm = 120.0; 
    287289        sync->beat_per_bar = 4; 
    288290} 
     
    291293static void 
    292294fm_input_cdj_get_buffer                 (FmElement      *element, 
    293                                          FmBuffer       *buffer) 
     295                                         FmBuffer       *buffer, 
     296                                         FmSync         *sync) 
    294297{ 
    295298        FmInputCDJ *input_cdj = FM_INPUT_CDJ (element); 
     
    300303 
    301304         
    302         fm_element_get_buffer (FM_ELEMENT (input_cdj->rate), buffer); 
     305//      fm_element_get_buffer (FM_ELEMENT (input_cdj->rate), buffer, sync); 
     306        fm_element_get_buffer (FM_ELEMENT (input_cdj->input), buffer, sync); 
     307//      g_print ("went %lld nsec ahead\n", (long long int) FM_BUFFER_DURATION (buffer)); 
    303308 
    304309        //g_print ("Used %d samples\n", fm_effect_rate_input_frames_used (input_cdj->rate)); 
    305310 
    306 //      if (fm_element_is_sync_master (element)) 
    307 //              fm_sync_master_played_samples (sync, fm_effect_rate_input_frames_used (input_cdj->rate)); 
     311 
     312 
     313        if (fm_element_is_sync_master (element)) { 
     314                if (FM_BUFFER_DISCONT (buffer)) { 
     315                        g_print ("**************************************************************************************************\n"); 
     316                        g_print ("DISCONT buffer! new pos %llu\n", (long long unsigned int) FM_BUFFER_TIMESTAMP (buffer)); 
     317                        fm_sync_set (sync, 0, FM_BUFFER_TIMESTAMP (buffer)); 
     318                        FM_BUFFER_DISCONT (buffer) = FALSE; 
     319                } else { 
     320                        fm_sync_master_played_ns (sync, FM_BUFFER_DURATION (buffer)); 
     321                        fm_sync_update_cycle (sync); 
     322                } 
     323 
     324                if (FM_BUFFER_DURATION (buffer) > 0) 
     325                        fm_sync_show_pos (sync); 
     326        } 
    308327} 
    309328 
     
    453472                                         gint           value) 
    454473{ 
    455 #define SAMPLES_FOR_UNIT 10000 
     474#define NSECS_FOR_UNIT (1000L * 1000 * 100) 
    456475 
    457476        g_print ("A seek button pressed while "); 
     
    465484        g_return_if_fail (value != 0); 
    466485 
    467         glong offset = value * SAMPLES_FOR_UNIT; 
     486        gint64 offset = value * NSECS_FOR_UNIT; 
    468487        fm_input_gst_seek_relative (input_cdj->input, offset); 
    469488}