mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-16 12:49:59 +01:00
BUGFIX FOR APPLE OSXAUDIOSINK
This commit is contained in:
@@ -374,6 +374,9 @@ void MediaPlayer::execute_open()
|
|||||||
// set uri of file to open
|
// set uri of file to open
|
||||||
g_object_set ( G_OBJECT (pipeline_), "uri", uri_.c_str(), NULL);
|
g_object_set ( G_OBJECT (pipeline_), "uri", uri_.c_str(), NULL);
|
||||||
|
|
||||||
|
// connect to callback for elements monitoring
|
||||||
|
g_signal_connect ( G_OBJECT (pipeline_), "element-setup", G_CALLBACK (callback_element_setup), this);
|
||||||
|
|
||||||
// Get and modify playbin flags
|
// Get and modify playbin flags
|
||||||
gint flags;
|
gint flags;
|
||||||
// ENABLE ONLY VIDEO, NOT AUDIO AND TEXT SUBTITLES
|
// ENABLE ONLY VIDEO, NOT AUDIO AND TEXT SUBTITLES
|
||||||
@@ -1738,44 +1741,47 @@ void MediaPlayer::setAudioEnabled(bool on)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaPlayer::setAudioVolume(float vol)
|
void MediaPlayer::setAudioVolume(gdouble vol)
|
||||||
{
|
{
|
||||||
if (pipeline_ && media_.hasaudio){
|
if (pipeline_ && media_.hasaudio){
|
||||||
|
|
||||||
|
#ifdef APPLE
|
||||||
|
// BUGFIX FOR APPLE OSXAUDIOSINK
|
||||||
GstElement *asink = NULL;
|
GstElement *asink = NULL;
|
||||||
g_object_get (G_OBJECT (pipeline_), "audio-sink", &asink, NULL);
|
g_object_get (G_OBJECT(pipeline_), "audio-sink", &asink, NULL);
|
||||||
if ( asink )
|
if ( asink )
|
||||||
g_object_set(G_OBJECT(asink), "volume", vol, NULL);
|
g_object_set (G_OBJECT(asink), "volume", vol, NULL);
|
||||||
else
|
#endif
|
||||||
g_object_set(G_OBJECT(pipeline_), "volume", vol, NULL);
|
|
||||||
|
|
||||||
|
g_object_set (G_OBJECT(pipeline_), "volume", vol, NULL);
|
||||||
}
|
}
|
||||||
// gst_stream_volume_set_volume (GST_STREAM_VOLUME (pipeline_), GST_STREAM_VOLUME_FORMAT_LINEAR, vol);
|
// gst_stream_volume_set_volume (GST_STREAM_VOLUME (pipeline_), GST_STREAM_VOLUME_FORMAT_LINEAR, vol);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MediaPlayer::audioVolume() const
|
gdouble MediaPlayer::audioVolume() const
|
||||||
{
|
{
|
||||||
float vol = 0.f;
|
gdouble vol = 1.0;
|
||||||
if (pipeline_ && media_.hasaudio){
|
if (pipeline_ && media_.hasaudio)
|
||||||
GstElement *asink = NULL;
|
g_object_get (G_OBJECT(pipeline_), "volume", &vol, NULL);
|
||||||
g_object_get (G_OBJECT (pipeline_), "audio-sink", &asink, NULL);
|
|
||||||
if ( asink )
|
|
||||||
g_object_get(G_OBJECT(asink), "volume", &vol, NULL);
|
|
||||||
else
|
|
||||||
g_object_get(G_OBJECT(pipeline_), "volume", &vol, NULL);
|
|
||||||
}
|
|
||||||
return vol;
|
return vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
//static void audio_changed_callback (GstElement *pipeline, MediaPlayer *mp)
|
void MediaPlayer::callback_element_setup (GstElement *pipeline, GstElement *element, MediaPlayer *mp)
|
||||||
//{
|
{
|
||||||
// gint n_audio;
|
if (pipeline && element && mp)
|
||||||
// g_object_get (G_OBJECT (pipeline), "n-audio", &n_audio, NULL);
|
{
|
||||||
// if ( n_audio > 0 ) {
|
|
||||||
// Log::Info("MediaPlayer %d Audio stream muted", std::to_string( mp->id() ).c_str() );
|
#ifdef APPLE
|
||||||
// gst_stream_volume_set_volume (GST_STREAM_VOLUME (pipeline), GST_STREAM_VOLUME_FORMAT_LINEAR, 0.);
|
// BUGFIX FOR APPLE OSXAUDIOSINK
|
||||||
// gst_stream_volume_set_mute (GST_STREAM_VOLUME (pipeline), true);
|
// detect setup of audio sink
|
||||||
// }
|
GstElement *audio_sink = NULL;
|
||||||
//}
|
g_object_get (G_OBJECT(pipeline), "audio-sink", &audio_sink, NULL);
|
||||||
// flags |= GST_PLAY_FLAG_AUDIO;
|
if (element == audio_sink) {
|
||||||
// g_signal_connect ( G_OBJECT (pipeline_), "audio-changed", G_CALLBACK (audio_changed_callback), this);
|
// force volume to pipeline volume
|
||||||
|
mp->setAudioVolume( mp->audioVolume() );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -281,8 +281,8 @@ public:
|
|||||||
* */
|
* */
|
||||||
inline bool audioAvailable() const { return media_.hasaudio; }
|
inline bool audioAvailable() const { return media_.hasaudio; }
|
||||||
void setAudioEnabled(bool on);
|
void setAudioEnabled(bool on);
|
||||||
void setAudioVolume(float v);
|
void setAudioVolume(gdouble v);
|
||||||
float audioVolume() const;
|
gdouble audioVolume() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept visitors
|
* Accept visitors
|
||||||
@@ -406,6 +406,7 @@ private:
|
|||||||
static GstFlowReturn callback_new_preroll (GstAppSink *, gpointer );
|
static GstFlowReturn callback_new_preroll (GstAppSink *, gpointer );
|
||||||
static GstFlowReturn callback_new_sample (GstAppSink *, gpointer);
|
static GstFlowReturn callback_new_sample (GstAppSink *, gpointer);
|
||||||
static GstBusSyncReply signal_handler(GstBus *, GstMessage *, gpointer);
|
static GstBusSyncReply signal_handler(GstBus *, GstMessage *, gpointer);
|
||||||
|
static void callback_element_setup (GstElement *pipeline, GstElement *element, MediaPlayer *mp);
|
||||||
|
|
||||||
// global list of registered media player
|
// global list of registered media player
|
||||||
static void pipeline_terminate(GstElement *p);
|
static void pipeline_terminate(GstElement *p);
|
||||||
|
|||||||
Reference in New Issue
Block a user