[LAD] snd_seq_port_info and shared_ptr

Christian krampenschiesser at freenet.de
Sat Sep 5 11:35:50 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Davis schrieb:
> On Sat, Sep 5, 2009 at 3:38 AM, Christian<krampenschiesser at freenet.de> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> As I'm new to smart pointers and memory management in C++ I have a short
>> question on this topic.
>> I'm now using the following code to traverse the devices and their ports:
>>        snd_seq_client_info_t *clientInfo = 0;
>>        snd_seq_port_info_t *portInfo = 0;
>>        snd_seq_client_info_malloc(&clientInfo);
>>        snd_seq_port_info_malloc(&portInfo);
>>        shared_ptr<snd_seq_client_info_t> clientInfoMemoryHandler(clientInfo,
>> snd_seq_client_info_free);
>>        shared_ptr<snd_seq_port_info_t> portInfoMemoryHandler(portInfo,
>> snd_seq_port_info_free);
>>        .
>>        .
>>        .
>> snd_seq_port_info_set_client( portInfo,
>> snd_seq_client_info_get_client(clientInfo ) );
>> snd_seq_port_info_set_port( portInfo, -1 );
>> while ( snd_seq_query_next_port( seq, portInfo ) >= 0 ) {
>>        string portName = snd_seq_port_info_get_name( portInfo );
>>        unsigned int capability = snd_seq_port_info_get_capability( portInfo );
>>        .
>>        .
>>        .
>> Well the cleanUp methods are called at block-leaving.
>> I'm only a bit curious because after giving portInfo and clientInfo to
>> the shared_ptr for cleanup management I have to use them for all the
>> alsa queries.
>> But since I'm not using malloc and free in these queries everything is
>> ok, isn't it?
> 
> I'm unclear why you are attempting to use C++ shared ptr's with ALSA's
> very clearly C-style explicit memory management of various opaque data
> objects. What are you attempting to do?
> 
> 

Well I actually want a c++ wrapper and these are my first alsa-steps.
Used RtMidi in the past but want to have access to the suscription api.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqiTRYACgkQVC26eJ+o0+0tlwCdFfoC9bZ4rQp4QaTdaCc1kfNO
kqUAn0IdLH3aCDmfk8KAvVKlBh3TBEv0
=b507
-----END PGP SIGNATURE-----



More information about the Linux-audio-dev mailing list