41
41
#include "upnp_connmgr.h"
42
42
#include "output_module.h"
43
43
44
- void output_gstreamer_initlib (void ) __attribute__((constructor ));
45
-
46
44
static double buffer_duration = 0.0 ; /* Buffer disbled by default, see #182 */
47
45
48
46
static void scan_mime_list (void )
@@ -160,6 +158,15 @@ static void output_gstreamer_set_uri(const char *uri,
160
158
}
161
159
162
160
static int output_gstreamer_play (output_transition_cb_t callback ) {
161
+ Log_info ("gstreamer" , "PLAY requested" );
162
+
163
+ //ASimb: the following lines ensure, that no empty URI
164
+ // is transmitted to the GStreamer
165
+ if (gsuri_ == NULL ) {
166
+ Log_info ("gstreamer" , "setting play state failed (No URI to play)" );
167
+ return -1 ;
168
+ }
169
+
163
170
play_trans_callback_ = callback ;
164
171
if (get_current_player_state () != GST_STATE_PAUSED ) {
165
172
if (gst_element_set_state (player_ , GST_STATE_READY ) ==
@@ -178,6 +185,7 @@ static int output_gstreamer_play(output_transition_cb_t callback) {
178
185
}
179
186
180
187
static int output_gstreamer_stop (void ) {
188
+ Log_info ("gstreamer" , "STOP requested" );
181
189
if (gst_element_set_state (player_ , GST_STATE_READY ) ==
182
190
GST_STATE_CHANGE_FAILURE ) {
183
191
return -1 ;
@@ -187,6 +195,7 @@ static int output_gstreamer_stop(void) {
187
195
}
188
196
189
197
static int output_gstreamer_pause (void ) {
198
+ Log_info ("gstreamer" , "PAUSE requested" );
190
199
if (gst_element_set_state (player_ , GST_STATE_PAUSED ) ==
191
200
GST_STATE_CHANGE_FAILURE ) {
192
201
return -1 ;
@@ -195,7 +204,8 @@ static int output_gstreamer_pause(void) {
195
204
}
196
205
}
197
206
198
- static int output_gstreamer_seek (int64_t position_nanos ) {
207
+ static int output_gstreamer_seek (gint64 position_nanos ) {
208
+ Log_info ("gstreamer" , "SEEK requested" );
199
209
if (gst_element_seek (player_ , 1.0 , GST_FORMAT_TIME ,
200
210
GST_SEEK_FLAG_FLUSH ,
201
211
GST_SEEK_TYPE_SET , position_nanos ,
@@ -285,14 +295,28 @@ static gboolean my_bus_callback(GstBus * bus, GstMessage * msg,
285
295
free (gsuri_ );
286
296
gsuri_ = gs_next_uri_ ;
287
297
gs_next_uri_ = NULL ;
288
- gst_element_set_state (player_ , GST_STATE_READY );
298
+ //ASimb: ensure, that gstreamer REALLY stops
299
+ while (get_current_player_state () != GST_STATE_READY ) {
300
+ gst_element_set_state (player_ , GST_STATE_READY );
301
+ }
302
+ Log_info ("gstreamer" , "%s: starting next stream (NextURI)" , msgSrcName );
289
303
g_object_set (G_OBJECT (player_ ), "uri" , gsuri_ , NULL );
290
304
gst_element_set_state (player_ , GST_STATE_PLAYING );
291
305
if (play_trans_callback_ ) {
292
306
play_trans_callback_ (PLAY_STARTED_NEXT_STREAM );
293
307
}
294
- } else if (play_trans_callback_ ) {
295
- play_trans_callback_ (PLAY_STOPPED );
308
+ } else {
309
+ //ASimb: the following second line is needed to ensure,
310
+ // that the GStreamer really stops
311
+ Log_info ("gstreamer" , "%s: No further stream available" , msgSrcName );
312
+ gst_element_set_state (player_ , GST_STATE_READY );
313
+
314
+ if (play_trans_callback_ ) {
315
+ play_trans_callback_ (PLAY_STOPPED );
316
+ }
317
+ //ASimb: URI has to cleared
318
+ free (gsuri_ );
319
+ gsuri_ = NULL ;
296
320
}
297
321
break ;
298
322
@@ -483,18 +507,19 @@ static void prepare_next_stream(GstElement *obj, gpointer userdata) {
483
507
484
508
Log_info ("gstreamer" , "about-to-finish cb: setting uri %s" ,
485
509
gs_next_uri_ );
486
- free (gsuri_ );
487
- gsuri_ = gs_next_uri_ ;
488
- gs_next_uri_ = NULL ;
489
- if (gsuri_ != NULL ) {
490
- g_object_set (G_OBJECT (player_ ), "uri" , gsuri_ , NULL );
491
- if (play_trans_callback_ ) {
492
- // TODO(hzeller): can we figure out when we _actually_
493
- // start playing this ? there are probably a couple
494
- // of seconds between now and actual start.
495
- play_trans_callback_ (PLAY_STARTED_NEXT_STREAM );
496
- }
497
- }
510
+ //ASimb: not needed any more due to sampling-rate-problem
511
+ // free(gsuri_);
512
+ // gsuri_ = gs_next_uri_;
513
+ // gs_next_uri_ = NULL;
514
+ // if (gsuri_ != NULL) {
515
+ // g_object_set(G_OBJECT(player_), "uri", gsuri_, NULL);
516
+ // if (play_trans_callback_) {
517
+ // // TODO(hzeller): can we figure out when we _actually_
518
+ // // start playing this ? there are probably a couple
519
+ // // of seconds between now and actual start.
520
+ // play_trans_callback_(PLAY_STARTED_NEXT_STREAM);
521
+ // }
522
+ // }
498
523
}
499
524
500
525
static int output_gstreamer_init (void )
@@ -590,9 +615,9 @@ static int output_gstreamer_init(void)
590
615
static const char * output_gstreamer_version (char * buffer , size_t len )
591
616
{
592
617
snprintf (buffer , len , "%d.%d.%d (glib-%d.%d.%d; gstreamer-%d.%d.%d)" ,
593
- MOD_MAJOR_VERSION , MOD_MINOR_VERSION , MOD_MICRO_VERSION ,
594
- GLIB_MAJOR_VERSION , GLIB_MINOR_VERSION , GLIB_MICRO_VERSION ,
595
- GST_VERSION_MAJOR , GST_VERSION_MINOR , GST_VERSION_MICRO );
618
+ MOD_MAJOR_VERSION , MOD_MINOR_VERSION , MOD_MICRO_VERSION ,
619
+ GLIB_MAJOR_VERSION , GLIB_MINOR_VERSION , GLIB_MICRO_VERSION ,
620
+ GST_VERSION_MAJOR , GST_VERSION_MINOR , GST_VERSION_MICRO );
596
621
return buffer ;
597
622
}
598
623
@@ -618,6 +643,8 @@ static struct output_module gstreamer_output = {
618
643
.next = NULL ,
619
644
};
620
645
646
+ void output_gstreamer_initlib (void ) __attribute__((constructor ));
647
+
621
648
void output_gstreamer_initlib (void )
622
649
{
623
650
#if !GLIB_CHECK_VERSION (2 ,32 ,0 )
0 commit comments