libsaria: Set about-to-finish from ALSA
I've found that without ALSA enabled, the about-to-finish will hang. To solve this, I only enable it when ALSA is enabled. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
46ae66634e
commit
9e322433d5
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker.
|
||||
#include <gst/interfaces/propertyprobe.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/controls.h>
|
||||
#include <libsaria/prefs.h>
|
||||
#include <libsaria/print.h>
|
||||
#include "audio.h"
|
||||
|
@ -10,6 +11,17 @@ using namespace std;
|
|||
|
||||
static GstElement *alsa = NULL;
|
||||
static list<string> devices;
|
||||
gulong about_to_finish_id;
|
||||
|
||||
static void about_to_finish(GstElement *playbin, gpointer data)
|
||||
{
|
||||
string file;
|
||||
|
||||
println("About to finish!");
|
||||
file = libsaria::next_file();
|
||||
if (file != "")
|
||||
load_file(playbin, file);
|
||||
}
|
||||
|
||||
static void probe_devices()
|
||||
{
|
||||
|
@ -37,11 +49,16 @@ static void add_alsa()
|
|||
alsa = gst_element_factory_make("alsasink", "alsa");
|
||||
probe_devices();
|
||||
set_audio_sink(alsa);
|
||||
about_to_finish_id = g_signal_connect(player,
|
||||
"about-to-finish",
|
||||
G_CALLBACK(about_to_finish),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void remove_alsa()
|
||||
{
|
||||
println("Removing ALSA");
|
||||
g_signal_handler_disconnect(player, about_to_finish_id);
|
||||
set_alsa_device("default");
|
||||
/* Removing the sink will also deallocate it */
|
||||
set_audio_sink(NULL);
|
||||
|
|
|
@ -45,16 +45,6 @@ static gboolean on_message(GstBus *bus, GstMessage *message, gpointer data)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void about_to_finish(GstElement *playbin, gpointer data)
|
||||
{
|
||||
string file;
|
||||
|
||||
println("About to finish!");
|
||||
file = libsaria::next_file();
|
||||
if (file != "")
|
||||
load_file(playbin, file);
|
||||
}
|
||||
|
||||
static void audio_changed(GstElement *playbin, gpointer data)
|
||||
{
|
||||
notify_audio_changed();
|
||||
|
@ -107,7 +97,6 @@ namespace libsaria
|
|||
|
||||
gst_bus_add_watch(bus, on_message, NULL);
|
||||
|
||||
g_signal_connect(player, "about-to-finish", G_CALLBACK(about_to_finish), NULL);
|
||||
g_signal_connect(player, "audio-changed", G_CALLBACK(audio_changed), NULL);
|
||||
|
||||
init_volume();
|
||||
|
|
Loading…
Reference in New Issue