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:
@@ -211,19 +211,12 @@ BGameSoundDevice::ReleaseBuffer(gs_id sound)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BGameSoundDevice::Buffer(gs_id sound,
|
BGameSoundDevice::Buffer(gs_id sound, gs_audio_format* format, void *& data)
|
||||||
gs_audio_format * format,
|
|
||||||
void * data)
|
|
||||||
{
|
{
|
||||||
if (!format || sound <= 0)
|
if (!format || sound <= 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
memcpy(format, &fSounds[sound-1]->Format(), sizeof(gs_audio_format));
|
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()) {
|
if (fSounds[sound-1]->Data()) {
|
||||||
data = malloc(format->buffer_size);
|
data = malloc(format->buffer_size);
|
||||||
memcpy(data, fSounds[sound-1]->Data(), format->buffer_size);
|
memcpy(data, fSounds[sound-1]->Data(), format->buffer_size);
|
||||||
|
|||||||
@@ -29,27 +29,16 @@
|
|||||||
#ifndef _GAMESOUNDDEVICE_H
|
#ifndef _GAMESOUNDDEVICE_H
|
||||||
#define _GAMESOUNDDEVICE_H
|
#define _GAMESOUNDDEVICE_H
|
||||||
|
|
||||||
// Standard Includes -----------------------------------------------------------
|
|
||||||
|
|
||||||
// System Includes -------------------------------------------------------------
|
|
||||||
#include <GameSoundDefs.h>
|
#include <GameSoundDefs.h>
|
||||||
|
|
||||||
// Project Includes ------------------------------------------------------------
|
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
|
||||||
|
|
||||||
// Local Defines ---------------------------------------------------------------
|
|
||||||
|
|
||||||
// Globals ---------------------------------------------------------------------
|
|
||||||
class BMediaNode;
|
class BMediaNode;
|
||||||
class GameSoundBuffer;
|
class GameSoundBuffer;
|
||||||
struct Connection;
|
struct Connection;
|
||||||
|
|
||||||
// BGameSoundDevice ------------------------------------------------------------
|
class BGameSoundDevice {
|
||||||
class BGameSoundDevice
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BGameSoundDevice();
|
BGameSoundDevice();
|
||||||
virtual ~BGameSoundDevice();
|
virtual ~BGameSoundDevice();
|
||||||
|
|
||||||
status_t InitCheck() const;
|
status_t InitCheck() const;
|
||||||
@@ -67,7 +56,7 @@ public:
|
|||||||
|
|
||||||
virtual status_t Buffer(gs_id sound,
|
virtual status_t Buffer(gs_id sound,
|
||||||
gs_audio_format * format,
|
gs_audio_format * format,
|
||||||
void * data);
|
void *& data);
|
||||||
|
|
||||||
virtual bool IsPlaying(gs_id sound);
|
virtual bool IsPlaying(gs_id sound);
|
||||||
virtual status_t StartPlaying(gs_id sound);
|
virtual status_t StartPlaying(gs_id sound);
|
||||||
|
|||||||
Reference in New Issue
Block a user