style cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25177 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2008-04-26 12:16:53 +00:00
parent 5b89ed13fd
commit fc1ca2da5c
10 changed files with 212 additions and 255 deletions
+18 -28
View File
@@ -33,13 +33,11 @@ bool FillBuffer(_gs_ramp * ramp, uint8 * data, uint8 * buffer, size_t * bytes)
{ {
int32 samples = *bytes / sizeof(int16); int32 samples = *bytes / sizeof(int16);
for(int32 byte = 0; byte < samples; byte++) for (int32 byte = 0; byte < samples; byte++) {
{
float gain = *ramp->value; float gain = *ramp->value;
data[byte] = uint8(float(buffer[byte]) * gain); data[byte] = uint8(float(buffer[byte]) * gain);
if (ChangeRamp(ramp)) if (ChangeRamp(ramp)) {
{
*bytes = byte * sizeof(int16); *bytes = byte * sizeof(int16);
return true; return true;
} }
@@ -52,13 +50,11 @@ bool FillBuffer(_gs_ramp * ramp, int16 * data, int16 * buffer, size_t * bytes)
{ {
int32 samples = *bytes / sizeof(int16); int32 samples = *bytes / sizeof(int16);
for(int32 byte = 0; byte < samples; byte++) for (int32 byte = 0; byte < samples; byte++) {
{
float gain = *ramp->value; float gain = *ramp->value;
data[byte] = int16(float(buffer[byte]) * gain); data[byte] = int16(float(buffer[byte]) * gain);
if (ChangeRamp(ramp)) if (ChangeRamp(ramp)) {
{
*bytes = byte * sizeof(int16); *bytes = byte * sizeof(int16);
return true; return true;
} }
@@ -72,13 +68,11 @@ bool FillBuffer(_gs_ramp * ramp, int32 * data, int32 * buffer, size_t * bytes)
size_t byte = 0; size_t byte = 0;
bool bytesAreReady = (*bytes > 0); bool bytesAreReady = (*bytes > 0);
while(bytesAreReady) while (bytesAreReady) {
{
float gain = *ramp->value; float gain = *ramp->value;
data[byte] = int32(float(buffer[byte]) * gain); data[byte] = int32(float(buffer[byte]) * gain);
if (ChangeRamp(ramp)) if (ChangeRamp(ramp)) {
{
*bytes = byte; *bytes = byte;
return true; return true;
} }
@@ -95,13 +89,11 @@ bool FillBuffer(_gs_ramp * ramp, float * data, float * buffer, size_t * bytes)
size_t byte = 0; size_t byte = 0;
bool bytesAreReady = (*bytes > 0); bool bytesAreReady = (*bytes > 0);
while(bytesAreReady) while (bytesAreReady) {
{
float gain = *ramp->value; float gain = *ramp->value;
data[byte] = buffer[byte] * gain; data[byte] = buffer[byte] * gain;
if (ChangeRamp(ramp)) if (ChangeRamp(ramp)) {
{
*bytes = byte; *bytes = byte;
return true; return true;
} }
@@ -145,8 +137,7 @@ BFileGameSound::BFileGameSound(const char *file,
fPaused(false), fPaused(false),
fPauseGain(1.0) fPauseGain(1.0)
{ {
if (InitCheck() == B_OK) if (InitCheck() == B_OK) {
{
entry_ref node; entry_ref node;
if (get_ref_for_path(file, &node) != B_OK) if (get_ref_for_path(file, &node) != B_OK)
@@ -159,10 +150,10 @@ BFileGameSound::BFileGameSound(const char *file,
BFileGameSound::~BFileGameSound() BFileGameSound::~BFileGameSound()
{ {
if (fReadThread >= 0) kill_thread(fReadThread); if (fReadThread >= 0)
kill_thread(fReadThread);
if (fAudioStream) if (fAudioStream) {
{
if (fAudioStream->stream) if (fAudioStream->stream)
fAudioStream->file->ReleaseTrack(fAudioStream->stream); fAudioStream->file->ReleaseTrack(fAudioStream->stream);
@@ -307,16 +298,14 @@ status_t
BFileGameSound::SetPaused(bool isPaused, BFileGameSound::SetPaused(bool isPaused,
bigtime_t rampTime) bigtime_t rampTime)
{ {
if (fPaused != isPaused) if (fPaused != isPaused) {
{
Lock(); Lock();
// Clear any old ramping // Clear any old ramping
delete fPausing; delete fPausing;
fPausing = NULL; fPausing = NULL;
if (rampTime > 100000) if (rampTime > 100000) {
{
// Setup for ramping // Setup for ramping
if (isPaused) if (isPaused)
fPausing = InitRamp(&fPauseGain, 0.0, Format().frame_rate, rampTime); fPausing = InitRamp(&fPauseGain, 0.0, Format().frame_rate, rampTime);
@@ -335,9 +324,11 @@ BFileGameSound::SetPaused(bool isPaused,
int32 int32
BFileGameSound::IsPaused() BFileGameSound::IsPaused()
{ {
if (fPausing) return B_PAUSE_IN_PROGRESS; if (fPausing)
return B_PAUSE_IN_PROGRESS;
if (fPaused) return B_PAUSED; if (fPaused)
return B_PAUSED;
return B_NOT_PAUSED; return B_NOT_PAUSED;
} }
@@ -403,7 +394,6 @@ BFileGameSound::Init(const entry_ref* file)
bool bool
BFileGameSound::Load() BFileGameSound::Load()
{ {
if (fPlayPosition != 0) { if (fPlayPosition != 0) {
if (fBufferSize > fPlayPosition) if (fBufferSize > fPlayPosition)
memcpy(fBuffer, fBuffer + fPlayPosition, fBufferSize - fPlayPosition); memcpy(fBuffer, fBuffer + fPlayPosition, fBufferSize - fPlayPosition);
+62 -83
View File
@@ -217,59 +217,55 @@ GameProducer::Connect(status_t error, const media_source& source, const media_de
// If something earlier failed, Connect() might still be called, but with a non-zero // If something earlier failed, Connect() might still be called, but with a non-zero
// error code. When that happens we simply unreserve the connection and do // error code. When that happens we simply unreserve the connection and do
// nothing else. // nothing else.
if (error) if (error) {
{
fOutput.destination = media_destination::null; fOutput.destination = media_destination::null;
fOutput.format = fPreferredFormat; fOutput.format = fPreferredFormat;
return;
} }
else
{
// Okay, the connection has been confirmed. Record the destination and format
// that we agreed on, and report our connection name again.
fOutput.destination = destination;
fOutput.format = format;
strncpy(io_name, fOutput.name, B_MEDIA_NAME_LENGTH);
// Now that we're connected, we can determine our downstream latency. // Okay, the connection has been confirmed. Record the destination and format
// Do so, then make sure we get our events early enough. // that we agreed on, and report our connection name again.
media_node_id id; fOutput.destination = destination;
FindLatencyFor(fOutput.destination, &fLatency, &id); fOutput.format = format;
strncpy(io_name, fOutput.name, B_MEDIA_NAME_LENGTH);
// Use a dry run to see how long it takes me to fill a buffer of data // Now that we're connected, we can determine our downstream latency.
// Do so, then make sure we get our events early enough.
media_node_id id;
FindLatencyFor(fOutput.destination, &fLatency, &id);
// Use a dry run to see how long it takes me to fill a buffer of data
// The first step to setup the buffer // The first step to setup the buffer
bigtime_t start, produceLatency; bigtime_t start, produceLatency;
int32 frames = int32(fOutput.format.u.raw_audio.buffer_size / fFrameSize); int32 frames = int32(fOutput.format.u.raw_audio.buffer_size / fFrameSize);
float* data = new float[frames * 2]; float* data = new float[frames * 2];
// Second, fill the buffer // Second, fill the buffer
start = ::system_time(); start = ::system_time();
for(int32 i = 0; i < frames; i++) for (int32 i = 0; i < frames; i++) {
{ data[i*2] = 0.8 * float(i/frames);
data[i*2] = 0.8 * float(i/frames); data[i*2+1] = 0.8 * float(i/frames);
data[i*2+1] = 0.8 * float(i/frames); }
} produceLatency = ::system_time();
produceLatency = ::system_time();
// Thid, calculate the latency // Third, calculate the latency
fInternalLatency = produceLatency - start; fInternalLatency = produceLatency - start;
SetEventLatency(fLatency + fInternalLatency); SetEventLatency(fLatency + fInternalLatency);
// Finaily, clean up // Finaily, clean up
delete [] data; delete [] data;
// reset our buffer duration, etc. to avoid later calculations // reset our buffer duration, etc. to avoid later calculations
bigtime_t duration = bigtime_t(1000000) * frames / bigtime_t(fOutput.format.u.raw_audio.frame_rate); bigtime_t duration = bigtime_t(1000000) * frames / bigtime_t(fOutput.format.u.raw_audio.frame_rate);
SetBufferDuration(duration); SetBufferDuration(duration);
// Set up the buffer group for our connection, as long as nobody handed us a // Set up the buffer group for our connection, as long as nobody handed us a
// buffer group (via SetBufferGroup()) prior to this. // buffer group (via SetBufferGroup()) prior to this.
if (!fBufferGroup) if (!fBufferGroup) {
{ size_t size = fOutput.format.u.raw_audio.buffer_size;
size_t size = fOutput.format.u.raw_audio.buffer_size; int32 count = int32(fLatency / BufferDuration() + 2);
int32 count = int32(fLatency / BufferDuration() + 2); fBufferGroup = new BBufferGroup(size, count);
fBufferGroup = new BBufferGroup(size, count);
}
} }
} }
@@ -278,8 +274,7 @@ void
GameProducer::Disconnect(const media_source& what, const media_destination& where) GameProducer::Disconnect(const media_source& what, const media_destination& where)
{ {
// Make sure that our connection is the one being disconnected // Make sure that our connection is the one being disconnected
if ((where == fOutput.destination) && (what == fOutput.source)) if ((where == fOutput.destination) && (what == fOutput.source)) {
{
fOutput.destination = media_destination::null; fOutput.destination = media_destination::null;
fOutput.format = fPreferredFormat; fOutput.format = fPreferredFormat;
delete fBufferGroup; delete fBufferGroup;
@@ -300,10 +295,12 @@ status_t
GameProducer::SetBufferGroup(const media_source& for_source, BBufferGroup* newGroup) GameProducer::SetBufferGroup(const media_source& for_source, BBufferGroup* newGroup)
{ {
// verify that we didn't get bogus arguments before we proceed // verify that we didn't get bogus arguments before we proceed
if (for_source != fOutput.source) return B_MEDIA_BAD_SOURCE; if (for_source != fOutput.source)
return B_MEDIA_BAD_SOURCE;
// Are we being passed the buffer group we're already using? // Are we being passed the buffer group we're already using?
if (newGroup == fBufferGroup) return B_OK; if (newGroup == fBufferGroup)
return B_OK;
// Ahh, someone wants us to use a different buffer group. At this point we delete // Ahh, someone wants us to use a different buffer group. At this point we delete
// the one we are using and use the specified one instead. If the specified group is // the one we are using and use the specified one instead. If the specified group is
@@ -312,13 +309,10 @@ GameProducer::SetBufferGroup(const media_source& for_source, BBufferGroup* newGr
// *before* deleting the buffer group, otherwise we'll deadlock waiting for that // *before* deleting the buffer group, otherwise we'll deadlock waiting for that
// buffer to be recycled! // buffer to be recycled!
delete fBufferGroup; // waits for all buffers to recycle delete fBufferGroup; // waits for all buffers to recycle
if (newGroup != NULL) if (newGroup != NULL) {
{
// we were given a valid group; just use that one from now on // we were given a valid group; just use that one from now on
fBufferGroup = newGroup; fBufferGroup = newGroup;
} } else {
else
{
// we were passed a NULL group pointer; that means we construct // we were passed a NULL group pointer; that means we construct
// our own buffer group to use from now on // our own buffer group to use from now on
size_t size = fOutput.format.u.raw_audio.buffer_size; size_t size = fOutput.format.u.raw_audio.buffer_size;
@@ -344,17 +338,13 @@ GameProducer::LateNoticeReceived(const media_source& what, bigtime_t how_much, b
{ {
// If we're late, we need to catch up. Respond in a manner appropriate to our // If we're late, we need to catch up. Respond in a manner appropriate to our
// current run mode. // current run mode.
if (what == fOutput.source) if (what == fOutput.source) {
{ if (RunMode() == B_RECORDING) {
if (RunMode() == B_RECORDING)
{
// A hardware capture node can't adjust; it simply emits buffers at // A hardware capture node can't adjust; it simply emits buffers at
// appropriate points. We (partially) simulate this by not adjusting // appropriate points. We (partially) simulate this by not adjusting
// our behavior upon receiving late notices -- after all, the hardware // our behavior upon receiving late notices -- after all, the hardware
// can't choose to capture "sooner".... // can't choose to capture "sooner"....
} } else if (RunMode() == B_INCREASE_LATENCY) {
else if (RunMode() == B_INCREASE_LATENCY)
{
// We're late, and our run mode dictates that we try to produce buffers // We're late, and our run mode dictates that we try to produce buffers
// earlier in order to catch up. This argues that the downstream nodes are // earlier in order to catch up. This argues that the downstream nodes are
// not properly reporting their latency, but there's not much we can do about // not properly reporting their latency, but there's not much we can do about
@@ -362,9 +352,7 @@ GameProducer::LateNoticeReceived(const media_source& what, bigtime_t how_much, b
// compensate. // compensate.
fInternalLatency += how_much; fInternalLatency += how_much;
SetEventLatency(fLatency + fInternalLatency); SetEventLatency(fLatency + fInternalLatency);
} } else {
else
{
// The other run modes dictate various strategies for sacrificing data quality // The other run modes dictate various strategies for sacrificing data quality
// in the interests of timely data delivery. The way *we* do this is to skip // in the interests of timely data delivery. The way *we* do this is to skip
// a buffer, which catches us up in time by one buffer duration. // a buffer, which catches us up in time by one buffer duration.
@@ -382,8 +370,7 @@ GameProducer::LatencyChanged(const media_source& source, const media_destination
// buffers earlier (or later) than we were previously. Make sure that the // buffers earlier (or later) than we were previously. Make sure that the
// connection that changed is ours, and adjust to the new downstream // connection that changed is ours, and adjust to the new downstream
// latency if so. // latency if so.
if ((source == fOutput.source) && (destination == fOutput.destination)) if ((source == fOutput.source) && (destination == fOutput.destination)) {
{
fLatency = new_latency; fLatency = new_latency;
SetEventLatency(fLatency + fInternalLatency); SetEventLatency(fLatency + fInternalLatency);
} }
@@ -435,8 +422,7 @@ GameProducer::SetRunMode(run_mode mode)
{ {
// We don't support offline run mode, so broadcast an error if we're set to // We don't support offline run mode, so broadcast an error if we're set to
// B_OFFLINE. Unfortunately, we can't actually reject the mode change... // B_OFFLINE. Unfortunately, we can't actually reject the mode change...
if (B_OFFLINE == mode) if (B_OFFLINE == mode) {
{
ReportError(B_NODE_FAILED_SET_RUN_MODE); ReportError(B_NODE_FAILED_SET_RUN_MODE);
} }
} }
@@ -450,8 +436,7 @@ GameProducer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bo
{ {
case BTimedEventQueue::B_START: case BTimedEventQueue::B_START:
// don't do anything if we're already running // don't do anything if we're already running
if (RunState() != B_STARTED) if (RunState() != B_STARTED) {
{
// We are going to start sending buffers so setup the needed bookkeeping // We are going to start sending buffers so setup the needed bookkeeping
fFramesSent = 0; fFramesSent = 0;
fStartTime = event->event_time; fStartTime = event->event_time;
@@ -476,17 +461,16 @@ GameProducer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bo
case BTimedEventQueue::B_HANDLE_BUFFER: case BTimedEventQueue::B_HANDLE_BUFFER:
{ {
// make sure we're both started *and* connected before delivering a buffer // make sure we're both started *and* connected before delivering a buffer
if ((RunState() == BMediaEventLooper::B_STARTED) && (fOutput.destination != media_destination::null)) if ((RunState() == BMediaEventLooper::B_STARTED)
{ && (fOutput.destination != media_destination::null)) {
// Get the next buffer of data // Get the next buffer of data
BBuffer* buffer = FillNextBuffer(event->event_time); BBuffer* buffer = FillNextBuffer(event->event_time);
if (buffer) if (buffer) {
{
// send the buffer downstream if and only if output is enabled // send the buffer downstream if and only if output is enabled
status_t err = B_ERROR; status_t err = B_ERROR;
if (fOutputEnabled) err = SendBuffer(buffer, fOutput.destination); if (fOutputEnabled)
if (err) err = SendBuffer(buffer, fOutput.destination);
{ if (err) {
// we need to recycle the buffer ourselves if output is disabled or // we need to recycle the buffer ourselves if output is disabled or
// if the call to SendBuffer() fails // if the call to SendBuffer() fails
buffer->Recycle(); buffer->Recycle();
@@ -511,8 +495,6 @@ GameProducer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bo
} }
// --------------------------------
// GameProducer
BBuffer* BBuffer*
GameProducer::FillNextBuffer(bigtime_t event_time) GameProducer::FillNextBuffer(bigtime_t event_time)
{ {
@@ -521,7 +503,8 @@ GameProducer::FillNextBuffer(bigtime_t event_time)
// if we fail to get a buffer (for example, if the request times out), we skip this // if we fail to get a buffer (for example, if the request times out), we skip this
// buffer and go on to the next, to avoid locking up the control thread // buffer and go on to the next, to avoid locking up the control thread
if (!buf) return NULL; if (!buf)
return NULL;
// we need to discribe the buffer // we need to discribe the buffer
int64 frames = int64(fOutput.format.u.raw_audio.buffer_size / fFrameSize); int64 frames = int64(fOutput.format.u.raw_audio.buffer_size / fFrameSize);
@@ -537,15 +520,12 @@ GameProducer::FillNextBuffer(bigtime_t event_time)
hdr->time_source = TimeSource()->ID(); hdr->time_source = TimeSource()->ID();
bigtime_t stamp; bigtime_t stamp;
if (RunMode() == B_RECORDING) if (RunMode() == B_RECORDING) {
{
// In B_RECORDING mode, we stamp with the capture time. We're not // In B_RECORDING mode, we stamp with the capture time. We're not
// really a hardware capture node, but we simulate it by using the (precalculated) // really a hardware capture node, but we simulate it by using the (precalculated)
// time at which this buffer "should" have been created. // time at which this buffer "should" have been created.
stamp = event_time; stamp = event_time;
} } else {
else
{
// okay, we're in one of the "live" performance run modes. in these modes, we // okay, we're in one of the "live" performance run modes. in these modes, we
// stamp the buffer with the time at which the buffer should be rendered to the // stamp the buffer with the time at which the buffer should be rendered to the
// output, not with the capture time. fStartTime is the cached value of the // output, not with the capture time. fStartTime is the cached value of the
@@ -559,4 +539,3 @@ GameProducer::FillNextBuffer(bigtime_t event_time)
return buf; return buf;
} }
+51 -68
View File
@@ -93,8 +93,7 @@ GameSoundBuffer::~GameSoundBuffer()
{ {
BMediaRoster* r = BMediaRoster::Roster(); BMediaRoster* r = BMediaRoster::Roster();
if (fIsConnected) if (fIsConnected) {
{
// Ordinarily we'd stop *all* of the nodes in the chain at this point. However, // Ordinarily we'd stop *all* of the nodes in the chain at this point. However,
// one of the nodes is the System Mixer, and stopping the Mixer is a Bad Idea (tm). // one of the nodes is the System Mixer, and stopping the Mixer is a Bad Idea (tm).
// So, we just disconnect from it, and release our references to the nodes that // So, we just disconnect from it, and release our references to the nodes that
@@ -172,24 +171,21 @@ GameSoundBuffer::SetPan(float pan, bigtime_t duration)
if (pan < -1.0 || pan > 1.0) if (pan < -1.0 || pan > 1.0)
return B_BAD_VALUE; return B_BAD_VALUE;
if (fPanRamp) delete fPanRamp; if (fPanRamp)
delete fPanRamp;
if (duration < 100000) if (duration < 100000) {
{
fPan = pan; fPan = pan;
if (fPan < 0.0) if (fPan < 0.0) {
{
fPanLeft = 1.0; fPanLeft = 1.0;
fPanRight = 1.0 + fPan; fPanRight = 1.0 + fPan;
} } else {
else
{
fPanRight = 1.0; fPanRight = 1.0;
fPanLeft = 1.0 - fPan; fPanLeft = 1.0 - fPan;
} }
} } else
else fPanRamp = InitRamp(&fPan, pan, fFormat.frame_rate, duration); fPanRamp = InitRamp(&fPan, pan, fFormat.frame_rate, duration);
return B_OK; return B_OK;
} }
@@ -199,18 +195,18 @@ status_t
GameSoundBuffer::GetAttributes(gs_attribute * attributes, GameSoundBuffer::GetAttributes(gs_attribute * attributes,
size_t attributeCount) size_t attributeCount)
{ {
for(size_t i = 0; i < attributeCount; i++) for (size_t i = 0; i < attributeCount; i++) {
{ switch(attributes[i].attribute) {
switch(attributes[i].attribute)
{
case B_GS_GAIN: case B_GS_GAIN:
attributes[i].value = fGain; attributes[i].value = fGain;
if (fGainRamp) attributes[i].duration = fGainRamp->duration; if (fGainRamp)
attributes[i].duration = fGainRamp->duration;
break; break;
case B_GS_PAN: case B_GS_PAN:
attributes[i].value = fPan; attributes[i].value = fPan;
if (fPanRamp) attributes[i].duration = fGainRamp->duration; if (fPanRamp)
attributes[i].duration = fGainRamp->duration;
case B_GS_LOOPING: case B_GS_LOOPING:
attributes[i].value = (fLooping) ? -1.0 : 0.0; attributes[i].value = (fLooping) ? -1.0 : 0.0;
@@ -232,10 +228,8 @@ GameSoundBuffer::SetAttributes(gs_attribute * attributes,
{ {
status_t error = B_OK; status_t error = B_OK;
for(size_t i = 0; i < attributeCount; i++) for (size_t i = 0; i < attributeCount; i++) {
{ switch(attributes[i].attribute) {
switch(attributes[i].attribute)
{
case B_GS_GAIN: case B_GS_GAIN:
error = SetGain(attributes[i].value, attributes[i].duration); error = SetGain(attributes[i].value, attributes[i].duration);
break; break;
@@ -264,12 +258,10 @@ GameSoundBuffer::Play(void * data, int64 frames)
FillBuffer(buffer, frames); FillBuffer(buffer, frames);
switch(fFormat.format) switch(fFormat.format) {
{
case gs_audio_format::B_GS_U8: case gs_audio_format::B_GS_U8:
{ {
for(int64 i = 0; i < frames; i++) for (int64 i = 0; i < frames; i++) {
{
ApplyMod((uint8*)data, (uint8*)buffer, i, fGain, pan); ApplyMod((uint8*)data, (uint8*)buffer, i, fGain, pan);
UpdateMods(); UpdateMods();
} }
@@ -279,8 +271,7 @@ GameSoundBuffer::Play(void * data, int64 frames)
case gs_audio_format::B_GS_S16: case gs_audio_format::B_GS_S16:
{ {
for(int64 i = 0; i < frames; i++) for (int64 i = 0; i < frames; i++) {
{
ApplyMod((int16*)data, (int16*)buffer, i, fGain, pan); ApplyMod((int16*)data, (int16*)buffer, i, fGain, pan);
UpdateMods(); UpdateMods();
} }
@@ -290,8 +281,7 @@ GameSoundBuffer::Play(void * data, int64 frames)
case gs_audio_format::B_GS_S32: case gs_audio_format::B_GS_S32:
{ {
for(int64 i = 0; i < frames; i++) for (int64 i = 0; i < frames; i++) {
{
ApplyMod((int32*)data, (int32*)buffer, i, fGain, pan); ApplyMod((int32*)data, (int32*)buffer, i, fGain, pan);
UpdateMods(); UpdateMods();
} }
@@ -301,8 +291,7 @@ GameSoundBuffer::Play(void * data, int64 frames)
case gs_audio_format::B_GS_F: case gs_audio_format::B_GS_F:
{ {
for(int64 i = 0; i < frames; i++) for (int64 i = 0; i < frames; i++) {
{
ApplyMod((float*)data, (float*)buffer, i, fGain, pan); ApplyMod((float*)data, (float*)buffer, i, fGain, pan);
UpdateMods(); UpdateMods();
} }
@@ -320,32 +309,23 @@ void
GameSoundBuffer::UpdateMods() GameSoundBuffer::UpdateMods()
{ {
// adjust the gain if needed // adjust the gain if needed
if (fGainRamp) if (fGainRamp) {
{ if (ChangeRamp(fGainRamp)) {
if (ChangeRamp(fGainRamp))
{
delete fGainRamp; delete fGainRamp;
fGainRamp = NULL; fGainRamp = NULL;
} }
} }
// adjust the ramp if needed // adjust the ramp if needed
if (fPanRamp) if (fPanRamp) {
{ if (ChangeRamp(fPanRamp)) {
if (ChangeRamp(fPanRamp))
{
delete fPanRamp; delete fPanRamp;
fPanRamp = NULL; fPanRamp = NULL;
} } else {
else if (fPan < 0.0) {
{
if (fPan < 0.0)
{
fPanLeft = 1.0; fPanLeft = 1.0;
fPanRight = 1.0 + fPan; fPanRight = 1.0 + fPan;
} } else {
else
{
fPanRight = 1.0; fPanRight = 1.0;
fPanLeft = 1.0 - fPan; fPanLeft = 1.0 - fPan;
} }
@@ -378,14 +358,16 @@ GameSoundBuffer::Connect(media_node * consumer)
status_t err; status_t err;
err = r->RegisterNode(fNode); err = r->RegisterNode(fNode);
if (err != B_OK) return err; if (err != B_OK)
return err;
// make sure the Media Roster knows that we're using the node // make sure the Media Roster knows that we're using the node
r->GetNodeFor(fNode->Node().node, &fConnection->producer); r->GetNodeFor(fNode->Node().node, &fConnection->producer);
// connect to the mixer // connect to the mixer
fConnection->consumer = *consumer; fConnection->consumer = *consumer;
if (err != B_OK) return err; if (err != B_OK)
return err;
// set the producer's time source to be the "default" time source, which // set the producer's time source to be the "default" time source, which
// the Mixer uses too. // the Mixer uses too.
@@ -397,17 +379,20 @@ GameSoundBuffer::Connect(media_node * consumer)
media_output soundOutput; media_output soundOutput;
int32 count = 1; int32 count = 1;
err = r->GetFreeOutputsFor(fConnection->producer, &soundOutput, 1, &count); err = r->GetFreeOutputsFor(fConnection->producer, &soundOutput, 1, &count);
if (err != B_OK) return err; if (err != B_OK)
return err;
count = 1; count = 1;
err = r->GetFreeInputsFor(fConnection->consumer, &mixerInput, 1, &count); err = r->GetFreeInputsFor(fConnection->consumer, &mixerInput, 1, &count);
if (err != B_OK) return err; if (err != B_OK)
return err;
// got the endpoints; now we connect it! // got the endpoints; now we connect it!
media_format format; media_format format;
format.type = B_MEDIA_RAW_AUDIO; format.type = B_MEDIA_RAW_AUDIO;
format.u.raw_audio = media_raw_audio_format::wildcard; format.u.raw_audio = media_raw_audio_format::wildcard;
err = r->Connect(soundOutput.source, mixerInput.destination, &format, &soundOutput, &mixerInput); err = r->Connect(soundOutput.source, mixerInput.destination, &format, &soundOutput, &mixerInput);
if (err != B_OK) return err; if (err != B_OK)
return err;
// the inputs and outputs might have been reassigned during the // the inputs and outputs might have been reassigned during the
// nodes' negotiation of the Connect(). That's why we wait until // nodes' negotiation of the Connect(). That's why we wait until
@@ -424,7 +409,8 @@ GameSoundBuffer::Connect(media_node * consumer)
status_t status_t
GameSoundBuffer::StartPlaying() GameSoundBuffer::StartPlaying()
{ {
if (fIsPlaying) return EALREADY; if (fIsPlaying)
return EALREADY;
BMediaRoster* r = BMediaRoster::Roster(); BMediaRoster* r = BMediaRoster::Roster();
BTimeSource* ts = r->MakeTimeSourceFor(fConnection->producer); BTimeSource* ts = r->MakeTimeSourceFor(fConnection->producer);
@@ -445,7 +431,8 @@ GameSoundBuffer::StartPlaying()
status_t status_t
GameSoundBuffer::StopPlaying() GameSoundBuffer::StopPlaying()
{ {
if (!fIsPlaying) return EALREADY; if (!fIsPlaying)
return EALREADY;
BMediaRoster* r = BMediaRoster::Roster(); BMediaRoster* r = BMediaRoster::Roster();
r->StopNode(fConnection->producer, 0, true); // synchronous stop r->StopNode(fConnection->producer, 0, true); // synchronous stop
@@ -499,27 +486,22 @@ SimpleSoundBuffer::FillBuffer(void * data, int64 frames)
char * buffer = (char*)data; char * buffer = (char*)data;
size_t bytes = fFrameSize * frames; size_t bytes = fFrameSize * frames;
if (fPosition + bytes >= fBufferSize) if (fPosition + bytes >= fBufferSize) {
{ if (fPosition < fBufferSize) {
if (fPosition < fBufferSize)
{
// copy the remaining frames // copy the remaining frames
size_t remainder = fBufferSize - fPosition; size_t remainder = fBufferSize - fPosition;
memcpy(buffer, &fBuffer[fPosition], remainder); memcpy(buffer, &fBuffer[fPosition], remainder);
if (fLooping) if (fLooping) {
{
// restart the sound from the begging // restart the sound from the begging
memcpy(&buffer[remainder], fBuffer, bytes - remainder); memcpy(&buffer[remainder], fBuffer, bytes - remainder);
fPosition = bytes - remainder; fPosition = bytes - remainder;
} } else
else fPosition = fBufferSize; fPosition = fBufferSize;
} } else
else memset(data, 0, bytes); memset(data, 0, bytes);
// there is nothing left to play // there is nothing left to play
} } else {
else
{
memcpy(buffer, &fBuffer[fPosition], bytes); memcpy(buffer, &fBuffer[fPosition], bytes);
fPosition += bytes; fPosition += bytes;
} }
@@ -549,3 +531,4 @@ StreamingSoundBuffer::FillBuffer(void * buffer,
size_t bytes = fFrameSize * frames; size_t bytes = fFrameSize * frames;
object->FillBuffer(buffer, bytes); object->FillBuffer(buffer, bytes);
} }
+40 -35
View File
@@ -61,8 +61,7 @@ void ReleaseDevice()
{ {
deviceCount--; deviceCount--;
if (deviceCount <= 0) if (deviceCount <= 0) {
{
delete theDevice; delete theDevice;
theDevice = NULL; theDevice = NULL;
} }
@@ -79,7 +78,7 @@ BGameSoundDevice::BGameSoundDevice()
fInitError = Connect(); fInitError = Connect();
fSounds = new GameSoundBuffer*[kInitSoundCount]; fSounds = new GameSoundBuffer*[kInitSoundCount];
for(int32 i = 0; i < kInitSoundCount; i++) for (int32 i = 0; i < kInitSoundCount; i++)
fSounds[i] = NULL; fSounds[i] = NULL;
} }
@@ -89,14 +88,13 @@ BGameSoundDevice::~BGameSoundDevice()
BMediaRoster* r = BMediaRoster::Roster(); BMediaRoster* r = BMediaRoster::Roster();
// We need to stop all the sounds before we stop the mixer // We need to stop all the sounds before we stop the mixer
for(int32 i = 0; i < fSoundCount; i++) for (int32 i = 0; i < fSoundCount; i++) {
{ if (fSounds[i])
if (fSounds[i]) fSounds[i]->StopPlaying(); fSounds[i]->StopPlaying();
delete fSounds[i]; delete fSounds[i];
} }
if (fIsConnected) if (fIsConnected) {
{
// stop the nodes if they are running // stop the nodes if they are running
r->StopNode(fConnection->producer, 0, true); // synchronous stop r->StopNode(fConnection->producer, 0, true); // synchronous stop
@@ -150,13 +148,13 @@ BGameSoundDevice::CreateBuffer(gs_id * sound,
const void * data, const void * data,
int64 frames) int64 frames)
{ {
if (frames <= 0 || !sound) return B_BAD_VALUE; if (frames <= 0 || !sound)
return B_BAD_VALUE;
status_t err = B_MEDIA_TOO_MANY_BUFFERS; status_t err = B_MEDIA_TOO_MANY_BUFFERS;
int32 position = AllocateSound(); int32 position = AllocateSound();
if (position >= 0) if (position >= 0) {
{
fSounds[position] = new SimpleSoundBuffer(format, data, frames); fSounds[position] = new SimpleSoundBuffer(format, data, frames);
err = fSounds[position]->Connect(&fConnection->producer); err = fSounds[position]->Connect(&fConnection->producer);
} }
@@ -171,13 +169,13 @@ BGameSoundDevice::CreateBuffer(gs_id * sound,
const void * object, const void * object,
const gs_audio_format * format) const gs_audio_format * format)
{ {
if (!object || !sound) return B_BAD_VALUE; if (!object || !sound)
return B_BAD_VALUE;
status_t err = B_MEDIA_TOO_MANY_BUFFERS; status_t err = B_MEDIA_TOO_MANY_BUFFERS;
int32 position = AllocateSound(); int32 position = AllocateSound();
if (position >= 0) if (position >= 0) {
{
fSounds[position] = new StreamingSoundBuffer(format, object); fSounds[position] = new StreamingSoundBuffer(format, object);
err = fSounds[position]->Connect(&fConnection->producer); err = fSounds[position]->Connect(&fConnection->producer);
} }
@@ -193,8 +191,7 @@ BGameSoundDevice::ReleaseBuffer(gs_id sound)
if (sound <= 0) if (sound <= 0)
return; return;
if (fSounds[sound-1]) if (fSounds[sound-1]) {
{
// We must stop playback befor destroying the sound or else // We must stop playback befor destroying the sound or else
// we may recieve fatel errors. // we may recieve fatel errors.
fSounds[sound-1]->StopPlaying(); fSounds[sound-1]->StopPlaying();
@@ -218,8 +215,8 @@ BGameSoundDevice::Buffer(gs_id sound,
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);
} } else
else data = NULL; data = NULL;
return B_OK; return B_OK;
} }
@@ -270,7 +267,8 @@ BGameSoundDevice::GetAttributes(gs_id sound,
gs_attribute * attributes, gs_attribute * attributes,
size_t attributeCount) size_t attributeCount)
{ {
if (!fSounds[sound-1]) return B_ERROR; if (!fSounds[sound-1])
return B_ERROR;
return fSounds[sound-1]->GetAttributes(attributes, attributeCount); return fSounds[sound-1]->GetAttributes(attributes, attributeCount);
} }
@@ -281,7 +279,8 @@ BGameSoundDevice::SetAttributes(gs_id sound,
gs_attribute * attributes, gs_attribute * attributes,
size_t attributeCount) size_t attributeCount)
{ {
if (!fSounds[sound-1]) return B_ERROR; if (!fSounds[sound-1])
return B_ERROR;
return fSounds[sound-1]->SetAttributes(attributes, attributeCount); return fSounds[sound-1]->SetAttributes(attributes, attributeCount);
} }
@@ -297,29 +296,35 @@ BGameSoundDevice::Connect()
dormant_node_info mixer_dormant_info; dormant_node_info mixer_dormant_info;
int32 mixer_count = 1; // for now, we only care about the first we find. int32 mixer_count = 1; // for now, we only care about the first we find.
err = r->GetDormantNodes(&mixer_dormant_info, &mixer_count, 0, 0, 0, B_SYSTEM_MIXER, 0); err = r->GetDormantNodes(&mixer_dormant_info, &mixer_count, 0, 0, 0, B_SYSTEM_MIXER, 0);
if (err != B_OK) return err; if (err != B_OK)
return err;
//fMixer = new media_node; //fMixer = new media_node;
err = r->InstantiateDormantNode(mixer_dormant_info, &fConnection->producer); err = r->InstantiateDormantNode(mixer_dormant_info, &fConnection->producer);
if (err != B_OK) return err; if (err != B_OK)
return err;
// retieve the system's audio mixer // retieve the system's audio mixer
err = r->GetAudioMixer(&fConnection->consumer); err = r->GetAudioMixer(&fConnection->consumer);
if (err != B_OK) return err; if (err != B_OK)
return err;
int32 count = 1; int32 count = 1;
media_input mixerInput; media_input mixerInput;
err = r->GetFreeInputsFor(fConnection->consumer, &mixerInput, 1, &count); err = r->GetFreeInputsFor(fConnection->consumer, &mixerInput, 1, &count);
if (err != B_OK) return err; if (err != B_OK)
return err;
count = 1; count = 1;
media_output mixerOutput; media_output mixerOutput;
err = r->GetFreeOutputsFor(fConnection->producer, &mixerOutput, 1, &count); err = r->GetFreeOutputsFor(fConnection->producer, &mixerOutput, 1, &count);
if (err != B_OK) return err; if (err != B_OK)
return err;
media_format format(mixerOutput.format); media_format format(mixerOutput.format);
err = r->Connect(mixerOutput.source, mixerInput.destination, &format, &mixerOutput, &mixerInput); err = r->Connect(mixerOutput.source, mixerInput.destination, &format, &mixerOutput, &mixerInput);
if (err != B_OK) return err; if (err != B_OK)
return err;
// set the producer's time source to be the "default" time source, which // set the producer's time source to be the "default" time source, which
// the Mixer uses too. // the Mixer uses too.
@@ -329,13 +334,12 @@ BGameSoundDevice::Connect()
// Start our mixer's time source if need be. Chances are, it won't need to be, // Start our mixer's time source if need be. Chances are, it won't need to be,
// but if we forget to do this, our mixer might not do anything at all. // but if we forget to do this, our mixer might not do anything at all.
BTimeSource* mixerTimeSource = r->MakeTimeSourceFor(fConnection->producer); BTimeSource* mixerTimeSource = r->MakeTimeSourceFor(fConnection->producer);
if (! mixerTimeSource) return B_ERROR; if (!mixerTimeSource)
return B_ERROR;
if (!mixerTimeSource->IsRunning()) if (!mixerTimeSource->IsRunning()) {
{
status_t err = r->StartNode(mixerTimeSource->Node(), BTimeSource::RealTime()); status_t err = r->StartNode(mixerTimeSource->Node(), BTimeSource::RealTime());
if (err != B_OK) if (err != B_OK) {
{
mixerTimeSource->Release(); mixerTimeSource->Release();
return err; return err;
} }
@@ -345,7 +349,8 @@ BGameSoundDevice::Connect()
bigtime_t tpNow = mixerTimeSource->Now(); bigtime_t tpNow = mixerTimeSource->Now();
err = r->StartNode(fConnection->producer, tpNow + 10000); err = r->StartNode(fConnection->producer, tpNow + 10000);
mixerTimeSource->Release(); mixerTimeSource->Release();
if (err != B_OK) return err; if (err != B_OK)
return err;
// the inputs and outputs might have been reassigned during the // the inputs and outputs might have been reassigned during the
// nodes' negotiation of the Connect(). That's why we wait until // nodes' negotiation of the Connect(). That's why we wait until
@@ -366,16 +371,16 @@ BGameSoundDevice::Connect()
int32 int32
BGameSoundDevice::AllocateSound() BGameSoundDevice::AllocateSound()
{ {
for(int32 i = 0; i < fSoundCount; i++) for (int32 i = 0; i < fSoundCount; i++)
if (!fSounds[i]) if (!fSounds[i])
return i; return i;
// we need to allocate new space for the sound // we need to allocate new space for the sound
GameSoundBuffer ** sounds = new GameSoundBuffer*[fSoundCount + kGrowth]; GameSoundBuffer ** sounds = new GameSoundBuffer*[fSoundCount + kGrowth];
for(int32 i = 0; i < fSoundCount; i++) for (int32 i = 0; i < fSoundCount; i++)
sounds[i] = fSounds[i]; sounds[i] = fSounds[i];
for(int32 i = fSoundCount; i < fSoundCount + kGrowth; i++) for (int32 i = fSoundCount; i < fSoundCount + kGrowth; i++)
sounds[i] = NULL; sounds[i] = NULL;
// replace the old list // replace the old list
+3 -5
View File
@@ -27,10 +27,9 @@ _EXPORT BNode& operator<<(BNode& n, const BMessage& m)
ssize_t bytes; ssize_t bytes;
const void *data; const void *data;
for(int32 i = 0; for (int32 i = 0;
m.GetInfo(B_ANY_TYPE, i, &name, &type) == 0; m.GetInfo(B_ANY_TYPE, i, &name, &type) == 0;
i++) i++) {
{
m.FindData (name,type,0,&data,&bytes); m.FindData (name,type,0,&data,&bytes);
n.WriteAttr(name,type,0, data, bytes); n.WriteAttr(name,type,0, data, bytes);
} }
@@ -45,8 +44,7 @@ _EXPORT BNode& operator>>(BNode& n, BMessage& m)
char *buf = NULL; char *buf = NULL;
n.RewindAttrs(); n.RewindAttrs();
while (n.GetNextAttrName(name)==B_OK) while (n.GetNextAttrName(name) == B_OK) {
{
if (n.GetAttrInfo(name,&info) != B_OK) if (n.GetAttrInfo(name,&info) != B_OK)
continue; continue;
+2 -2
View File
@@ -37,7 +37,7 @@ BMediaFiles::RewindTypes()
server_rewindtypes_request request; server_rewindtypes_request request;
server_rewindtypes_reply reply; server_rewindtypes_reply reply;
for(int32 i = 0; i < m_types.CountItems(); i++) for (int32 i = 0; i < m_types.CountItems(); i++)
delete (BString*)m_types.ItemAt(i); delete (BString*)m_types.ItemAt(i);
m_types.MakeEmpty(); m_types.MakeEmpty();
@@ -97,7 +97,7 @@ BMediaFiles::RewindRefs(const char *type)
server_rewindrefs_request request; server_rewindrefs_request request;
server_rewindrefs_reply reply; server_rewindrefs_reply reply;
for(int32 i = 0; i < m_items.CountItems(); i++) for (int32 i = 0; i < m_items.CountItems(); i++)
delete (BString*)m_items.ItemAt(i); delete (BString*)m_items.ItemAt(i);
m_items.MakeEmpty(); m_items.MakeEmpty();
+5 -5
View File
@@ -344,7 +344,7 @@ BParameterWeb::~BParameterWeb()
CALLED(); CALLED();
if (mGroups != NULL) { if (mGroups != NULL) {
for(int32 i = mGroups->CountItems(); i-- > 0;) { for (int32 i = mGroups->CountItems(); i-- > 0;) {
delete static_cast<BParameterGroup *>(mGroups->ItemAt(i)); delete static_cast<BParameterGroup *>(mGroups->ItemAt(i));
} }
@@ -1097,7 +1097,7 @@ BParameterGroup::Unflatten(type_code code, const void *buffer, ssize_t size)
//Clear all existing parameters/subgroups //Clear all existing parameters/subgroups
int i; int i;
if (mControls != NULL) { if (mControls != NULL) {
for(i = 0; i < mControls->CountItems(); i++) { for (i = 0; i < mControls->CountItems(); i++) {
BParameter *CurrentItem = static_cast<BParameter *>(mControls->ItemAt(i)); BParameter *CurrentItem = static_cast<BParameter *>(mControls->ItemAt(i));
if (CurrentItem != NULL) { if (CurrentItem != NULL) {
delete CurrentItem; delete CurrentItem;
@@ -2135,7 +2135,7 @@ BDiscreteParameter::MakeItemsFromInputs()
ASSERT(mInputs != NULL); ASSERT(mInputs != NULL);
int32 count = mInputs->CountItems(); int32 count = mInputs->CountItems();
for(int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
BParameter *parameter = static_cast<BParameter *>(mInputs->ItemAt(i)); BParameter *parameter = static_cast<BParameter *>(mInputs->ItemAt(i));
AddItem(i, parameter->Name()); AddItem(i, parameter->Name());
} }
@@ -2153,7 +2153,7 @@ BDiscreteParameter::MakeItemsFromOutputs()
ASSERT(mOutputs != NULL); ASSERT(mOutputs != NULL);
int32 count = mOutputs->CountItems(); int32 count = mOutputs->CountItems();
for(int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
BParameter *parameter = static_cast<BParameter *>(mOutputs->ItemAt(i)); BParameter *parameter = static_cast<BParameter *>(mOutputs->ItemAt(i));
AddItem(i, parameter->Name()); AddItem(i, parameter->Name());
} }
@@ -2174,7 +2174,7 @@ BDiscreteParameter::MakeEmpty()
} }
mValues->MakeEmpty(); mValues->MakeEmpty();
for(int32 i = mSelections->CountItems(); i-- > 0;) { for (int32 i = mSelections->CountItems(); i-- > 0;) {
free(static_cast<char *>(mSelections->ItemAt(i))); free(static_cast<char *>(mSelections->ItemAt(i)));
} }
mSelections->MakeEmpty(); mSelections->MakeEmpty();
+1 -1
View File
@@ -54,7 +54,7 @@ void
BCommandPipe::FlushArgs() BCommandPipe::FlushArgs()
{ {
// Delete all arguments from the list // Delete all arguments from the list
for(int32 i = 0; i < fArgList.CountItems(); i++) for (int32 i = 0; i < fArgList.CountItems(); i++)
free(fArgList.RemoveItem(0L)); free(fArgList.RemoveItem(0L));
fArgList.MakeEmpty(); fArgList.MakeEmpty();
+27 -27
View File
@@ -35,7 +35,7 @@ AddOnMonitorHandler::AddDirectory(const node_ref * nref)
{ {
// ignore directories added twice // ignore directories added twice
std::list<add_on_directory_info>::iterator diter = directories.begin(); std::list<add_on_directory_info>::iterator diter = directories.begin();
for( ; diter != directories.end() ; diter++) { for (; diter != directories.end() ; diter++) {
if (diter->nref == *nref) { if (diter->nref == *nref) {
return B_OK; return B_OK;
} }
@@ -147,10 +147,10 @@ AddOnMonitorHandler::EntryRemoved(ino_t directory, dev_t device, ino_t node)
// find the entry's info, and the entry's directory info // find the entry's info, and the entry's directory info
std::list<add_on_directory_info>::iterator diter = directories.begin(); std::list<add_on_directory_info>::iterator diter = directories.begin();
for( ; diter != directories.end() ; diter++) { for (; diter != directories.end() ; diter++) {
if (diter->nref == dir_nref) { if (diter->nref == dir_nref) {
std::list<add_on_entry_info>::iterator eiter = diter->entries.begin(); std::list<add_on_entry_info>::iterator eiter = diter->entries.begin();
for( ; eiter != diter->entries.end() ; eiter++) { for (; eiter != diter->entries.end() ; eiter++) {
info = *eiter; info = *eiter;
if (eiter->nref == entry_nref) { if (eiter->nref == entry_nref) {
info = *eiter; info = *eiter;
@@ -172,9 +172,9 @@ AddOnMonitorHandler::EntryRemoved(ino_t directory, dev_t device, ino_t node)
// the old add_on was not enabled. So we deallocate the old // the old add_on was not enabled. So we deallocate the old
// add_on and return. // add_on and return.
std::list<add_on_directory_info>::iterator diter2 = directories.begin(); std::list<add_on_directory_info>::iterator diter2 = directories.begin();
for( ; diter2 != diter ; diter2++) { for (; diter2 != diter ; diter2++) {
std::list<add_on_entry_info>::iterator eiter = diter2->entries.begin(); std::list<add_on_entry_info>::iterator eiter = diter2->entries.begin();
for( ; eiter != diter2->entries.end() ; eiter++) { for (; eiter != diter2->entries.end() ; eiter++) {
if (strcmp(eiter->name, info.name) == 0) { if (strcmp(eiter->name, info.name) == 0) {
AddOnRemoved(&info); AddOnRemoved(&info);
return; return;
@@ -191,7 +191,7 @@ AddOnMonitorHandler::EntryRemoved(ino_t directory, dev_t device, ino_t node)
// with the same name, we must enable it. // with the same name, we must enable it.
for (diter++ ; diter != directories.end() ; diter++) { for (diter++ ; diter != directories.end() ; diter++) {
std::list<add_on_entry_info>::iterator eiter = diter->entries.begin(); std::list<add_on_entry_info>::iterator eiter = diter->entries.begin();
for( ; eiter != diter->entries.end() ; eiter++) { for (; eiter != diter->entries.end() ; eiter++) {
if (strcmp(eiter->name, info.name) == 0) { if (strcmp(eiter->name, info.name) == 0) {
AddOnEnabled(&*eiter); AddOnEnabled(&*eiter);
return; return;
@@ -235,7 +235,7 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
if (to_iter == directories.end()) { if (to_iter == directories.end()) {
// moved out of our view // moved out of our view
std::list<add_on_entry_info>::iterator eiter = from_iter->entries.begin(); std::list<add_on_entry_info>::iterator eiter = from_iter->entries.begin();
for( ; eiter != from_iter->entries.end() ; eiter++) { for (; eiter != from_iter->entries.end() ; eiter++) {
if (entry_nref == eiter->nref) { if (entry_nref == eiter->nref) {
// save the info and remove the entry // save the info and remove the entry
info = *eiter; info = *eiter;
@@ -259,9 +259,9 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
// If we find a add_on with the same name then the moved add_on // If we find a add_on with the same name then the moved add_on
// was not enabled. So we are done. // was not enabled. So we are done.
std::list<add_on_directory_info>::iterator diter = directories.begin(); std::list<add_on_directory_info>::iterator diter = directories.begin();
for( ; diter != from_iter ; diter++) { for (; diter != from_iter ; diter++) {
std::list<add_on_entry_info>::iterator eiter2 = diter->entries.begin(); std::list<add_on_entry_info>::iterator eiter2 = diter->entries.begin();
for( ; eiter2 != diter->entries.end() ; eiter2++) { for (; eiter2 != diter->entries.end() ; eiter2++) {
if (strcmp(eiter2->name, info.name) == 0) { if (strcmp(eiter2->name, info.name) == 0) {
return; return;
} }
@@ -275,7 +275,7 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
// with the same name, we must enable it. // with the same name, we must enable it.
for (from_iter++ ; from_iter != directories.end() ; from_iter++) { for (from_iter++ ; from_iter != directories.end() ; from_iter++) {
std::list<add_on_entry_info>::iterator eiter2 = from_iter->entries.begin(); std::list<add_on_entry_info>::iterator eiter2 = from_iter->entries.begin();
for( ; eiter2 != from_iter->entries.end() ; eiter2++) { for (; eiter2 != from_iter->entries.end() ; eiter2++) {
if (strcmp(eiter2->name, info.name) == 0) { if (strcmp(eiter2->name, info.name) == 0) {
AddOnEnabled(&*eiter2); AddOnEnabled(&*eiter2);
return; return;
@@ -295,7 +295,7 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
if (from_iter == directories.end()) { if (from_iter == directories.end()) {
// moved into our view // moved into our view
std::list<add_on_entry_info>::iterator eiter = former_entries.begin(); std::list<add_on_entry_info>::iterator eiter = former_entries.begin();
for( ; eiter != former_entries.end() ; eiter++) { for (; eiter != former_entries.end() ; eiter++) {
if (entry_nref == eiter->nref) { if (entry_nref == eiter->nref) {
// save the info and remove the entry // save the info and remove the entry
info = *eiter; info = *eiter;
@@ -325,9 +325,9 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
// If we find a add_on with the same name then the moved add_on // If we find a add_on with the same name then the moved add_on
// is not to be enabled. So we are done. // is not to be enabled. So we are done.
std::list<add_on_directory_info>::iterator diter = directories.begin(); std::list<add_on_directory_info>::iterator diter = directories.begin();
for( ; diter != to_iter ; diter++) { for (; diter != to_iter ; diter++) {
std::list<add_on_entry_info>::iterator eiter2 = diter->entries.begin(); std::list<add_on_entry_info>::iterator eiter2 = diter->entries.begin();
for( ; eiter2 != diter->entries.end() ; eiter2++) { for (; eiter2 != diter->entries.end() ; eiter2++) {
if (strcmp(eiter2->name, info.name) == 0) { if (strcmp(eiter2->name, info.name) == 0) {
return; return;
} }
@@ -339,7 +339,7 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
bool shadowing = false; bool shadowing = false;
for (diter++ ; diter != directories.end() ; diter++) { for (diter++ ; diter != directories.end() ; diter++) {
std::list<add_on_entry_info>::iterator eiter2 = diter->entries.begin(); std::list<add_on_entry_info>::iterator eiter2 = diter->entries.begin();
for( ; eiter2 != diter->entries.end() ; eiter2++) { for (; eiter2 != diter->entries.end() ; eiter2++) {
if (strcmp(eiter2->name, info.name) == 0) { if (strcmp(eiter2->name, info.name) == 0) {
AddOnDisabled(&*eiter2); AddOnDisabled(&*eiter2);
shadowing = true; shadowing = true;
@@ -362,7 +362,7 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
} }
std::list<add_on_entry_info>::iterator eiter = from_iter->entries.begin(); std::list<add_on_entry_info>::iterator eiter = from_iter->entries.begin();
for( ; eiter != from_iter->entries.end() ; eiter++) { for (; eiter != from_iter->entries.end() ; eiter++) {
if (entry_nref == eiter->nref) { if (entry_nref == eiter->nref) {
// save the old info and remove the entry // save the old info and remove the entry
info = *eiter; info = *eiter;
@@ -378,9 +378,9 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
// check to see if it was formerly enabled // check to see if it was formerly enabled
bool was_enabled = true; bool was_enabled = true;
std::list<add_on_directory_info>::iterator old_iter = directories.begin(); std::list<add_on_directory_info>::iterator old_iter = directories.begin();
for( ; old_iter != from_iter ; old_iter++) { for (; old_iter != from_iter ; old_iter++) {
std::list<add_on_entry_info>::iterator eiter2 = old_iter->entries.begin(); std::list<add_on_entry_info>::iterator eiter2 = old_iter->entries.begin();
for( ; eiter2 != old_iter->entries.end() ; eiter2++) { for (; eiter2 != old_iter->entries.end() ; eiter2++) {
if (strcmp(eiter2->name, info.name) == 0) { if (strcmp(eiter2->name, info.name) == 0) {
was_enabled = false; was_enabled = false;
break; break;
@@ -395,9 +395,9 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
if (was_enabled) { if (was_enabled) {
AddOnDisabled(&info); AddOnDisabled(&info);
bool done = false; bool done = false;
for( ; old_iter != directories.end() ; old_iter++) { for (; old_iter != directories.end() ; old_iter++) {
std::list<add_on_entry_info>::iterator eiter2 = old_iter->entries.begin(); std::list<add_on_entry_info>::iterator eiter2 = old_iter->entries.begin();
for( ; eiter2 != old_iter->entries.end() ; eiter2++) { for (; eiter2 != old_iter->entries.end() ; eiter2++) {
if (strcmp(eiter2->name, info.name) == 0) { if (strcmp(eiter2->name, info.name) == 0) {
AddOnEnabled(&*eiter2); AddOnEnabled(&*eiter2);
done = true; done = true;
@@ -423,9 +423,9 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
// check to see if we are newly enabled // check to see if we are newly enabled
bool is_enabled = true; bool is_enabled = true;
std::list<add_on_directory_info>::iterator new_iter = directories.begin(); std::list<add_on_directory_info>::iterator new_iter = directories.begin();
for( ; new_iter != to_iter ; new_iter++) { for (; new_iter != to_iter ; new_iter++) {
std::list<add_on_entry_info>::iterator eiter2 = new_iter->entries.begin(); std::list<add_on_entry_info>::iterator eiter2 = new_iter->entries.begin();
for( ; eiter2 != new_iter->entries.end() ; eiter2++) { for (; eiter2 != new_iter->entries.end() ; eiter2++) {
if (strcmp(eiter2->name, info.name) == 0) { if (strcmp(eiter2->name, info.name) == 0) {
is_enabled = false; is_enabled = false;
break; break;
@@ -439,9 +439,9 @@ AddOnMonitorHandler::EntryMoved(const char *name, ino_t from_directory,
// if it is newly enabled, check under us for an enabled one, and disable that first // if it is newly enabled, check under us for an enabled one, and disable that first
if (is_enabled) { if (is_enabled) {
bool done = false; bool done = false;
for( ; new_iter != directories.end() ; new_iter++) { for (; new_iter != directories.end() ; new_iter++) {
std::list<add_on_entry_info>::iterator eiter2 = new_iter->entries.begin(); std::list<add_on_entry_info>::iterator eiter2 = new_iter->entries.begin();
for( ; eiter2 != new_iter->entries.end() ; eiter2++) { for (; eiter2 != new_iter->entries.end() ; eiter2++) {
if (strcmp(eiter2->name, info.name) == 0) { if (strcmp(eiter2->name, info.name) == 0) {
AddOnDisabled(&*eiter2); AddOnDisabled(&*eiter2);
done = true; done = true;
@@ -503,7 +503,7 @@ AddOnMonitorHandler::HandlePulse()
// put the new entry into the directory info // put the new entry into the directory info
std::list<add_on_directory_info>::iterator diter = directories.begin(); std::list<add_on_directory_info>::iterator diter = directories.begin();
for( ; diter != directories.end() ; diter++) { for (; diter != directories.end() ; diter++) {
if (diter->nref == dir_nref) { if (diter->nref == dir_nref) {
diter->entries.push_back(info); diter->entries.push_back(info);
break; break;
@@ -518,9 +518,9 @@ AddOnMonitorHandler::HandlePulse()
// the new add_on should not be enabled. // the new add_on should not be enabled.
bool enabled = true; bool enabled = true;
std::list<add_on_directory_info>::iterator diter2 = directories.begin(); std::list<add_on_directory_info>::iterator diter2 = directories.begin();
for( ; diter2 != diter ; diter2++) { for (; diter2 != diter ; diter2++) {
std::list<add_on_entry_info>::iterator eiter = diter2->entries.begin(); std::list<add_on_entry_info>::iterator eiter = diter2->entries.begin();
for( ; eiter != diter2->entries.end() ; eiter++) { for (; eiter != diter2->entries.end() ; eiter++) {
if (strcmp(eiter->name, info.name) == 0) { if (strcmp(eiter->name, info.name) == 0) {
enabled = false; enabled = false;
break; break;
@@ -540,7 +540,7 @@ AddOnMonitorHandler::HandlePulse()
bool shadowing = false; bool shadowing = false;
for (diter++ ; diter != directories.end() ; diter++) { for (diter++ ; diter != directories.end() ; diter++) {
std::list<add_on_entry_info>::iterator eiter = diter->entries.begin(); std::list<add_on_entry_info>::iterator eiter = diter->entries.begin();
for( ; eiter != diter->entries.end() ; eiter++) { for (; eiter != diter->entries.end() ; eiter++) {
if (strcmp(eiter->name, info.name) == 0) { if (strcmp(eiter->name, info.name) == 0) {
AddOnDisabled(&*eiter); AddOnDisabled(&*eiter);
shadowing = true; shadowing = true;
+3 -1
View File
@@ -235,8 +235,10 @@ BBitmapStream::WriteAt(off_t pos, const void *data, size_t size)
fBitmap = new BBitmap(fHeader.bounds, fHeader.colors); fBitmap = new BBitmap(fHeader.bounds, fHeader.colors);
if (!fBitmap) if (!fBitmap)
return B_ERROR; return B_ERROR;
if ((uint32)fBitmap->BytesPerRow() != fHeader.rowBytes) if ((uint32)fBitmap->BytesPerRow() != fHeader.rowBytes) {
fprintf(stderr, "BitmapStream %ld %ld\n", fBitmap->BytesPerRow(), fHeader.rowBytes);
return B_MISMATCHED_VALUES; return B_MISMATCHED_VALUES;
}
} }
if (fBitmap) if (fBitmap)
fSize = sizeof(TranslatorBitmap) + fBitmap->BitsLength(); fSize = sizeof(TranslatorBitmap) + fBitmap->BitsLength();