can I use g_mail_loop_run() inside a while loop?

ge_keep pcouliba at yahoo.com
Wed Sep 7 18:01:44 UTC 2016


I am writing an audio application that will play audio stream using gstreamer
based on events its received from external application.
So i have something like this in my main function:

int main(void)
{
  int Chnl1=0, Chnl2=1;
...
    /* init */
   gst_init ();

    * while(event)*
     {
        .....
      if (event == File1PlayToChl1)
        playAudioFileWithGstreamer(Chnl1);
     if (event == File2PlayToChl2)
        playAudioFileWithGstreamer(Chnl2);
        ....
     }
....
...
}

and  for example:
void playAudioFileWithGstreamer(int chnl_number)
{
   /* create source and destination elements */
       // source is File1 or File2
      // destination is a audio output stereo (2chl) sound card

   /* put together a pipeline */
     //if file == File1, connect File1 to sound card Channel 0
     //if file == File2, connect File2 to sound card Channel 1

  /* start the pipeline */
   gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
   loop = g_main_loop_new (NULL, FALSE);
  *  g_main_loop_run (loop);*

   [..]
}


*Is g_main_loop_run (loop) a blocking function and will not return until the
file playback is done?*
My objective is  to be able to play File1 (if that was the first event) and
then allow the while loop to still listen to events and when an event for
File2 arrive (assuming that File1 event will not come anymore), I want to
play File 2 on the 2nd channel of the SAME sound card.  My problem is that
g_main_loop_run (loop) blocks the first playback and prevent the while loop
to receive events and does not allow my application to play the 2 files in
parallel (simultaneously)!!!

Is anyone can give me some hints how to implement this use case as regards
to how/where to use g_main_loop_run() ?


Thanks.





--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/can-I-use-g-mail-loop-run-inside-a-while-loop-tp4679474.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list