fix the problem reported in the TODO by using a reference to pointer

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27724 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2008-09-25 06:12:02 +00:00
parent 07865c4022
commit e7d2f0f0e8
2 changed files with 4 additions and 22 deletions

View File

@ -211,19 +211,12 @@ BGameSoundDevice::ReleaseBuffer(gs_id sound)
status_t
BGameSoundDevice::Buffer(gs_id sound,
gs_audio_format * format,
void * data)
BGameSoundDevice::Buffer(gs_id sound, gs_audio_format* format, void *& data)
{
if (!format || sound <= 0)
return B_BAD_VALUE;
memcpy(format, &fSounds[sound-1]->Format(), sizeof(gs_audio_format));
// TODO: This is broken!!!
// here we leak the memory allocated by malloc, since data
// is not a reference nor a pointer to a pointer.
// The caller will never have the chance to access the allocated memory.
if (fSounds[sound-1]->Data()) {
data = malloc(format->buffer_size);
memcpy(data, fSounds[sound-1]->Data(), format->buffer_size);

View File

@ -29,27 +29,16 @@
#ifndef _GAMESOUNDDEVICE_H
#define _GAMESOUNDDEVICE_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <GameSoundDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMediaNode;
class GameSoundBuffer;
struct Connection;
// BGameSoundDevice ------------------------------------------------------------
class BGameSoundDevice
{
class BGameSoundDevice {
public:
BGameSoundDevice();
BGameSoundDevice();
virtual ~BGameSoundDevice();
status_t InitCheck() const;
@ -67,7 +56,7 @@ public:
virtual status_t Buffer(gs_id sound,
gs_audio_format * format,
void * data);
void *& data);
virtual bool IsPlaying(gs_id sound);
virtual status_t StartPlaying(gs_id sound);