[MacRuby] #1173: Impossible to have a pointer to an opaque structure

MacRuby ruby-noreply at macosforge.org
Sun Feb 27 21:10:04 PST 2011


#1173: Impossible to have a pointer to an opaque structure
----------------------------------------+-----------------------------------
 Reporter:  vincent.isambart@…          |       Owner:  lsansonetti@…        
     Type:  defect                      |      Status:  new                  
 Priority:  major                       |   Milestone:  MacRuby 1.0          
Component:  MacRuby                     |    Keywords:                       
----------------------------------------+-----------------------------------
 The following code:
 {{{
 if ARGV.length != 1
   puts "Usage: #{$0} /path/to/file"
   exit
 end

 def CheckError(err)
   return if err == 0
   raise "CoreAudio Error"
 end

 framework "Foundation"
 framework "AudioUnit"
 framework "AudioToolbox"

 inputFilePath = ARGV[0]

 url = CFURLCreateFromFileSystemRepresentation(nil, inputFilePath,
 inputFilePath.bytesize, false)

 audioFilePtr = Pointer.new("^{OpaqueAudioFileID}")
 CheckError(AudioFileOpenURL(url, KAudioFileReadPermission, 0,
 audioFilePtr))

 fileFormat = AudioStreamBasicDescription.new
 propSizePtr = Pointer.new("i")
 propSizePtr[0] = AudioStreamBasicDescription.size
 CheckError(AudioFileGetProperty(audioFilePtr[0],
 KAudioFilePropertyDataFormat, propSizePtr, fileFormat))
 }}}
 results in an error:
 {{{
 /Users/system/playfile.rb:23:in `<main>': unrecognized runtime type
 `{OpaqueAudioFileID}' (TypeError)
 }}}
 Dereferencing {{{audioFilePtr[0]}}} should probably just return a pointer
 object to an opaque structure. Being able to use {{{Pointer.new("^v")}}}
 instead of {{{Pointer.new("^{OpaqueAudioFileID}")}}} might be an other way
 to be able to use AudioFile ids.

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1173>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list