cleanup
This commit is contained in:
@@ -105,7 +105,7 @@ bool RageSound_DSound::stream::GetData(bool init)
|
|||||||
|
|
||||||
char *locked_buf;
|
char *locked_buf;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
int play_pos = str_ds->GetOutputPosition();
|
const int play_pos = str_ds->GetOutputPosition();
|
||||||
const int cur_play_pos = str_ds->GetPosition();
|
const int cur_play_pos = str_ds->GetPosition();
|
||||||
|
|
||||||
if(init) {
|
if(init) {
|
||||||
@@ -133,8 +133,8 @@ bool RageSound_DSound::stream::GetData(bool init)
|
|||||||
const int iFramesUntilThisBuffer = play_pos - cur_play_pos;
|
const int iFramesUntilThisBuffer = play_pos - cur_play_pos;
|
||||||
const float fSecondsBeforeStart = -start_time.Ago();
|
const float fSecondsBeforeStart = -start_time.Ago();
|
||||||
const int iFramesBeforeStart = int(fSecondsBeforeStart * str_ds->GetSampleRate());
|
const int iFramesBeforeStart = int(fSecondsBeforeStart * str_ds->GetSampleRate());
|
||||||
const int iSilentFramesInThisBuffer = max( 0, iFramesBeforeStart-iFramesUntilThisBuffer );
|
const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer;
|
||||||
const int iSilentBytesInThisBuffer = min( iSilentFramesInThisBuffer * bytes_per_frame, bytes_left );
|
const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left );
|
||||||
|
|
||||||
memset( locked_buf, 0, iSilentBytesInThisBuffer );
|
memset( locked_buf, 0, iSilentBytesInThisBuffer );
|
||||||
bytes_read += iSilentBytesInThisBuffer;
|
bytes_read += iSilentBytesInThisBuffer;
|
||||||
@@ -156,7 +156,7 @@ bool RageSound_DSound::stream::GetData(bool init)
|
|||||||
* buffers have been flushed. */
|
* buffers have been flushed. */
|
||||||
state = STOPPING;
|
state = STOPPING;
|
||||||
|
|
||||||
/* Flush two buffers worth of data. */
|
/* Keep playing until the data we currently have locked has played. */
|
||||||
flush_pos = str_ds->GetOutputPosition();
|
flush_pos = str_ds->GetOutputPosition();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -95,11 +95,10 @@ bool RageSound_DSound_Software::GetData()
|
|||||||
{
|
{
|
||||||
/* If the sound is supposed to start at a time past this buffer, insert silence. */
|
/* If the sound is supposed to start at a time past this buffer, insert silence. */
|
||||||
const int iFramesUntilThisBuffer = play_pos - cur_play_pos;
|
const int iFramesUntilThisBuffer = play_pos - cur_play_pos;
|
||||||
|
|
||||||
const float fSecondsBeforeStart = -sounds[i]->start_time.Ago();
|
const float fSecondsBeforeStart = -sounds[i]->start_time.Ago();
|
||||||
const int iFramesBeforeStart = int(fSecondsBeforeStart * samplerate);
|
const int iFramesBeforeStart = int(fSecondsBeforeStart * samplerate);
|
||||||
const int iSilentFramesInThisBuffer = max( 0, iFramesBeforeStart-iFramesUntilThisBuffer );
|
const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer;
|
||||||
const int iSilentBytesInThisBuffer = min( iSilentFramesInThisBuffer * bytes_per_frame, bytes_left );
|
const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left );
|
||||||
|
|
||||||
memset( buf+bytes_read, 0, iSilentBytesInThisBuffer );
|
memset( buf+bytes_read, 0, iSilentBytesInThisBuffer );
|
||||||
bytes_read += iSilentBytesInThisBuffer;
|
bytes_read += iSilentBytesInThisBuffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user