SDL and sound problem
Moderator: ScummVM Team
SDL and sound problem
Hi,
I'm the developer of the Sally Project: www.sally-project.de
I started to port ScummVM as an plugin to Sally.
First of all: It's really easy to make a port! Good Job!!!
I'm basically using the windows SDL port and changed just the output surface. Afterwards I copy the SDL surface to a DirectX Texture and display that one in the plugin... so far every thing is already working (Mouse / Keyboard input, starting of games, ...).
There is only a problem with the sound... I don't hear anything.
I hunted the error and found the problem.
I changed in the loadGFXMode() method the creation of the _hwscreen surface from:
_hwscreen = SDL_SetVideoMode(hwW, hwH, 16,
_videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
);
to:
_hwscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, hwW, hwH, 16, 0, 0, 0, 0);
When I change it back, I can hear the sound (but it opens a new window... and that is not what I want).
I'm new to SDL.
My first thougth was that SDL needs a window to play sound, so I created a little test program and it's possible to play sound if you don't have a window...
Can anyone help me with this?
Any idea? Any function I should take a look at?
Regards
Knob
I'm the developer of the Sally Project: www.sally-project.de
I started to port ScummVM as an plugin to Sally.
First of all: It's really easy to make a port! Good Job!!!
I'm basically using the windows SDL port and changed just the output surface. Afterwards I copy the SDL surface to a DirectX Texture and display that one in the plugin... so far every thing is already working (Mouse / Keyboard input, starting of games, ...).
There is only a problem with the sound... I don't hear anything.
I hunted the error and found the problem.
I changed in the loadGFXMode() method the creation of the _hwscreen surface from:
_hwscreen = SDL_SetVideoMode(hwW, hwH, 16,
_videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
);
to:
_hwscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, hwW, hwH, 16, 0, 0, 0, 0);
When I change it back, I can hear the sound (but it opens a new window... and that is not what I want).
I'm new to SDL.
My first thougth was that SDL needs a window to play sound, so I created a little test program and it's possible to play sound if you don't have a window...
Can anyone help me with this?
Any idea? Any function I should take a look at?
Regards
Knob
- eriktorbjorn
- ScummVM Developer
- Posts: 3561
- Joined: Mon Oct 31, 2005 7:39 am
I've hardly ever used SDL directly myself, but the idea (as far as I know) is that when you call SDL_OpenAudio() you tell SDL how you want to generate audio data ("desired"). SDL replies back with how it wants you to do ("obtainedRate"). ScummVM assumes that the only thing there could possibly be any doubt about is the sample rate, so it looks at obtainedRate.freq and sends that to the mixer.Der_Knob wrote: Just if someone know: How is the sound be played over / with the SDL_OpenAudio device?
After that, once SDL_PauseAudio(0) has been called, SDL will automatically call the audio callback function (desired.callback) mixCallback(). This function is responsible for filling a buffer with audio data, which SDL plays.
The SDL Documentation Wiki describes this in greater detail.
Just a little update...
When I start Sally (my program) ScummVM is not directly started. Just the plugin is loaded and waits for the start of ScummVM. At this state you can't see the program in the volume control of vista (there you can see all program with audio output).
But when I start ScummVM it's shown in the list... so he starts some kind of audio interface - but don't sends anything.
I already debugged through some classes and compared the steps with the original ScummVM SDL. Here everything look good.
I think is some kind of SDL behaviour
As I mentioned, when I created the SDL window, I hear sound. Even it is not the used by ScummVM (I created a new one outside of ScummVM).
But I will not give up!!
When I start Sally (my program) ScummVM is not directly started. Just the plugin is loaded and waits for the start of ScummVM. At this state you can't see the program in the volume control of vista (there you can see all program with audio output).
But when I start ScummVM it's shown in the list... so he starts some kind of audio interface - but don't sends anything.
I already debugged through some classes and compared the steps with the original ScummVM SDL. Here everything look good.
I think is some kind of SDL behaviour
As I mentioned, when I created the SDL window, I hear sound. Even it is not the used by ScummVM (I created a new one outside of ScummVM).
But I will not give up!!
Last edited by Der_Knob on Wed Jan 13, 2010 8:37 pm, edited 1 time in total.
ok, I found a (solution) hack for this...
I set SDL_putenv("SDL_VIDEODRIVER=dummy"); and create the window as normal:
_hwscreen = SDL_SetVideoMode(hwW, hwH, 16,
_videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
But it than opens no window (dummy video driver) and than I can still copy the content to my directx texture
I'm not sure if that is ... a ... good behaviour?!?!
But it is working
Thanks all for the help so far!
In the new year I will come back to you because of cvs checkin and so on
I set SDL_putenv("SDL_VIDEODRIVER=dummy"); and create the window as normal:
_hwscreen = SDL_SetVideoMode(hwW, hwH, 16,
_videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
But it than opens no window (dummy video driver) and than I can still copy the content to my directx texture
I'm not sure if that is ... a ... good behaviour?!?!
But it is working
Thanks all for the help so far!
In the new year I will come back to you because of cvs checkin and so on
On a different note... I just had a peek at this "Sally" project you want to integrate ScummVM into. While the page says that it is freeware, I see no link nor offer for source code, nor any reference to the GPL, so I assume that it is not an open source project.
So, just to avoid any bad mutual feelings in the future, I just wanted to point out that if you want to ever release what you are doing there to the public in the future, you'll of course have to comply to the GPL, and release the complete source code.
If you plan to release this as an open source plugin for the "Sally" project, then also note that this may not be legal if you are using dynamic linking (although the details may vary between countries, and also may depend on case law; see e.g. http://www.gnu.org/licenses/gpl-faq.html#GPLPluginsInNF )
So, just to avoid any bad mutual feelings in the future, I just wanted to point out that if you want to ever release what you are doing there to the public in the future, you'll of course have to comply to the GPL, and release the complete source code.
If you plan to release this as an open source plugin for the "Sally" project, then also note that this may not be legal if you are using dynamic linking (although the details may vary between countries, and also may depend on case law; see e.g. http://www.gnu.org/licenses/gpl-faq.html#GPLPluginsInNF )
Thanks, I already thought about that...
1. I will offer ScummVM as a single Plugin. You can download it (from your side or so) and install it by double clicking. So it's not linked static. We have a full plugin engine where everyone can create new plugins. So it will not be included in the main pack.
I will of course open the source of the ScummVM plugin.
So, that should be no problem, or? It's like you are installing an application in windows or on the iPhone...
We have an API for the developers, but right now it is changing nearly every day => no docu is available. And the dev area on the homepage is in a very early stage... The API is only available on request.
2. I think we will put Sally an open source project to sourceforge. Right now I had no time to create a sourceforge project and put the stuff in there and so on... I'm have to do nearly the complete stuff (programming, webpage and so on) by my self
--- edit
The ScummVM Plugin for sally links dynamically the SallyAPI.dll... not the other way around. Sally don't know anything about the scummvm plugin (or any other plugin which is deliverd with it or downloaded).
So it Should be ok, as far as I understand the licence.
But I will check this again in the new year... I don't want to make any mistake here
1. I will offer ScummVM as a single Plugin. You can download it (from your side or so) and install it by double clicking. So it's not linked static. We have a full plugin engine where everyone can create new plugins. So it will not be included in the main pack.
I will of course open the source of the ScummVM plugin.
So, that should be no problem, or? It's like you are installing an application in windows or on the iPhone...
We have an API for the developers, but right now it is changing nearly every day => no docu is available. And the dev area on the homepage is in a very early stage... The API is only available on request.
2. I think we will put Sally an open source project to sourceforge. Right now I had no time to create a sourceforge project and put the stuff in there and so on... I'm have to do nearly the complete stuff (programming, webpage and so on) by my self
--- edit
The ScummVM Plugin for sally links dynamically the SallyAPI.dll... not the other way around. Sally don't know anything about the scummvm plugin (or any other plugin which is deliverd with it or downloaded).
So it Should be ok, as far as I understand the licence.
But I will check this again in the new year... I don't want to make any mistake here
Last edited by Der_Knob on Thu Dec 31, 2009 12:40 am, edited 3 times in total.