update license headers, code style
In BPushGameSound, SetParameter and SetStreamHook return B_UNSUPPORTED while Perform calls the parent class. Moved code to the constructor. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20682 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
49f3c71e21
commit
ea4f253fd6
@ -1,28 +1,11 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: FileGameSound.cpp
|
||||
// Author: Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
// Description: BFileGameSound is a class that streams data out of a file.
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
* Copyright 2001-2007, Haiku Inc.
|
||||
* Authors:
|
||||
* Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
* Jérôme Duval
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -1,44 +1,19 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: GameSoundDevice.h
|
||||
// Author: Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
// Description: Utility functions used by sound system
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
* Copyright 2001-2002, Haiku Inc.
|
||||
* Authors:
|
||||
* Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <GameSoundDefs.h>
|
||||
#include <MediaDefs.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
#include <GameSoundDefs.h>
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "GSUtility.h"
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Utility functions -----------------------------------------------------------
|
||||
_gs_ramp* InitRamp(float* value, float set, float frames, bigtime_t duration)
|
||||
_gs_ramp*
|
||||
InitRamp(float* value, float set, float frames, bigtime_t duration)
|
||||
{
|
||||
float diff = (set > *value) ? set - *value : *value - set;
|
||||
bigtime_t sec = bigtime_t(duration / 1000000.0);
|
||||
@ -60,27 +35,31 @@ _gs_ramp* InitRamp(float* value, float set, float frames, bigtime_t duration)
|
||||
return ramp;
|
||||
}
|
||||
|
||||
bool ChangeRamp(_gs_ramp* ramp)
|
||||
|
||||
bool
|
||||
ChangeRamp(_gs_ramp* ramp)
|
||||
{
|
||||
if (ramp->frame_count > ramp->frame_total) return true;
|
||||
if (ramp->frame_count > ramp->frame_total)
|
||||
return true;
|
||||
|
||||
if (ramp->frame_inc_count >= ramp->frame_inc)
|
||||
{
|
||||
if (ramp->frame_inc_count >= ramp->frame_inc) {
|
||||
ramp->frame_inc_count = 0;
|
||||
*ramp->value += ramp->inc;
|
||||
}
|
||||
else ramp->frame_inc_count++;
|
||||
else
|
||||
ramp->frame_inc_count++;
|
||||
|
||||
ramp->frame_count++;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t get_sample_size(int32 format)
|
||||
|
||||
size_t
|
||||
get_sample_size(int32 format)
|
||||
{
|
||||
size_t sample;
|
||||
|
||||
switch(format)
|
||||
{
|
||||
switch(format) {
|
||||
case media_raw_audio_format::B_AUDIO_CHAR:
|
||||
sample = sizeof(char);
|
||||
break;
|
||||
@ -107,7 +86,9 @@ size_t get_sample_size(int32 format)
|
||||
return sample;
|
||||
}
|
||||
|
||||
void media_to_gs_format(gs_audio_format* dest, media_raw_audio_format* source)
|
||||
|
||||
void
|
||||
media_to_gs_format(gs_audio_format* dest, media_raw_audio_format* source)
|
||||
{
|
||||
dest->format = source->format;
|
||||
dest->frame_rate = source->frame_rate;
|
||||
|
@ -1,29 +1,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: GameSound.cpp
|
||||
// Author: Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
// Description: Provides much of interfaces with BGameSoundDevice on behalf
|
||||
// of the rest of it's childern.
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
* Copyright 2001-2002, Haiku Inc.
|
||||
* Authors:
|
||||
* Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -1,28 +1,11 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: GameSound.cpp
|
||||
// Author: Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
// Description: BPushGameSound class
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
* Copyright 2001-2007, Haiku Inc.
|
||||
* Authors:
|
||||
* Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
* Jérôme Duval
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -36,14 +19,15 @@ BPushGameSound::BPushGameSound(size_t inBufferFrameCount, const gs_audio_format
|
||||
size_t inBufferCount, BGameSoundDevice *device)
|
||||
: BStreamingGameSound(inBufferFrameCount, format, inBufferCount, device)
|
||||
{
|
||||
if (InitCheck() != B_OK)
|
||||
return;
|
||||
fPageLocked = new BList;
|
||||
|
||||
size_t frameSize = get_sample_size(format->format) * format->channel_count;
|
||||
|
||||
status_t error = SetParameters(inBufferFrameCount, format, inBufferCount);
|
||||
if (error == B_OK)
|
||||
fPageLocked = new BList;
|
||||
else
|
||||
SetInitError(error);
|
||||
fPageCount = inBufferCount;
|
||||
fPageSize = frameSize * inBufferFrameCount;
|
||||
fBufferSize = fPageSize * fPageCount;
|
||||
|
||||
fBuffer = new char[fBufferSize];
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +42,8 @@ BPushGameSound::BPushGameSound(BGameSoundDevice * device)
|
||||
{
|
||||
fPageLocked = new BList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BPushGameSound::~BPushGameSound()
|
||||
{
|
||||
delete [] fBuffer;
|
||||
@ -70,12 +55,12 @@ BPushGameSound::lock_status
|
||||
BPushGameSound::LockNextPage(void **out_pagePtr, size_t *out_pageSize)
|
||||
{
|
||||
// the user can not lock every page
|
||||
if (fPageLocked->CountItems() > fPageCount - 3)
|
||||
if (fPageLocked->CountItems() > fPageCount - 3)
|
||||
return lock_failed;
|
||||
|
||||
// the user cann't lock a page being played
|
||||
if (fLockPos < fPlayPos
|
||||
&& fLockPos + fPageSize > fPlayPos)
|
||||
&& fLockPos + fPageSize > fPlayPos)
|
||||
return lock_failed;
|
||||
|
||||
// lock the page
|
||||
@ -84,7 +69,7 @@ BPushGameSound::LockNextPage(void **out_pagePtr, size_t *out_pageSize)
|
||||
|
||||
// move the locker to the next page
|
||||
fLockPos += fPageSize;
|
||||
if (fLockPos > fBufferSize)
|
||||
if (fLockPos > fBufferSize)
|
||||
fLockPos = 0;
|
||||
|
||||
*out_pagePtr = lockPage;
|
||||
@ -138,7 +123,7 @@ BPushGameSound::Clone() const
|
||||
status_t
|
||||
BPushGameSound::Perform(int32 selector, void *data)
|
||||
{
|
||||
return B_ERROR;
|
||||
return BStreamingGameSound::Perform(selector, data);
|
||||
}
|
||||
|
||||
|
||||
@ -147,19 +132,7 @@ BPushGameSound::SetParameters(size_t inBufferFrameCount,
|
||||
const gs_audio_format *format,
|
||||
size_t inBufferCount)
|
||||
{
|
||||
status_t error = BStreamingGameSound::SetParameters(inBufferFrameCount, format, inBufferCount);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
size_t frameSize = get_sample_size(format->format) * format->channel_count;
|
||||
|
||||
fPageCount = inBufferCount;
|
||||
fPageSize = frameSize * inBufferFrameCount;
|
||||
fBufferSize = fPageSize * fPageCount;
|
||||
|
||||
fBuffer = new char[fBufferSize];
|
||||
|
||||
return B_OK;
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
@ -167,7 +140,7 @@ status_t
|
||||
BPushGameSound::SetStreamHook(void (*hook)(void * inCookie, void * inBuffer, size_t inByteCount, BStreamingGameSound * me),
|
||||
void * cookie)
|
||||
{
|
||||
return B_ERROR;
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,29 +1,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: SimpleGameSound.h
|
||||
// Author: Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
// Description: BSimpleGameSound is a class for sound effects that are
|
||||
// short, and consists of non-changing samples in memory.
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku Inc.
|
||||
* Authors:
|
||||
* Christopher ML Zumwalt May (zummy@users.sf.net)
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -25,17 +25,10 @@
|
||||
// (data not known beforehand) game sounds.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
#include "GameSoundDevice.h"
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "StreamingGameSound.h"
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
BStreamingGameSound::BStreamingGameSound(size_t inBufferFrameCount,
|
||||
const gs_audio_format *format,
|
||||
size_t inBufferCount,
|
||||
@ -44,8 +37,7 @@ BStreamingGameSound::BStreamingGameSound(size_t inBufferFrameCount,
|
||||
fStreamHook(NULL),
|
||||
fStreamCookie(NULL)
|
||||
{
|
||||
if (InitCheck() == B_OK)
|
||||
{
|
||||
if (InitCheck() == B_OK) {
|
||||
status_t error = SetParameters(inBufferFrameCount, format, inBufferCount);
|
||||
SetInitError(error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user