Esempio n. 1
0
/**
 * rb_removable_media_manager_queue_transfer:
 * @manager: the #RBRemovableMediaManager
 * @entry: the #RhythmDBEntry to transfer
 * @dest: the destination URI
 * @mime_types: a list of acceptable output MIME types
 * @callback: function to call when the transfer is complete
 * @userdata: data to pass to the callback
 *
 * Initiates a track transfer.  This will transfer the track identified by the
 * #RhythmDBEntry to the given destination, transcoding it if its
 * current media type is not in the list of acceptable output types.
 */
void
rb_removable_media_manager_queue_transfer (RBRemovableMediaManager *manager,
					  RhythmDBEntry *entry,
					  const char *dest,
					  GList *mime_types,
					  RBTransferCompleteCallback callback,
					  gpointer userdata)
{
	RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (manager);
	TransferData *data;

	g_assert (rb_is_main_thread ());

	data = g_new0 (TransferData, 1);
	data->manager = manager;
	data->entry = entry;
	data->dest = g_strdup (dest);
	data->mime_types = rb_string_list_copy (mime_types);
	data->callback = callback;
	data->userdata = userdata;

	g_async_queue_push (priv->transfer_queue, data);
	priv->transfer_total++;
	do_transfer (manager);
}
Esempio n. 2
0
/**
 * _rb_player_emit_info:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the stream
 * @field: updated metadata field
 * @value: metadata field value
 *
 * Emits the 'info' signal for a stream.  To be used by
 * implementations only.
 */
void
_rb_player_emit_info (RBPlayer *player,
		      gpointer stream_data,
		      RBMetaDataField field,
		      GValue *value)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[INFO], 0, stream_data, field, value);
}
Esempio n. 3
0
static void
do_transfer (RBRemovableMediaManager *manager)
{
	RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (manager);
	TransferData *data;
	RBEncoder *encoder;

	g_assert (rb_is_main_thread ());

	emit_progress (manager);

	if (priv->transfer_running) {
		rb_debug ("already transferring something");
		return;
	}

	data = g_async_queue_try_pop (priv->transfer_queue);
	if (data == NULL) {
		rb_debug ("transfer queue is empty");
		priv->transfer_total = 0;
		priv->transfer_done = 0;
		emit_progress (manager);
		return;
	}

	priv->transfer_running = TRUE;
	priv->transfer_fraction = 0.0;

	encoder = rb_encoder_new ();
	g_signal_connect (G_OBJECT (encoder),
			  "error", G_CALLBACK (error_cb),
			  data);
	g_signal_connect (G_OBJECT (encoder),
			  "progress", G_CALLBACK (progress_cb),
			  data);
	g_signal_connect (G_OBJECT (encoder),
			  "completed", G_CALLBACK (completed_cb),
			  data);
	rb_debug ("starting transfer of %s to %s",
		  rhythmdb_entry_get_string (data->entry, RHYTHMDB_PROP_LOCATION),
		  data->dest);
	if (rb_encoder_encode (encoder, data->entry, data->dest, data->mime_types) == FALSE) {
		rb_debug ("unable to start transfer");
	}
}
Esempio n. 4
0
static void
emit_playing_stream_and_tags (RBPlayerGst *player, gboolean track_change)
{
	if (track_change) {
		/* swap stream data */
		_destroy_stream_data (player);
		player->priv->stream_data = player->priv->next_stream_data;
		player->priv->stream_data_destroy = player->priv->next_stream_data_destroy;
		player->priv->next_stream_data = NULL;
		player->priv->next_stream_data_destroy = NULL;
	}

	if (rb_is_main_thread ()) {
		if (player->priv->emit_stream_idle_id != 0) {
			g_source_remove (player->priv->emit_stream_idle_id);
		}
		actually_emit_stream_and_tags (player);
	} else if (player->priv->emit_stream_idle_id == 0) {
		player->priv->emit_stream_idle_id = g_idle_add ((GSourceFunc) actually_emit_stream_and_tags, player);
	}
}
Esempio n. 5
0
/**
 * _rb_player_emit_redirect:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the stream
 * @uri: URI to redirect to
 *
 * Emits the 'redirect' signal to notify listeners that the stream has been
 * redirected. To be used by implementations only.
 */
void
_rb_player_emit_redirect (RBPlayer *player, gpointer stream_data, const char *uri)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[REDIRECT], 0, stream_data, uri);
}
Esempio n. 6
0
/**
 * _rb_player_emit_image:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the stream
 * @image: an image extracted from the stream
 *
 * Emits the 'image' signal to notify listeners of an image that
 * has been extracted from the stream.  To be used by implementations only.
 */
void
_rb_player_emit_image (RBPlayer *player, gpointer stream_data, GdkPixbuf *image)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[IMAGE], 0, stream_data, image);
}
Esempio n. 7
0
/**
 * _rb_player_emit_volume_changed:
 * @player: a #RBPlayer implementation
 * @volume: the new volume level
 *
 * Emits the 'volume-changed' signal to indicate the output stream
 * volume has been changed.  To be used by implementations only.
 */
void
_rb_player_emit_volume_changed (RBPlayer *player, float volume)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[VOLUME_CHANGED], 0, volume);
}
Esempio n. 8
0
/**
 * _rb_player_emit_playing_stream:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the new playing stream
 *
 * Emits the 'playing-stream' signal to indicate the current
 * playing stream has changed.  To be used by implementations only.
 */
void
_rb_player_emit_playing_stream (RBPlayer *player, gpointer stream_data)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[PLAYING_STREAM], 0, stream_data);
}
Esempio n. 9
0
/**
 * _rb_player_emit_event:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the stream
 * @name: event name
 * @data: event data
 *
 * Emits the 'event' signal for a stream.
 * To be used by implementations only.
 */
void
_rb_player_emit_event (RBPlayer *player, gpointer stream_data, const char *name, gpointer data)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[EVENT], g_quark_from_string (name), stream_data, data);
}
Esempio n. 10
0
/**
 * _rb_player_emit_tick:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the stream
 * @elapsed: current playback position
 * @duration: current perception of the duration of the stream (-1 if not applicable)
 *
 * Emits the 'tick' signal for a stream.
 * To be used by implementations only.
 */
void
_rb_player_emit_tick (RBPlayer *player, gpointer stream_data, gint64 elapsed, gint64 duration)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[TICK], 0, stream_data, elapsed, duration);
}
Esempio n. 11
0
/**
 * _rb_player_emit_error:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the stream
 * @error: playback error
 *
 * Emits the 'error' signal for a stream.
 * To be used by implementations only.
 */
void
_rb_player_emit_error (RBPlayer *player, gpointer stream_data, GError *error)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[ERROR], 0, stream_data, error);
}
Esempio n. 12
0
/**
 * _rb_player_emit_buffering:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the stream
 * @progress: current buffering progress.
 *
 * Emits the 'buffering' signal for a stream.
 * To be used by implementations only.
 */
void
_rb_player_emit_buffering (RBPlayer *player, gpointer stream_data, guint progress)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[BUFFERING], 0, stream_data, progress);
}
Esempio n. 13
0
/**
 * _rb_player_emit_eos:
 * @player: a #RBPlayer implementation
 * @stream_data: data associated with the stream
 * @early: whether this is an early EOS notification
 *
 * Emits the 'eos' signal for a stream.  To be used by
 * implementations only.
 */
void
_rb_player_emit_eos (RBPlayer *player, gpointer stream_data, gboolean early)
{
	g_assert (rb_is_main_thread ());
	g_signal_emit (player, signals[EOS], 0, stream_data, early);
}