void
ags_recycling_test_remove_audio_signal()
{
  AgsRecycling *recycling;
  AgsAudioSignal *audio_signal;
  
  /* instantiate recycling */
  recycling = ags_recycling_new(G_OBJECT(devout));

  /* instantiate audio signal */
  audio_signal = ags_audio_signal_new(G_OBJECT(devout),
				      recycling,
				      NULL);

  /* add audio signal */
  ags_recycling_add_audio_signal(recycling,
				 audio_signal);

  /* assert if audio signal available in recycling */
  CU_ASSERT(g_list_find(recycling->audio_signal,
			audio_signal) != NULL);

  /* add audio signal */
  ags_recycling_remove_audio_signal(recycling,
				    audio_signal);

  /* assert if no audio signal in recycling */
  CU_ASSERT(g_list_find(recycling->audio_signal,
			audio_signal) == NULL);
}
Example #2
0
void
ags_open_single_file_launch(AgsTask *task)
{
  AgsOpenSingleFile *open_single_file;
  AgsChannel *channel;
  AgsAudioSignal *old_template;
  AgsAudioFile *audio_file;
  GList *audio_signal;
  guint i;
  GError *error;

  open_single_file = AGS_OPEN_SINGLE_FILE(task);

  /* open audio file and read audio signal */
  audio_file = ags_audio_file_new(open_single_file->filename,
				  open_single_file->devout,
				  open_single_file->start_channel, open_single_file->audio_channels);

  ags_audio_file_open(audio_file);
  ags_audio_file_read_audio_signal(audio_file);

  /* iterate channels */
  channel = open_single_file->channel;
  audio_signal = audio_file->audio_signal;

  for(i = 0; i < open_single_file->audio_channels; i++){
    /* unset link */
    if(channel->link != NULL){
      error = NULL;
      ags_channel_set_link(channel, NULL,
			   &error);

      if(error != NULL){
	g_warning(error->message);
      }
    }

    /* mark as template */
    AGS_AUDIO_SIGNAL(audio_signal->data)->flags |= AGS_AUDIO_SIGNAL_TEMPLATE;

    /* old source */
    old_template = ags_audio_signal_get_template(channel->first_recycling->audio_signal);
    
    /* add as template */
    ags_recycling_add_audio_signal(channel->first_recycling,
				   AGS_AUDIO_SIGNAL(audio_signal->data));

    /* remove old template */
    ags_recycling_remove_audio_signal(channel->first_recycling,
				      old_template);

    /* iterate */
    channel = channel->next;
    audio_signal = audio_signal->next;
  }

  g_object_unref(audio_file);
}
Example #3
0
void
ags_remove_audio_signal_launch(AgsTask *task)
{
  AgsRemoveAudioSignal *remove_audio_signal;

  remove_audio_signal = AGS_REMOVE_AUDIO_SIGNAL(task);

  ags_recycling_remove_audio_signal(remove_audio_signal->recycling,
				    remove_audio_signal->audio_signal);
}
Example #4
0
void
ags_stream_audio_signal_finalize(GObject *gobject)
{
  if(AGS_RECALL_AUDIO_SIGNAL(gobject)->source != NULL &&
     AGS_RECALL(gobject)->parent != NULL){
    ags_recycling_remove_audio_signal(AGS_RECALL_RECYCLING(AGS_RECALL(gobject)->parent)->source,
				      AGS_RECALL_AUDIO_SIGNAL(gobject)->source);
  }
  //  g_object_unref(AGS_RECALL_AUDIO_SIGNAL(gobject)->source);	
  //  g_object_unref(AGS_RECALL_AUDIO_SIGNAL(gobject)->source);	

  /* call parent */
  G_OBJECT_CLASS(ags_stream_audio_signal_parent_class)->finalize(gobject); 
}
void
ags_stream_audio_signal_finalize(GObject *gobject)
{
  AgsAudioSignal *audio_signal;

  audio_signal = (AgsAudioSignal *) AGS_STREAM_AUDIO_SIGNAL(gobject)->dispose_source;
  
  if(audio_signal != NULL){
    AgsRecycling *recycling;

    AgsDestroyWorker *destroy_worker;

    recycling = (AgsRecycling *) audio_signal->recycling;

#ifdef AGS_DEBUG
    g_message("%d %x -> %x", g_atomic_int_get(&(G_OBJECT(audio_signal)->ref_count)), audio_signal, AGS_RECALL_ID(audio_signal->recall_id)->recycling_context->parent);
#endif
        
    if(recycling != NULL){
      ags_recycling_remove_audio_signal(recycling,
					audio_signal);
    }

    if(TRUE){
      destroy_worker = ags_destroy_worker_get_instance();
      ags_destroy_worker_add(destroy_worker,
			     audio_signal, ags_destroy_util_dispose_and_unref);
    }else{
      g_object_run_dispose(audio_signal);

      g_object_unref(audio_signal);
    }
  }

  /* call parent */
  G_OBJECT_CLASS(ags_stream_audio_signal_parent_class)->finalize(gobject); 
}
Example #6
0
void
ags_stream_audio_signal_run_post(AgsRecall *recall)
{
  AgsStreamChannel *stream_channel;
  AgsStreamChannelRun *stream_channel_run;
  AgsStreamAudioSignal *stream_audio_signal;

  stream_audio_signal = AGS_STREAM_AUDIO_SIGNAL(recall);
  
  if(recall->parent != NULL &&
     recall->parent->parent != NULL){
    stream_channel_run = recall->parent->parent;
    stream_channel = AGS_RECALL_CHANNEL_RUN(stream_channel_run)->recall_channel;
  }else{
    stream_channel_run = NULL;
    stream_channel = NULL;
  }
  
  if(AGS_RECALL_AUDIO_SIGNAL(recall)->source->stream_current != NULL){
    if(stream_channel != NULL &&
       AGS_RECALL_AUDIO_SIGNAL(recall)->source->stream_current->next == NULL){
      GValue value = {0,};
      
      g_value_init(&value, G_TYPE_BOOLEAN);
      ags_port_safe_read(stream_channel->auto_sense,
			 &value);

      if(g_value_get_boolean(&value)){
	signed short *buffer;
	guint buffer_size;
	guint i;
	gboolean add_stream;

	buffer = AGS_RECALL_AUDIO_SIGNAL(recall)->source->stream_current->data;
	
	buffer_size = AGS_RECALL_AUDIO_SIGNAL(recall)->source->buffer_size;
	add_stream = FALSE;
	
	for(i = buffer_size - 1; i > buffer_size / 2; i--){
	  if(buffer[i] != 0){
	    add_stream = TRUE;
	    break;
	  }
	}
	
	if(add_stream){
	  ags_audio_signal_add_stream(AGS_RECALL_AUDIO_SIGNAL(recall)->source);
	}
      }
    }
    
    AGS_RECALL_AUDIO_SIGNAL(recall)->source->stream_current = AGS_RECALL_AUDIO_SIGNAL(recall)->source->stream_current->next;

    /* call parent */
    AGS_RECALL_CLASS(ags_stream_audio_signal_parent_class)->run_post(recall);
  }else{
    /* call parent */
    AGS_RECALL_CLASS(ags_stream_audio_signal_parent_class)->run_post(recall);

    if(recall->parent != NULL){
      ags_recycling_remove_audio_signal(AGS_RECALL_RECYCLING(recall->parent)->source,
					AGS_RECALL_AUDIO_SIGNAL(recall)->source);
    }

    ags_recall_done(recall);
  }
}