🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.multimedia
6 messages
6 total messages Started by Mike Thu, 23 Aug 2001 08:31
Playbacking from thread
#1168
Author: Mike
Date: Thu, 23 Aug 2001 08:31
20 lines
1394 bytes
Hi!

I have a problem with threads.

I have a thread which controls playback of a WAVE file.

And for controlling it I have to get a handle of thread. But handle
which I get with "this->handle" isn't the right handle (if I use for
example "Form1->handle" everything works). So, how can I
get an "right" handle?

Can I make a message map for thread (I have to process some
messages which are sent (playbacking events)) - and they are
sent to the handle, which I sent previously. But that handle isn't
correct, so what's wrong?

Please help


Mike
Re: Playbacking from thread
#1170
Author: Mike
Date: Thu, 23 Aug 2001 09:14
32 lines
1749 bytes
Hi!

I forget to change CALLBACK_WINDOW to CALLBACK_THREAD.

But it still doesn't work. waveOutOpen still returns "invalid parameter"

(for handle I use this->Handle - and this is thread class).


Mike

Mike wrote:

> Hi!
>
> I have a problem with threads.
>
> I have a thread which controls playback of a WAVE file.
>
> And for controlling it I have to get a handle of thread. But handle
> which I get with "this->handle" isn't the right handle (if I use for
> example "Form1->handle" everything works). So, how can I
> get an "right" handle?
>
> Can I make a message map for thread (I have to process some
> messages which are sent (playbacking events)) - and they are
> sent to the handle, which I sent previously. But that handle isn't
> correct, so what's wrong?
>
> Please help
>
> Mike
Re: Playbacking from thread
#1171
Author: Michael Crapo
Date: Thu, 23 Aug 2001 15:34
33 lines
1770 bytes
Mike
	Are you trying to post a windows message to your thread???  If
that is what you are doing then you need to use PostThreadMessage
instead of PostMessage.   The PostThreadMessage takes a ThreadID
instead of a handle.  If this is not what you are tying to do, then I
need more information..

Mike

On Thu, 23 Aug 2001 10:31:19 +0200, Mike <someone@somewhere.com>
wrote:

>Hi!
>
>I have a problem with threads.
>
>I have a thread which controls playback of a WAVE file.
>
>And for controlling it I have to get a handle of thread. But handle
>which I get with "this->handle" isn't the right handle (if I use for
>example "Form1->handle" everything works). So, how can I
>get an "right" handle?
>
>Can I make a message map for thread (I have to process some
>messages which are sent (playbacking events)) - and they are
>sent to the handle, which I sent previously. But that handle isn't
>correct, so what's wrong?
>
>Please help
>
>
>Mike
>
Re: Playbacking from thread
#1172
Author: bcb
Date: Fri, 24 Aug 2001 02:22
38 lines
2086 bytes
Mike, I will post the code tommorow, not at my working computer right now.

Michael Crapo <mcrapo@tng-ida.com> wrote in message
news:3b852215.700166@newsgroups.borland.com...
> Mike
> Are you trying to post a windows message to your thread???  If
> that is what you are doing then you need to use PostThreadMessage
> instead of PostMessage.   The PostThreadMessage takes a ThreadID
> instead of a handle.  If this is not what you are tying to do, then I
> need more information..
>
> Mike
>
> On Thu, 23 Aug 2001 10:31:19 +0200, Mike <someone@somewhere.com>
> wrote:
>
> >Hi!
> >
> >I have a problem with threads.
> >
> >I have a thread which controls playback of a WAVE file.
> >
> >And for controlling it I have to get a handle of thread. But handle
> >which I get with "this->handle" isn't the right handle (if I use for
> >example "Form1->handle" everything works). So, how can I
> >get an "right" handle?
> >
> >Can I make a message map for thread (I have to process some
> >messages which are sent (playbacking events)) - and they are
> >sent to the handle, which I sent previously. But that handle isn't
> >correct, so what's wrong?
> >
> >Please help
> >
> >
> >Mike
> >
>
Re: Playbacking from thread
#1173
Author: Mike
Date: Fri, 24 Aug 2001 10:55
30 lines
1948 bytes
Hi!

So, I read help about threads and WAVE playback and I found out
that for me it would be the best to use "callback function". And, so,
I have some questions about it.

I have an thread which is created when I would like to playback
WAVE file (and if I would like to use "thread callback" there would
be yet another one, wouldn't be?), but I need very accurate playback
(without dropping any samples and that it would be as real-time
as it is possible (so little buffers, because WAVE files is generated
in real time)), so "callback function" is what I need.

How can I declare it (so that I can than with an argument
(DWORD)WaveProc give waveOutOpen function's location (so that it
would know what to call))? I tryed this

void CALLBACK WaveProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam) {
... I left code for function the same

but I get illegal operations

Maybe I should make it thread-function (how?)?

And what's the priority of this function (it's default or it is thread's
priority)?


Mike
Re: Playbacking from thread
#1175
Author: bcb
Date: Sun, 26 Aug 2001 17:11
62 lines
2631 bytes
Hello, Here is a thread example:

DWORD CALLBACK ThreadFunc(void* P)
{
 HDC DC=GetDC(Form1->Handle);

PlaySound("c:\\Key.wav",NULL,SND_FILENAME);
ReleaseDC(Form1->Handle, DC);

 return 0;
}

void __fastcall TForm1::PlaySoundInThread()    file://play sound in edit
boxes
{
  DWORD ThreadID;

HANDLE hthread = CreateThread(0,0,ThreadFunc, 0,0, &ThreadID);
}


So to play the sound in the thread on a button click just use this line
instead of playsound(),

PlaySoundInThread();

Goodluck.

Mike <someone@somewhere.com> wrote in message
news:3B8632A5.5F1864A9@somewhere.com...
> Hi!
>
> So, I read help about threads and WAVE playback and I found out
> that for me it would be the best to use "callback function". And, so,
> I have some questions about it.
>
> I have an thread which is created when I would like to playback
> WAVE file (and if I would like to use "thread callback" there would
> be yet another one, wouldn't be?), but I need very accurate playback
> (without dropping any samples and that it would be as real-time
> as it is possible (so little buffers, because WAVE files is generated
> in real time)), so "callback function" is what I need.
>
> How can I declare it (so that I can than with an argument
> (DWORD)WaveProc give waveOutOpen function's location (so that it
> would know what to call))? I tryed this
>
> void CALLBACK WaveProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
> lParam) {
> ... I left code for function the same
>
> but I get illegal operations
>
> Maybe I should make it thread-function (how?)?
>
> And what's the priority of this function (it's default or it is thread's
> priority)?
>
>
> Mike
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads