20 May '13 - 21:57 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Winsock vb6 and EncodeProc  (Read 1657 times)
shuttle
Posts: 70


« on: 12 Aug '08 - 15:36 »
Reply with quoteQuote

Hi everybody!

In this code I have the problem:

......'this is in user control "Cast"
Bass_Encode_Start(chan,"lame --alt-preset standard - -", 0,Addressof ENCODEPROC, 0)
......'I see in the Task Manager and the Lame go

......'this is in the bassenc module
encodeproc (byval hundle, byval channel, ect....)
dim D(4095)
copymemory D(0), buffer, length
UserControl.Cast.sendD D(0)
.......

.......'this is in the user control "Cast"----
sub sendD (buffer() as byte)
debug.print buffer(1 or 2 or 3 or 4) '''I have tested that the byte arrived ok and is ok!
winsock.SendData buffer()       ' at this point crash....
.......

Any help for me?
Thank you!!
Logged
(: JOBnik! :)
Posts: 984


« Reply #1 on: 12 Aug '08 - 16:13 »
Reply with quoteQuote

Hi Grin

I guess the buffer() should actually be buffer(0) Smiley
Logged
shuttle
Posts: 70


« Reply #2 on: 12 Aug '08 - 16:33 »
Reply with quoteQuote

Hi Jobnik!!    Thank you for your answere!!!   
mmmmmmmmmmm.......
But in your case the Winsock should send only Value of buffer(0), or not?
The buffer is an array with 4096 values!
OK.....anyway I try to send a simple string "Bye" and the error is the same!
It is possible that EncodeProc is too fast to Winsock.SendData?
Sorry for my bad bad english!!!!!!!
Logged
radio42
Posts: 4012


« Reply #3 on: 12 Aug '08 - 16:34 »
Reply with quoteQuote

No I guess Jobby ment, that you should replace:

winsock.SendData buffer()       ' at this point crash....
by
winsock.SendData buffer(0)
Logged
shuttle
Posts: 70


« Reply #4 on: 12 Aug '08 - 16:41 »
Reply with quoteQuote

HI Radio42!
mmmmmm
I don't believe that is the rigth method of use Winsock.SendData.
In my another application I use Winsock.SendData buffer() and he run well!
Anyway ...I tryed but the problem is the same!!!
Logged
(: JOBnik! :)
Posts: 984


« Reply #5 on: 12 Aug '08 - 19:18 »
Reply with quoteQuote

Hi Grin

Yep, you're right it shouldn't be with (0).
Can you please write what kind of error you get after the crash?

One thing I've noticed is about the CopyMemory, it should be like this:
CopyMemory D(0), ByVal buffer, length
Logged
shuttle
Posts: 70


« Reply #6 on: 12 Aug '08 - 19:26 »
Reply with quoteQuote

the message error is this:

Err.Numb = -2147417848 ; Err.Descr = Method 'SendData' of Object IMSWinsockControl failed.

About "BYval" I already try but without results!!

I try to send a simple string but the error flags too.
Seems that the EncodeProc system block the sequence.....or similar...
Logged
(: JOBnik! :)
Posts: 984


« Reply #7 on: 12 Aug '08 - 19:27 »
Reply with quoteQuote

Hi Grin

Can you make a small example and send it to me to make tests? Smiley
Logged
shuttle
Posts: 70


« Reply #8 on: 12 Aug '08 - 21:18 »
Reply with quoteQuote

ok...I made a sample from my big project!!!! Grin

In one form there is one user control called Caster and in that the code is this:


Private rchan As Long
Private encoder As Long

Sub sendD(buffer() As Byte)
    On Error GoTo handler
    Winsock.SendData buffer()
    Exit Sub
handler:
    Debug.Print Err.Number & vbCrLf & Err.Description
    BASS_Encode_Stop (rchan)
End Sub

Private Sub Command1_Click()
    BASS_RecordInit -1
    BASS_RecordSetDevice 0
    rchan = BASS_RecordStart(44100, 2, BASS_RECORD_PAUSE, AddressOf RecordingCallback, 0)
    BASS_ChannelPlay rchan, True
    encoder = BASS_Encode_Start(rchan, "lame --alt-preset standard - -", 0, AddressOf ENCODEPROC, 0) ' start the encoder
    If encoder = 0 Then
        Call BASS_StreamFree(rchan)
        Call BASS_Encode_Stop(rchan)
    End If
End Sub

Private Sub Winsock_Close()
    If Winsock.State <> sckClosed Then
        Winsock.close
    End If
End Sub

Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
    If Winsock.State <> sckClosed Then Winsock.close
    Winsock.accept requestID
    Winsock.SendData "CONNECTED"
End Sub

Private Sub UserControl_Initialize()
    Winsock.LocalPort = "8000"
    If Winsock.State = sckClosed Then
        Winsock.Listen
    End If
End Sub

In module BassEnc:

Sub ENCODEPROC(ByVal handle As Long, ByVal channel As Long, ByVal buffer As     Long, ByVal length As Long, ByVal user As Long)
    Dim dati() As Byte
    ReDim dati(length) As Byte
    CopyMemory dati(0), buffer, length - 1
    form.Caster.sendD dati()
End Sub

in another module

Public Function RecordingCallback(ByVal handle As Long, ByVal buffer As Long, ByVal length As Long, ByVal user As Long) As Long
    RecordingCallback = BASS_Encode_IsActive(handle)   ' continue recording if encoder is alive
End Function


This is all.....I believe!
Check this, and good luck!
Bye!
« Last Edit: 12 Aug '08 - 21:22 by shuttle » Logged
(: JOBnik! :)
Posts: 984


« Reply #9 on: 13 Aug '08 - 13:34 »
Reply with quoteQuote

Hi Grin

Actually I meant if you could send me a working example, so I can run & test it in VB Wink
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines