The problem might be that arrayIndex is 32bit and it is used to calculate *samples which is 64bit. This would be a problem if arrayIndex has bit31 set.
EXAMPLE: If arrayIndex comes in with bit31 set (e.g. 0x911f13fc), which is negative, the top bit is extended when *samples is calculated. samples becomes 0xffffffff911f13fc.(actual values while debugging)
Perhaps the cast (void *)arrayIndex was to fix that.
Here's the function... I'm referencing lines 5 and 6 of the function:
==================== 1 static sqInt sound_PlaySamplesFromAtLength(sqInt frameCount, sqInt arrayIndex, sqInt startIndex) 2 { 3 if (output_handle) 4 { 5 void *samples= (void *)arrayIndex + startIndex * output_channels * 2; 6 int count= snd_pcm_writei(output_handle, samples, frameCount); 7 if (count < frameCount / 2) 8 { 9 output_buffer_frames_available= 0; } if (count < 0) { if (count == -EPIPE) /* underrun */ { int err; snd(pcm_prepare(output_handle), "sound_PlaySamples: snd_pcm_prepare"); return 0; } fprintf(stderr, "snd_pcm_writei returned %i\n", count); return 0; } return count; } success(false); ============
Does that seem right to you all?
Maybe sqInt never gets to be long long? sqMemoryAccess.h defines:
#if defined(SQ_IMAGE32) typedef int sqInt; typedef unsigned int usqInt; #elif defined(SQ_HOST64) typedef long sqInt; typedef unsigned long usqInt; #else # if (SIZEOF_LONG_LONG != 8) # error long long integers are not 64-bits wide? # endif typedef long long sqInt; typedef unsigned long long usqInt; #endif
On Tue, Nov 18, 2008 at 10:22 AM, Brad Fuller bradallenfuller@gmail.com wrote:
The problem might be that arrayIndex is 32bit and it is used to calculate *samples which is 64bit. This would be a problem if arrayIndex has bit31 set.
EXAMPLE: If arrayIndex comes in with bit31 set (e.g. 0x911f13fc), which is negative, the top bit is extended when *samples is calculated. samples becomes 0xffffffff911f13fc.(actual values while debugging)
Perhaps the cast (void *)arrayIndex was to fix that.
Here's the function... I'm referencing lines 5 and 6 of the function:
==================== 1 static sqInt sound_PlaySamplesFromAtLength(sqInt frameCount, sqInt arrayIndex, sqInt startIndex) 2 { 3 if (output_handle) 4 { 5 void *samples= (void *)arrayIndex + startIndex * output_channels * 2; 6 int count= snd_pcm_writei(output_handle, samples, frameCount); 7 if (count < frameCount / 2) 8 { 9 output_buffer_frames_available= 0; } if (count < 0) { if (count == -EPIPE) /* underrun */ { int err; snd(pcm_prepare(output_handle), "sound_PlaySamples: snd_pcm_prepare"); return 0; } fprintf(stderr, "snd_pcm_writei returned %i\n", count); return 0; } return count; } success(false); ============
Does that seem right to you all?
Maybe sqInt never gets to be long long? sqMemoryAccess.h defines:
#if defined(SQ_IMAGE32) typedef int sqInt; typedef unsigned int usqInt; #elif defined(SQ_HOST64) typedef long sqInt; typedef unsigned long usqInt; #else # if (SIZEOF_LONG_LONG != 8) # error long long integers are not 64-bits wide? # endif typedef long long sqInt; typedef unsigned long long usqInt; #endif
oh... I should add I see warnings during compilation. This is applicable:
platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c: In function 'sound_PlaySamplesFromAtLength': platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c:204: warning: cast to pointer from integer of different size
Line 204 in this error is line 5 above
On Tue, Nov 18, 2008 at 10:22:36AM -0800, Brad Fuller wrote:
The problem might be that arrayIndex is 32bit and it is used to calculate *samples which is 64bit. This would be a problem if arrayIndex has bit31 set.
Brad,
You're looking in the right place. Most of the problems on 64 bit platforms relate to mixing 64 bit pointers with 32 bit integers.
I have worked through these issues for a few plugins, but as far as I know no one has addressed them for sound support, so you are probably the first person to do so (please proceed!).
You will probably be able to identify most of the issues by tracking down compiler warnings and looking at the corresponding C code, but one thing that has been helpful for me in matching up the Smalltalk slang with the external support code is SlangBrowser. This allows you to look at generated C code in Squeak (this of course being where many of the questionable type casts happen). http://wiki.squeak.org/squeak/5916 You can get a VMMaker with SlangBrowser support from SqueakSource. VMMaker-dtl.107 would be the most recent in that branch. You'll still need to separately load the browser support from http://bugs.squeak.org/view.php?id=5932
If you want to get a better feel for the type conversions involved, then MemoryAccess package may also be of interest. Support for this is also included in VMMaker-dtl.107. http://wiki.squeak.org/squeak/6081
Good luck, and please post your results if you get the sound support working.
Dave
On Wed, Nov 19, 2008 at 4:19 AM, David T. Lewis lewis@mail.msen.com wrote:
On Tue, Nov 18, 2008 at 10:22:36AM -0800, Brad Fuller wrote:
The problem might be that arrayIndex is 32bit and it is used to calculate *samples which is 64bit. This would be a problem if arrayIndex has bit31 set.
Brad,
You're looking in the right place. Most of the problems on 64 bit platforms relate to mixing 64 bit pointers with 32 bit integers.
I have worked through these issues for a few plugins, but as far as I know no one has addressed them for sound support, so you are probably the first person to do so (please proceed!).
You will probably be able to identify most of the issues by tracking down compiler warnings and looking at the corresponding C code, but one thing that has been helpful for me in matching up the Smalltalk slang with the external support code is SlangBrowser. This allows you to look at generated C code in Squeak (this of course being where many of the questionable type casts happen). http://wiki.squeak.org/squeak/5916 You can get a VMMaker with SlangBrowser support from SqueakSource. VMMaker-dtl.107 would be the most recent in that branch. You'll still need to separately load the browser support from http://bugs.squeak.org/view.php?id=5932
If you want to get a better feel for the type conversions involved, then MemoryAccess package may also be of interest. Support for this is also included in VMMaker-dtl.107. http://wiki.squeak.org/squeak/6081
Good luck, and please post your results if you get the sound support working.
So, there's no way, .... good way.... to do this outside of squeak?
Oh.. are there any examples of how to set the right values?
Thanks Dave, you've been a big help. I'll have to now get comfortable with all the work you and TIm have done first before I fiddle with anything.
On Wed, Nov 19, 2008 at 07:50:40AM -0800, Brad Fuller wrote:
Oh.. are there any examples of how to set the right values?
Brad,
Here is a link to some earlier work that I did, that may give you some ideas of what is involved.
http://lists.squeakfoundation.org/pipermail/vm-dev/2007-November/001675.html
Dave
On Thu, Nov 20, 2008 at 3:30 AM, David T. Lewis lewis@mail.msen.com wrote:
Here is a link to some earlier work that I did, that may give you some ideas of what is involved.
http://lists.squeakfoundation.org/pipermail/vm-dev/2007-November/001675.html
I appreciate your help!
On Wed, Nov 19, 2008 at 4:19 AM, David T. Lewis lewis@mail.msen.com wrote:
You can get a VMMaker with SlangBrowser support from SqueakSource. VMMaker-dtl.107 would be the most recent in that branch.
Where can I find VMMaker 107? I only see 106 on SqueakSource
On Thu, Nov 20, 2008 at 3:17 PM, Brad Fuller bradallenfuller@gmail.com wrote:
On Wed, Nov 19, 2008 at 4:19 AM, David T. Lewis lewis@mail.msen.com wrote:
You can get a VMMaker with SlangBrowser support from SqueakSource. VMMaker-dtl.107 would be the most recent in that branch.
Where can I find VMMaker 107? I only see 106 on SqueakSource
Also, how does one use the SlangBrowser? I don't see it anywhere.
I also don't think that the vm-sound-ALSA C code was generated from Slang. I can't seem to locate it, so I assume that it was generated outside of Squeak. Can anyone (Ian?) confirm this?
On Thu, Nov 20, 2008 at 03:17:37PM -0800, Brad Fuller wrote:
On Wed, Nov 19, 2008 at 4:19 AM, David T. Lewis lewis@mail.msen.com wrote:
You can get a VMMaker with SlangBrowser support from SqueakSource. VMMaker-dtl.107 would be the most recent in that branch.
Where can I find VMMaker 107? I only see 106 on SqueakSource
If you are using a Monticello browser, do a "refresh" to update it from the server. If you are using a web browser, look under the "Versions" tab instead of the "Releases" tab.
Dave
vm-dev@lists.squeakfoundation.org