[vlc-devel] How to share a variable between qt4 ui (c++) and playlist thread (c)

Casian Andrei skeletk13 at gmail.com
Thu Jan 10 07:13:51 CET 2013


Hello,

Have you looked at VLC variables? Afaik these are used to communicate
between different modules / threads.

http://www.videolan.org/developers/vlc/doc/doxygen/html/group__variables.html

I don't know any details, but I guess that you should try these if you
have not done it until now.

2013/1/10 fayyaz lodhi <fayyazkl at gmail.com>
>
> To elaborate further, i created a global variable in /vlc/src/playlist/thread.c
> It is extern in playlist_internal.h
>
> This variable is read from in the LoopRequest function when a playlist is signaled to start playing.
>
> Before the start of a play list some gui dialogs appear which are located in modules/gui/qt4/dialogs (some what similar to firstrun.cpp).
>
> Now if firstrun.cpp has extern the same variable i.e. (extern type name), and it is filled with in this dialog (actually it is a c string i.e. char array filled from a QString using  strcpy(c_string, q_string.toLocal8Bit().constData()). This compiles successfully, but i get following run time errors with no GUI loaded.
>
> no suitable dialogs provider found (hint: compile the qt4 plugin, and make sure it is loaded properly)
> [0x1ea18b8] skins2 interface error: cannot instantiate qt4 dialogs provider
> [0x1ea18b8] main interface error: no suitable interface module
> [0x1e72388] main libvlc error: interface "default" initialization failed
>
>
> I have tried several other combinations like instead of using extern, declaring the variable in playlist_internal.h or say vlc_common.h and including the header file on the gui side (if not included already) or vice versa. But usually i start getting multiple inclusion errors though the variable is only created once.
>
> All errors go away as soon as i comment out the variable from any one side or even if i make it static on one side. GUI starts loading normally.

I am unable to understand how the solution you are trying can ever work...

>
> Can some one help?
>
> Regards,
> Fayyaz
>
>
>
> On Wed, Jan 9, 2013 at 5:16 PM, Fayyaz Khan <fayyazkl at gmail.com> wrote:
>>
>>
>> Thank you Remi.
>>
>> I understand that well and probably that is not a problem in my case.
>>
>> The shared variable (char array) that i wish to create will be updated by a dialog in the beginning of the program (though it can be chosen from a list of dynamic options), before playlist components picks it up. So there will be no sync issue.
>>
>> Moreover, i am using PL Lock / unlock in both scenarios to ensure synchronized access.
>>
>> Could you please elaborate a little more on a good location in source code to prevent other include file issues? Right now i am a victim of those.
>>
>> Thank you
>> Fayyaz
>>
>>
>> On 1/9/2013 5:11 PM, Rémi Denis-Courmont wrote:
>>>
>>> On Wed, 9 Jan 2013 14:28:28 +0500, fayyaz lodhi <fayyazkl at gmail.com>
>>> wrote:
>>>>
>>>> What is the correct way of sharing data between the two?
>>>
>>> I don't need to remind you that the multi-threaded memory model (either
>>> POSIX or C11) forbids sharing data directly unless the data is constant
>>> read-only.
>>>
>>> You need to add functions instead, including appropriate synchronization
>>> depending on the actual case.
>>>
>>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
>



More information about the vlc-devel mailing list