Exemplo n.º 1
0
static void _on_response( void* context, int res_status, TtsSynthResponseData* response_data )
{
   TtsProviderRequest *provider_request = (TtsProviderRequest*) context;
   unsigned int delta = roadmap_time_get_millis() - provider_request->start_time;
   int matched_count;

   roadmap_log( ROADMAP_DEBUG, TTS_LOG_STR( "Request was completed in %d ms. Status: %d" ), delta, res_status );

   if ( res_status == TTS_RES_STATUS_SUCCESS )
   {
      // Call the process received one more time - for sure ( if progress was not called for the last chunk )
      matched_count = _process_received( provider_request, response_data );

      roadmap_log( ROADMAP_DEBUG, TTS_LOG_STR( "Received %d elements in tts response. Matched: %d. Requested: %d" ),
            response_data->count, matched_count, provider_request->idx_list_count );

   }
   else
   {
      roadmap_log( ROADMAP_ERROR, TTS_LOG_STR( "Error in response" ) );
      _process_error( provider_request );
   }

   // Deallocate the context
   _provider_ctx_free( provider_request );

   sgActiveRequestsCount--;

   // Commit the remaining entries in the queue if existing
   tts_commit();
}
Exemplo n.º 2
0
int ssd_dialog_drag_start (RoadMapGuiPoint *point) {
   SsdDialog dialog = RoadMapDialogCurrent;
   if (dialog == NULL){
      return 0;
   }

   if (dialog->container->flags & SSD_DIALOG_FLOAT){
      if (LastPointerPoint.x == -1)
         return 0;
      else
         return 1;
   }

   if (dialog->scroll_container && dialog->scroll_container->drag_start)
         return (*dialog->scroll_container->drag_start)(dialog->container, point);
   else{
      dialog->drag_start_point.x = point->x;
      dialog->drag_start_point.y = point->y;
      dialog->drag_last_motion.x = point->x;
      dialog->drag_last_motion.y = point->y;
      dialog->scroll_counter = 0;
      dialog->drag_start_time_ms = roadmap_time_get_millis();
      if (dialog->time_active){
         roadmap_main_remove_periodic (keep_dragging);
         dialog->time_active = FALSE;
      }
   }
   return 1;
}
Exemplo n.º 3
0
BOOL tts_commit( void )
{
   TtsProviderRequest *provider_request= NULL;
   TtsRequest *tts_request;
   int i;
   const char* text;
   TtsTextList text_list = TTS_GENERIC_LIST_INITIALIZER;
   int queue_idx;
   int idx_list[TTS_QUEUE_SIZE];
   int idx_list_count;
   TtsSynthRequestParams params = TTS_SYNTH_PARMAS_INITIALIZER;

   if ( !tts_enabled() )
   {
      roadmap_log(ROADMAP_WARNING, TTS_LOG_STR( "TTS is not enabled. Cannot commit synthesize requests. Feature: %d, Provider: %d" ),
            sgTtsFeatureEnabled, ( sgActiveProvider != NULL ) );
      return FALSE;
   }

   if ( sgActiveProvider->concurrent_limit >= 0 && sgActiveRequestsCount >= sgActiveProvider->concurrent_limit )
   {
      roadmap_log( ROADMAP_WARNING, TTS_LOG_STR( "Overflow in concurrent requests for the provider. Maximum: %d" ),
                   sgActiveProvider->concurrent_limit );
      return FALSE;
   }

   idx_list_count = tts_queue_get_indexes( idx_list,
         MIN( TTS_QUEUE_SIZE, sgActiveProvider->batch_request_limit ), TTS_QUEUE_STATUS_IDLE );


   if ( idx_list_count == 0 )
   {
      roadmap_log( ROADMAP_DEBUG, TTS_LOG_STR( "There are no strings to commit." ) );
      return TRUE;
   }

   /*
    * Parameters
    */
   params.voice_id = sgTtsVoiceId;

   /*
    * Building the context.
    */
   provider_request = _provider_ctx_allocate();
   if ( provider_request == NULL )
   {
      roadmap_log( ROADMAP_ERROR, TTS_LOG_STR( "Error allocating provider context!" ) );
      return FALSE;
   }
   provider_request->start_time = roadmap_time_get_millis();
   provider_request->voice_id = sgTtsVoiceId;
   memcpy( provider_request->idx_list, idx_list, sizeof( idx_list[0] ) * idx_list_count );
   provider_request->idx_list_count = idx_list_count;

   for ( i = 0; i < idx_list_count ; ++i )
   {
      queue_idx = provider_request->idx_list[i];

      text = tts_queue_get_key( queue_idx );
      // Set status
      tts_queue_set_status( provider_request->idx_list[i], TTS_QUEUE_STATUS_COMMITTED );
      // Fill the text list
      text_list[i] = text;
      // Fill the path list
      if ( sgActiveProvider->storage_type & __tts_db_data_storage__file )
      {
         tts_request = ( TtsRequest * ) tts_queue_get_context( queue_idx );
         tts_db_generate_path( sgTtsVoiceId, &tts_request->tts_path );
         params.types_list[i] = tts_request->text_type;
         params.path_list[i] = &tts_request->tts_path;
      }
   }

   roadmap_log( ROADMAP_DEBUG, TTS_LOG_STR( "Committing list of %d tts strings." ), i );
   // Send request to the provider
   sgActiveProvider->request_cb( provider_request, text_list, &params, ( TtsSynthResponseCb ) _on_response );
   sgActiveRequestsCount++;

   return TRUE;
}
Exemplo n.º 4
0
int ssd_dialog_drag_end (RoadMapGuiPoint *point) {
   uint32_t time_diff, drag_diff, speed;
   SsdDialog dialog = RoadMapDialogCurrent;

   if (dialog == NULL)
      return 0;

   if (dialog->container->flags & SSD_DIALOG_FLOAT){
      if (LastPointerPoint.x == -1)
         return 0;
      else
         return 1;
   }

   dialog->drag_end_time_ms = roadmap_time_get_millis();

   dialog->drag_end_motion.y = point->y;
   dialog->drag_end_motion.x = point->x;

   time_diff = dialog->drag_end_time_ms - dialog->drag_start_time_ms;
   drag_diff = abs(dialog->drag_end_motion.y - dialog->drag_start_point.y);
   if (time_diff > 0)
      speed = (int)(drag_diff*10)/time_diff;

#if 0
   if ((dialog->scroll_counter < SCROLL_AFTER_END_COUNTER) &&  (drag_diff > 40)){
      dialog->drag_speed = speed;
      roadmap_main_set_periodic (30, keep_dragging);
      dialog->time_active = TRUE;
      return 1;
   }
#endif

   if (dialog->scroll_container && dialog->scroll_container->drag_end)
      return (*dialog->scroll_container->drag_end)(dialog->container, point);
   else if ((dialog->scroll_container) && (dialog->scroll)){
      SsdWidget title;
      SsdSize size, size2;
      int height;
      int goffsef = (int)(1 * (point->y - dialog->drag_start_point.y ) + dialog->stop_offset);
      title = ssd_widget_get (RoadMapDialogCurrent->container, "title_bar");

      height = roadmap_canvas_height() - title->cached_size.height - 4;

      ssd_widget_reset_cache(dialog->scroll_container);
      ssd_widget_get_size(dialog->scroll_container, &size, NULL);
      if (size.height == roadmap_canvas_height() +1){
         ssd_widget_reset_cache(dialog->scroll_container);
         size2.width = SSD_MIN_SIZE;
         size2.height = SSD_MIN_SIZE;
         ssd_widget_get_size(dialog->scroll_container, &size, &size2);
      }

      if (size.height < height)
          goffsef = 0;
      else if ((goffsef + size.height) > height) {
        if (goffsef + dialog->scroll_container->position.y >  dialog->container->children->cached_size.height)
           goffsef = 0 ;
      }

      else if ((goffsef + dialog->scroll_container->position.y + size.height ) < roadmap_canvas_height()){
            goffsef = height - size.height -2 ;
      }

      ssd_widget_set_offset(dialog->scroll_container,0,goffsef);
      dialog->stop_offset = goffsef;
      ssd_dialog_draw();
   }

   return 1;
}