Results 1 to 2 of 2

Thread: Core dumped - clan::SoundOutput_Impl::mixer_thread()

  1. #1
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default Core dumped - clan::SoundOutput_Impl::mixer_thread()

    ( Restored deleted thread from daltomi )

    I was testing a few things.
    When "SoundOutput" has no parameters the example fails.
    When have parameters, it works fine, for example: SoundOutput so(44100)

    Then this example does not work, Segmentation fault.

    Code:
    Code:
    #include <ClanLib/core.h>
    #include <ClanLib/application.h>
    #include <ClanLib/sound.h>
    
    static int AppMain(const std::vector<std::string>& args)
    {
      clan::SetupCore	setupCore;
      clan::SetupSound	setupSound;
      clan::SoundOutput soundOutput;
    
      clan::SoundBuffer sound("click.ogg");
      sound.play();
      
      return 0;
    }
    
    clan::Application app(&AppMain);
    The difference in the definition of SoundOutput lies here:



    Code:
    Code:
    SoundBuffer_Session SoundBuffer::prepare(bool looping, SoundOutput *output)
    {
    	SoundOutput current_output = Sound::get_current_output();
    	if (output == 0) output = &current_output;
    
    	MutexSection mutex_lock(&impl->mutex);
    	return SoundBuffer_Session(*this, looping, *output);
    }
    Value current_output:


    Code:
    Code:
    $1 = {_vptr.SoundOutput = 0x7ffff7bd3b70 <vtable for clan::SoundOutput+16>, impl = std::shared_ptr (empty) 0x0}
    Then current_output->impl is 0x0.
    Later:


    Code:
    Code:
    void SoundBuffer_Session::play()
    {
    	if (impl)
    	{
    		MutexSection mutex_lock(&impl->mutex);
    		if (impl->playing) return;
    		if (impl->provider_session->play())
    		{
    			impl->playing = true;
    			mutex_lock.unlock();
    			impl->output.impl->play_session(*this);
    		}
    	}
    }
    Code:
    Code:
    (gdb) p impl->output.impl
    $6 = std::shared_ptr (empty) 0x0
    Where "output.impl" is equal to "current_output.impl(0x0)".
    Then it calls a:


    Code:
    Code:
    void SoundOutput_Impl::play_session(SoundBuffer_Session &session)
    {
    	MutexSection mutex_lock(&mutex);
    	sessions.push_back(session);
    }
    mutex = 0x70(garbage), inside MutexSection call mutex-lock() -> Segmentation fault.

    Value current_output when SoundOutput();


    Code:
    Code:
    $1 = {_vptr.SoundOutput = 0x7ffff7bd3b70 <vtable for clan::SoundOutput+16>, impl = std::shared_ptr (empty) 0x0}
    Value current_output when SoundOutput(XXXX);


    Code:
    Code:
    $1 = {_vptr.SoundOutput = 0x7ffff7bd3b70 <vtable for clan::SoundOutput+16>, impl = std::shared_ptr (count 2, weak 1) 0x6022a0}
    Maybe it's a bug.

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    ... Now to try to remember what I put

    Code:
    	/// \brief Constructs a null instance
    	SoundOutput();
    
    	/// \brief Constructs a SoundOutput
    	///
    	/// \param mixing_frequency = value
    	/// \param latency = value
    	SoundOutput(int mixing_frequency, int latency = 50);
    Many ClanLib classes, have default constructors like this. This means that the implementation for that class is unset ( std::shared_ptr<SoundOutput_Impl> impl )

    Classes that contain this feature are classes that require parameters to initialise them

    All these classes contain "is_null()" and "throw_if_null()" functions

    This feature allows you to treat the classes as handle objects. For example
    Code:
    class Apple
    {
    public:
    	Apple(blah blah blah);
    	clan::Image m_Image;
     }
    
    Apple::Apple(blah blah blah)
    {
      m_Image = clan::Image(blah blah blah);
    }
    Ideally all handle object classes should contain

    Code:
    void clan_class::my_function()
    {
    #ifdef DEBUG
    	throw_if_null();
    #endif
    	...
    
    }
    But that's very boring to implement. Maybe one day we will receive a patch.

Similar Threads

  1. make html no ClanLib/core.h
    By bvanevery in forum Official ClanLib SDK Forums
    Replies: 10
    Last Post: 04-04-2013, 09:51 PM
  2. posts oddly dumped to the moderator queue
    By bvanevery in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 03-18-2013, 11:40 PM
  3. Error including ClanLib/core.h
    By Bsloane in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 03-05-2012, 08:30 AM
  4. Core lib and multiple threads?
    By cdoty in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 12-09-2011, 10:37 PM
  5. 0.8.1 mingw32 crush when Core is deinit
    By alexv1 in forum Official ClanLib SDK Forums
    Replies: 8
    Last Post: 02-18-2009, 04:35 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •