Skip to content

Commit

Permalink
change audio && video output mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed May 15, 2012
1 parent 30c0beb commit 10308d9
Show file tree
Hide file tree
Showing 8 changed files with 560 additions and 362 deletions.
20 changes: 13 additions & 7 deletions audio/audio_out.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ins.h"
#include "defs.h"
#include "wave_render.h"
#include "dsound_render.h"
#include "audio_out.h"
Expand All @@ -8,34 +9,39 @@
extern "C" {
#endif

EXPORT_API int wave_init_audio(void** ctx, uint32_t channels,
EXPORT_API int wave_init_audio(void* ctx, uint32_t channels,
uint32_t bits_per_sample, uint32_t sample_rate, int format)
{
wave_render* wave = new wave_render;
*ctx = wave;
return wave->init_audio((void*)wave, channels, bits_per_sample, sample_rate, format) ? 0 : -1;
ao_context *ao = (ao_context*)ctx;
wave_render* wave = NULL;
ao->audio_dev = (void*)(wave = new wave_render);
return wave->init_audio((void*)ao->audio_dev, channels, bits_per_sample, sample_rate, format) ? 0 : -1;
}

EXPORT_API int wave_play_audio(void* ctx, uint8_t* data, uint32_t size)
{
wave_render* wave = (wave_render*)ctx;
ao_context *ao = (ao_context*)ctx;
wave_render* wave = (wave_render*)ao->audio_dev;
return wave->play_audio(data, size);
}

EXPORT_API void wave_audio_control(void* ctx, double vol)
{
wave_render* wave = (wave_render*)ctx;
ao_context *ao = (ao_context*)ctx;
wave_render* wave = (wave_render*)ao->audio_dev;
control_vol_t ctrl_vol = { vol, vol };
wave->audio_control(CONTROL_SET_VOLUME, &ctrl_vol);
}

EXPORT_API void wave_destory_audio(void* ctx)
{
wave_render* wave = (wave_render*)ctx;
ao_context *ao = (ao_context*)ctx;
wave_render* wave = (wave_render*)ao->audio_dev;
if (wave)
{
wave->destory_audio();
delete wave;
ao->audio_dev = NULL;
}
}

Expand Down
9 changes: 8 additions & 1 deletion audio/audio_out.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@
extern "C" {
#endif

EXPORT_API int wave_init_audio(void** ctx, uint32_t channels,
// EXPORT_API int wave_init_audio(void** ctx, uint32_t channels,
// uint32_t bits_per_sample, uint32_t sample_rate, int format);
// EXPORT_API int wave_play_audio(void* ctx, uint8_t* data, uint32_t size);
// EXPORT_API void wave_audio_control(void* ctx, double vol);
// EXPORT_API void wave_destory_audio(void* ctx);

EXPORT_API int wave_init_audio(void* ctx, uint32_t channels,
uint32_t bits_per_sample, uint32_t sample_rate, int format);
EXPORT_API int wave_play_audio(void* ctx, uint8_t* data, uint32_t size);
EXPORT_API void wave_audio_control(void* ctx, double vol);
EXPORT_API void wave_destory_audio(void* ctx);


EXPORT_API int dsound_init_audio(void** ctx, void* user_data, uint32_t channels,
uint32_t bits_per_sample, uint32_t sample_rate, int format);
EXPORT_API int dsound_play_audio(void* ctx, uint8_t* data, uint32_t size);
Expand Down
Loading

0 comments on commit 10308d9

Please sign in to comment.