fix ALSA problems when going through plug
This commit is contained in:
@@ -218,7 +218,9 @@ Alsa9Buf::~Alsa9Buf()
|
||||
}
|
||||
|
||||
|
||||
int Alsa9Buf::GetNumFramesToFill( int writeahead )
|
||||
/* Don't fill the buffer any more than than "writeahead". Don't write any
|
||||
* more than "chunksize" at a time. */
|
||||
int Alsa9Buf::GetNumFramesToFill( snd_pcm_sframes_t writeahead, snd_pcm_sframes_t chunksize )
|
||||
{
|
||||
snd_pcm_sframes_t avail_frames = dsnd_pcm_avail_update(pcm);
|
||||
|
||||
@@ -253,6 +255,8 @@ int Alsa9Buf::GetNumFramesToFill( int writeahead )
|
||||
const snd_pcm_sframes_t filled_frames = max( 0l, total_frames - avail_frames );
|
||||
|
||||
snd_pcm_sframes_t frames_to_fill = clamp( writeahead - filled_frames, 0l, (snd_pcm_sframes_t)writeahead );
|
||||
frames_to_fill = min( frames_to_fill, chunksize );
|
||||
|
||||
frames_to_fill -= frames_to_fill % xfer_align;
|
||||
|
||||
return frames_to_fill;
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
Alsa9Buf( hw hardware, int channels );
|
||||
~Alsa9Buf();
|
||||
|
||||
int GetNumFramesToFill( int writeahead );
|
||||
int GetNumFramesToFill( snd_pcm_sframes_t writeahead, snd_pcm_sframes_t chunksize );
|
||||
void Write( const Sint16 *buffer, int frames );
|
||||
unsigned FindSampleRate( unsigned rate );
|
||||
|
||||
|
||||
@@ -56,10 +56,7 @@ RageSound_ALSA9::stream::~stream()
|
||||
/* Returns the number of frames processed */
|
||||
bool RageSound_ALSA9::stream::GetData(bool init)
|
||||
{
|
||||
int frames_to_fill = pcm->GetNumFramesToFill( max_writeahead );
|
||||
if( !init )
|
||||
frames_to_fill = min( frames_to_fill, chunksize );
|
||||
|
||||
int frames_to_fill = pcm->GetNumFramesToFill( max_writeahead, init? max_writeahead:chunksize );
|
||||
if( frames_to_fill < chunksize )
|
||||
return false;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ bool RageSound_ALSA9_Software::GetData()
|
||||
{
|
||||
const int chunksize = max_writeahead / num_chunks;
|
||||
|
||||
const int frames_to_fill = min( chunksize, pcm->GetNumFramesToFill( max_writeahead ) );
|
||||
const int frames_to_fill = pcm->GetNumFramesToFill( max_writeahead, chunksize );
|
||||
if( frames_to_fill <= 0 )
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user