[haiku-bugs] Re: [Haiku] #9920: BSynth upgrade

  • From: "Pete" <trac@xxxxxxxxxxxx>
  • Date: Mon, 22 Sep 2014 01:37:20 -0000

#9920: BSynth upgrade
-----------------------------+-------------------------
   Reporter:  Pete           |      Owner:  korli
       Type:  enhancement    |     Status:  new
   Priority:  normal         |  Milestone:  R1
  Component:  Kits/Midi Kit  |    Version:  R1/alpha4.1
 Resolution:                 |   Keywords:
 Blocked By:                 |   Blocking:
Has a Patch:  1              |   Platform:  All
-----------------------------+-------------------------

Comment (by Pete):

 Replying to [comment:21 jackburton]:
 > About the GetAudio part:
 > From what I see, playsound can be called multiple times. If so, there is
 a memory leak, since we allocate memory and assign it to fMonitor without
 deleting it first. Would be okay to call delete[] on it first ?
 > Moreover, we write the data as floats and then we read it as int16s in
 BSynth::GetAudio(). Is it okay ?

 Actually looking at my original code, I don't see a leak...  Maybe I'm
 looking at things wrong, but I only create the fMonitor buffer if it
 doesn't exist. All further calls to PlayBuffer use that.  It then gets
 deleted when BSynth finally goes away.  (I'm not sure if it's possible for
 'size' to vary, but it doesn't matter if it does because any attempt to
 transfer sommething larger just gets clipped; smaller just leaves a hole.
 For the crude purposes of GetAudio, we don't care.)  And deleting and
 creating the buffer each time must slow things down quite a bit.

 I think your code is crashing due to a race condition.  GetAudio can get
 invoked just when fMonitor has been deleted.

 Check my logic, but I think it's OK to use my code.

--
Ticket URL: <https://dev.haiku-os.org/ticket/9920#comment:27>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: