This is now checked into HEAD and 150Cay. --greg.
Greg Wright wrote:
Ryan Gammon wrote:
Greg Wright wrote:
Synopsis:
The alsa driver wasn't working, it would only write a partial buffer before returning from _WriteBytes(). This resulted in an assert for debug builds and choppy cricket sounds for release builds. The following patch fixes this by making ALSA write the whole buffer before returning.
Sounds good to me if it sounds good to you... _WriteBytes has an api that looks like it can handle partial writes, an alternative fix would be to move this write-until-everything-is-written loop up into audUnix(?)
It could use some work. The rollback buffer, if that is what you are looking
at, is only used for pause/resume. If we don't write the whole audio buffer
we will loose the portion we don't write.
Are you using threaded audio? I was getting asserts / problems with the audio thread turned on, and those went away when I turned it off... not sure if the problems here are related.
Yes, I run with all the threads on. That is where I saw the problem, but only for high samplerate content (44.1).
PushBits() is suppose to be blocking and always right all the data. It is for that reason that the non-threaded mode calls _GetRoomOnDevice() before writing to make sure _PushBits() will return quickly. With the threads on we don't care and just call _PushBits() all the time to keep the audio device as full as we can.
There is some clean up we could do for sure, but this at least gets ALSA working in both modes as far as I can see.
I have noticed that the ALSA driver uses about 100% cpu on my system when using ALSA as opposed to OSS which uses only about 20%. The increase is all SYS time as oppose to user time. The user time for both OSS and ALSA are the same.
Weird...
I have not looked into if my changes caused this yet. I will back them out and test it to make sure it didn't.
--greg.
Files Modified:
audio/device/platform/unix/audlinux_alsa.cpp
Platforms and Profiles Affected:
linux only.
Branch: HEAD, 150Cay(after branch).
Index: platform/unix/audlinux_alsa.cpp =================================================================== RCS file: /cvsroot/audio/device/platform/unix/audlinux_alsa.cpp,v retrieving revision 1.4 diff -u -w -r1.4 audlinux_alsa.cpp --- platform/unix/audlinux_alsa.cpp 28 Sep 2004 21:04:17 -0000 1.4 +++ platform/unix/audlinux_alsa.cpp 8 Mar 2005 19:48:44 -0000 @@ -856,6 +856,8 @@ int err = 0; unsigned int frames_written = 0; snd_pcm_sframes_t num_frames; + ULONG32 ulBytesToWrite = ulBuffLength; + ULONG32 ulBytesWrote = 0;
lCount = 0;
@@ -874,15 +876,19 @@ return m_wLastError; }
- num_frames = snd_pcm_bytes_to_frames(m_pAlsaPCMHandle, ulBuffLength);
do
{
+ num_frames = snd_pcm_bytes_to_frames(m_pAlsaPCMHandle, ulBytesToWrite);
err = snd_pcm_writei( m_pAlsaPCMHandle, buffer, num_frames );
+
if (err >= 0)
{
frames_written = err;
- lCount = snd_pcm_frames_to_bytes (m_pAlsaPCMHandle, frames_written);
+ ulBytesWrote = snd_pcm_frames_to_bytes (m_pAlsaPCMHandle, frames_written);
+ buffer += ulBytesWrote;
+ ulBytesToWrite -= ulBytesWrote;
+ lCount += ulBytesWrote;
}
else
{
@@ -906,8 +912,9 @@
m_wLastError = RA_AOE_DEVBUSY;
}
}
- } while (err == -EAGAIN);
+ } while (err == -EAGAIN || (err>0 && ulBytesToWrite>0));
+ HX_ASSERT( lCount == ulBuffLength ); return m_wLastError; }
_______________________________________________ Player-dev mailing list [EMAIL PROTECTED] http://lists.helixcommunity.org/mailman/listinfo/player-dev
_______________________________________________ Audio-dev mailing list [email protected] http://lists.helixcommunity.org/mailman/listinfo/audio-dev
_______________________________________________ Audio-dev mailing list [email protected] http://lists.helixcommunity.org/mailman/listinfo/audio-dev
